修改了次级配电协议,优化消息结构
This commit is contained in:
+233
-118
@@ -4,6 +4,7 @@ import socket
|
||||
import threading
|
||||
import time
|
||||
from db import DB
|
||||
import os
|
||||
from udpMsg import (
|
||||
msg_disHighVolBusFbMsg,
|
||||
msg_disHighAVolBusFbMsg,
|
||||
@@ -36,12 +37,12 @@ class PowerManagerApp:
|
||||
|
||||
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 = DB('/home/zjk/project/H100/H100PowerManger/test/disSysTest/test.db')
|
||||
self.db = DB(os.path.join(os.path.dirname(__file__), 'test.db'))
|
||||
self.db.connect()
|
||||
|
||||
# 状态数据 - 完全匹配udpMsg.py中的定义
|
||||
@@ -167,7 +168,8 @@ class PowerManagerApp:
|
||||
"应急锂电池组1断路器": 0
|
||||
},
|
||||
"alarms": {
|
||||
"电源故障信号": 0,
|
||||
"仪表电源故障": 0,
|
||||
"应急电源故障": 0,
|
||||
"进水报警": 0
|
||||
},
|
||||
"voltage": {
|
||||
@@ -373,7 +375,7 @@ class PowerManagerApp:
|
||||
|
||||
def send_hvb_cmd(self, breaker_name, state):
|
||||
"""发送动力母线配电指令"""
|
||||
print(breaker_name,state)
|
||||
# print(breaker_name,state)
|
||||
cmd = msg_disHVBCmdMsg()
|
||||
if breaker_name == "燃料电池断路器":
|
||||
cmd.fuelCellCircuitBreaker = state
|
||||
@@ -498,11 +500,11 @@ class PowerManagerApp:
|
||||
def udp_receive_loop(self):
|
||||
"""UDP接收消息循环"""
|
||||
while self.running:
|
||||
print('接收中')
|
||||
# print('接收中')
|
||||
try:
|
||||
data, addr = self.sock.recvfrom(1024)
|
||||
self.process_udp_message(data)
|
||||
print('接收成功')
|
||||
# print('接收成功')
|
||||
except Exception as e:
|
||||
self.log_message(f"接收错误: {str(e)}")
|
||||
|
||||
@@ -552,7 +554,7 @@ class PowerManagerApp:
|
||||
|
||||
# 故障状态 - 扩展显示所有故障位
|
||||
fault_labels1 = ["过温关机", "输出过流", "输出过压", "输出欠压", "输入过压", "输入欠压", "输出短路保护", "内部故障"]
|
||||
fault_labels2 = ["通信故障", "工作状态", "冷却泵1故障", "冷却泵2故障", "冷却水泄漏", "保留", "保留", "保留"]
|
||||
fault_labels2 = ["通信故障", "工作状态", "冷却泵1故障", "冷却泵2故障", "冷却水泄漏", "冷却泵1运行状态", "冷却泵2运行状态", "保留"]
|
||||
|
||||
# DC/DC故障显示
|
||||
fault_frame = ttk.Frame(frame)
|
||||
@@ -574,26 +576,29 @@ class PowerManagerApp:
|
||||
|
||||
# 绝缘状态 - 详细显示
|
||||
ttk.Label(frame, text="动力母线绝缘:").grid(row=16, column=0, sticky=tk.W)
|
||||
self.high_vol_power_insulation = ttk.Label(frame, text="正常(0.0MΩ)")
|
||||
self.high_vol_power_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_power_insulation.grid(row=16, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="A母线绝缘:").grid(row=16, column=2, sticky=tk.W)
|
||||
self.high_vol_a_insulation = ttk.Label(frame, text="正常(0.0MΩ)")
|
||||
self.high_vol_a_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_a_insulation.grid(row=16, column=3, sticky=tk.W)
|
||||
|
||||
# 电流值显示
|
||||
current_labels = [
|
||||
("动力母线电流(A):", "powerBusCurrent"),
|
||||
("A母线电流(A):", "busbarACurrent"),
|
||||
("A汇流排电流(A):", "busbarACurrent"),
|
||||
("DC/DC5模块电流(A):", "dcDc5ModuleCurrent"),
|
||||
("推进电机控制箱电流(A):", "propulsionMotorControlBoxCurrent"),
|
||||
("锂电池组表电流(A):", "lithiumBatteryGroupMeterCurrent"),
|
||||
("艏高压配电箱电流(A):", "bowHighVoltageDistributionBoxCurrent"),
|
||||
("艉FT设备45电流(A):", "sternFTDevice45Current"),
|
||||
("TYZ备用开关电流(A):", "tyzReservedSwitchCurrent"),
|
||||
("艉舵机开关1电流(A):", "sternRudderSwitch1Current"),
|
||||
("艉舵机开关2电流(A):", "sternRudderSwitch2Current"),
|
||||
("FB备用开关电流(A):", "fbReservedSwitchCurrent")
|
||||
("锂电池组(仪表)电流(A):", "lithiumBatteryGroupMeterCurrent"),
|
||||
("艏部高压配电箱电流(A):", "bowHighVoltageDistributionBoxCurrent"),
|
||||
("艉部FT装置4/5电流(A):", "sternFTDevice45Current"),
|
||||
("TYZ预留开关电流(A):", "tyzReservedSwitchCurrent"),
|
||||
("艉舵开关1电流(A):", "sternRudderSwitch1Current"),
|
||||
("艉舵开关2电流(A):", "sternRudderSwitch2Current"),
|
||||
("FB预留开关电流(A):", "fbReservedSwitchCurrent"),
|
||||
("备用电流1(A):", "reservedCurrent1"),
|
||||
("备用电流2(A):", "reservedCurrent2"),
|
||||
("备用电流3(A):", "reservedCurrent3")
|
||||
]
|
||||
|
||||
for i, (label, _) in enumerate(current_labels):
|
||||
@@ -603,14 +608,22 @@ class PowerManagerApp:
|
||||
setattr(self, f"high_vol_{current_labels[i][1]}", label_var)
|
||||
|
||||
# 冷却水压力
|
||||
ttk.Label(frame, text="冷却水压力(MPa):").grid(row=23, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="冷却水压力(MPa):").grid(row=24, column=0, sticky=tk.W)
|
||||
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)
|
||||
self.high_vol_cool_water_pressure.grid(row=24, column=1, sticky=tk.W)
|
||||
|
||||
# 冷却水压力
|
||||
ttk.Label(frame, text="DC/DC温度:").grid(row=24, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="DC/DC温度:").grid(row=24, column=3, 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)
|
||||
self.high_vol_dcdc_temp.grid(row=24, column=4, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="仪表失电信号:").grid(row=25, column=0, sticky=tk.W)
|
||||
self.high_vol_losspower_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_losspower_insulation.grid(row=25, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急失电信号").grid(row=25, column=2, sticky=tk.W)
|
||||
self.high_vol_loss_emerpower_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_loss_emerpower_insulation.grid(row=25, column=3, sticky=tk.W)
|
||||
|
||||
def setup_high_a_vol_ui(self, parent):
|
||||
"""设置高压A母线状态界面"""
|
||||
@@ -623,46 +636,63 @@ class PowerManagerApp:
|
||||
frame.grid_columnconfigure(2, weight=1)
|
||||
|
||||
# 电压显示 - 添加详细说明
|
||||
ttk.Label(frame, text="高压B母线电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
self.high_a_vol_voltage = ttk.Label(frame, text="0.0")
|
||||
ttk.Label(frame, text="汇流排B电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
self.high_a_vol_voltage = ttk.Label(frame, text="0.0 V")
|
||||
self.high_a_vol_voltage.grid(row=0, column=1, sticky=tk.W)
|
||||
|
||||
# 电流显示 - 统一格式
|
||||
ttk.Label(frame, text="高压B母线电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
self.high_a_vol_current = ttk.Label(frame, text="0.0")
|
||||
ttk.Label(frame, text="汇流排B电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
self.high_a_vol_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_current.grid(row=1, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="艏部FT设备123电流(A):").grid(row=2, column=0, sticky=tk.W)
|
||||
self.high_a_vol_bow_ft_current = ttk.Label(frame, text="0.0")
|
||||
self.high_a_vol_bow_ft_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_bow_ft_current.grid(row=2, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="执行机构工作电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.high_a_vol_actuator_current = ttk.Label(frame, text="0.0")
|
||||
ttk.Label(frame, text="启闭机构电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.high_a_vol_actuator_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_actuator_current.grid(row=3, column=1, sticky=tk.W)
|
||||
|
||||
# 补充缺失的电流显示项
|
||||
ttk.Label(frame, text="桅杆舵机控制箱电流(A):").grid(row=4, column=0, sticky=tk.W)
|
||||
self.high_a_vol_mast_steering_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_mast_steering_current.grid(row=4, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="XCZ电流(A):").grid(row=4, column=2, sticky=tk.W)
|
||||
self.high_a_vol_xcz_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_xcz_current.grid(row=4, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="艏舵控制箱电流(A):").grid(row=5, column=0, sticky=tk.W)
|
||||
self.high_a_vol_bow_rudder_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_bow_rudder_current.grid(row=5, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="敞水盖启动电缸电流(A):").grid(row=5, column=2, sticky=tk.W)
|
||||
self.high_a_vol_open_cover_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_open_cover_current.grid(row=5, column=3, sticky=tk.W)
|
||||
|
||||
# 断路器状态 - 添加详细说明
|
||||
ttk.Label(frame, text="高压A母线断路器状态:").grid(row=4, column=0, columnspan=4, sticky=tk.W)
|
||||
ttk.Label(frame, text="高压A母线断路器状态:").grid(row=10, column=0, columnspan=4, sticky=tk.W)
|
||||
self.high_a_vol_breakers = {}
|
||||
breaker_names = list(self.status_data["high_a_vol_bus"]["breakers"].keys())
|
||||
|
||||
for i, name in enumerate(breaker_names):
|
||||
ttk.Label(frame, text=f"{name}状态:").grid(row=5+i//2, column=(i%2)*2, sticky=tk.W)
|
||||
ttk.Label(frame, text=f"{name}状态:").grid(row=8+i//2, column=(i%2)*2, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
canvas.grid(row=5+i//2, column=(i%2)*2+1, sticky=tk.W)
|
||||
canvas.grid(row=8+i//2, column=(i%2)*2+1, sticky=tk.W)
|
||||
self.high_a_vol_breakers[name] = canvas
|
||||
|
||||
# 报警状态 - 更详细描述
|
||||
ttk.Label(frame, text="仪表电源故障状态:").grid(row=8, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表电源失电信号:").grid(row=11, column=0, sticky=tk.W)
|
||||
self.high_a_vol_instrument_power_fault = ttk.Label(frame, text="正常")
|
||||
self.high_a_vol_instrument_power_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
self.high_a_vol_instrument_power_fault.grid(row=11, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急电源故障状态:").grid(row=8, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="应急电源失电信号:").grid(row=11, column=2, sticky=tk.W)
|
||||
self.high_a_vol_emergency_power_fault = ttk.Label(frame, text="正常")
|
||||
self.high_a_vol_emergency_power_fault.grid(row=8, column=3, sticky=tk.W)
|
||||
self.high_a_vol_emergency_power_fault.grid(row=11, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="进水报警:").grid(row=9, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="进水报警:").grid(row=12, column=0, sticky=tk.W)
|
||||
self.high_a_vol_water_alarm = ttk.Label(frame, text="无")
|
||||
self.high_a_vol_water_alarm.grid(row=9, column=1, sticky=tk.W)
|
||||
self.high_a_vol_water_alarm.grid(row=12, column=1, sticky=tk.W)
|
||||
|
||||
def process_udp_message(self, data):
|
||||
"""处理接收到的UDP消息"""
|
||||
@@ -733,15 +763,16 @@ class PowerManagerApp:
|
||||
else:
|
||||
bus["insulation"]["A母线绝缘状态"] = 1
|
||||
|
||||
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
|
||||
# if msg.meterPowerLossSignal == 0x55:
|
||||
# bus["alarms"]["仪表电源丢失信号"] = 0
|
||||
# else:
|
||||
# bus["alarms"]["仪表电源丢失信号"] = 1
|
||||
bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerLossSignal
|
||||
bus["alarms"]["仪表电源丢失信号"] = msg.meterPowerLossSignal
|
||||
# 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
|
||||
|
||||
@@ -778,8 +809,8 @@ class PowerManagerApp:
|
||||
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母线状态更新")
|
||||
@@ -818,16 +849,16 @@ class PowerManagerApp:
|
||||
|
||||
# 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
|
||||
# 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
|
||||
@@ -835,7 +866,9 @@ class PowerManagerApp:
|
||||
bus["insulation"] = 1
|
||||
|
||||
self.log_message("收到仪表主母线状态更新")
|
||||
|
||||
else:
|
||||
print("仪表主母线状态","解析失败")
|
||||
|
||||
elif msg_id == 0x0008: # 仪表母线状态
|
||||
msg = msg_disLowBusFbMsg()
|
||||
if msg.unpack(data):
|
||||
@@ -864,22 +897,17 @@ class PowerManagerApp:
|
||||
bus["breakers"]["单元2断路器"] = msg.unit2CircuitBreaker
|
||||
bus["breakers"]["单元3断路器"] = msg.unit3CircuitBreaker
|
||||
bus["breakers"]["单元5断路器"] = msg.unit5CircuitBreaker
|
||||
bus["breakers"]["艏PZ设备断路器"] = msg.bowPZDeviceCircuitBreake
|
||||
bus["breakers"]["艏PZ设备断路器"] = msg.bowPZDeviceCircuitBreaker
|
||||
bus["breakers"]["备用断路器1"] = msg.reservedCircuitBreaker1
|
||||
bus["breakers"]["备用断路器2"] = msg.reservedCircuitBreaker2
|
||||
bus["breakers"]["应急锂电池组1断路器"] = msg.emergencyLithiumBatteryGroup1CircuitBreaker
|
||||
|
||||
# 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
|
||||
bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
bus["alarms"]["进水报警"] = msg.waterIngressionAlarm
|
||||
self.log_message("收到仪表母线状态更新")
|
||||
else:
|
||||
print("仪表母线状态","解析失败")
|
||||
|
||||
else:
|
||||
self.log_message("消息解析失败")
|
||||
@@ -904,54 +932,81 @@ class PowerManagerApp:
|
||||
self.low_main_instrument_voltage = ttk.Label(frame, text="0.0")
|
||||
self.low_main_instrument_voltage.grid(row=0, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急2母线电压(V):").grid(row=0, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="应急2汇流排电压(V):").grid(row=0, column=2, sticky=tk.W)
|
||||
self.low_main_emergency2_voltage = ttk.Label(frame, text="0.0")
|
||||
self.low_main_emergency2_voltage.grid(row=0, column=3, sticky=tk.W)
|
||||
|
||||
# 电流显示
|
||||
ttk.Label(frame, text="艏低压配电盒电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="艏部低压配电箱电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
self.low_main_bow_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_bow_current.grid(row=1, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="锂电池组仪表电流(A):").grid(row=1, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="锂电池组(仪表)电流(A):").grid(row=1, column=2, sticky=tk.W)
|
||||
self.low_main_battery_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_battery_current.grid(row=1, column=3, sticky=tk.W)
|
||||
|
||||
# 补充其他电流显示项
|
||||
ttk.Label(frame, text="DC-C1(直流配电板1)仪表DC48V电流(A):").grid(row=2, column=0, sticky=tk.W)
|
||||
self.low_main_dcc1_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_dcc1_current.grid(row=2, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急锂电池组2电流(A):").grid(row=2, column=2, sticky=tk.W)
|
||||
self.low_main_emergency2_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_emergency2_current.grid(row=2, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="单元4仪表48V电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.low_main_unit4_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_unit4_current.grid(row=3, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="复合能源管控系统应急DC48V电流(A):").grid(row=3, column=2, sticky=tk.W)
|
||||
self.low_main_energy_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_energy_current.grid(row=3, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="燃料电池安保系统应急DC48V电流(A):").grid(row=4, column=0, sticky=tk.W)
|
||||
self.low_main_fuelcell_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_fuelcell_current.grid(row=4, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="PLC控制电源电流(A):").grid(row=4, column=2, sticky=tk.W)
|
||||
self.low_main_plc_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_plc_current.grid(row=4, column=3, sticky=tk.W)
|
||||
|
||||
# 断路器状态
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=2, column=0, columnspan=4, sticky=tk.W)
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=5, column=0, columnspan=4, sticky=tk.W)
|
||||
self.low_main_breakers = {}
|
||||
breaker_names = list(self.status_data["low_main_bus"]["breakers"].keys())
|
||||
|
||||
# 断路器状态 - 调整为每行3个断路器,从行6开始
|
||||
for i, name in enumerate(breaker_names):
|
||||
row = 3 + i//2
|
||||
col = (i%2)*2
|
||||
row = 6 + i//3
|
||||
col = (i%3)*2
|
||||
ttk.Label(frame, text=name).grid(row=row, column=col, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
canvas.grid(row=row, column=col+1, sticky=tk.W)
|
||||
self.low_main_breakers[name] = canvas
|
||||
|
||||
# 报警状态
|
||||
ttk.Label(frame, text="仪表电源故障:").grid(row=8, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表电源失电信号 :").grid(row=9, column=0, sticky=tk.W)
|
||||
self.low_main_instrument_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_instrument_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
self.low_main_instrument_fault.grid(row=9, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急电源故障:").grid(row=8, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="应急电源失电信号 :").grid(row=9, column=2, sticky=tk.W)
|
||||
self.low_main_emergency_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_emergency_fault.grid(row=8, column=3, sticky=tk.W)
|
||||
|
||||
# 报警状态
|
||||
ttk.Label(frame, text="仪表电源故障:").grid(row=8, column=0, sticky=tk.W)
|
||||
self.low_main_instrument_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_instrument_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急电源故障:").grid(row=8, column=2, sticky=tk.W)
|
||||
self.low_main_emergency_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_emergency_fault.grid(row=8, column=3, sticky=tk.W)
|
||||
self.low_main_emergency_fault.grid(row=9, column=3, sticky=tk.W)
|
||||
|
||||
# 绝缘状态
|
||||
ttk.Label(frame, text="绝缘状态:").grid(row=9, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表汇流排绝缘低 :").grid(row=10, column=0, sticky=tk.W)
|
||||
self.low_main_insulation = ttk.Label(frame, text="正常")
|
||||
self.low_main_insulation.grid(row=9, column=1, sticky=tk.W)
|
||||
self.low_main_insulation.grid(row=10, column=1, sticky=tk.W)
|
||||
|
||||
# 备用电流
|
||||
ttk.Label(frame, text="备用电流1 :").grid(row=11, column=0, sticky=tk.W)
|
||||
self.low_main_reserved1 = ttk.Label(frame, text="0.0")
|
||||
self.low_main_reserved1.grid(row=11, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="备用电流2 :").grid(row=11, column=2, sticky=tk.W)
|
||||
self.low_main_reserved2 = ttk.Label(frame, text="0.0")
|
||||
self.low_main_reserved2.grid(row=11, column=3, sticky=tk.W)
|
||||
|
||||
|
||||
return frame
|
||||
|
||||
@@ -967,7 +1022,7 @@ class PowerManagerApp:
|
||||
frame.grid_columnconfigure(3, weight=1)
|
||||
|
||||
# 电压显示
|
||||
ttk.Label(frame, text="仪表母线电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表母排电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
self.low_bus_instrument_voltage = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_instrument_voltage.grid(row=0, column=1, sticky=tk.W)
|
||||
|
||||
@@ -983,14 +1038,34 @@ class PowerManagerApp:
|
||||
ttk.Label(frame, text="单元2电流(A):").grid(row=1, column=2, sticky=tk.W)
|
||||
self.low_bus_unit2_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_unit2_current.grid(row=1, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="仪表母排电流(A):").grid(row=2, column=0, sticky=tk.W)
|
||||
self.low_bus_main_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_main_current.grid(row=2, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="单元3电流(A):").grid(row=2, column=2, sticky=tk.W)
|
||||
self.low_bus_unit3_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_unit3_current.grid(row=2, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="单元5电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.low_bus_unit5_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_unit5_current.grid(row=3, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="艏PZ设备电流(A):").grid(row=3, column=2, sticky=tk.W)
|
||||
self.low_bus_bow_pz_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_bow_pz_current.grid(row=3, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急锂电池组1电流(A):").grid(row=4, column=0, sticky=tk.W)
|
||||
self.low_bus_emergency1_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_emergency1_current.grid(row=4, column=1, sticky=tk.W)
|
||||
|
||||
# 断路器状态
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=2, column=0, columnspan=4, sticky=tk.W)
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=5, column=0, columnspan=4, sticky=tk.W)
|
||||
self.low_bus_breakers = {}
|
||||
breaker_names = list(self.status_data["low_bus"]["breakers"].keys())
|
||||
|
||||
for i, name in enumerate(breaker_names):
|
||||
row = 3 + i//2
|
||||
row = 6 + i//2
|
||||
col = (i%2)*2
|
||||
ttk.Label(frame, text=name).grid(row=row, column=col, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
@@ -998,19 +1073,17 @@ class PowerManagerApp:
|
||||
self.low_bus_breakers[name] = canvas
|
||||
|
||||
# 报警状态
|
||||
ttk.Label(frame, text="电源故障信号:").grid(row=8, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表电失电信号 :").grid(row=10, 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)
|
||||
self.low_bus_power_fault.grid(row=10, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急电失电信号 :").grid(row=11, column=0, sticky=tk.W)
|
||||
self.low_bus_emgpower_fault = ttk.Label(frame, text="无")
|
||||
self.low_bus_emgpower_fault.grid(row=11, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="进水报警:").grid(row=8, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="浸水报警 :").grid(row=10, column=2, sticky=tk.W)
|
||||
self.low_bus_water_alarm = ttk.Label(frame, text="无")
|
||||
self.low_bus_water_alarm.grid(row=8, column=3, sticky=tk.W)
|
||||
|
||||
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)
|
||||
self.low_bus_water_alarm = ttk.Label(frame, text="无")
|
||||
self.low_bus_water_alarm.grid(row=8, column=3, sticky=tk.W)
|
||||
self.low_bus_water_alarm.grid(row=10, column=3, sticky=tk.W)
|
||||
|
||||
return frame
|
||||
|
||||
@@ -1045,7 +1118,10 @@ class PowerManagerApp:
|
||||
('tyzReservedSwitchCurrent', 'TYZ备用开关电流'),
|
||||
('sternRudderSwitch1Current', '艉舵机开关1电流'),
|
||||
('sternRudderSwitch2Current', '艉舵机开关2电流'),
|
||||
('fbReservedSwitchCurrent', 'FB备用开关电流')
|
||||
('fbReservedSwitchCurrent', 'FB备用开关电流'),
|
||||
('reservedCurrent1', '备用电流1'),
|
||||
('reservedCurrent2', '备用电流2'),
|
||||
('reservedCurrent3', '备用电流3')
|
||||
]
|
||||
|
||||
for var_name, data_key in current_vars:
|
||||
@@ -1057,7 +1133,7 @@ class PowerManagerApp:
|
||||
if name in self.high_vol_breakers:
|
||||
canvas = self.high_vol_breakers[name]
|
||||
# color = 'green' if state else 'red'
|
||||
print(name, hex(state))
|
||||
# print(name, hex(state))
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
@@ -1094,6 +1170,11 @@ class PowerManagerApp:
|
||||
|
||||
# # 更新温度状态
|
||||
self.high_vol_dcdc_temp.config(text=f"{status['dcdc_temp']} 摄氏度")
|
||||
# "仪表电源丢失信号": 0,
|
||||
# "应急电源丢失信号": 0
|
||||
# 更新失电故障显示
|
||||
self.high_vol_losspower_insulation.config(text="正常" if status['alarms']['仪表电源丢失信号'] == 0x55 else "故障")
|
||||
self.high_vol_loss_emerpower_insulation.config(text="正常" if status['alarms']['应急电源丢失信号'] == 0x55 else "故障")
|
||||
|
||||
def update_ui(self):
|
||||
"""更新界面状态"""
|
||||
@@ -1107,6 +1188,12 @@ class PowerManagerApp:
|
||||
self.high_a_vol_bow_ft_current.config(text=f"{high_a_vol['current']['艏FT设备123电流']:.1f} A")
|
||||
self.high_a_vol_actuator_current.config(text=f"{high_a_vol['current']['执行机构电流']:.1f} A")
|
||||
|
||||
# 更新新增的电流显示项
|
||||
self.high_a_vol_mast_steering_current.config(text=f"{high_a_vol['current']['桅舵机控制箱电流']:.1f} A")
|
||||
self.high_a_vol_xcz_current.config(text=f"{high_a_vol['current']['XCZ电流']:.1f} A")
|
||||
self.high_a_vol_bow_rudder_current.config(text=f"{high_a_vol['current']['艏舵控制箱电流']:.1f} A")
|
||||
self.high_a_vol_open_cover_current.config(text=f"{high_a_vol['current']['开盖启动气缸电流']:.1f} A")
|
||||
|
||||
for name, canvas in self.high_a_vol_breakers.items():
|
||||
state = high_a_vol["breakers"].get(name, 0)
|
||||
if state == 0x55:
|
||||
@@ -1151,22 +1238,32 @@ class PowerManagerApp:
|
||||
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 high_a_vol["alarms"]["仪表电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.high_a_vol_emergency_power_fault.config(
|
||||
text="正常" if not high_a_vol["alarms"]["应急电源故障"] else "故障"
|
||||
text="正常" if high_a_vol["alarms"]["应急电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.high_a_vol_water_alarm.config(
|
||||
text="正常" if not high_a_vol["alarms"]["进水报警"] else "故障"
|
||||
text="正常" if high_a_vol["alarms"]["进水报警"]==0x55 else "故障"
|
||||
)
|
||||
|
||||
# 更新仪表主母线状态
|
||||
low_main = self.status_data["low_main_bus"]
|
||||
self.low_main_instrument_voltage.config(text=f"{low_main['voltage']['仪表母线电压']:.1f} V")
|
||||
self.low_main_emergency2_voltage.config(text=f"{low_main['voltage']['应急2母线电压']:.1f} V")
|
||||
self.low_main_bow_current.config(text=f"{low_main['current']['艏低压配电盒电流']:.1f}")
|
||||
self.low_main_battery_current.config(text=f"{low_main['current']['锂电池组仪表电流']:.1f} A")
|
||||
self.low_main_bow_current.config(text=f"{low_main['current']['艏低压配电盒电流']:.1f} A")
|
||||
self.low_main_battery_current.config(text=f"{low_main['current']['锂电池组仪表电流']:.1f} A")
|
||||
|
||||
# 更新新增的电流显示项
|
||||
self.low_main_dcc1_current.config(text=f"{low_main['current']['DC/C1仪表48V电流']:.1f} A")
|
||||
self.low_main_emergency2_current.config(text=f"{low_main['current']['应急锂电池组2电流']:.1f} A")
|
||||
self.low_main_unit4_current.config(text=f"{low_main['current']['单元4仪表48V电流']:.1f} A")
|
||||
self.low_main_energy_current.config(text=f"{low_main['current']['综合能量管理系统应急DC48V电流']:.1f} A")
|
||||
self.low_main_fuelcell_current.config(text=f"{low_main['current']['燃料电池安全系统应急DC48V电流']:.1f} A")
|
||||
self.low_main_plc_current.config(text=f"{low_main['current']['PLC控制电源电流']:.1f} A")
|
||||
# 新增加备用电流
|
||||
self.low_main_reserved1.config(text=f"{low_main['current']['备用电流1']:.1f} A")
|
||||
self.low_main_reserved2.config(text=f"{low_main['current']['备用电流2']:.1f} A")
|
||||
|
||||
for name, canvas in self.low_main_breakers.items():
|
||||
state = low_main["breakers"].get(name, 0)
|
||||
@@ -1182,21 +1279,29 @@ class PowerManagerApp:
|
||||
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 low_main["alarms"]["仪表电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_main_emergency_fault.config(
|
||||
text="正常" if not low_main["alarms"]["应急电源故障"] else "故障"
|
||||
text="正常" if low_main["alarms"]["应急电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_main_insulation.config(
|
||||
text="正常" if not low_main["insulation"] else "故障"
|
||||
text="正常" if low_main["insulation"]==0x55 else "故障"
|
||||
)
|
||||
|
||||
# 更新仪表母线状态
|
||||
low_bus = self.status_data["low_bus"]
|
||||
self.low_bus_instrument_voltage.config(text=f"{low_bus['voltage']['仪表母线电压']:.1f} V")
|
||||
self.low_bus_emergency1_voltage.config(text=f"{low_bus['voltage']['应急1母线电压']:.1f} V")
|
||||
self.low_bus_unit1_current.config(text=f"{low_bus['current']['单元1电流']:.1f}")
|
||||
self.low_bus_unit2_current.config(text=f"{low_bus['current']['单元2电流']:.1f}")
|
||||
self.low_bus_unit1_current.config(text=f"{low_bus['current']['单元1电流']:.1f} A")
|
||||
self.low_bus_unit2_current.config(text=f"{low_bus['current']['单元2电流']:.1f} A")
|
||||
|
||||
# 更新新增的电流显示项
|
||||
self.low_bus_main_current.config(text=f"{low_bus['current']['仪表母线电流']:.1f} A")
|
||||
self.low_bus_unit3_current.config(text=f"{low_bus['current']['单元3电流']:.1f} A")
|
||||
self.low_bus_unit5_current.config(text=f"{low_bus['current']['单元5电流']:.1f} A")
|
||||
self.low_bus_bow_pz_current.config(text=f"{low_bus['current']['艏PZ设备电流']:.1f} A")
|
||||
self.low_bus_emergency1_current.config(text=f"{low_bus['current']['应急锂电池组1电流']:.1f} A")
|
||||
|
||||
|
||||
for name, canvas in self.low_bus_breakers.items():
|
||||
state = low_bus["breakers"].get(name, 0)
|
||||
@@ -1212,10 +1317,13 @@ class PowerManagerApp:
|
||||
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 low_bus["alarms"]["仪表电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_bus_emgpower_fault.config(
|
||||
text="正常" if low_bus["alarms"]["应急电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_bus_water_alarm.config(
|
||||
text="正常" if not low_bus["alarms"]["进水报警"] else "故障"
|
||||
text="正常" if low_bus["alarms"]["进水报警"]==0x55 else "故障"
|
||||
)
|
||||
# print('update_ui')
|
||||
# 每500ms更新一次
|
||||
@@ -1226,6 +1334,13 @@ class PowerManagerApp:
|
||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
self.log_text.config(state=tk.NORMAL)
|
||||
self.log_text.insert(tk.END, f"[{timestamp}] {message}\n")
|
||||
|
||||
# 获取当前所有行数
|
||||
line_count = int(self.log_text.index('end-1c').split('.')[0])
|
||||
# 如果超过50行,删除最旧的行
|
||||
if line_count > 50:
|
||||
self.log_text.delete(1.0, 2.0)
|
||||
|
||||
self.log_text.config(state=tk.DISABLED)
|
||||
self.log_text.see(tk.END)
|
||||
|
||||
|
||||
@@ -143,7 +143,8 @@ class DB:
|
||||
reservedCircuitBreaker1 INTEGER,
|
||||
reservedCircuitBreaker2 INTEGER,
|
||||
emergencyLithiumBatteryGroup1CircuitBreaker INTEGER,
|
||||
powerFailureSignal INTEGER,
|
||||
instrumentPowerFailureSignal INTEGER,
|
||||
emergencyPowerFailureSignal INTEGER,
|
||||
waterIngressionAlarm INTEGER,
|
||||
instrumentBusbarVoltage INTEGER,
|
||||
instrumentBusbarCurrent INTEGER,
|
||||
@@ -369,7 +370,9 @@ class DB:
|
||||
'reservedCircuitBreaker1': data.reservedCircuitBreaker1,
|
||||
'reservedCircuitBreaker2': data.reservedCircuitBreaker2,
|
||||
'emergencyLithiumBatteryGroup1CircuitBreaker': data.emergencyLithiumBatteryGroup1CircuitBreaker,
|
||||
'powerFailureSignal': data.powerFailureSignal,
|
||||
# 'powerFailureSignal': data.powerFailureSignal,
|
||||
'instrumentPowerFailureSignal': data.instrumentPowerFailureSignal,
|
||||
'emergencyPowerFailureSignal': data.emergencyPowerFailureSignal,
|
||||
'waterIngressionAlarm': data.waterIngressionAlarm,
|
||||
'instrumentBusbarVoltage': data.instrumentBusbarVoltage,
|
||||
'instrumentBusbarCurrent': data.instrumentBusbarCurrent,
|
||||
@@ -556,7 +559,9 @@ if __name__ == "__main__":
|
||||
fb4.reservedCircuitBreaker1 = 0
|
||||
fb4.reservedCircuitBreaker2 = 0
|
||||
fb4.emergencyLithiumBatteryGroup1CircuitBreaker = 1
|
||||
fb4.powerFailureSignal = 0
|
||||
# fb4.powerFailureSignal = 0
|
||||
fb4.instrumentPowerFailureSignal = 0
|
||||
fb4.emergencyPowerFailureSignal = 0
|
||||
fb4.waterIngressionAlarm = 0
|
||||
fb4.instrumentBusbarVoltage = 48
|
||||
fb4.instrumentBusbarCurrent = 10
|
||||
|
||||
+28
-27
@@ -14,7 +14,7 @@ from udpMsg import (
|
||||
)
|
||||
|
||||
class PowerManagerSimulator:
|
||||
def __init__(self, host='127.0.0.1', port=5001):
|
||||
def __init__(self, host='127.0.0.1', port=6000):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.running = False
|
||||
@@ -63,19 +63,19 @@ class PowerManagerSimulator:
|
||||
self.high_vol_fb.sternFTDevice45Current = 15
|
||||
self.high_vol_fb.tyzReservedSwitchCurrent = 0
|
||||
self.high_vol_fb.sternRudderSwitch1Current = 10
|
||||
self.high_vol_fb.reservedCurrent1 = 0
|
||||
self.high_vol_fb.reservedCurrent1 = 100
|
||||
self.high_vol_fb.sternRudderSwitch2Current = 10
|
||||
self.high_vol_fb.reservedCurrent2 = 0
|
||||
self.high_vol_fb.fbReservedSwitchCurrent = 0
|
||||
self.high_vol_fb.reservedCurrent3 = 0
|
||||
self.high_vol_fb.reservedCurrent2 = 100
|
||||
self.high_vol_fb.fbReservedSwitchCurrent = 1000
|
||||
self.high_vol_fb.reservedCurrent3 = 100
|
||||
self.high_vol_fb.coolWaterPressure = 100
|
||||
|
||||
# 高压A母线反馈数据 - 测试所有成员
|
||||
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.bowFTDevice123CircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.actuatorCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.mastSteeringGearControlBoxCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.xczCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.bowRudderControlBoxCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.openWaterCoverStartCylinderCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.instrumentPowerFailureSignal = 0x55
|
||||
self.high_a_vol_fb.emergencyPowerFailureSignal = 0x55
|
||||
@@ -90,40 +90,41 @@ class PowerManagerSimulator:
|
||||
self.high_a_vol_fb.openWaterCoverStartCylinderCurrent = 0
|
||||
|
||||
# 仪表主母线反馈数据 - 测试所有成员
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 0x55
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 0x5A
|
||||
self.low_main_fb.bowLowVoltageDistributionBoxCircuitBreaker = 0x55
|
||||
self.low_main_fb.unit4InstrumentDC48VCircuitBreaker = 0x55
|
||||
self.low_main_fb.dcC1DCDistributionPanelCircuitBreaker = 0x55
|
||||
self.low_main_fb.dcC1DCDistributionPanelCircuitBreaker = 0x5A
|
||||
self.low_main_fb.reservedCircuitBreaker1 = 0x55
|
||||
self.low_main_fb.reservedCircuitBreaker2 = 0x55
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2CircuitBreaker = 0x55
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2CircuitBreaker = 0x5A
|
||||
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
|
||||
self.low_main_fb.reservedCurrent1 = 0
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2Current = 0
|
||||
self.low_main_fb.reservedCurrent1 = 110
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2Current = 100
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCurrent = 20
|
||||
self.low_main_fb.unit4InstrumentDC48VCurrent = 5
|
||||
self.low_main_fb.reservedCurrent2 = 0
|
||||
self.low_main_fb.reservedCurrent2 = 100
|
||||
self.low_main_fb.emergency2BusbarVoltage = 48
|
||||
self.low_main_fb.compositeEnergyManagementSystemEmergencyDC48VCurrent = 2
|
||||
self.low_main_fb.fuelCellSecuritySystemEmergencyDC48VCurrent = 2
|
||||
self.low_main_fb.plcControlPowerCurrent = 1
|
||||
|
||||
# 仪表汇流排反馈数据 - 测试所有成员
|
||||
self.low_bus_fb.unit1CircuitBreaker = 1
|
||||
self.low_bus_fb.unit2CircuitBreaker = 1
|
||||
self.low_bus_fb.unit3CircuitBreaker = 1
|
||||
self.low_bus_fb.unit5CircuitBreaker = 1
|
||||
self.low_bus_fb.bowPZDeviceCircuitBreaker = 1
|
||||
self.low_bus_fb.reservedCircuitBreaker1 = 0
|
||||
self.low_bus_fb.reservedCircuitBreaker2 = 0
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1CircuitBreaker = 0
|
||||
self.low_bus_fb.powerFailureSignal = 0
|
||||
self.low_bus_fb.waterIngressionAlarm = 0
|
||||
self.low_bus_fb.unit1CircuitBreaker = 0x55
|
||||
self.low_bus_fb.unit2CircuitBreaker = 0x55
|
||||
self.low_bus_fb.unit3CircuitBreaker = 0x55
|
||||
self.low_bus_fb.unit5CircuitBreaker = 0x55
|
||||
self.low_bus_fb.bowPZDeviceCircuitBreaker = 0x55
|
||||
self.low_bus_fb.reservedCircuitBreaker1 = 0x55
|
||||
self.low_bus_fb.reservedCircuitBreaker2 = 0x55
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1CircuitBreaker = 0x55
|
||||
self.low_bus_fb.instrumentPowerFailureSignal = 0x5A
|
||||
self.low_bus_fb.emergencyPowerFailureSignal = 0x5A
|
||||
self.low_bus_fb.waterIngressionAlarm = 0x55
|
||||
self.low_bus_fb.instrumentBusbarVoltage = 48
|
||||
self.low_bus_fb.instrumentBusbarCurrent = 500
|
||||
self.low_bus_fb.unit1Current = 100
|
||||
@@ -131,7 +132,7 @@ class PowerManagerSimulator:
|
||||
self.low_bus_fb.unit3Current = 100
|
||||
self.low_bus_fb.unit5Current = 100
|
||||
self.low_bus_fb.bowPZDeviceCurrent = 50
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1Current = 0
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1Current = 100
|
||||
self.low_bus_fb.emergency1BusbarVoltage = 48
|
||||
|
||||
def start(self):
|
||||
|
||||
@@ -366,7 +366,7 @@ class msg_disLowBusFbMsg:
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0008
|
||||
self.length = 24 # disLowBusState结构体大小
|
||||
self.length = 25 # disLowBusState结构体大小
|
||||
self.checkCode = 0x00
|
||||
|
||||
# disLowBusState成员
|
||||
@@ -378,7 +378,8 @@ class msg_disLowBusFbMsg:
|
||||
self.reservedCircuitBreaker1 = 0x00
|
||||
self.reservedCircuitBreaker2 = 0x00
|
||||
self.emergencyLithiumBatteryGroup1CircuitBreaker = 0x00
|
||||
self.powerFailureSignal = 0x00
|
||||
self.instrumentPowerFailureSignal = 0x00
|
||||
self.emergencyPowerFailureSignal = 0x00
|
||||
self.waterIngressionAlarm = 0x00
|
||||
self.instrumentBusbarVoltage = 0
|
||||
self.instrumentBusbarCurrent = 0
|
||||
@@ -406,7 +407,8 @@ class msg_disLowBusFbMsg:
|
||||
data += struct.pack('<B', self.reservedCircuitBreaker1)
|
||||
data += struct.pack('<B', self.reservedCircuitBreaker2)
|
||||
data += struct.pack('<B', self.emergencyLithiumBatteryGroup1CircuitBreaker)
|
||||
data += struct.pack('<B', self.powerFailureSignal)
|
||||
data += struct.pack('<B', self.instrumentPowerFailureSignal)
|
||||
data += struct.pack('<B', self.emergencyPowerFailureSignal)
|
||||
data += struct.pack('<B', self.waterIngressionAlarm)
|
||||
data += struct.pack('<H', self.instrumentBusbarVoltage)
|
||||
data += struct.pack('<H', self.instrumentBusbarCurrent)
|
||||
@@ -426,8 +428,8 @@ class msg_disLowBusFbMsg:
|
||||
return data
|
||||
|
||||
def unpack(self, data):
|
||||
if len(data) < 4 + self.length + 1: # 头部4字节+数据长度+校验码1字节
|
||||
return False
|
||||
# if len(data) < 4 + self.length + 1: # 头部4字节+数据长度+校验码1字节
|
||||
# return False
|
||||
|
||||
self.start1 = data[0]
|
||||
self.start2 = data[1]
|
||||
@@ -443,7 +445,9 @@ class msg_disLowBusFbMsg:
|
||||
self.reservedCircuitBreaker1 = data[offset]; offset +=1
|
||||
self.reservedCircuitBreaker2 = data[offset]; offset +=1
|
||||
self.emergencyLithiumBatteryGroup1CircuitBreaker = data[offset]; offset +=1
|
||||
self.powerFailureSignal = data[offset]; offset +=1
|
||||
# self.powerFailureSignal = data[offset]; offset +=1
|
||||
self.instrumentPowerFailureSignal = data[offset]; offset +=1
|
||||
self.emergencyPowerFailureSignal = data[offset]; offset +=1
|
||||
self.waterIngressionAlarm = data[offset]; offset +=1
|
||||
self.instrumentBusbarVoltage = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
self.instrumentBusbarCurrent = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
|
||||
Reference in New Issue
Block a user