配线app可用
This commit is contained in:
@@ -677,8 +677,18 @@ class PowerManagerApp:
|
||||
|
||||
bus["faults"]["DC/DC故障1"] = msg.dcDcFaultWord1
|
||||
bus["faults"]["DC/DC故障2"] = msg.dcDcFaultWord2
|
||||
bus["insulation"]["动力母线绝缘状态"] = msg.powerBusInsulationStatus
|
||||
bus["insulation"]["A母线绝缘状态"] = msg.aBusInsulationStatus
|
||||
|
||||
if msg.powerBusInsulationStatus == 0x55:
|
||||
bus["insulation"]["动力母线绝缘状态"] = 0
|
||||
else:
|
||||
bus["insulation"]["动力母线绝缘状态"] = 1
|
||||
|
||||
if msg.aBusInsulationStatus == 0x55:
|
||||
bus["insulation"]["A母线绝缘状态"] = 0
|
||||
else:
|
||||
bus["insulation"]["A母线绝缘状态"] = 1
|
||||
|
||||
# bus["insulation"]["A母线绝缘状态"] = msg.aBusInsulationStatus
|
||||
bus["alarms"]["仪表电源丢失信号"] = msg.meterPowerLossSignal
|
||||
bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerLossSignal
|
||||
bus["cool_water_pressure"] = msg.coolWaterPressure / 10.0
|
||||
@@ -937,9 +947,11 @@ class PowerManagerApp:
|
||||
# 更新断路器状态
|
||||
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'
|
||||
self.high_vol_breakers[name].config(background=color)
|
||||
|
||||
canvas.delete("all")
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
# 更新DC/DC故障状态
|
||||
dcdc_fault1 = status['faults']['DC/DC故障1']
|
||||
dcdc_fault2 = status['faults']['DC/DC故障2']
|
||||
@@ -954,8 +966,8 @@ class PowerManagerApp:
|
||||
insulation_power = status['insulation']['动力母线绝缘状态']
|
||||
insulation_a = status['insulation']['A母线绝缘状态']
|
||||
|
||||
power_text = "故障" if insulation_power else f"正常({status['voltage']['动力母线电压']:.1f}MΩ)"
|
||||
a_text = "故障" if insulation_a else f"正常({status['voltage']['A母线电压']:.1f}MΩ)"
|
||||
power_text = "故障" if insulation_power else f"正常"
|
||||
a_text = "故障" if insulation_a else f"正常"
|
||||
|
||||
self.high_vol_power_insulation.config(text=power_text)
|
||||
self.high_vol_a_insulation.config(text=a_text)
|
||||
|
||||
+4
-13
@@ -226,27 +226,18 @@ class DB:
|
||||
self.conn.commit()
|
||||
|
||||
def _insert_data(self, table_name, data_dict):
|
||||
print('-----------------insert_data start')
|
||||
'''内部方法:执行实际的数据库插入操作'''
|
||||
with self.lock:
|
||||
try:
|
||||
# 检查并建立连接
|
||||
if not self.conn:
|
||||
print('-----------------connecting to database')
|
||||
self.connect()
|
||||
|
||||
print(f'-----------------connection status: {"connected" if self.conn else "disconnected"}')
|
||||
if not self.conn:
|
||||
print('-----------------connection failed')
|
||||
return False
|
||||
|
||||
print(f'-----------------connection object: {self.conn}')
|
||||
|
||||
# 创建cursor
|
||||
try:
|
||||
print('-----------------creating cursor')
|
||||
cursor = self.conn.cursor()
|
||||
print('-----------------cursor created successfully')
|
||||
except sqlite3.Error as e:
|
||||
print(f'-----------------cursor creation failed: {e}')
|
||||
return False
|
||||
@@ -255,14 +246,14 @@ class DB:
|
||||
columns = ', '.join(data_dict.keys())
|
||||
placeholders = ', '.join(['?'] * len(data_dict))
|
||||
query = f'INSERT INTO {table_name} ({columns}) VALUES ({placeholders})'
|
||||
print(f'-----------------prepared query: {query}')
|
||||
# print(f'-----------------prepared query: {query}')
|
||||
|
||||
# 执行查询
|
||||
try:
|
||||
print('-----------------executing query')
|
||||
# print('-----------------executing query')
|
||||
cursor.execute(query, list(data_dict.values()))
|
||||
self.conn.commit()
|
||||
print(f"-----------------Data inserted successfully into {table_name}")
|
||||
# print(f"-----------------Data inserted successfully into {table_name}")
|
||||
return True
|
||||
except sqlite3.Error as e:
|
||||
print(f"-----------------Error executing query: {e}")
|
||||
@@ -274,7 +265,7 @@ class DB:
|
||||
|
||||
def insertHighVolBusData(self, data:msg_disHighVolBusFbMsg):
|
||||
'''插入高压母线配电反馈数据'''
|
||||
print('-----------------insertHighVolBusData')
|
||||
# print('-----------------insertHighVolBusData')
|
||||
data_dict = {
|
||||
'fuelCellCircuitBreaker': data.fuelCellCircuitBreaker,
|
||||
'powerLithiumBatteryCircuitBreaker': data.powerLithiumBatteryCircuitBreaker,
|
||||
|
||||
@@ -45,10 +45,10 @@ class PowerManagerSimulator:
|
||||
self.high_vol_fb.fbReservedCircuitBreaker = 0
|
||||
self.high_vol_fb.tyzReservedCircuitBreaker = 0
|
||||
self.high_vol_fb.reservedCircuitBreaker = 0
|
||||
self.high_vol_fb.dcDcFaultWord1 = 0x55 # 测试故障模式
|
||||
self.high_vol_fb.dcDcFaultWord1 = 0xFF # 测试故障模式
|
||||
self.high_vol_fb.dcDcFaultWord2 = 0xAA
|
||||
self.high_vol_fb.powerBusInsulationStatus = 1
|
||||
self.high_vol_fb.aBusInsulationStatus = 1
|
||||
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.powerBusVoltage = 600 # 正常值
|
||||
|
||||
Reference in New Issue
Block a user