diff --git a/data/msg/uPower_fcsState_st.json b/data/msg/uPower_fcsState_st.json index df58b39..27efb55 100644 --- a/data/msg/uPower_fcsState_st.json +++ b/data/msg/uPower_fcsState_st.json @@ -1,30 +1,30 @@ { - "backpressure1_fp32": 0.0, - "backpressure2_fp32": 9.0, - "ch4oConcent1_fp32": 72.0, - "ch4oConcent2_fp32": 3.0, + "backpressure1_fp32": 7.0, + "backpressure2_fp32": 7.0, + "ch4oConcent1_fp32": 75.0, + "ch4oConcent2_fp32": 11.0, "ch4o_fp32": 0.0, - "excTemp_fp32": 46.0, + "excTemp_fp32": 64.0, "faultCode1_uint16": 0, "faultCode2_uint16": 0, "faultCode3_uint16": 0, "fcuCurIns_fp32": 0.0, "fcuCurPower_fp32": 0.0, - "fcuCur_fp32": 61.0, + "fcuCur_fp32": 22.0, "fcuFaultLeve_uint8": 0, - "fcuOutIns_fp32": 94.0, - "fcuOutPower_fp32": 536.0, + "fcuOutIns_fp32": 99.0, + "fcuOutPower_fp32": 260.0, "fcuState_uint8": 0, "fcuVolIns_fp32": 0.0, "fcuVolPower_fp32": 0.0, - "fcuVol_fp32": 319.0, - "flameDet_uint8": 1, - "h2Concent1_fp32": 30.0, - "h2Concent2_fp32": 10.0, - "o2Concent1_fp32": 53.0, - "o2Concent2_fp32": 0.0, + "fcuVol_fp32": 244.0, + "flameDet_uint8": 0, + "h2Concent1_fp32": 58.0, + "h2Concent2_fp32": 59.0, + "o2Concent1_fp32": 9.0, + "o2Concent2_fp32": 38.0, "o2Level_fp32": 0.0, "o2_fp32": 0.0, - "powLimit_fp32": 60.0, - "powerGen_fp32": 155.0 + "powLimit_fp32": 41.0, + "powerGen_fp32": 911.0 } \ No newline at end of file diff --git a/data/msg/uPower_liBatState_st.json b/data/msg/uPower_liBatState_st.json index b48ef8b..633ec6f 100644 --- a/data/msg/uPower_liBatState_st.json +++ b/data/msg/uPower_liBatState_st.json @@ -2,37 +2,37 @@ "fcuCurToInsLimit1_uint8": 0, "fcuCurToinsLimit2_uint8": 0, "insBatCurElect_uint16": 0, - "insBatLimit_uint16": 95, - "insBatSoc_uint8": 11, - "insBatTotalElect_uint16": 631, + "insBatLimit_uint16": 39, + "insBatSoc_uint8": 85, + "insBatTotalElect_uint16": 304, "insChargeState_uint8": 0, "insCurSocHold1_uint8": 0, "insCurSocHold2_uint8": 0, "insCurSocHold3_uint8": 0, - "insCurrent_uint16": 89, + "insCurrent_uint16": 78, "insLinkVol_uint16": 0, - "insNegRelayState_uint8": 1, + "insNegRelayState_uint8": 0, "insNegRes_uint16": 0, "insPackVol_uint16": 0, - "insPosRelayState_uint8": 0, + "insPosRelayState_uint8": 1, "insPosRes_uint16": 0, "insfaultCode_uint8": 0, "powBatCurElect_uint16": 0, - "powBatSoc_uint8": 86, - "powBatTotalElect_uint16": 826, + "powBatSoc_uint8": 60, + "powBatTotalElect_uint16": 413, "powChargeState_uint8": 0, "powCurSocHold1_uint8": 0, "powCurSocHold2_uint8": 0, "powCurSocHold3_uint8": 0, "powCurToInsLimit1_uint8": 0, "powCurToinsLimit2_uint8": 0, - "powCur_uint16": 41, + "powCur_uint16": 72, "powLinkVol_uint16": 0, "powNegRelayState_uint8": 0, "powNegRes_uint16": 0, "powPosRelayState_uint8": 0, "powPosRes_uint16": 0, - "powerBatLimit_uint16": 71, + "powerBatLimit_uint16": 82, "powerPackVol_uint16": 0, "powfaultCode_uint8": 0 } \ No newline at end of file diff --git a/src/pPowerManger/PowerManger.cpp b/src/pPowerManger/PowerManger.cpp index 5ddc4c8..6465d83 100644 --- a/src/pPowerManger/PowerManger.cpp +++ b/src/pPowerManger/PowerManger.cpp @@ -100,13 +100,12 @@ bool PowerManger::OnConnectToServer() bool PowerManger::Iterate() { + AppCastingMOOSApp::Iterate(); //1. 更新当前状态 updatePmState(); updateTime(); //2. 运行状态机 m_fsm.run(m_pmState,this); - // cout <<"CURRENT STATE:" << m_pmState.name << " | CURRENT EVENT :" << m_pmEvent << endl; - AppCastingMOOSApp::Iterate(); //3. 输出报告 buildPowerSysReport(); //4. 打印错误信息 @@ -796,12 +795,10 @@ int PowerManger::handleInite_s1(FSM_State &fsm, void* pData) double StartTime = pm->GetAppStartTime(); while (!pm->m_connected) { - - disHighVolBusCmd a; - a.fuelCellCircuitBreaker = DIS_BREAKER_OFF; - a.propulsionMotorCircuitBreaker = DIS_BREAKER_OFF; - pm->m_udpComm.sendDisSysCmd(a); - + // disHighVolBusCmd a; + // a.fuelCellCircuitBreaker = DIS_BREAKER_OFF; + // a.propulsionMotorCircuitBreaker = DIS_BREAKER_OFF; + // pm->m_udpComm.sendDisSysCmd(a); MOOSPause(1000); pm->updateTime(); double dft = abs(pm->m_current_time - StartTime); diff --git a/src/pPowerManger/pmSysvariable.h b/src/pPowerManger/pmSysvariable.h index e9d8fe0..bbd722f 100644 --- a/src/pPowerManger/pmSysvariable.h +++ b/src/pPowerManger/pmSysvariable.h @@ -91,6 +91,20 @@ typedef struct ccuState float placeholder5; } 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 { unsigned char fuelCellCircuitBreaker; diff --git a/test/scripts/ccuSys.py b/test/scripts/ccuSys.py index abd6903..6e93065 100644 --- a/test/scripts/ccuSys.py +++ b/test/scripts/ccuSys.py @@ -1,6 +1,7 @@ import socket import struct import tkinter as tk +from tkinter import messagebox import threading import random from udpmsg import * @@ -54,7 +55,8 @@ class ccuSys(Frame): self._create_status_column("FCU Status", [ "fcuState", "fcuFaultLeve", "powerLimit", "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", [ @@ -141,6 +143,56 @@ class ccuSys(Frame): ) 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("", 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("", 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("", 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("", 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("", 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("", lambda e: self.set_fcu_gz3h()) + def _create_status_column(self, title, fields): """Create a status column with specified fields""" col_frame = tk.LabelFrame( @@ -205,6 +257,13 @@ class ccuSys(Frame): self.ccuState.insEmergencyStatusWord = 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): """Update all displayed values""" # Generate simulated data if no real data available @@ -277,6 +336,72 @@ class ccuSys(Frame): self.ccuState.fcuFaultLeve = level 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): """Start the periodic display update timer""" if not hasattr(self, 'data_update_thread'): diff --git a/test/scripts/udpComm.py b/test/scripts/udpComm.py index b2f06ac..1d18a6d 100644 --- a/test/scripts/udpComm.py +++ b/test/scripts/udpComm.py @@ -18,6 +18,7 @@ def receive_messages(sock, logwin:logWin, disSysWin:disSys): current_time = datetime.now() formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S") data, address = sock.recvfrom(4096) + # 接受配电系统消息 disSysWin.update_fromMsg(data) headBuf = data[:6] header = struct.unpack('