增加了新的调试界面,优化了一些功能

This commit is contained in:
zjk
2025-02-06 12:01:18 +08:00
parent c824caa27e
commit 6f5de4b614
14 changed files with 718 additions and 157 deletions
+109
View File
@@ -547,6 +547,115 @@ class disSys(Frame):
c = self.disHVBB.pack()
d = self.disLVB.pack()
return a,b,c,d
def update_fromMsg(self, data):
'''通过这个可以更新数据'''
try:
# 解析消息头
headBuf = data[:6]
header = struct.unpack('<BBHH', headBuf)
start1 = header[0]
start2 = header[1]
msg_id = header[2]
msg_len = header[3]
if start1 == 0x40 and start2 == 0x40:
if msg_id == 0x0001: # 高压母线配电指令
msg = msg_disHVBCmd()
msg.unpack(data)
self.disHVB.DCB1 = msg.fuelCellCircuitBreaker
self.disHVB.DCB2 = msg.powerLithiumBatteryCircuitBreaker
self.disHVB.ZK1 = msg.propulsionMotorCircuitBreaker
self.disHVB.ZK2 = msg.lithiumBatteryGroupInstrumentCircuitBreaker
self.disHVB.ZK3 = msg.dcDc5ModuleCircuitBreaker
self.disHVB.ZK4 = msg.bowHighVoltageDistributionBoxCircuitBreaker
self.disHVB.ZK5 = msg.sternFTDevice45CircuitBreaker
self.disHVB.ZK6 = msg.sternRudderSwitch1CircuitBreaker
self.disHVB.ZK7 = msg.sternRudderSwitch2CircuitBreaker
self.disHVB.ZK8 = msg.fbReservedCircuitBreaker
self.disHVB.ZK9 = msg.tyzReservedCircuitBreaker
self.disHVB.ZK10 = msg.reservedCircuitBreaker
self.disHVB.inputWater = msg.inputWater
self.disHVB.outputWater = msg.outputWater
self.disHVB.dcdc5dcdc5Module = msg.dcdc5dcdc5Module
# 更新dict1
self.dict1['燃料电池断路器'] = '闭合' if msg.fuelCellCircuitBreaker == 0x55 else '断开'
self.dict1['动力锂电池断路器'] = '闭合' if msg.powerLithiumBatteryCircuitBreaker == 0x55 else '断开'
self.dict1['推进电机断路器'] = '闭合' if msg.propulsionMotorCircuitBreaker == 0x55 else '断开'
self.dict1['仪表锂电池断路器'] = '闭合' if msg.lithiumBatteryGroupInstrumentCircuitBreaker == 0x55 else '断开'
self.dict1['DC/DC5模块断路器'] = '闭合' if msg.dcDc5ModuleCircuitBreaker == 0x55 else '断开'
self.dict1['艏部高压配电断路器'] = '闭合' if msg.bowHighVoltageDistributionBoxCircuitBreaker == 0x55 else '断开'
self.dict1['艏部FT4/5断路器'] = '闭合' if msg.sternFTDevice45CircuitBreaker == 0x55 else '断开'
self.dict1['艉舵1/2断路器'] = '闭合' if msg.sternRudderSwitch1CircuitBreaker == 0x55 else '断开'
self.dict1['艉舵3/4断路器'] = '闭合' if msg.sternRudderSwitch2CircuitBreaker == 0x55 else '断开'
self.dict1['FB预留断路器'] = '闭合' if msg.fbReservedCircuitBreaker == 0x55 else '断开'
self.dict1['TYZ预留断路器'] = '闭合' if msg.tyzReservedCircuitBreaker == 0x55 else '断开'
self.dict1['预留断路器'] = '闭合' if msg.reservedCircuitBreaker == 0x55 else '断开'
elif msg_id == 0x0002: # 高电压A母线配电指令
msg = msg_disHVBACmd()
msg.unpack(data)
self.disHVBA.bowFTDevice123CircuitBreaker = msg.bowFTDevice123CircuitBreaker
self.disHVBA.actuatorCircuitBreaker = msg.actuatorCircuitBreaker
self.disHVBA.mastSteeringGearControlBoxCircuitBreaker = msg.mastSteeringGearControlBoxCircuitBreaker
self.disHVBA.xczCircuitBreaker = msg.xczCircuitBreaker
self.disHVBA.bowRudderControlBoxCircuitBreaker = msg.bowRudderControlBoxCircuitBreaker
self.disHVBA.openWaterCoverStartCylinderCircuitBreaker = msg.openWaterCoverStartCylinderCircuitBreaker
# 更新dict2
self.dict2['艏部FT1-3断路器'] = '闭合' if msg.bowFTDevice123CircuitBreaker == 0x55 else '断开'
self.dict2['启闭机构断路器'] = '闭合' if msg.actuatorCircuitBreaker == 0x55 else '断开'
self.dict2['桅杆舵机断路器'] = '闭合' if msg.mastSteeringGearControlBoxCircuitBreaker == 0x55 else '断开'
self.dict2['XCZ断路器'] = '闭合' if msg.xczCircuitBreaker == 0x55 else '断开'
self.dict2['艏舵断路器'] = '闭合' if msg.bowRudderControlBoxCircuitBreaker == 0x55 else '断开'
self.dict2['敞开电缸断路器'] = '闭合' if msg.openWaterCoverStartCylinderCircuitBreaker == 0x55 else '断开'
elif msg_id == 0x0003: # 高电压B母线配电指令
msg = msg_disHVBBCmd()
msg.unpack(data)
self.disHVBB.lithiumBatteryGroupInstrumentCircuitBreaker = msg.lithiumBatteryGroupInstrumentCircuitBreaker
self.disHVBB.bowLowVoltageDistributionBoxCircuitBreaker = msg.bowLowVoltageDistributionBoxCircuitBreaker
self.disHVBB.unit4InstrumentDC48VCircuitBreaker = msg.unit4InstrumentDC48VCircuitBreaker
self.disHVBB.dcC1DCDistributionPanelCircuitBreaker = msg.dcC1DCDistributionPanelCircuitBreaker
self.disHVBB.reservedCircuitBreaker1 = msg.reservedCircuitBreaker1
self.disHVBB.reservedCircuitBreaker2 = msg.reservedCircuitBreaker2
self.disHVBB.emergencyLithiumBatteryGroup2CircuitBreaker = msg.emergencyLithiumBatteryGroup2CircuitBreaker
# 更新dict3
self.dict3['仪表锂电池断路器'] = '闭合' if msg.lithiumBatteryGroupInstrumentCircuitBreaker == 0x55 else '断开'
self.dict3['艏部低压断路器'] = '闭合' if msg.bowLowVoltageDistributionBoxCircuitBreaker == 0x55 else '断开'
self.dict3['UNIT4断路器'] = '闭合' if msg.unit4InstrumentDC48VCircuitBreaker == 0x55 else '断开'
self.dict3['DC/DC1断路器'] = '闭合' if msg.dcC1DCDistributionPanelCircuitBreaker == 0x55 else '断开'
self.dict3['预留断路器1'] = '闭合' if msg.reservedCircuitBreaker1 == 0x55 else '断开'
self.dict3['预留断路器2'] = '闭合' if msg.reservedCircuitBreaker2 == 0x55 else '断开'
self.dict3['艉部应急电池开关'] = '闭合' if msg.emergencyLithiumBatteryGroup2CircuitBreaker == 0x55 else '断开'
elif msg_id == 0x0004: # 低电压母线配电指令
msg = msg_disLVBCmd()
msg.unpack(data)
self.disLVB.unit1CircuitBreaker = msg.unit1CircuitBreaker
self.disLVB.unit2CircuitBreaker = msg.unit2CircuitBreaker
self.disLVB.unit3CircuitBreaker = msg.unit3CircuitBreaker
self.disLVB.unit5CircuitBreaker = msg.unit5CircuitBreaker
self.disLVB.bowPZDeviceCircuitBreaker = msg.bowPZDeviceCircuitBreaker
self.disLVB.reservedCircuitBreaker1 = msg.reservedCircuitBreaker1
self.disLVB.reservedCircuitBreaker2 = msg.reservedCircuitBreaker2
self.disLVB.emergencyLithiumBatteryGroup1CircuitBreaker = msg.emergencyLithiumBatteryGroup1CircuitBreaker
# 更新dict4
self.dict4['UNIT1断路器'] = '闭合' if msg.unit1CircuitBreaker == 0x55 else '断开'
self.dict4['UNIT2断路器'] = '闭合' if msg.unit2CircuitBreaker == 0x55 else '断开'
self.dict4['UNIT3断路器'] = '闭合' if msg.unit3CircuitBreaker == 0x55 else '断开'
self.dict4['UNIT5断路器'] = '闭合' if msg.unit5CircuitBreaker == 0x55 else '断开'
self.dict4['艏部抛载断路器'] = '闭合' if msg.bowPZDeviceCircuitBreaker == 0x55 else '断开'
self.dict4['预留断路器1'] = '闭合' if msg.reservedCircuitBreaker1 == 0x55 else '断开'
self.dict4['预留断路器2'] = '闭合' if msg.reservedCircuitBreaker2 == 0x55 else '断开'
self.dict4['艏部应急电池开关'] = '闭合' if msg.emergencyLithiumBatteryGroup1CircuitBreaker == 0x55 else '断开'
self.update_disp() # 更新界面显示
except Exception as e:
print(f"Error updating from message: {e}")
if __name__ == "__main__":
root = tk.Tk()