调试完成了动力母线消息
This commit is contained in:
@@ -28,11 +28,18 @@ class PowerManagerApp:
|
||||
self.root.tk.call('tk', 'scaling', 1.5) # 适配高DPI显示
|
||||
|
||||
# UDP通信配置
|
||||
self.udp_ip = "127.0.0.1"
|
||||
self.udp_port = 5000
|
||||
# self.udp_ip = "127.0.0.1"
|
||||
self.udp_ip = "192.168.0.140"
|
||||
self.udp_port = 7000
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.sock.bind((self.udp_ip, self.udp_port))
|
||||
|
||||
self.disSysPortC1 = 6000
|
||||
self.disSysHostC1 = '192.168.1.154'
|
||||
# self.disSysHostC1 = '192.168.0.140'
|
||||
self.disSysPortC2 = 6000
|
||||
self.disSysHostC2 = '192.168.1.158'
|
||||
|
||||
# 数据库配置
|
||||
self.db = DB('/home/zjk/project/H100/H100PowerManger/test/disSysTest/test.db')
|
||||
self.db.connect()
|
||||
@@ -86,7 +93,8 @@ class PowerManagerApp:
|
||||
"FB备用开关电流": 0.0,
|
||||
"备用电流3": 0.0
|
||||
},
|
||||
"cool_water_pressure": 0.0
|
||||
"cool_water_pressure": 0.0,
|
||||
"dcdc_temp":0
|
||||
},
|
||||
"high_a_vol_bus": {
|
||||
"breakers": {
|
||||
@@ -276,9 +284,9 @@ class PowerManagerApp:
|
||||
row = i // 3
|
||||
col = i % 3
|
||||
btn_frame = ttk.Frame(frame)
|
||||
btn_frame.grid(row=row, column=col, padx=5, pady=2, sticky=tk.W)
|
||||
btn_frame.grid(row=row, column=col, padx=10, pady=2, sticky=tk.W)
|
||||
|
||||
ttk.Label(btn_frame, text=name).pack(side=tk.LEFT)
|
||||
ttk.Label(btn_frame, text=name, width=20).pack(side=tk.LEFT)
|
||||
on_btn = ttk.Button(btn_frame, text="合", width=3,
|
||||
command=lambda n=name: self.send_hvb_cmd(n, 0x55))
|
||||
on_btn.pack(side=tk.LEFT, padx=2)
|
||||
@@ -301,14 +309,14 @@ class PowerManagerApp:
|
||||
row = i // 3
|
||||
col = i % 3
|
||||
btn_frame = ttk.Frame(frame)
|
||||
btn_frame.grid(row=row, column=col, padx=5, pady=2, sticky=tk.W)
|
||||
btn_frame.grid(row=row, column=col, padx=10, pady=2, sticky=tk.W)
|
||||
|
||||
ttk.Label(btn_frame, text=name).pack(side=tk.LEFT)
|
||||
ttk.Label(btn_frame, text=name, width=20).pack(side=tk.LEFT)
|
||||
on_btn = ttk.Button(btn_frame, text="合", width=3,
|
||||
command=lambda n=name: self.send_hvba_cmd(n, 1))
|
||||
command=lambda n=name: self.send_hvba_cmd(n, 0x55))
|
||||
on_btn.pack(side=tk.LEFT, padx=2)
|
||||
off_btn = ttk.Button(btn_frame, text="分", width=3,
|
||||
command=lambda n=name: self.send_hvba_cmd(n, 0))
|
||||
command=lambda n=name: self.send_hvba_cmd(n, 0xAA))
|
||||
off_btn.pack(side=tk.LEFT, padx=2)
|
||||
|
||||
def setup_lvmb_control(self, parent):
|
||||
@@ -327,9 +335,9 @@ class PowerManagerApp:
|
||||
row = i // 3
|
||||
col = i % 3
|
||||
btn_frame = ttk.Frame(frame)
|
||||
btn_frame.grid(row=row, column=col, padx=5, pady=2, sticky=tk.W)
|
||||
btn_frame.grid(row=row, column=col, padx=10, pady=2, sticky=tk.W)
|
||||
|
||||
ttk.Label(btn_frame, text=name).pack(side=tk.LEFT)
|
||||
ttk.Label(btn_frame, text=name, width=20).pack(side=tk.LEFT)
|
||||
on_btn = ttk.Button(btn_frame, text="合", width=3,
|
||||
command=lambda n=name: self.send_lvmb_cmd(n, 0x55))
|
||||
on_btn.pack(side=tk.LEFT, padx=2)
|
||||
@@ -353,9 +361,9 @@ class PowerManagerApp:
|
||||
row = i // 3
|
||||
col = i % 3
|
||||
btn_frame = ttk.Frame(frame)
|
||||
btn_frame.grid(row=row, column=col, padx=5, pady=2, sticky=tk.W)
|
||||
btn_frame.grid(row=row, column=col, padx=10, pady=2, sticky=tk.W)
|
||||
|
||||
ttk.Label(btn_frame, text=name).pack(side=tk.LEFT)
|
||||
ttk.Label(btn_frame, text=name, width=20).pack(side=tk.LEFT)
|
||||
on_btn = ttk.Button(btn_frame, text="合", width=3,
|
||||
command=lambda n=name: self.send_lvb_cmd(n, 0x55))
|
||||
on_btn.pack(side=tk.LEFT, padx=2)
|
||||
@@ -365,6 +373,7 @@ class PowerManagerApp:
|
||||
|
||||
def send_hvb_cmd(self, breaker_name, state):
|
||||
"""发送动力母线配电指令"""
|
||||
print(breaker_name,state)
|
||||
cmd = msg_disHVBCmdMsg()
|
||||
if breaker_name == "燃料电池断路器":
|
||||
cmd.fuelCellCircuitBreaker = state
|
||||
@@ -391,13 +400,18 @@ class PowerManagerApp:
|
||||
elif breaker_name == "备用断路器":
|
||||
cmd.reservedCircuitBreaker = state
|
||||
elif breaker_name == "DC/DC模块启动":
|
||||
cmd.dcDcModuleStart = state
|
||||
cmd.dcdc5Module = state
|
||||
elif breaker_name == "冷却系统启动":
|
||||
cmd.coolingSystemStart = state
|
||||
cmd.coolingSystem = state
|
||||
|
||||
self.send_udp_command(cmd.pack())
|
||||
# self.send_udp_command(cmd.pack())
|
||||
self.send_udp_command(cmd.pack(), self.disSysHostC1, self.disSysPortC1)
|
||||
self.db.insertHighVolBusCmd(cmd)
|
||||
self.log_message(f"发送动力母线配电指令: {breaker_name} {'合' if state else '分'}")
|
||||
if state==0x55:
|
||||
buntu=True
|
||||
else:
|
||||
buntu=False
|
||||
self.log_message(f"发送动力母线配电指令: {breaker_name} {'合' if buntu else '分'}")
|
||||
|
||||
def send_hvba_cmd(self, breaker_name, state):
|
||||
"""发送动力汇流排A配电指令"""
|
||||
@@ -415,10 +429,15 @@ class PowerManagerApp:
|
||||
cmd.bowRudderControlBoxCircuitBreaker = state
|
||||
elif breaker_name == "开盖启动气缸断路器":
|
||||
cmd.openWaterCoverStartCylinderCircuitBreaker = state
|
||||
|
||||
self.send_udp_command(cmd.pack())
|
||||
if state==0x55:
|
||||
buntu=True
|
||||
else:
|
||||
buntu=False
|
||||
self.log_message(f"发送动力汇流排A配电指令: {breaker_name} {'合' if buntu else '分'}")
|
||||
# self.send_udp_command(cmd.pack())
|
||||
self.send_udp_command(cmd.pack(), self.disSysHostC1, self.disSysPortC1)
|
||||
self.db.insertHighAVolBusCmd(cmd)
|
||||
self.log_message(f"发送动力汇流排A配电指令: {breaker_name} {'合' if state else '分'}")
|
||||
|
||||
|
||||
def send_lvmb_cmd(self, breaker_name, state):
|
||||
"""发送仪表母线配电指令"""
|
||||
@@ -438,9 +457,14 @@ class PowerManagerApp:
|
||||
elif breaker_name == "应急锂电池组2断路器":
|
||||
cmd.emergencyLithiumBatteryGroup2CircuitBreaker = state
|
||||
|
||||
self.send_udp_command(cmd.pack())
|
||||
# self.send_udp_command(cmd.pack())
|
||||
self.send_udp_command(cmd.pack(), self.disSysHostC2, self.disSysPortC2)
|
||||
self.db.insertLowMainBusCmd(cmd)
|
||||
self.log_message(f"发送仪表母线配电指令: {breaker_name} {'合' if state else '分'}")
|
||||
if state==0x55:
|
||||
buntu=True
|
||||
else:
|
||||
buntu=False
|
||||
self.log_message(f"发送仪表母线配电指令: {breaker_name} {'合' if buntu else '分'}")
|
||||
|
||||
def send_lvb_cmd(self, breaker_name, state):
|
||||
"""发送仪表汇流排配电指令"""
|
||||
@@ -462,9 +486,14 @@ class PowerManagerApp:
|
||||
elif breaker_name == "应急锂电池组1断路器":
|
||||
cmd.emergencyLithiumBatteryGroup1CircuitBreaker = state
|
||||
|
||||
self.send_udp_command(cmd.pack())
|
||||
# self.send_udp_command(cmd.pack())
|
||||
self.send_udp_command(cmd.pack(), self.disSysHostC2, self.disSysPortC2)
|
||||
self.db.insertLowBusCmd(cmd)
|
||||
self.log_message(f"发送仪表汇流排配电指令: {breaker_name} {'合' if state else '分'}")
|
||||
if state==0x55:
|
||||
buntu=True
|
||||
else:
|
||||
buntu=False
|
||||
self.log_message(f"发送仪表汇流排配电指令: {breaker_name} {'合' if buntu else '分'}")
|
||||
|
||||
def udp_receive_loop(self):
|
||||
"""UDP接收消息循环"""
|
||||
@@ -484,31 +513,23 @@ class PowerManagerApp:
|
||||
self.high_vol_dcdc_fault2_bits = []
|
||||
|
||||
frame = ttk.LabelFrame(parent, text="高压母线状态")
|
||||
frame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
|
||||
frame.pack(fill=tk.BOTH, expand=True, padx=2, pady=2)
|
||||
|
||||
# 使用网格布局管理器
|
||||
frame.grid_columnconfigure(0, weight=1)
|
||||
frame.grid_columnconfigure(1, weight=1)
|
||||
frame.grid_columnconfigure(2, weight=1)
|
||||
frame.grid_columnconfigure(3, weight=1)
|
||||
|
||||
# 电压显示
|
||||
ttk.Label(frame, text="动力母线电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
self.high_vol_power_voltage = ttk.Label(frame, text="0.0")
|
||||
self.high_vol_power_voltage = ttk.Label(frame, text="0.0V")
|
||||
self.high_vol_power_voltage.grid(row=0, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="A母线电压(V):").grid(row=0, column=2, sticky=tk.W)
|
||||
self.high_vol_a_voltage = ttk.Label(frame, text="0.0")
|
||||
self.high_vol_a_voltage = ttk.Label(frame, text="0.0V")
|
||||
self.high_vol_a_voltage.grid(row=0, column=3, sticky=tk.W)
|
||||
|
||||
# 电流显示
|
||||
ttk.Label(frame, text="动力母线电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
self.high_vol_power_current = ttk.Label(frame, text="0.0")
|
||||
self.high_vol_power_current.grid(row=1, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="A母线电流(A):").grid(row=1, column=2, sticky=tk.W)
|
||||
self.high_vol_a_current = ttk.Label(frame, text="0.0")
|
||||
self.high_vol_a_current.grid(row=1, column=3, sticky=tk.W)
|
||||
|
||||
# 断路器状态
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=2, column=0, columnspan=4, sticky=tk.W)
|
||||
self.high_vol_breakers = {}
|
||||
@@ -533,18 +554,22 @@ class PowerManagerApp:
|
||||
fault_labels1 = ["过温关机", "输出过流", "输出过压", "输出欠压", "输入过压", "输入欠压", "输出短路保护", "内部故障"]
|
||||
fault_labels2 = ["通信故障", "工作状态", "冷却泵1故障", "冷却泵2故障", "冷却水泄漏", "保留", "保留", "保留"]
|
||||
|
||||
ttk.Label(frame, text="DC/DC故障字1:").grid(row=10, column=0, sticky=tk.W)
|
||||
# DC/DC故障显示
|
||||
fault_frame = ttk.Frame(frame)
|
||||
fault_frame.grid(row=10, column=0, columnspan=4, sticky=tk.W, pady=2)
|
||||
|
||||
ttk.Label(fault_frame, text="DC/DC故障字1:").grid(row=0, column=0, sticky=tk.W)
|
||||
for i, label in enumerate(fault_labels1):
|
||||
ttk.Label(frame, text=label).grid(row=11+i//4, column=(i%4)*2, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
canvas.grid(row=11+i//4, column=(i%4)*2+1, sticky=tk.W)
|
||||
ttk.Label(fault_frame, text=label).grid(row=1+i//4, column=(i%4)*2, sticky=tk.W, padx=2)
|
||||
canvas = tk.Canvas(fault_frame, width=16, height=16, bg="white", highlightthickness=1)
|
||||
canvas.grid(row=1+i//4, column=(i%4)*2+1, sticky=tk.W, padx=2)
|
||||
self.high_vol_dcdc_fault1_bits.append(canvas)
|
||||
|
||||
ttk.Label(frame, text="DC/DC故障字2:").grid(row=13, column=0, sticky=tk.W)
|
||||
ttk.Label(fault_frame, text="DC/DC故障字2:").grid(row=3, column=0, sticky=tk.W)
|
||||
for i, label in enumerate(fault_labels2):
|
||||
ttk.Label(frame, text=label).grid(row=14+i//4, column=(i%4)*2, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
canvas.grid(row=14+i//4, column=(i%4)*2+1, sticky=tk.W)
|
||||
ttk.Label(fault_frame, text=label).grid(row=4+i//4, column=(i%4)*2, sticky=tk.W, padx=2)
|
||||
canvas = tk.Canvas(fault_frame, width=16, height=16, bg="white", highlightthickness=1)
|
||||
canvas.grid(row=4+i//4, column=(i%4)*2+1, sticky=tk.W, padx=2)
|
||||
self.high_vol_dcdc_fault2_bits.append(canvas)
|
||||
|
||||
# 绝缘状态 - 详细显示
|
||||
@@ -573,15 +598,20 @@ class PowerManagerApp:
|
||||
|
||||
for i, (label, _) in enumerate(current_labels):
|
||||
ttk.Label(frame, text=label).grid(row=17+i//2, column=(i%2)*2, sticky=tk.W)
|
||||
label_var = ttk.Label(frame, text="0.0")
|
||||
label_var = ttk.Label(frame, text="0.0A")
|
||||
label_var.grid(row=17+i//2, column=(i%2)*2+1, sticky=tk.W)
|
||||
setattr(self, f"high_vol_{current_labels[i][1]}", label_var)
|
||||
|
||||
# 冷却水压力
|
||||
ttk.Label(frame, text="冷却水压力(MPa):").grid(row=23, column=0, sticky=tk.W)
|
||||
self.high_vol_cool_water_pressure = ttk.Label(frame, text="0.00")
|
||||
self.high_vol_cool_water_pressure = ttk.Label(frame, text="0.00KPa")
|
||||
self.high_vol_cool_water_pressure.grid(row=23, column=1, sticky=tk.W)
|
||||
|
||||
# 冷却水压力
|
||||
ttk.Label(frame, text="DC/DC温度:").grid(row=24, column=0, sticky=tk.W)
|
||||
self.high_vol_dcdc_temp = ttk.Label(frame, text="0.00摄氏度")
|
||||
self.high_vol_dcdc_temp.grid(row=24, column=1, sticky=tk.W)
|
||||
|
||||
def setup_high_a_vol_ui(self, parent):
|
||||
"""设置高压A母线状态界面"""
|
||||
frame = ttk.LabelFrame(parent, text="高压A母线状态")
|
||||
@@ -638,7 +668,7 @@ class PowerManagerApp:
|
||||
"""处理接收到的UDP消息"""
|
||||
try:
|
||||
msg_id = int.from_bytes(data[2:4], byteorder='little')
|
||||
|
||||
print('----------------------------',hex(msg_id))
|
||||
if msg_id == 0x0005: # 高压母线状态
|
||||
msg = msg_disHighVolBusFbMsg()
|
||||
if msg.unpack(data):
|
||||
@@ -662,6 +692,19 @@ class PowerManagerApp:
|
||||
bus["current"]["FB备用开关电流"] = msg.fbReservedSwitchCurrent / 10.0
|
||||
bus["current"]["备用电流3"] = msg.reservedCurrent3 / 10.0
|
||||
|
||||
# bus["breakers"]["燃料电池断路器"] = 1 if msg.fuelCellCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["动力锂电池断路器"] = 1 if msg.powerLithiumBatteryCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["推进电机断路器"] = 1 if msg.propulsionMotorCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["锂电池组仪表断路器"] = 1 if msg.lithiumBatteryGroupInstrumentCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["DC/DC模块断路器"] = 1 if msg.dcDc5ModuleCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["艏高压配电盒断路器"] = 1 if msg.bowHighVoltageDistributionBoxCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["艉FT设备45断路器"] = 1 if msg.sternFTDevice45CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["艉舵机开关1断路器"] = 1 if msg.sternRudderSwitch1CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["艉舵机开关2断路器"] = 1 if msg.sternRudderSwitch2CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["FB备用断路器"] = 1 if msg.fbReservedCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["TYZ备用断路器"] = 1 if msg.tyzReservedCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["备用断路器"] = 1 if msg.reservedCircuitBreaker == 0x55 else 0
|
||||
|
||||
bus["breakers"]["燃料电池断路器"] = msg.fuelCellCircuitBreaker
|
||||
bus["breakers"]["动力锂电池断路器"] = msg.powerLithiumBatteryCircuitBreaker
|
||||
bus["breakers"]["推进电机断路器"] = msg.propulsionMotorCircuitBreaker
|
||||
@@ -669,11 +712,13 @@ class PowerManagerApp:
|
||||
bus["breakers"]["DC/DC模块断路器"] = msg.dcDc5ModuleCircuitBreaker
|
||||
bus["breakers"]["艏高压配电盒断路器"] = msg.bowHighVoltageDistributionBoxCircuitBreaker
|
||||
bus["breakers"]["艉FT设备45断路器"] = msg.sternFTDevice45CircuitBreaker
|
||||
bus["breakers"]["艉舵机开关1断路器"] = msg.sternRudderSwitch1CircuitBreaker
|
||||
bus["breakers"]["艉舵机开关1断路器"] = msg.sternRudderSwitch1CircuitBreaker
|
||||
bus["breakers"]["艉舵机开关2断路器"] = msg.sternRudderSwitch2CircuitBreaker
|
||||
bus["breakers"]["FB备用断路器"] = msg.fbReservedCircuitBreaker
|
||||
bus["breakers"]["TYZ备用断路器"] = msg.tyzReservedCircuitBreaker
|
||||
bus["breakers"]["TYZ备用断路器"] = msg.tyzReservedCircuitBreaker
|
||||
bus["breakers"]["备用断路器"] = msg.reservedCircuitBreaker
|
||||
|
||||
# print('----------------------------',bus["breakers"])
|
||||
|
||||
bus["faults"]["DC/DC故障1"] = msg.dcDcFaultWord1
|
||||
bus["faults"]["DC/DC故障2"] = msg.dcDcFaultWord2
|
||||
@@ -688,14 +733,21 @@ class PowerManagerApp:
|
||||
else:
|
||||
bus["insulation"]["A母线绝缘状态"] = 1
|
||||
|
||||
# bus["insulation"]["A母线绝缘状态"] = msg.aBusInsulationStatus
|
||||
bus["alarms"]["仪表电源丢失信号"] = msg.meterPowerLossSignal
|
||||
bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerLossSignal
|
||||
if msg.meterPowerLossSignal == 0x55:
|
||||
bus["alarms"]["仪表电源丢失信号"] = 0
|
||||
else:
|
||||
bus["alarms"]["仪表电源丢失信号"] = 1
|
||||
# bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerLossSignal
|
||||
if msg.emergencyPowerLossSignal == 0x55:
|
||||
bus["alarms"]["应急电源丢失信号"] = 0
|
||||
else:
|
||||
bus["alarms"]["应急电源丢失信号"] = 1
|
||||
bus["cool_water_pressure"] = msg.coolWaterPressure / 10.0
|
||||
bus["dcdc_temp"] = msg.dcdcTemperature-40
|
||||
|
||||
self.status_data["high_vol_bus"] = bus
|
||||
# 更新UI显示
|
||||
print(self.status_data)
|
||||
# print(self.status_data)
|
||||
|
||||
self.log_message("收到高压母线状态更新")
|
||||
elif msg_id == 0x0006: # 高压A母线状态
|
||||
@@ -712,15 +764,22 @@ class PowerManagerApp:
|
||||
bus["current"]["艏舵控制箱电流"] = msg.bowRudderControlBoxCurrent / 10.0
|
||||
bus["current"]["开盖启动气缸电流"] = msg.openWaterCoverStartCylinderCurrent / 10.0
|
||||
|
||||
# bus["breakers"]["艏FT设备123断路器"] = 1 if msg.bowFTDevice123CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["执行机构断路器"] = 1 if msg.actuatorCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["桅舵机控制箱断路器"] = 1 if msg.mastSteeringGearControlBoxCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["XCZ断路器"] = 1 if msg.xczCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["艏舵控制箱断路器"] = 1 if msg.bowRudderControlBoxCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["开盖启动气缸断路器"] = 1 if msg.openWaterCoverStartCylinderCircuitBreaker == 0x55 else 0
|
||||
bus["breakers"]["艏FT设备123断路器"] = msg.bowFTDevice123CircuitBreaker
|
||||
bus["breakers"]["执行机构断路器"] = msg.actuatorCircuitBreaker
|
||||
bus["breakers"]["桅舵机控制箱断路器"] = msg.mastSteeringGearControlBoxCircuitBreaker
|
||||
bus["breakers"]["XCZ断路器"] = msg.xczCircuitBreaker
|
||||
bus["breakers"]["艏舵控制箱断路器"] = msg.bowRudderControlBoxCircuitBreaker
|
||||
bus["breakers"]["开盖启动气缸断路器"] = msg.openWaterCoverStartCylinderCircuitBreaker
|
||||
|
||||
|
||||
bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
bus["alarms"]["仪表电源丢失信号"] = msg.instrumentPowerFailureSignal
|
||||
bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerFailureSignal
|
||||
bus["alarms"]["进水报警"] = msg.waterIngressionAlarm
|
||||
|
||||
self.log_message("收到高压A母线状态更新")
|
||||
@@ -742,6 +801,13 @@ class PowerManagerApp:
|
||||
bus["current"]["燃料电池安全系统应急DC48V电流"] = msg.fuelCellSecuritySystemEmergencyDC48VCurrent / 10.0
|
||||
bus["current"]["PLC控制电源电流"] = msg.plcControlPowerCurrent / 10.0
|
||||
|
||||
# bus["breakers"]["锂电池组仪表断路器"] = 1 if msg.lithiumBatteryGroupInstrumentCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["艏低压配电盒断路器"] = 1 if msg.bowLowVoltageDistributionBoxCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["单元4仪表48V断路器"] = 1 if msg.unit4InstrumentDC48VCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["DC/C1直流配电板断路器"] = 1 if msg.dcC1DCDistributionPanelCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["备用断路器1"] = 1 if msg.reservedCircuitBreaker1 == 0x55 else 0
|
||||
# bus["breakers"]["备用断路器2"] = 1 if msg.reservedCircuitBreaker2 == 0x55 else 0
|
||||
# bus["breakers"]["应急锂电池组2断路器"] = 1 if msg.emergencyLithiumBatteryGroup2CircuitBreaker == 0x55 else 0
|
||||
bus["breakers"]["锂电池组仪表断路器"] = msg.lithiumBatteryGroupInstrumentCircuitBreaker
|
||||
bus["breakers"]["艏低压配电盒断路器"] = msg.bowLowVoltageDistributionBoxCircuitBreaker
|
||||
bus["breakers"]["单元4仪表48V断路器"] = msg.unit4InstrumentDC48VCircuitBreaker
|
||||
@@ -749,10 +815,24 @@ class PowerManagerApp:
|
||||
bus["breakers"]["备用断路器1"] = msg.reservedCircuitBreaker1
|
||||
bus["breakers"]["备用断路器2"] = msg.reservedCircuitBreaker2
|
||||
bus["breakers"]["应急锂电池组2断路器"] = msg.emergencyLithiumBatteryGroup2CircuitBreaker
|
||||
|
||||
bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
bus["insulation"] = msg.instrumentBusbarInsulationLow
|
||||
|
||||
# 0x55 正常
|
||||
# 0xaa 故障
|
||||
if msg.instrumentPowerFailureSignal == 0x55:
|
||||
bus["alarms"]["仪表电源故障"] = 0
|
||||
else:
|
||||
bus["alarms"]["仪表电源故障"] = 1
|
||||
# bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
if msg.emergencyPowerFailureSignal == 0x55:
|
||||
bus["alarms"]["应急电源故障"] = 0
|
||||
else:
|
||||
bus["alarms"]["应急电源故障"] = 1
|
||||
# bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
# bus["insulation"] = msg.instrumentBusbarInsulationLow
|
||||
if msg.instrumentBusbarInsulationLow == 0x55:
|
||||
bus["insulation"] = 0
|
||||
else:
|
||||
bus["insulation"] = 1
|
||||
|
||||
self.log_message("收到仪表主母线状态更新")
|
||||
|
||||
@@ -771,17 +851,34 @@ class PowerManagerApp:
|
||||
bus["current"]["艏PZ设备电流"] = msg.bowPZDeviceCurrent / 10.0
|
||||
bus["current"]["应急锂电池组1电流"] = msg.emergencyLithiumBatteryGroup1Current / 10.0
|
||||
|
||||
# bus["breakers"]["单元1断路器"] = 1 if msg.unit1CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["单元2断路器"] = 1 if msg.unit2CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["单元3断路器"] = 1 if msg.unit3CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["单元5断路器"] = 1 if msg.unit5CircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["艏PZ设备断路器"] = 1 if msg.bowPZDeviceCircuitBreaker == 0x55 else 0
|
||||
# bus["breakers"]["备用断路器1"] = 1 if msg.reservedCircuitBreaker1 == 0x55 else 0
|
||||
# bus["breakers"]["备用断路器2"] = 1 if msg.reservedCircuitBreaker2 == 0x55 else 0
|
||||
# bus["breakers"]["应急锂电池组1断路器"] = 1 if msg.emergencyLithiumBatteryGroup1CircuitBreaker == 0x55 else 0
|
||||
|
||||
bus["breakers"]["单元1断路器"] = msg.unit1CircuitBreaker
|
||||
bus["breakers"]["单元2断路器"] = msg.unit2CircuitBreaker
|
||||
bus["breakers"]["单元3断路器"] = msg.unit3CircuitBreaker
|
||||
bus["breakers"]["单元5断路器"] = msg.unit5CircuitBreaker
|
||||
bus["breakers"]["艏PZ设备断路器"] = msg.bowPZDeviceCircuitBreaker
|
||||
bus["breakers"]["艏PZ设备断路器"] = msg.bowPZDeviceCircuitBreake
|
||||
bus["breakers"]["备用断路器1"] = msg.reservedCircuitBreaker1
|
||||
bus["breakers"]["备用断路器2"] = msg.reservedCircuitBreaker2
|
||||
bus["breakers"]["应急锂电池组1断路器"] = msg.emergencyLithiumBatteryGroup1CircuitBreaker
|
||||
|
||||
bus["alarms"]["电源故障信号"] = msg.powerFailureSignal
|
||||
bus["alarms"]["进水报警"] = msg.waterIngressionAlarm
|
||||
# bus["alarms"]["电源故障信号"] = msg.powerFailureSignal
|
||||
if msg.powerFailureSignal == 0x55:
|
||||
bus["alarms"]["电源故障信号"] = 0
|
||||
else:
|
||||
bus["alarms"]["电源故障信号"] = 1
|
||||
# bus["alarms"]["进水报警"] = msg.waterIngressionAlarm
|
||||
if msg.waterIngressionAlarm == 0x55:
|
||||
bus["alarms"]["进水报警"] = 0
|
||||
else:
|
||||
bus["alarms"]["进水报警"] = 1
|
||||
self.log_message("收到仪表母线状态更新")
|
||||
|
||||
else:
|
||||
@@ -794,7 +891,13 @@ class PowerManagerApp:
|
||||
def setup_low_main_ui(self, parent):
|
||||
"""设置仪表主母线状态界面"""
|
||||
frame = ttk.LabelFrame(parent, text="仪表主母线状态")
|
||||
frame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
|
||||
frame.pack(fill=tk.BOTH, expand=True, padx=2, pady=2)
|
||||
|
||||
# 显式配置4列网格布局
|
||||
frame.grid_columnconfigure(0, weight=1)
|
||||
frame.grid_columnconfigure(1, weight=1)
|
||||
frame.grid_columnconfigure(2, weight=1)
|
||||
frame.grid_columnconfigure(3, weight=1)
|
||||
|
||||
# 电压显示
|
||||
ttk.Label(frame, text="仪表母线电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
@@ -855,7 +958,13 @@ class PowerManagerApp:
|
||||
def setup_low_bus_ui(self, parent):
|
||||
"""设置仪表母线状态界面"""
|
||||
frame = ttk.LabelFrame(parent, text="仪表母线状态")
|
||||
frame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
|
||||
frame.pack(fill=tk.BOTH, expand=True, padx=2, pady=2)
|
||||
|
||||
# 显式配置4列网格布局
|
||||
frame.grid_columnconfigure(0, weight=1)
|
||||
frame.grid_columnconfigure(1, weight=1)
|
||||
frame.grid_columnconfigure(2, weight=1)
|
||||
frame.grid_columnconfigure(3, weight=1)
|
||||
|
||||
# 电压显示
|
||||
ttk.Label(frame, text="仪表母线电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
@@ -897,9 +1006,6 @@ class PowerManagerApp:
|
||||
self.low_bus_water_alarm = ttk.Label(frame, text="无")
|
||||
self.low_bus_water_alarm.grid(row=8, column=3, sticky=tk.W)
|
||||
|
||||
# 报警状态
|
||||
ttk.Label(frame, text="电源故障信号:").grid(row=8, column=0, sticky=tk.W)
|
||||
self.low_bus_power_fault = ttk.Label(frame, text="无")
|
||||
self.low_bus_power_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="进水报警:").grid(row=8, column=2, sticky=tk.W)
|
||||
@@ -908,22 +1014,24 @@ class PowerManagerApp:
|
||||
|
||||
return frame
|
||||
|
||||
def send_udp_command(self, data):
|
||||
def send_udp_command(self, data, ip, port):
|
||||
"""发送UDP命令"""
|
||||
try:
|
||||
self.sock.sendto(data, (self.udp_ip, self.udp_port + 1))
|
||||
# self.sock.sendto(data, (self.udp_ip, self.udp_port + 1))
|
||||
self.sock.sendto(data, (ip, port))
|
||||
print(f"发送命令到 {ip}:{port} ", data)
|
||||
except Exception as e:
|
||||
self.log_message(f"发送命令失败: {str(e)}")
|
||||
|
||||
def update_high_vol_ui(self, status):
|
||||
"""更新高压母线UI显示"""
|
||||
# 更新电压显示
|
||||
self.high_vol_power_voltage.config(text=f"{status['voltage']['动力母线电压']:.1f}")
|
||||
self.high_vol_a_voltage.config(text=f"{status['voltage']['A母线电压']:.1f}")
|
||||
self.high_vol_power_voltage.config(text=f"{status['voltage']['动力母线电压']:.1f} V")
|
||||
self.high_vol_a_voltage.config(text=f"{status['voltage']['A母线电压']:.1f} V")
|
||||
|
||||
# 更新电流显示
|
||||
self.high_vol_power_current.config(text=f"{status['current']['动力母线电流']:.1f}")
|
||||
self.high_vol_a_current.config(text=f"{status['current']['A母线电流']:.1f}")
|
||||
# # 更新电流显示
|
||||
# self.high_vol_power_current.config(text=f"{status['current']['动力母线电流']:.1f}")
|
||||
# self.high_vol_a_current.config(text=f"{status['current']['A母线电流']:.1f}")
|
||||
|
||||
# 更新所有电流值
|
||||
current_vars = [
|
||||
@@ -942,13 +1050,22 @@ class PowerManagerApp:
|
||||
|
||||
for var_name, data_key in current_vars:
|
||||
label = getattr(self, f"high_vol_{var_name}")
|
||||
label.config(text=f"{status['current'][data_key]:.1f}")
|
||||
label.config(text=f"{status['current'][data_key]:.1f} A")
|
||||
|
||||
# 更新断路器状态
|
||||
for name, state in status['breakers'].items():
|
||||
if name in self.high_vol_breakers:
|
||||
canvas = self.high_vol_breakers[name]
|
||||
color = 'green' if state else 'red'
|
||||
# color = 'green' if state else 'red'
|
||||
print(name, hex(state))
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
color = "black"
|
||||
elif state == 0x5A:
|
||||
color = "red"
|
||||
else:
|
||||
color = "white"
|
||||
canvas.delete("all")
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
@@ -973,7 +1090,10 @@ class PowerManagerApp:
|
||||
self.high_vol_a_insulation.config(text=a_text)
|
||||
|
||||
# 更新冷却水压力
|
||||
self.high_vol_cool_water_pressure.config(text=f"{status['cool_water_pressure']:.2f}")
|
||||
self.high_vol_cool_water_pressure.config(text=f"{status['cool_water_pressure']:.1f} Kpa")
|
||||
|
||||
# # 更新温度状态
|
||||
self.high_vol_dcdc_temp.config(text=f"{status['dcdc_temp']} 摄氏度")
|
||||
|
||||
def update_ui(self):
|
||||
"""更新界面状态"""
|
||||
@@ -989,31 +1109,55 @@ class PowerManagerApp:
|
||||
|
||||
for name, canvas in self.high_a_vol_breakers.items():
|
||||
state = high_a_vol["breakers"].get(name, 0)
|
||||
color = "green" if state else "red"
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
color = "black"
|
||||
elif state == 0x5A:
|
||||
color = "red"
|
||||
else:
|
||||
color = "white"
|
||||
# color = "green" if state else "red"
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
# 更新仪表主母线状态
|
||||
low_main = self.status_data["low_main_bus"]
|
||||
for name, canvas in self.low_main_breakers.items():
|
||||
state = low_main["breakers"].get(name, 0)
|
||||
color = "green" if state else "red"
|
||||
# color = "green" if state else "red"
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
color = "black"
|
||||
elif state == 0x5A:
|
||||
color = "red"
|
||||
else:
|
||||
color = "white"
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
# 更新仪表母线状态
|
||||
low_bus = self.status_data["low_bus"]
|
||||
for name, canvas in self.low_bus_breakers.items():
|
||||
state = low_bus["breakers"].get(name, 0)
|
||||
color = "green" if state else "red"
|
||||
# color = "green" if state else "red"
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
color = "black"
|
||||
elif state == 0x5A:
|
||||
color = "red"
|
||||
else:
|
||||
color = "white"
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
self.high_a_vol_instrument_power_fault.config(
|
||||
text="无" if not high_a_vol["alarms"]["仪表电源故障"] else "有"
|
||||
text="正常" if not high_a_vol["alarms"]["仪表电源故障"] else "故障"
|
||||
)
|
||||
self.high_a_vol_emergency_power_fault.config(
|
||||
text="无" if not high_a_vol["alarms"]["应急电源故障"] else "有"
|
||||
text="正常" if not high_a_vol["alarms"]["应急电源故障"] else "故障"
|
||||
)
|
||||
self.high_a_vol_water_alarm.config(
|
||||
text="无" if not high_a_vol["alarms"]["进水报警"] else "有"
|
||||
text="正常" if not high_a_vol["alarms"]["进水报警"] else "故障"
|
||||
)
|
||||
|
||||
# 更新仪表主母线状态
|
||||
@@ -1026,17 +1170,25 @@ class PowerManagerApp:
|
||||
|
||||
for name, canvas in self.low_main_breakers.items():
|
||||
state = low_main["breakers"].get(name, 0)
|
||||
color = "green" if state else "red"
|
||||
# color = "green" if state else "red"
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
color = "black"
|
||||
elif state == 0x5A:
|
||||
color = "red"
|
||||
else:
|
||||
color = "white"
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
self.low_main_instrument_fault.config(
|
||||
text="无" if not low_main["alarms"]["仪表电源故障"] else "有"
|
||||
text="正常" if not low_main["alarms"]["仪表电源故障"] else "故障"
|
||||
)
|
||||
self.low_main_emergency_fault.config(
|
||||
text="无" if not low_main["alarms"]["应急电源故障"] else "有"
|
||||
text="正常" if not low_main["alarms"]["应急电源故障"] else "故障"
|
||||
)
|
||||
self.low_main_insulation.config(
|
||||
text="正常" if not low_main["insulation"] else "异常"
|
||||
text="正常" if not low_main["insulation"] else "故障"
|
||||
)
|
||||
|
||||
# 更新仪表母线状态
|
||||
@@ -1048,16 +1200,24 @@ class PowerManagerApp:
|
||||
|
||||
for name, canvas in self.low_bus_breakers.items():
|
||||
state = low_bus["breakers"].get(name, 0)
|
||||
color = "green" if state else "red"
|
||||
# color = "green" if state else "red"
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
color = "black"
|
||||
elif state == 0x5A:
|
||||
color = "red"
|
||||
else:
|
||||
color = "white"
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
self.low_bus_power_fault.config(
|
||||
text="无" if not low_bus["alarms"]["电源故障信号"] else "有"
|
||||
text="正常" if not low_bus["alarms"]["电源故障信号"] else "故障"
|
||||
)
|
||||
self.low_bus_water_alarm.config(
|
||||
text="无" if not low_bus["alarms"]["进水报警"] else "有"
|
||||
text="正常" if not low_bus["alarms"]["进水报警"] else "故障"
|
||||
)
|
||||
print('update_ui')
|
||||
# print('update_ui')
|
||||
# 每500ms更新一次
|
||||
self.root.after(1000, self.update_ui)
|
||||
|
||||
|
||||
+10
-8
@@ -35,7 +35,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disHighVolBusFbMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
fuelCellCircuitBreaker INTEGER,
|
||||
powerLithiumBatteryCircuitBreaker INTEGER,
|
||||
propulsionMotorCircuitBreaker INTEGER,
|
||||
@@ -54,6 +54,7 @@ class DB:
|
||||
aBusInsulationStatus INTEGER,
|
||||
meterPowerLossSignal INTEGER,
|
||||
emergencyPowerLossSignal INTEGER,
|
||||
dcdcTemperature INTEGER,
|
||||
powerBusVoltage INTEGER,
|
||||
dcDc5ModuleCurrent INTEGER,
|
||||
powerBusCurrent INTEGER,
|
||||
@@ -78,7 +79,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disHighAVolBusFbMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
bowFTDevice123CircuitBreaker INTEGER,
|
||||
actuatorCircuitBreaker INTEGER,
|
||||
mastSteeringGearControlBoxCircuitBreaker INTEGER,
|
||||
@@ -103,7 +104,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disLowMainBusFbMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
lithiumBatteryGroupInstrumentCircuitBreaker INTEGER,
|
||||
bowLowVoltageDistributionBoxCircuitBreaker INTEGER,
|
||||
unit4InstrumentDC48VCircuitBreaker INTEGER,
|
||||
@@ -133,7 +134,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disLowBusFbMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
unit1CircuitBreaker INTEGER,
|
||||
unit2CircuitBreaker INTEGER,
|
||||
unit3CircuitBreaker INTEGER,
|
||||
@@ -160,7 +161,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disHVBCmdMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
fuelCellCircuitBreakerCmd INTEGER,
|
||||
powerLithiumBatteryCircuitBreakerCmd INTEGER,
|
||||
propulsionMotorCircuitBreakerCmd INTEGER,
|
||||
@@ -182,7 +183,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disHVBACmdMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
bowFTDevice123CircuitBreakerCmd INTEGER,
|
||||
actuatorCircuitBreakerCmd INTEGER,
|
||||
mastSteeringGearControlBoxCircuitBreakerCmd INTEGER,
|
||||
@@ -196,7 +197,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disLVMBCmdMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
lithiumBatteryGroupInstrumentCircuitBreakerCmd INTEGER,
|
||||
bowLowVoltageDistributionBoxCircuitBreakerCmd INTEGER,
|
||||
unit4InstrumentDC48VCircuitBreakerCmd INTEGER,
|
||||
@@ -211,7 +212,7 @@ class DB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS msg_disLVBCmdMsg (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
timestamp DATETIME DEFAULT (datetime('now', 'localtime')),
|
||||
unit1CircuitBreakerCmd INTEGER,
|
||||
unit2CircuitBreakerCmd INTEGER,
|
||||
unit3CircuitBreakerCmd INTEGER,
|
||||
@@ -285,6 +286,7 @@ class DB:
|
||||
'aBusInsulationStatus': data.aBusInsulationStatus,
|
||||
'meterPowerLossSignal': data.meterPowerLossSignal,
|
||||
'emergencyPowerLossSignal': data.emergencyPowerLossSignal,
|
||||
'dcdcTemperature': data.dcdcTemperature,
|
||||
'powerBusVoltage': data.powerBusVoltage,
|
||||
'dcDc5ModuleCurrent': data.dcDc5ModuleCurrent,
|
||||
'powerBusCurrent': data.powerBusCurrent,
|
||||
|
||||
+36
-35
@@ -33,24 +33,25 @@ class PowerManagerSimulator:
|
||||
def _init_sim_data(self):
|
||||
"""初始化模拟数据"""
|
||||
# 高压母线反馈数据 - 测试所有成员
|
||||
self.high_vol_fb.fuelCellCircuitBreaker = 1
|
||||
self.high_vol_fb.powerLithiumBatteryCircuitBreaker = 1
|
||||
self.high_vol_fb.propulsionMotorCircuitBreaker = 1
|
||||
self.high_vol_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 1
|
||||
self.high_vol_fb.dcDc5ModuleCircuitBreaker = 1
|
||||
self.high_vol_fb.bowHighVoltageDistributionBoxCircuitBreaker = 1
|
||||
self.high_vol_fb.sternFTDevice45CircuitBreaker = 1
|
||||
self.high_vol_fb.sternRudderSwitch1CircuitBreaker = 1
|
||||
self.high_vol_fb.sternRudderSwitch2CircuitBreaker = 1
|
||||
self.high_vol_fb.fbReservedCircuitBreaker = 0
|
||||
self.high_vol_fb.tyzReservedCircuitBreaker = 0
|
||||
self.high_vol_fb.reservedCircuitBreaker = 0
|
||||
self.high_vol_fb.fuelCellCircuitBreaker = 0x55
|
||||
self.high_vol_fb.powerLithiumBatteryCircuitBreaker = 0x55
|
||||
self.high_vol_fb.propulsionMotorCircuitBreaker = 0x55
|
||||
self.high_vol_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 0x55
|
||||
self.high_vol_fb.dcDc5ModuleCircuitBreaker = 0x55
|
||||
self.high_vol_fb.bowHighVoltageDistributionBoxCircuitBreaker = 0x55
|
||||
self.high_vol_fb.sternFTDevice45CircuitBreaker = 0x55
|
||||
self.high_vol_fb.sternRudderSwitch1CircuitBreaker = 0x55
|
||||
self.high_vol_fb.sternRudderSwitch2CircuitBreaker = 0x55
|
||||
self.high_vol_fb.fbReservedCircuitBreaker = 0x55
|
||||
self.high_vol_fb.tyzReservedCircuitBreaker = 0x55
|
||||
self.high_vol_fb.reservedCircuitBreaker = 0x55
|
||||
self.high_vol_fb.dcDcFaultWord1 = 0xFF # 测试故障模式
|
||||
self.high_vol_fb.dcDcFaultWord2 = 0xAA
|
||||
self.high_vol_fb.powerBusInsulationStatus = 0x55
|
||||
self.high_vol_fb.aBusInsulationStatus = 0x55
|
||||
self.high_vol_fb.meterPowerLossSignal = 0
|
||||
self.high_vol_fb.emergencyPowerLossSignal = 0
|
||||
self.high_vol_fb.dcdcTemperature = 0x08 # 正常值
|
||||
self.high_vol_fb.powerBusVoltage = 600 # 正常值
|
||||
self.high_vol_fb.dcDc5ModuleCurrent = 50
|
||||
self.high_vol_fb.powerBusCurrent = 100
|
||||
@@ -70,15 +71,15 @@ class PowerManagerSimulator:
|
||||
self.high_vol_fb.coolWaterPressure = 100
|
||||
|
||||
# 高压A母线反馈数据 - 测试所有成员
|
||||
self.high_a_vol_fb.bowFTDevice123CircuitBreaker = 1
|
||||
self.high_a_vol_fb.actuatorCircuitBreaker = 1
|
||||
self.high_a_vol_fb.mastSteeringGearControlBoxCircuitBreaker = 1
|
||||
self.high_a_vol_fb.xczCircuitBreaker = 1
|
||||
self.high_a_vol_fb.bowRudderControlBoxCircuitBreaker = 1
|
||||
self.high_a_vol_fb.openWaterCoverStartCylinderCircuitBreaker = 0
|
||||
self.high_a_vol_fb.instrumentPowerFailureSignal = 0
|
||||
self.high_a_vol_fb.emergencyPowerFailureSignal = 0
|
||||
self.high_a_vol_fb.waterIngressionAlarm = 0
|
||||
self.high_a_vol_fb.bowFTDevice123CircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.actuatorCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.mastSteeringGearControlBoxCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.xczCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.bowRudderControlBoxCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.openWaterCoverStartCylinderCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.instrumentPowerFailureSignal = 0x55
|
||||
self.high_a_vol_fb.emergencyPowerFailureSignal = 0x55
|
||||
self.high_a_vol_fb.waterIngressionAlarm = 0x55
|
||||
self.high_a_vol_fb.busbarBVoltage = 600
|
||||
self.high_a_vol_fb.busbarBCurrent = 30
|
||||
self.high_a_vol_fb.bowFTDevice123Current = 20
|
||||
@@ -89,16 +90,16 @@ class PowerManagerSimulator:
|
||||
self.high_a_vol_fb.openWaterCoverStartCylinderCurrent = 0
|
||||
|
||||
# 仪表主母线反馈数据 - 测试所有成员
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 1
|
||||
self.low_main_fb.bowLowVoltageDistributionBoxCircuitBreaker = 1
|
||||
self.low_main_fb.unit4InstrumentDC48VCircuitBreaker = 1
|
||||
self.low_main_fb.dcC1DCDistributionPanelCircuitBreaker = 1
|
||||
self.low_main_fb.reservedCircuitBreaker1 = 0
|
||||
self.low_main_fb.reservedCircuitBreaker2 = 0
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2CircuitBreaker = 0
|
||||
self.low_main_fb.instrumentPowerFailureSignal = 0
|
||||
self.low_main_fb.emergencyPowerFailureSignal = 0
|
||||
self.low_main_fb.instrumentBusbarInsulationLow = 0
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 0x55
|
||||
self.low_main_fb.bowLowVoltageDistributionBoxCircuitBreaker = 0x55
|
||||
self.low_main_fb.unit4InstrumentDC48VCircuitBreaker = 0x55
|
||||
self.low_main_fb.dcC1DCDistributionPanelCircuitBreaker = 0x55
|
||||
self.low_main_fb.reservedCircuitBreaker1 = 0x55
|
||||
self.low_main_fb.reservedCircuitBreaker2 = 0x55
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2CircuitBreaker = 0x55
|
||||
self.low_main_fb.instrumentPowerFailureSignal = 0x55
|
||||
self.low_main_fb.emergencyPowerFailureSignal = 0x55
|
||||
self.low_main_fb.instrumentBusbarInsulationLow = 0x55
|
||||
self.low_main_fb.instrumentBusbarVoltage = 48
|
||||
self.low_main_fb.bowLowVoltageDistributionBoxCurrent = 10
|
||||
self.low_main_fb.dcC1InstrumentDC48VCurrent = 5
|
||||
@@ -157,19 +158,19 @@ class PowerManagerSimulator:
|
||||
try:
|
||||
# 发送高压母线反馈
|
||||
data = self.high_vol_fb.pack()
|
||||
self.sock.sendto(data, (self.host, 5000))
|
||||
self.sock.sendto(data, (self.host, 7000))
|
||||
|
||||
# 发送高压A母线反馈
|
||||
data = self.high_a_vol_fb.pack()
|
||||
self.sock.sendto(data, (self.host, 5000))
|
||||
self.sock.sendto(data, (self.host, 7000))
|
||||
|
||||
# 发送仪表主母线反馈
|
||||
data = self.low_main_fb.pack()
|
||||
self.sock.sendto(data, (self.host, 5000))
|
||||
self.sock.sendto(data, (self.host, 7000))
|
||||
|
||||
# 发送仪表汇流排反馈
|
||||
data = self.low_bus_fb.pack()
|
||||
self.sock.sendto(data, (self.host, 5000))
|
||||
self.sock.sendto(data, (self.host, 7000))
|
||||
|
||||
time.sleep(1) # 每秒发送一次
|
||||
|
||||
|
||||
+45
-64
@@ -3,10 +3,10 @@ import struct
|
||||
# 高压母线配电反馈
|
||||
class msg_disHighVolBusFbMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0005
|
||||
self.length = 38 # disHighVolBusState结构体大小
|
||||
self.length = 59
|
||||
self.checkCode = 0x00
|
||||
|
||||
# disHighVolBusState成员
|
||||
@@ -28,6 +28,7 @@ class msg_disHighVolBusFbMsg:
|
||||
self.aBusInsulationStatus = 0x00
|
||||
self.meterPowerLossSignal = 0x00
|
||||
self.emergencyPowerLossSignal = 0x00
|
||||
self.dcdcTemperature = 0x00
|
||||
self.powerBusVoltage = 0
|
||||
self.dcDc5ModuleCurrent = 0
|
||||
self.powerBusCurrent = 0
|
||||
@@ -72,6 +73,7 @@ class msg_disHighVolBusFbMsg:
|
||||
data += struct.pack('<B', self.aBusInsulationStatus)
|
||||
data += struct.pack('<B', self.meterPowerLossSignal)
|
||||
data += struct.pack('<B', self.emergencyPowerLossSignal)
|
||||
data += struct.pack('<B', self.dcdcTemperature)
|
||||
data += struct.pack('<H', self.powerBusVoltage)
|
||||
data += struct.pack('<H', self.dcDc5ModuleCurrent)
|
||||
data += struct.pack('<H', self.powerBusCurrent)
|
||||
@@ -98,8 +100,8 @@ class msg_disHighVolBusFbMsg:
|
||||
return data
|
||||
|
||||
def unpack(self, data):
|
||||
if len(data) < 4 + self.length + 1:
|
||||
return False
|
||||
# if len(data) < 4 + self.length + 1:
|
||||
# return False
|
||||
|
||||
self.start1 = data[0]
|
||||
self.start2 = data[1]
|
||||
@@ -125,6 +127,7 @@ class msg_disHighVolBusFbMsg:
|
||||
self.aBusInsulationStatus = data[offset]; offset +=1
|
||||
self.meterPowerLossSignal = data[offset]; offset +=1
|
||||
self.emergencyPowerLossSignal = data[offset]; offset +=1
|
||||
self.dcdcTemperature = data[offset]; offset +=1 # 新增的温度信号解包
|
||||
|
||||
self.powerBusVoltage = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
self.dcDc5ModuleCurrent = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
@@ -153,8 +156,8 @@ class msg_disHighVolBusFbMsg:
|
||||
# 高压母线A配电反馈
|
||||
class msg_disHighAVolBusFbMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0006
|
||||
self.length = 18 # disHighAVolBusState结构体大小
|
||||
self.checkCode = 0x00
|
||||
@@ -249,8 +252,8 @@ class msg_disHighAVolBusFbMsg:
|
||||
# 仪表母线配电反馈
|
||||
class msg_disLowMainBusFbMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0007
|
||||
self.length = 36 # disLowMainBusState结构体大小
|
||||
self.checkCode = 0x00
|
||||
@@ -360,8 +363,8 @@ class msg_disLowMainBusFbMsg:
|
||||
# 仪表汇流排配电反馈
|
||||
class msg_disLowBusFbMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0008
|
||||
self.length = 24 # disLowBusState结构体大小
|
||||
self.checkCode = 0x00
|
||||
@@ -462,8 +465,8 @@ class msg_disLowBusFbMsg:
|
||||
# 动力母线配电指令
|
||||
class msg_disHVBCmdMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0001
|
||||
self.length = 18 # disHighVolBusCmd结构体大小
|
||||
self.checkCode = 0x00
|
||||
@@ -549,27 +552,19 @@ class msg_disHVBCmdMsg:
|
||||
# 动力汇流排A配电指令
|
||||
class msg_disHVBACmdMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0002
|
||||
self.length = 18 # disHighVolBusCmd结构体大小
|
||||
self.length = 6 # disHighAVolBusCmd结构体大小(6个unsigned char)
|
||||
self.checkCode = 0x00
|
||||
|
||||
# disHighVolBusCmd成员
|
||||
self.fuelCellCircuitBreaker = 0x00
|
||||
self.powerLithiumBatteryCircuitBreaker = 0x00
|
||||
self.propulsionMotorCircuitBreaker = 0x00
|
||||
self.lithiumBatteryGroupInstrumentCircuitBreaker = 0x00
|
||||
self.dcDc5ModuleCircuitBreaker = 0x00
|
||||
self.bowHighVoltageDistributionBoxCircuitBreaker = 0x00
|
||||
self.sternFTDevice45CircuitBreaker = 0x00
|
||||
self.sternRudderSwitch1CircuitBreaker = 0x00
|
||||
self.sternRudderSwitch2CircuitBreaker = 0x00
|
||||
self.fbReservedCircuitBreaker = 0x00
|
||||
self.tyzReservedCircuitBreaker = 0x00
|
||||
self.reservedCircuitBreaker = 0x00
|
||||
self.dcdc5Module = 0x00
|
||||
self.coolingSystem = 0x00
|
||||
# disHighAVolBusCmd成员
|
||||
self.bowFTDevice123CircuitBreaker = 0x00
|
||||
self.actuatorCircuitBreaker = 0x00
|
||||
self.mastSteeringGearControlBoxCircuitBreaker = 0x00
|
||||
self.xczCircuitBreaker = 0x00
|
||||
self.bowRudderControlBoxCircuitBreaker = 0x00
|
||||
self.openWaterCoverStartCylinderCircuitBreaker = 0x00
|
||||
|
||||
def pack(self):
|
||||
self.checkCode = 0x00
|
||||
@@ -578,21 +573,13 @@ class msg_disHVBACmdMsg:
|
||||
data += struct.pack('<H', self.id)
|
||||
data += struct.pack('<H', self.length)
|
||||
|
||||
# 打包数据部分
|
||||
data += struct.pack('<B', self.fuelCellCircuitBreaker)
|
||||
data += struct.pack('<B', self.powerLithiumBatteryCircuitBreaker)
|
||||
data += struct.pack('<B', self.propulsionMotorCircuitBreaker)
|
||||
data += struct.pack('<B', self.lithiumBatteryGroupInstrumentCircuitBreaker)
|
||||
data += struct.pack('<B', self.dcDc5ModuleCircuitBreaker)
|
||||
data += struct.pack('<B', self.bowHighVoltageDistributionBoxCircuitBreaker)
|
||||
data += struct.pack('<B', self.sternFTDevice45CircuitBreaker)
|
||||
data += struct.pack('<B', self.sternRudderSwitch1CircuitBreaker)
|
||||
data += struct.pack('<B', self.sternRudderSwitch2CircuitBreaker)
|
||||
data += struct.pack('<B', self.fbReservedCircuitBreaker)
|
||||
data += struct.pack('<B', self.tyzReservedCircuitBreaker)
|
||||
data += struct.pack('<B', self.reservedCircuitBreaker)
|
||||
data += struct.pack('<B', self.dcdc5Module)
|
||||
data += struct.pack('<B', self.coolingSystem)
|
||||
# 打包数据部分(6个断路器)
|
||||
data += struct.pack('<B', self.bowFTDevice123CircuitBreaker)
|
||||
data += struct.pack('<B', self.actuatorCircuitBreaker)
|
||||
data += struct.pack('<B', self.mastSteeringGearControlBoxCircuitBreaker)
|
||||
data += struct.pack('<B', self.xczCircuitBreaker)
|
||||
data += struct.pack('<B', self.bowRudderControlBoxCircuitBreaker)
|
||||
data += struct.pack('<B', self.openWaterCoverStartCylinderCircuitBreaker)
|
||||
|
||||
# 计算校验码
|
||||
for byte in data:
|
||||
@@ -611,20 +598,14 @@ class msg_disHVBACmdMsg:
|
||||
self.length = struct.unpack_from('<H', data, 4)[0]
|
||||
|
||||
offset = 6 # 头部结束位置
|
||||
self.fuelCellCircuitBreaker = data[offset]; offset +=1
|
||||
self.powerLithiumBatteryCircuitBreaker = data[offset]; offset +=1
|
||||
self.propulsionMotorCircuitBreaker = data[offset]; offset +=1
|
||||
self.lithiumBatteryGroupInstrumentCircuitBreaker = data[offset]; offset +=1
|
||||
self.dcDc5ModuleCircuitBreaker = data[offset]; offset +=1
|
||||
self.bowHighVoltageDistributionBoxCircuitBreaker = data[offset]; offset +=1
|
||||
self.sternFTDevice45CircuitBreaker = data[offset]; offset +=1
|
||||
self.sternRudderSwitch1CircuitBreaker = data[offset]; offset +=1
|
||||
self.sternRudderSwitch2CircuitBreaker = data[offset]; offset +=1
|
||||
self.fbReservedCircuitBreaker = data[offset]; offset +=1
|
||||
self.tyzReservedCircuitBreaker = data[offset]; offset +=1
|
||||
self.reservedCircuitBreaker = data[offset]; offset +=1
|
||||
self.dcdc5Module = data[offset]; offset +=1
|
||||
self.coolingSystem = data[offset]; offset +=1
|
||||
self.bowFTDevice123CircuitBreaker = data[offset]; offset +=1
|
||||
self.actuatorCircuitBreaker = data[offset]; offset +=1
|
||||
self.mastSteeringGearControlBoxCircuitBreaker = data[offset]; offset +=1
|
||||
self.xczCircuitBreaker = data[offset]; offset +=1
|
||||
self.bowRudderControlBoxCircuitBreaker = data[offset]; offset +=1
|
||||
self.openWaterCoverStartCylinderCircuitBreaker = data[offset]; offset +=1
|
||||
self.bowRudderControlBoxCurrent = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
self.openWaterCoverStartCylinderCurrent = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
|
||||
# 校验校验码
|
||||
checkCode = 0
|
||||
@@ -635,8 +616,8 @@ class msg_disHVBACmdMsg:
|
||||
# 仪表母线配电指令
|
||||
class msg_disLVMBCmdMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0003
|
||||
self.length = 8 # disLowMainBusCmd结构体大小
|
||||
self.checkCode = 0x00
|
||||
@@ -701,8 +682,8 @@ class msg_disLVMBCmdMsg:
|
||||
# 仪表汇流排配电指令
|
||||
class msg_disLVBCmdMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x20
|
||||
self.start2 = 0x20
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0004
|
||||
self.length = 8 # disLowBusCmd结构体大小
|
||||
self.checkCode = 0x00
|
||||
|
||||
Reference in New Issue
Block a user