优化了测试界面
This commit is contained in:
@@ -1,30 +1,30 @@
|
|||||||
{
|
{
|
||||||
"backpressure1_fp32": 0.0,
|
"backpressure1_fp32": 7.0,
|
||||||
"backpressure2_fp32": 9.0,
|
"backpressure2_fp32": 7.0,
|
||||||
"ch4oConcent1_fp32": 72.0,
|
"ch4oConcent1_fp32": 75.0,
|
||||||
"ch4oConcent2_fp32": 3.0,
|
"ch4oConcent2_fp32": 11.0,
|
||||||
"ch4o_fp32": 0.0,
|
"ch4o_fp32": 0.0,
|
||||||
"excTemp_fp32": 46.0,
|
"excTemp_fp32": 64.0,
|
||||||
"faultCode1_uint16": 0,
|
"faultCode1_uint16": 0,
|
||||||
"faultCode2_uint16": 0,
|
"faultCode2_uint16": 0,
|
||||||
"faultCode3_uint16": 0,
|
"faultCode3_uint16": 0,
|
||||||
"fcuCurIns_fp32": 0.0,
|
"fcuCurIns_fp32": 0.0,
|
||||||
"fcuCurPower_fp32": 0.0,
|
"fcuCurPower_fp32": 0.0,
|
||||||
"fcuCur_fp32": 61.0,
|
"fcuCur_fp32": 22.0,
|
||||||
"fcuFaultLeve_uint8": 0,
|
"fcuFaultLeve_uint8": 0,
|
||||||
"fcuOutIns_fp32": 94.0,
|
"fcuOutIns_fp32": 99.0,
|
||||||
"fcuOutPower_fp32": 536.0,
|
"fcuOutPower_fp32": 260.0,
|
||||||
"fcuState_uint8": 0,
|
"fcuState_uint8": 0,
|
||||||
"fcuVolIns_fp32": 0.0,
|
"fcuVolIns_fp32": 0.0,
|
||||||
"fcuVolPower_fp32": 0.0,
|
"fcuVolPower_fp32": 0.0,
|
||||||
"fcuVol_fp32": 319.0,
|
"fcuVol_fp32": 244.0,
|
||||||
"flameDet_uint8": 1,
|
"flameDet_uint8": 0,
|
||||||
"h2Concent1_fp32": 30.0,
|
"h2Concent1_fp32": 58.0,
|
||||||
"h2Concent2_fp32": 10.0,
|
"h2Concent2_fp32": 59.0,
|
||||||
"o2Concent1_fp32": 53.0,
|
"o2Concent1_fp32": 9.0,
|
||||||
"o2Concent2_fp32": 0.0,
|
"o2Concent2_fp32": 38.0,
|
||||||
"o2Level_fp32": 0.0,
|
"o2Level_fp32": 0.0,
|
||||||
"o2_fp32": 0.0,
|
"o2_fp32": 0.0,
|
||||||
"powLimit_fp32": 60.0,
|
"powLimit_fp32": 41.0,
|
||||||
"powerGen_fp32": 155.0
|
"powerGen_fp32": 911.0
|
||||||
}
|
}
|
||||||
@@ -2,37 +2,37 @@
|
|||||||
"fcuCurToInsLimit1_uint8": 0,
|
"fcuCurToInsLimit1_uint8": 0,
|
||||||
"fcuCurToinsLimit2_uint8": 0,
|
"fcuCurToinsLimit2_uint8": 0,
|
||||||
"insBatCurElect_uint16": 0,
|
"insBatCurElect_uint16": 0,
|
||||||
"insBatLimit_uint16": 95,
|
"insBatLimit_uint16": 39,
|
||||||
"insBatSoc_uint8": 11,
|
"insBatSoc_uint8": 85,
|
||||||
"insBatTotalElect_uint16": 631,
|
"insBatTotalElect_uint16": 304,
|
||||||
"insChargeState_uint8": 0,
|
"insChargeState_uint8": 0,
|
||||||
"insCurSocHold1_uint8": 0,
|
"insCurSocHold1_uint8": 0,
|
||||||
"insCurSocHold2_uint8": 0,
|
"insCurSocHold2_uint8": 0,
|
||||||
"insCurSocHold3_uint8": 0,
|
"insCurSocHold3_uint8": 0,
|
||||||
"insCurrent_uint16": 89,
|
"insCurrent_uint16": 78,
|
||||||
"insLinkVol_uint16": 0,
|
"insLinkVol_uint16": 0,
|
||||||
"insNegRelayState_uint8": 1,
|
"insNegRelayState_uint8": 0,
|
||||||
"insNegRes_uint16": 0,
|
"insNegRes_uint16": 0,
|
||||||
"insPackVol_uint16": 0,
|
"insPackVol_uint16": 0,
|
||||||
"insPosRelayState_uint8": 0,
|
"insPosRelayState_uint8": 1,
|
||||||
"insPosRes_uint16": 0,
|
"insPosRes_uint16": 0,
|
||||||
"insfaultCode_uint8": 0,
|
"insfaultCode_uint8": 0,
|
||||||
"powBatCurElect_uint16": 0,
|
"powBatCurElect_uint16": 0,
|
||||||
"powBatSoc_uint8": 86,
|
"powBatSoc_uint8": 60,
|
||||||
"powBatTotalElect_uint16": 826,
|
"powBatTotalElect_uint16": 413,
|
||||||
"powChargeState_uint8": 0,
|
"powChargeState_uint8": 0,
|
||||||
"powCurSocHold1_uint8": 0,
|
"powCurSocHold1_uint8": 0,
|
||||||
"powCurSocHold2_uint8": 0,
|
"powCurSocHold2_uint8": 0,
|
||||||
"powCurSocHold3_uint8": 0,
|
"powCurSocHold3_uint8": 0,
|
||||||
"powCurToInsLimit1_uint8": 0,
|
"powCurToInsLimit1_uint8": 0,
|
||||||
"powCurToinsLimit2_uint8": 0,
|
"powCurToinsLimit2_uint8": 0,
|
||||||
"powCur_uint16": 41,
|
"powCur_uint16": 72,
|
||||||
"powLinkVol_uint16": 0,
|
"powLinkVol_uint16": 0,
|
||||||
"powNegRelayState_uint8": 0,
|
"powNegRelayState_uint8": 0,
|
||||||
"powNegRes_uint16": 0,
|
"powNegRes_uint16": 0,
|
||||||
"powPosRelayState_uint8": 0,
|
"powPosRelayState_uint8": 0,
|
||||||
"powPosRes_uint16": 0,
|
"powPosRes_uint16": 0,
|
||||||
"powerBatLimit_uint16": 71,
|
"powerBatLimit_uint16": 82,
|
||||||
"powerPackVol_uint16": 0,
|
"powerPackVol_uint16": 0,
|
||||||
"powfaultCode_uint8": 0
|
"powfaultCode_uint8": 0
|
||||||
}
|
}
|
||||||
@@ -100,13 +100,12 @@ bool PowerManger::OnConnectToServer()
|
|||||||
|
|
||||||
bool PowerManger::Iterate()
|
bool PowerManger::Iterate()
|
||||||
{
|
{
|
||||||
|
AppCastingMOOSApp::Iterate();
|
||||||
//1. 更新当前状态
|
//1. 更新当前状态
|
||||||
updatePmState();
|
updatePmState();
|
||||||
updateTime();
|
updateTime();
|
||||||
//2. 运行状态机
|
//2. 运行状态机
|
||||||
m_fsm.run(m_pmState,this);
|
m_fsm.run(m_pmState,this);
|
||||||
// cout <<"CURRENT STATE:" << m_pmState.name << " | CURRENT EVENT :" << m_pmEvent << endl;
|
|
||||||
AppCastingMOOSApp::Iterate();
|
|
||||||
//3. 输出报告
|
//3. 输出报告
|
||||||
buildPowerSysReport();
|
buildPowerSysReport();
|
||||||
//4. 打印错误信息
|
//4. 打印错误信息
|
||||||
@@ -796,12 +795,10 @@ int PowerManger::handleInite_s1(FSM_State &fsm, void* pData)
|
|||||||
double StartTime = pm->GetAppStartTime();
|
double StartTime = pm->GetAppStartTime();
|
||||||
while (!pm->m_connected)
|
while (!pm->m_connected)
|
||||||
{
|
{
|
||||||
|
// disHighVolBusCmd a;
|
||||||
disHighVolBusCmd a;
|
// a.fuelCellCircuitBreaker = DIS_BREAKER_OFF;
|
||||||
a.fuelCellCircuitBreaker = DIS_BREAKER_OFF;
|
// a.propulsionMotorCircuitBreaker = DIS_BREAKER_OFF;
|
||||||
a.propulsionMotorCircuitBreaker = DIS_BREAKER_OFF;
|
// pm->m_udpComm.sendDisSysCmd(a);
|
||||||
pm->m_udpComm.sendDisSysCmd(a);
|
|
||||||
|
|
||||||
MOOSPause(1000);
|
MOOSPause(1000);
|
||||||
pm->updateTime();
|
pm->updateTime();
|
||||||
double dft = abs(pm->m_current_time - StartTime);
|
double dft = abs(pm->m_current_time - StartTime);
|
||||||
|
|||||||
@@ -91,6 +91,20 @@ typedef struct ccuState
|
|||||||
float placeholder5;
|
float placeholder5;
|
||||||
} ccuState;
|
} ccuState;
|
||||||
|
|
||||||
|
//TODO:增加复合管控的控制指令
|
||||||
|
// typedef struct ccuCmd
|
||||||
|
// {
|
||||||
|
// unsigned char currentWorkCondition;
|
||||||
|
// unsigned char fcuState;
|
||||||
|
// unsigned char fcuFaultLeve;
|
||||||
|
// } ccuCmd;
|
||||||
|
typedef struct ccuParamCmd
|
||||||
|
{
|
||||||
|
unsigned char insBat1Hold;
|
||||||
|
unsigned char insBat2Hold;
|
||||||
|
unsigned char insBat3Hold;
|
||||||
|
}ccuParamCmd;
|
||||||
|
|
||||||
typedef struct disHighVolBusState
|
typedef struct disHighVolBusState
|
||||||
{
|
{
|
||||||
unsigned char fuelCellCircuitBreaker;
|
unsigned char fuelCellCircuitBreaker;
|
||||||
|
|||||||
+126
-1
@@ -1,6 +1,7 @@
|
|||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
from tkinter import messagebox
|
||||||
import threading
|
import threading
|
||||||
import random
|
import random
|
||||||
from udpmsg import *
|
from udpmsg import *
|
||||||
@@ -54,7 +55,8 @@ class ccuSys(Frame):
|
|||||||
self._create_status_column("FCU Status", [
|
self._create_status_column("FCU Status", [
|
||||||
"fcuState", "fcuFaultLeve", "powerLimit",
|
"fcuState", "fcuFaultLeve", "powerLimit",
|
||||||
"totalPowerGeneration", "fcuVoltage", "fcuCurrent",
|
"totalPowerGeneration", "fcuVoltage", "fcuCurrent",
|
||||||
"fcuOutPower", "fcuOutIns"
|
"fcuOutPower", "fcuOutIns", "fcuGZ_1L", "fcuGZ_1H",
|
||||||
|
"fcuGZ_2L", "fcuGZ_2H", "fcuGZ_3L", "fcuGZ_3H"
|
||||||
])
|
])
|
||||||
|
|
||||||
self._create_status_column("Battery Status", [
|
self._create_status_column("Battery Status", [
|
||||||
@@ -141,6 +143,56 @@ class ccuSys(Frame):
|
|||||||
)
|
)
|
||||||
self.fcu_fault_menu.pack(side=tk.LEFT, padx=5)
|
self.fcu_fault_menu.pack(side=tk.LEFT, padx=5)
|
||||||
|
|
||||||
|
# FCU GZ control
|
||||||
|
tk.Label(self.fcu_frame, text="GZ 1L:").pack(side=tk.LEFT)
|
||||||
|
self.fcu_gz1l_var = tk.IntVar(value=0)
|
||||||
|
self.fcu_gz1l_entry = tk.Entry(
|
||||||
|
self.fcu_frame, textvariable=self.fcu_gz1l_var, width=5
|
||||||
|
)
|
||||||
|
self.fcu_gz1l_entry.pack(side=tk.LEFT, padx=5)
|
||||||
|
self.fcu_gz1l_entry.bind("<Return>", lambda e: self.set_fcu_gz1l())
|
||||||
|
|
||||||
|
tk.Label(self.fcu_frame, text="GZ 1H:").pack(side=tk.LEFT)
|
||||||
|
self.fcu_gz1h_var = tk.IntVar(value=0)
|
||||||
|
self.fcu_gz1h_entry = tk.Entry(
|
||||||
|
self.fcu_frame, textvariable=self.fcu_gz1h_var, width=5
|
||||||
|
)
|
||||||
|
self.fcu_gz1h_entry.pack(side=tk.LEFT, padx=5)
|
||||||
|
self.fcu_gz1h_entry.bind("<Return>", lambda e: self.set_fcu_gz1h())
|
||||||
|
|
||||||
|
# Add more GZ controls
|
||||||
|
tk.Label(self.fcu_frame, text="GZ 2L:").pack(side=tk.LEFT)
|
||||||
|
self.fcu_gz2l_var = tk.IntVar(value=0)
|
||||||
|
self.fcu_gz2l_entry = tk.Entry(
|
||||||
|
self.fcu_frame, textvariable=self.fcu_gz2l_var, width=5
|
||||||
|
)
|
||||||
|
self.fcu_gz2l_entry.pack(side=tk.LEFT, padx=5)
|
||||||
|
self.fcu_gz2l_entry.bind("<Return>", lambda e: self.set_fcu_gz2l())
|
||||||
|
|
||||||
|
tk.Label(self.fcu_frame, text="GZ 2H:").pack(side=tk.LEFT)
|
||||||
|
self.fcu_gz2h_var = tk.IntVar(value=0)
|
||||||
|
self.fcu_gz2h_entry = tk.Entry(
|
||||||
|
self.fcu_frame, textvariable=self.fcu_gz2h_var, width=5
|
||||||
|
)
|
||||||
|
self.fcu_gz2h_entry.pack(side=tk.LEFT, padx=5)
|
||||||
|
self.fcu_gz2h_entry.bind("<Return>", lambda e: self.set_fcu_gz2h())
|
||||||
|
|
||||||
|
tk.Label(self.fcu_frame, text="GZ 3L:").pack(side=tk.LEFT)
|
||||||
|
self.fcu_gz3l_var = tk.IntVar(value=0)
|
||||||
|
self.fcu_gz3l_entry = tk.Entry(
|
||||||
|
self.fcu_frame, textvariable=self.fcu_gz3l_var, width=5
|
||||||
|
)
|
||||||
|
self.fcu_gz3l_entry.pack(side=tk.LEFT, padx=5)
|
||||||
|
self.fcu_gz3l_entry.bind("<Return>", lambda e: self.set_fcu_gz3l())
|
||||||
|
|
||||||
|
tk.Label(self.fcu_frame, text="GZ 3H:").pack(side=tk.LEFT)
|
||||||
|
self.fcu_gz3h_var = tk.IntVar(value=0)
|
||||||
|
self.fcu_gz3h_entry = tk.Entry(
|
||||||
|
self.fcu_frame, textvariable=self.fcu_gz3h_var, width=5
|
||||||
|
)
|
||||||
|
self.fcu_gz3h_entry.pack(side=tk.LEFT, padx=5)
|
||||||
|
self.fcu_gz3h_entry.bind("<Return>", lambda e: self.set_fcu_gz3h())
|
||||||
|
|
||||||
def _create_status_column(self, title, fields):
|
def _create_status_column(self, title, fields):
|
||||||
"""Create a status column with specified fields"""
|
"""Create a status column with specified fields"""
|
||||||
col_frame = tk.LabelFrame(
|
col_frame = tk.LabelFrame(
|
||||||
@@ -205,6 +257,13 @@ class ccuSys(Frame):
|
|||||||
self.ccuState.insEmergencyStatusWord = random.randint(0, 255)
|
self.ccuState.insEmergencyStatusWord = random.randint(0, 255)
|
||||||
self.ccuState.powerEmergencyStatusWord = random.randint(0, 255)
|
self.ccuState.powerEmergencyStatusWord = random.randint(0, 255)
|
||||||
|
|
||||||
|
self.ccuState.fcuGZ_1L=self.fcu_gz1l_var.get()
|
||||||
|
self.ccuState.fcuGZ_1H=self.fcu_gz1h_var.get()
|
||||||
|
self.ccuState.fcuGZ_2L=self.fcu_gz2l_var.get()
|
||||||
|
self.ccuState.fcuGZ_2H=self.fcu_gz2h_var.get()
|
||||||
|
self.ccuState.fcuGZ_3L=self.fcu_gz3l_var.get()
|
||||||
|
self.ccuState.fcuGZ_3H=self.fcu_gz3h_var.get()
|
||||||
|
|
||||||
def update_display(self):
|
def update_display(self):
|
||||||
"""Update all displayed values"""
|
"""Update all displayed values"""
|
||||||
# Generate simulated data if no real data available
|
# Generate simulated data if no real data available
|
||||||
@@ -277,6 +336,72 @@ class ccuSys(Frame):
|
|||||||
self.ccuState.fcuFaultLeve = level
|
self.ccuState.fcuFaultLeve = level
|
||||||
self.update_display()
|
self.update_display()
|
||||||
|
|
||||||
|
def set_fcu_gz1l(self, value=None):
|
||||||
|
"""Set FCU GZ 1L and update display"""
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
value = self.fcu_gz1l_var.get()
|
||||||
|
except tk.TclError:
|
||||||
|
tk.messagebox.showwarning("Input Error", "Invalid GZ 1L value")
|
||||||
|
return
|
||||||
|
self.ccuState.fcuGZ_1L = value
|
||||||
|
self.update_display()
|
||||||
|
|
||||||
|
def set_fcu_gz1h(self, value=None):
|
||||||
|
"""Set FCU GZ 1H and update display"""
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
value = self.fcu_gz1h_var.get()
|
||||||
|
except tk.TclError:
|
||||||
|
tk.messagebox.showwarning("Input Error", "Invalid GZ 1H value")
|
||||||
|
return
|
||||||
|
self.ccuState.fcuGZ_1H = value
|
||||||
|
self.update_display()
|
||||||
|
|
||||||
|
def set_fcu_gz2l(self, value=None):
|
||||||
|
"""Set FCU GZ 2L and update display"""
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
value = self.fcu_gz2l_var.get()
|
||||||
|
except tk.TclError:
|
||||||
|
tk.messagebox.showwarning("Input Error", "Invalid GZ 2L value")
|
||||||
|
return
|
||||||
|
self.ccuState.fcuGZ_2L = value
|
||||||
|
self.update_display()
|
||||||
|
|
||||||
|
def set_fcu_gz2h(self, value=None):
|
||||||
|
"""Set FCU GZ 2H and update display"""
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
value = self.fcu_gz2h_var.get()
|
||||||
|
except tk.TclError:
|
||||||
|
tk.messagebox.showwarning("Input Error", "Invalid GZ 2H value")
|
||||||
|
return
|
||||||
|
self.ccuState.fcuGZ_2H = value
|
||||||
|
self.update_display()
|
||||||
|
|
||||||
|
def set_fcu_gz3l(self, value=None):
|
||||||
|
"""Set FCU GZ 3L and update display"""
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
value = self.fcu_gz3l_var.get()
|
||||||
|
except tk.TclError:
|
||||||
|
tk.messagebox.showwarning("Input Error", "Invalid GZ 3L value")
|
||||||
|
return
|
||||||
|
self.ccuState.fcuGZ_3L = value
|
||||||
|
self.update_display()
|
||||||
|
|
||||||
|
def set_fcu_gz3h(self, value=None):
|
||||||
|
"""Set FCU GZ 3H and update display"""
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
value = self.fcu_gz3h_var.get()
|
||||||
|
except tk.TclError:
|
||||||
|
tk.messagebox.showwarning("Input Error", "Invalid GZ 3H value")
|
||||||
|
return
|
||||||
|
self.ccuState.fcuGZ_3H = value
|
||||||
|
self.update_display()
|
||||||
|
|
||||||
def start_update_timer(self):
|
def start_update_timer(self):
|
||||||
"""Start the periodic display update timer"""
|
"""Start the periodic display update timer"""
|
||||||
if not hasattr(self, 'data_update_thread'):
|
if not hasattr(self, 'data_update_thread'):
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ def receive_messages(sock, logwin:logWin, disSysWin:disSys):
|
|||||||
current_time = datetime.now()
|
current_time = datetime.now()
|
||||||
formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
data, address = sock.recvfrom(4096)
|
data, address = sock.recvfrom(4096)
|
||||||
|
# 接受配电系统消息
|
||||||
disSysWin.update_fromMsg(data)
|
disSysWin.update_fromMsg(data)
|
||||||
headBuf = data[:6]
|
headBuf = data[:6]
|
||||||
header = struct.unpack('<BBHH',headBuf)
|
header = struct.unpack('<BBHH',headBuf)
|
||||||
@@ -49,8 +50,7 @@ def send_messages(sock, logwin:logWin, disSysWin:disSys,ccuSysWin:ccuSys):
|
|||||||
sock.sendto(d, (target_ip, target_port))
|
sock.sendto(d, (target_ip, target_port))
|
||||||
|
|
||||||
#TODO复合管控消息反馈
|
#TODO复合管控消息反馈
|
||||||
#TODOccu消息反馈
|
|
||||||
e = ccuSysWin.ccuState.pack()
|
e = ccuSysWin.ccuState.pack()
|
||||||
sock.sendto(e, (target_ip, target_port))
|
sock.sendto(e, (target_ip, target_port))
|
||||||
|
|
||||||
threading.Event().wait(1) # 每隔1秒发送一次消息
|
threading.Event().wait(1) # 每隔1秒发送一次消息
|
||||||
|
|||||||
Reference in New Issue
Block a user