使用状态机增加了初始状态和故障状态,编写了gui调试程序
This commit is contained in:
Vendored
+2
-1
@@ -52,7 +52,8 @@
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
"typeinfo": "cpp",
|
||||
"queue": "cpp"
|
||||
},
|
||||
"C_Cpp.errorSquiggles": "disabled",
|
||||
"marscode.chatLanguage": "cn"
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
{
|
||||
"HVABFTDev123Cur_uint16": 24953,
|
||||
"HVABactCur_uint16": 42982,
|
||||
"HVABbowRudCur_uint16": 31,
|
||||
"HVABbusBCur_uint16": 24576,
|
||||
"HVABFTDev123Cur_uint16": 0,
|
||||
"HVABactCur_uint16": 0,
|
||||
"HVABbowRudCur_uint16": 0,
|
||||
"HVABbusBCur_uint16": 0,
|
||||
"HVABbusBVol_uint16": 0,
|
||||
"HVABmastSteGeaCur_uint16": 127,
|
||||
"HVABopenWaterCur_uint16": 65280,
|
||||
"HVABxczCur_uint16": 32768,
|
||||
"HVBBCCUCur_uint16": 24851,
|
||||
"HVBBFCSSecurSysCur_uint16": 42982,
|
||||
"HVBBbatInsCur_uint16": 24851,
|
||||
"HVABmastSteGeaCur_uint16": 0,
|
||||
"HVABopenWaterCur_uint16": 0,
|
||||
"HVABxczCur_uint16": 1,
|
||||
"HVBBCCUCur_uint16": 0,
|
||||
"HVBBFCSSecurSysCur_uint16": 0,
|
||||
"HVBBbatInsCur_uint16": 0,
|
||||
"HVBBbowLowVolDisBoxCur_uint16": 0,
|
||||
"HVBBdcC1InsCur_uint16": 0,
|
||||
"HVBBemer2BusVol_uint16": 47104,
|
||||
"HVBBemerBatCur_uint16": 36864,
|
||||
"HVBBemer2BusVol_uint16": 0,
|
||||
"HVBBemerBatCur_uint16": 0,
|
||||
"HVBBinsBusVol_uint16": 0,
|
||||
"HVBBplcCur_uint16": 127,
|
||||
"HVBBplcCur_uint16": 0,
|
||||
"HVBBreservedCur1_uint16": 0,
|
||||
"HVBBreservedCur2_uint16": 127,
|
||||
"HVBBunit4Cur_uint16": 42982,
|
||||
"HVBFTDev45Cur_uint16": 32679,
|
||||
"HVBbatGroupCur_uint16": 48760,
|
||||
"HVBbowHVolDisBoxCur_uint16": 58976,
|
||||
"HVBBreservedCur2_uint16": 0,
|
||||
"HVBBunit4Cur_uint16": 0,
|
||||
"HVBFTDev45Cur_uint16": 0,
|
||||
"HVBbatGroupCur_uint16": 0,
|
||||
"HVBbowHVolDisBoxCur_uint16": 0,
|
||||
"HVBbusACur_uint16": 0,
|
||||
"HVBbusAVol_uint16": 58943,
|
||||
"HVBbusAVol_uint16": 0,
|
||||
"HVBdcDc5Cur_uint16": 0,
|
||||
"HVBfbCur_uint16": 5144,
|
||||
"HVBmotorCur_uint16": 32679,
|
||||
"HVBpowerBusCur_uint16": 7264,
|
||||
"HVBpowerBusVol_uint16": 32679,
|
||||
"HVBreservedCur1_uint16": 58977,
|
||||
"HVBfbCur_uint16": 0,
|
||||
"HVBmotorCur_uint16": 0,
|
||||
"HVBpowerBusCur_uint16": 0,
|
||||
"HVBpowerBusVol_uint16": 0,
|
||||
"HVBreservedCur1_uint16": 0,
|
||||
"HVBreservedCur2_uint16": 0,
|
||||
"HVBreservedCur3_uint16": 58977,
|
||||
"HVBsternRud1Cur_uint16": 5048,
|
||||
"HVBsternRud2Cur_uint16": 32679,
|
||||
"HVBreservedCur3_uint16": 0,
|
||||
"HVBsternRud1Cur_uint16": 0,
|
||||
"HVBsternRud2Cur_uint16": 0,
|
||||
"HVBtyzCur_uint16": 0,
|
||||
"LVBBbowPZDevCur_uint16": 127,
|
||||
"LVBBemerBatCur_uint16": 6144,
|
||||
"LVBBemerBusVol_uint16": 24852,
|
||||
"LVBBinsBusCur_uint16": 42982,
|
||||
"LVBBunit1Cur_uint16": 127,
|
||||
"LVBBunit2Cur_uint16": 61440,
|
||||
"LVBBunit3Cur_uint16": 24851,
|
||||
"LVBBunit5Cur_uint16": 42982,
|
||||
"LVBinsBusVol_uint16": 24852
|
||||
"LVBBbowPZDevCur_uint16": 0,
|
||||
"LVBBemerBatCur_uint16": 0,
|
||||
"LVBBemerBusVol_uint16": 0,
|
||||
"LVBBinsBusCur_uint16": 0,
|
||||
"LVBBunit1Cur_uint16": 0,
|
||||
"LVBBunit2Cur_uint16": 0,
|
||||
"LVBBunit3Cur_uint16": 0,
|
||||
"LVBBunit5Cur_uint16": 0,
|
||||
"LVBinsBusVol_uint16": 0
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"HVolABusBreaker_unit16": 0,
|
||||
"HVolBBusBreaker_unit16": 0,
|
||||
"HVolBusBreaker_uint16": 512,
|
||||
"LVolBusBreaker_uint16": 0,
|
||||
"HVolABusBreaker_unit16": 63,
|
||||
"HVolBBusBreaker_unit16": 113,
|
||||
"HVolBusBreaker_uint16": 4090,
|
||||
"LVolBusBreaker_uint16": 113,
|
||||
"faultCode_array":
|
||||
[
|
||||
0
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
{
|
||||
"backpressure1_fp32": -9.0950115693742826e-30,
|
||||
"backpressure2_fp32": 1.1723338622658493e-38,
|
||||
"ch4oConcent1_fp32": 0.0,
|
||||
"ch4oConcent2_fp32": 0.0,
|
||||
"ch4o_fp32": 0.0,
|
||||
"excTemp_fp32": 1.1723338622658493e-38,
|
||||
"faultCode1_uint16": 39232,
|
||||
"faultCode2_uint16": 59024,
|
||||
"faultCode3_uint16": 32679,
|
||||
"fcuCurIns_fp32": -6.5672670359649233e-28,
|
||||
"fcuCurPower_fp32": 1.1723338622658493e-38,
|
||||
"fcuCur_fp32": 4.6635212892729912e-42,
|
||||
"fcuFaultLeve_uint8": 144,
|
||||
"fcuOutIns_fp32": 1.1753926165537775e-38,
|
||||
"fcuOutPower_fp32": -1.104591035133728e+23,
|
||||
"fcuState_uint8": 46,
|
||||
"fcuVolIns_fp32": -410840465408.0,
|
||||
"fcuVolPower_fp32": 7.8490804765364189e-39,
|
||||
"fcuVol_fp32": 1.1723338622658493e-38,
|
||||
"backpressure1_fp32": -1.6155215737897056e+25,
|
||||
"backpressure2_fp32": 1.9618178500547439e-44,
|
||||
"ch4oConcent1_fp32": 3.7196912217041245e-12,
|
||||
"ch4oConcent2_fp32": 1.1664828806579075e-38,
|
||||
"ch4o_fp32": 1.1754855226419623e-38,
|
||||
"excTemp_fp32": 1.1664828806579075e-38,
|
||||
"faultCode1_uint16": 29888,
|
||||
"faultCode2_uint16": 49624,
|
||||
"faultCode3_uint16": 0,
|
||||
"fcuCurIns_fp32": -1775767650304.0,
|
||||
"fcuCurPower_fp32": 7.894814654516588e-39,
|
||||
"fcuCur_fp32": 1.7755460477889746e-38,
|
||||
"fcuFaultLeve_uint8": 194,
|
||||
"fcuOutIns_fp32": 0.0,
|
||||
"fcuOutPower_fp32": 2.152394441202919e-42,
|
||||
"fcuState_uint8": 124,
|
||||
"fcuVolIns_fp32": 0.0,
|
||||
"fcuVolPower_fp32": 1.1664542941692352e-38,
|
||||
"fcuVol_fp32": 1.1754855226419623e-38,
|
||||
"flameDet_uint8": 0,
|
||||
"h2Concent1_fp32": -3.4461820052887443e-29,
|
||||
"h2Concent2_fp32": 1.1723338622658493e-38,
|
||||
"o2Concent1_fp32": 3.5873240686715317e-43,
|
||||
"o2Concent2_fp32": 0.0,
|
||||
"o2Level_fp32": 0.0,
|
||||
"o2_fp32": -8.1197206455365864e-30,
|
||||
"powLimit_fp32": 1.1723338622658493e-38,
|
||||
"powerGen_fp32": 3.5873240686715317e-43
|
||||
"h2Concent1_fp32": 3.8200553831302386e-12,
|
||||
"h2Concent2_fp32": 1.1664828806579075e-38,
|
||||
"o2Concent1_fp32": 4.5144443738820428e-14,
|
||||
"o2Concent2_fp32": 1.1664828806579075e-38,
|
||||
"o2Level_fp32": 1.1664542941692352e-38,
|
||||
"o2_fp32": -1075184933011456.0,
|
||||
"powLimit_fp32": 1.166482740528061e-38,
|
||||
"powerGen_fp32": -1075322371964928.0
|
||||
}
|
||||
@@ -1,38 +1,38 @@
|
||||
{
|
||||
"fcuCurToInsLimit1_uint8": 127,
|
||||
"fcuCurToinsLimit2_uint8": 0,
|
||||
"insBatCurElect_uint16": 32765,
|
||||
"insBatLimit_uint16": 39552,
|
||||
"insBatSoc_uint8": 97,
|
||||
"insBatTotalElect_uint16": 47744,
|
||||
"insChargeState_uint8": 2,
|
||||
"insCurSocHold1_uint8": 144,
|
||||
"insCurSocHold2_uint8": 230,
|
||||
"insCurSocHold3_uint8": 167,
|
||||
"insBatCurElect_uint16": 0,
|
||||
"insBatLimit_uint16": 0,
|
||||
"insBatSoc_uint8": 0,
|
||||
"insBatTotalElect_uint16": 2,
|
||||
"insChargeState_uint8": 71,
|
||||
"insCurSocHold1_uint8": 41,
|
||||
"insCurSocHold2_uint8": 204,
|
||||
"insCurSocHold3_uint8": 4,
|
||||
"insCurrent_uint16": 0,
|
||||
"insLinkVol_uint16": 0,
|
||||
"insLinkVol_uint16": 52163,
|
||||
"insNegRelayState_uint8": 0,
|
||||
"insNegRes_uint16": 0,
|
||||
"insPackVol_uint16": 0,
|
||||
"insNegRes_uint16": 52265,
|
||||
"insPackVol_uint16": 32516,
|
||||
"insPosRelayState_uint8": 0,
|
||||
"insPosRes_uint16": 0,
|
||||
"insfaultCode_uint8": 186,
|
||||
"insPosRes_uint16": 18488,
|
||||
"insfaultCode_uint8": 176,
|
||||
"powBatCurElect_uint16": 0,
|
||||
"powBatSoc_uint8": 175,
|
||||
"powBatTotalElect_uint16": 10981,
|
||||
"powChargeState_uint8": 0,
|
||||
"powBatSoc_uint8": 0,
|
||||
"powBatTotalElect_uint16": 0,
|
||||
"powChargeState_uint8": 241,
|
||||
"powCurSocHold1_uint8": 0,
|
||||
"powCurSocHold2_uint8": 224,
|
||||
"powCurSocHold3_uint8": 233,
|
||||
"powCurToInsLimit1_uint8": 210,
|
||||
"powCurToinsLimit2_uint8": 11,
|
||||
"powCur_uint16": 47904,
|
||||
"powLinkVol_uint16": 0,
|
||||
"powNegRelayState_uint8": 115,
|
||||
"powNegRes_uint16": 32765,
|
||||
"powPosRelayState_uint8": 238,
|
||||
"powPosRes_uint16": 10981,
|
||||
"powerBatLimit_uint16": 42026,
|
||||
"powCurSocHold2_uint8": 228,
|
||||
"powCurSocHold3_uint8": 85,
|
||||
"powCurToInsLimit1_uint8": 48,
|
||||
"powCurToinsLimit2_uint8": 0,
|
||||
"powCur_uint16": 15376,
|
||||
"powLinkVol_uint16": 32516,
|
||||
"powNegRelayState_uint8": 0,
|
||||
"powNegRes_uint16": 32516,
|
||||
"powPosRelayState_uint8": 0,
|
||||
"powPosRes_uint16": 52247,
|
||||
"powerBatLimit_uint16": 0,
|
||||
"powerPackVol_uint16": 0,
|
||||
"powfaultCode_uint8": 81
|
||||
"powfaultCode_uint8": 68
|
||||
}
|
||||
@@ -7,6 +7,6 @@
|
||||
],
|
||||
"powerState_uint8": 0,
|
||||
"soc_uint32": 0,
|
||||
"sustainableTime_obj": 0,
|
||||
"sustainableTime_uint32": 0,
|
||||
"workCondition_uint8": 0
|
||||
}
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "MBUtils.h"
|
||||
#include "ACTable.h"
|
||||
#include "PowerManger.h"
|
||||
#include "MOOS/libMOOS/Utils/ConsoleColours.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
@@ -32,33 +31,18 @@ PowerManger::PowerManger()
|
||||
falutLevel = 0;
|
||||
soc = 0;
|
||||
sustainableTime = 0;
|
||||
m_connected = false;
|
||||
faultCode.push_back(0);
|
||||
|
||||
|
||||
|
||||
//注册状态机
|
||||
m_fsm.RegisterState("PM_STATE", 1, m_state1);
|
||||
m_fsm.RegisterState("PM_STATE2", 2, m_state2);
|
||||
m_fsm.RegisterState("PM_STATE3", 3, m_state3);
|
||||
m_fsm.RegisterState("Init", 1, m_Inite_s1);
|
||||
m_fsm.RegisterState("Fault", 99, m_Fault_s99);
|
||||
|
||||
m_fsm.RegisterHandleFunction(&m_state1,handleState1);
|
||||
m_fsm.RegisterHandleFunction(&m_state2,handleState2);
|
||||
m_fsm.RegisterHandleFunction(&m_state3,handleState3);
|
||||
|
||||
// 注册状态机转换条件
|
||||
// m_fsm.RegisterEvent(&m_state1, "a", &m_state2);
|
||||
// m_fsm.RegisterEvent(&m_state2, "b", &m_state3);
|
||||
// m_fsm.RegisterEvent(&m_state3, "c", &m_state1);
|
||||
|
||||
// cout << m_state1.event["a"]->name << endl;
|
||||
// cout << m_state2.event["b"]->name << endl;
|
||||
// cout << m_state1.event["a"]->id << endl;
|
||||
|
||||
// m_pmEvent = "a";
|
||||
m_fsm.RegisterHandleFunction(&m_Inite_s1, handleInite_s1);
|
||||
m_fsm.RegisterHandleFunction(&m_Fault_s99, handleFault_s99);
|
||||
|
||||
// 初始化状态机
|
||||
m_pmState = m_state1;
|
||||
|
||||
m_pmState = m_Inite_s1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
@@ -115,20 +99,17 @@ bool PowerManger::OnConnectToServer()
|
||||
|
||||
bool PowerManger::Iterate()
|
||||
{
|
||||
m_fsm.run(m_pmState,this);
|
||||
// m_fsm.run(&m_pmState,this,m_pmEvent);
|
||||
|
||||
cout <<"CURRENT STATE:" << m_pmState.name << " | CURRENT EVENT :" << m_pmEvent << endl;
|
||||
// cout <<"____________________________________-" << m_pmState.event[m_pmEvent]->name << endl;
|
||||
|
||||
// cout << m_pmState.name << endl;
|
||||
// cout << m_pmEvent << endl;
|
||||
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. 打印错误信息
|
||||
if(!m_udpComm.sError.empty())
|
||||
{
|
||||
for(int i=0;i<m_udpComm.sError.size();i++)
|
||||
@@ -138,6 +119,7 @@ bool PowerManger::Iterate()
|
||||
m_udpComm.sError.clear();
|
||||
}
|
||||
//AppCastingMOOSApp::PostReport();
|
||||
//5. 清空UDP消息队列
|
||||
m_udpComm.clearMsgQueue();
|
||||
return(true);
|
||||
}
|
||||
@@ -176,10 +158,13 @@ bool PowerManger::OnStartUp()
|
||||
}
|
||||
|
||||
registerVariables();
|
||||
|
||||
//绑定UDP端口
|
||||
if(m_pCcuUdpComm = setUdpScoket(IPORT))
|
||||
{
|
||||
cout<<MOOS::ConsoleColours::green()<< "UDP set succeed!"<< MOOS::ConsoleColours::reset() << endl;
|
||||
m_udpComm.ccuHost = CCUHOST;
|
||||
m_udpComm.ccuPort = CCUPORT;
|
||||
m_udpComm.udpScoket = m_pCcuUdpComm;
|
||||
MOOSTrace("UDP set succeed");
|
||||
}
|
||||
else
|
||||
@@ -253,7 +238,9 @@ bool PowerManger::ListenLoopUDP()
|
||||
cout<<MOOS::ConsoleColours::red()<< m_udpComm.sError[i] << MOOS::ConsoleColours::reset() << endl;
|
||||
}
|
||||
}
|
||||
m_connected = true;
|
||||
}
|
||||
// updatePmState();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -794,28 +781,97 @@ bool PowerManger::saveStringToJsonFile(const string &strJson, const string &file
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//TODO:配电系统操作函数
|
||||
bool PowerManger::disSystemOperation(disBreaker optBreaker, disBreakerOpt)
|
||||
{
|
||||
// switch (disBreaker)
|
||||
// {
|
||||
// case bus1_fuelCellCircuitBreaker :
|
||||
// // send()
|
||||
// break;
|
||||
|
||||
int PowerManger::handleState1(FSM_State &fsm,void* pData)
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
int PowerManger::handleInite_s1(FSM_State &fsm, void* pData)
|
||||
{
|
||||
cout << fsm.name << endl;
|
||||
PowerManger* pm = (PowerManger*)pData;
|
||||
fsm = pm->m_fsm.getState("PM_STATE2");
|
||||
// pm->m_pmEvent = "a";
|
||||
|
||||
//1. 检查复合管控器连接
|
||||
double StartTime = pm->GetAppStartTime();
|
||||
while (!pm->m_connected)
|
||||
{
|
||||
pm->updateTime();
|
||||
double dft = abs(pm->m_current_time - StartTime);
|
||||
if(dft > 1)
|
||||
{
|
||||
pm->m_pmState = pm->m_Fault_s99;
|
||||
break;
|
||||
}
|
||||
string desp = "等待复合管控消息 : 超时 : " + to_string(10-dft);
|
||||
pm->printState(fsm,desp);
|
||||
usleep(1000000);
|
||||
}
|
||||
//2. 检查复合管控器是否上报故障 如果故障则进入故障状态
|
||||
bool ok = true;
|
||||
if(pm->m_pmCurrentState.ccustate.fcuGZ_1H != 0 ||
|
||||
pm->m_pmCurrentState.ccustate.fcuGZ_1L != 0 ||
|
||||
pm->m_pmCurrentState.ccustate.fcuGZ_2H != 0 ||
|
||||
pm->m_pmCurrentState.ccustate.fcuGZ_2L != 0 ||
|
||||
pm->m_pmCurrentState.ccustate.fcuGZ_3H != 0 ||
|
||||
pm->m_pmCurrentState.ccustate.fcuGZ_3L != 0 ||
|
||||
pm->m_pmCurrentState.ccustate.insEmergencyStatusWord != 0)
|
||||
{
|
||||
ok = false;
|
||||
}
|
||||
if(!ok)
|
||||
{
|
||||
pm->m_pmState = pm->m_Fault_s99;
|
||||
}
|
||||
//3. 检查当前配电装置状态
|
||||
// 首先闭合应急电源开关
|
||||
//TODO 检查并配置当前配电装置状态
|
||||
disHighVolBusCmd a;
|
||||
a.fuelCellCircuitBreaker = 0xAA;
|
||||
a.propulsionMotorCircuitBreaker = 0xAA;
|
||||
pm->m_udpComm.sendDisSysCmd(a);
|
||||
MOOSPause(1000);
|
||||
|
||||
// pm->workCondition = "";
|
||||
return 0;
|
||||
}
|
||||
int PowerManger::handleState2(FSM_State &fsm,void* pData)
|
||||
|
||||
int PowerManger::handleFault_s99(FSM_State &fsm, void* pData)
|
||||
{
|
||||
cout << fsm.name << endl;
|
||||
PowerManger* pm = (PowerManger*)pData;
|
||||
fsm = pm->m_fsm.getState("PM_STATE3");
|
||||
// pm->m_pmEvent = "b";
|
||||
return 0;
|
||||
}
|
||||
int PowerManger::handleState3(FSM_State &fsm,void* pData)
|
||||
{
|
||||
cout << fsm.name << endl;
|
||||
PowerManger* pm = (PowerManger*)pData;
|
||||
fsm = pm->m_fsm.getState("PM_STATE");
|
||||
// pm->m_pmEvent = "c";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// int PowerManger::handleState1(FSM_State &fsm,void* pData)
|
||||
// {
|
||||
// cout << fsm.name << endl;
|
||||
// PowerManger* pm = (PowerManger*)pData;
|
||||
// fsm = pm->m_fsm.getState("PM_STATE2");
|
||||
// // pm->m_pmEvent = "a";
|
||||
// return 0;
|
||||
// }
|
||||
// int PowerManger::handleState2(FSM_State &fsm,void* pData)
|
||||
// {
|
||||
// cout << fsm.name << endl;
|
||||
// PowerManger* pm = (PowerManger*)pData;
|
||||
// fsm = pm->m_fsm.getState("PM_STATE3");
|
||||
// // pm->m_pmEvent = "b";
|
||||
// return 0;
|
||||
// }
|
||||
// int PowerManger::handleState3(FSM_State &fsm,void* pData)
|
||||
// {
|
||||
// cout << fsm.name << endl;
|
||||
// PowerManger* pm = (PowerManger*)pData;
|
||||
// fsm = pm->m_fsm.getState("PM_STATE");
|
||||
// // pm->m_pmEvent = "c";
|
||||
// return 0;
|
||||
// }
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "MOOS/libMOOS/Utils/MOOSThread.h"
|
||||
#include "MOOS/libMOOS/Comms/XPCUdpSocket.h"
|
||||
#include "MOOS/libMOOS/Utils/MOOSUtilityFunctions.h"
|
||||
#include "MOOS/libMOOS/Utils/ConsoleColours.h"
|
||||
#include "ccuUdpMsg.h"
|
||||
#include "json/json.h"
|
||||
#include "udpComm.h"
|
||||
@@ -33,6 +34,8 @@
|
||||
#define VAR_TO_STR(var) #var
|
||||
|
||||
#define IPORT 5000
|
||||
#define CCUPORT 5001
|
||||
#define CCUHOST "127.0.0.1"
|
||||
#define MAX_UDP_PKT_SIZE 65535
|
||||
#define SKEW_TOLERANCE 5
|
||||
|
||||
@@ -61,17 +64,17 @@ class PowerManger : public AppCastingMOOSApp
|
||||
|
||||
protected: // app function
|
||||
// bool _ListenCB();
|
||||
XPCUdpSocket* setUdpScoket(long lPort);
|
||||
|
||||
bool updatePmState();
|
||||
bool updatePmState();
|
||||
void updateTime(){m_current_time = MOOSTime();}
|
||||
bool IsSkewed(double dfTimeNow, double * pdfSkew = NULL);
|
||||
string getTypeName(const string typeName);
|
||||
|
||||
|
||||
|
||||
//通信相关
|
||||
XPCUdpSocket* setUdpScoket(long lPort);
|
||||
bool disSystemOperation(disBreaker optBreaker, disBreakerOpt);
|
||||
bool buildPowerSysReport();
|
||||
bool buildDisributionReport();
|
||||
bool buildSubDistributionReport();
|
||||
bool buildPredictionReport();
|
||||
|
||||
protected: // app variables
|
||||
//系统状态
|
||||
@@ -81,8 +84,9 @@ class PowerManger : public AppCastingMOOSApp
|
||||
unsigned char falutLevel;
|
||||
vector<unsigned int> faultCode;
|
||||
unsigned int soc;
|
||||
unsigned long int sustainableTime;
|
||||
unsigned int sustainableTime;
|
||||
pmState m_pmCurrentState;
|
||||
bool m_connected;
|
||||
// 当前传输状态
|
||||
msg_CcuStateFbMsg m_CcuCurrentState;
|
||||
msg_disHighVolBusFbMsg m_disHighVolBusCurrentState;
|
||||
@@ -105,16 +109,30 @@ class PowerManger : public AppCastingMOOSApp
|
||||
|
||||
|
||||
public: //状态实现
|
||||
FSM_State m_pmState;
|
||||
|
||||
void printState(FSM_State st, string desp){
|
||||
cout << MOOS::ConsoleColours::Yellow() << "STATE " << st.id << " [" << st.name << "] " << MOOS::ConsoleColours::reset();
|
||||
cout << MOOS::ConsoleColours::Blue() << " -> " << MOOS::ConsoleColours::reset();
|
||||
cout << MOOS::ConsoleColours::Green() << desp << MOOS::ConsoleColours::reset() << endl;
|
||||
}
|
||||
|
||||
FSM_State m_pmState; //当前状态
|
||||
string m_pmEvent;
|
||||
FSM m_fsm;
|
||||
//系统状态定义
|
||||
FSM_State m_state1;
|
||||
FSM_State m_state2;
|
||||
FSM_State m_state3;
|
||||
|
||||
static int handleState1(FSM_State &fsm, void* pData);
|
||||
static int handleState2(FSM_State &fsm, void* pData);
|
||||
static int handleState3(FSM_State &fsm, void* pData);
|
||||
FSM_State startState;
|
||||
FSM_State stopState;
|
||||
//初始化状态
|
||||
FSM_State m_Inite_s1;
|
||||
static int handleInite_s1(FSM_State &fsm, void* pData);
|
||||
|
||||
//故障处理
|
||||
FSM_State m_Fault_s99;
|
||||
static int handleFault_s99(FSM_State &fsm, void* pData);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -16,10 +16,15 @@
|
||||
#define DIS_HVBUSB_FB_ID 0x0007
|
||||
#define DIS_LVBUS_FB_ID 0x0008
|
||||
|
||||
#pragma pack (1)
|
||||
#define DIS_HVBUS_CMD_ID 0x0001
|
||||
#define DIS_HVBUSA_CMD_ID 0x0002
|
||||
#define DIS_HVBUSB_CMD_ID 0x0003
|
||||
#define DIS_LVBUS_CMD_ID 0x0004
|
||||
|
||||
typedef unsigned int Checksum;
|
||||
typedef unsigned char cChecksum;
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
unsigned char start1;
|
||||
unsigned char start2;
|
||||
@@ -68,43 +73,71 @@ typedef struct {
|
||||
} msg_CcuSetParmMsg;
|
||||
|
||||
// 配电指令
|
||||
typedef struct {
|
||||
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
unsigned char dcb1;
|
||||
unsigned char dcb2;
|
||||
unsigned char dcb3;
|
||||
unsigned char dcb4;
|
||||
unsigned char dcb5;
|
||||
unsigned char sw1;
|
||||
unsigned char sw2;
|
||||
unsigned char qf1;
|
||||
unsigned char qf2;
|
||||
unsigned char qf3;
|
||||
unsigned char qf4;
|
||||
unsigned char qf5;
|
||||
unsigned char qf6;
|
||||
unsigned char qf7;
|
||||
unsigned char qf8;
|
||||
unsigned char qf9;
|
||||
unsigned char qf10;
|
||||
unsigned char qf11;
|
||||
unsigned char qf12;
|
||||
unsigned char qf13;
|
||||
unsigned char qf14;
|
||||
unsigned char qf15;
|
||||
unsigned char qf16;
|
||||
unsigned char qf17;
|
||||
unsigned char qf18;
|
||||
unsigned char qf19;
|
||||
unsigned char qf20;
|
||||
unsigned char qf21;
|
||||
unsigned char qf22;
|
||||
unsigned char qf23;
|
||||
unsigned char qf24;
|
||||
unsigned char qf25;
|
||||
unsigned char qf26;
|
||||
Checksum checkCode;
|
||||
} msg_disSysCmdMsg;
|
||||
disHighVolBusCmd data;
|
||||
cChecksum checkCode;
|
||||
}msg_disHVBCmd;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
disHighAVolBusCmd data;
|
||||
cChecksum checkCode;
|
||||
}msg_disHVBACmd;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
disHighBVolBusCmd data;
|
||||
cChecksum checkCode;
|
||||
}msg_disHVBBCmd;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
disLowBusCmd data;
|
||||
cChecksum checkCode;
|
||||
}msg_disLVBCmd;
|
||||
// typedef struct {
|
||||
// m_header header;
|
||||
// unsigned char dcb1;
|
||||
// unsigned char dcb2;
|
||||
// unsigned char dcb3;
|
||||
// unsigned char dcb4;
|
||||
// unsigned char dcb5;
|
||||
// unsigned char sw1;
|
||||
// unsigned char sw2;
|
||||
// unsigned char qf1;
|
||||
// unsigned char qf2;
|
||||
// unsigned char qf3;
|
||||
// unsigned char qf4;
|
||||
// unsigned char qf5;
|
||||
// unsigned char qf6;
|
||||
// unsigned char qf7;
|
||||
// unsigned char qf8;
|
||||
// unsigned char qf9;
|
||||
// unsigned char qf10;
|
||||
// unsigned char qf11;
|
||||
// unsigned char qf12;
|
||||
// unsigned char qf13;
|
||||
// unsigned char qf14;
|
||||
// unsigned char qf15;
|
||||
// unsigned char qf16;
|
||||
// unsigned char qf17;
|
||||
// unsigned char qf18;
|
||||
// unsigned char qf19;
|
||||
// unsigned char qf20;
|
||||
// unsigned char qf21;
|
||||
// unsigned char qf22;
|
||||
// unsigned char qf23;
|
||||
// unsigned char qf24;
|
||||
// unsigned char qf25;
|
||||
// unsigned char qf26;
|
||||
// Checksum checkCode;
|
||||
// } msg_disSysCmdMsg;
|
||||
|
||||
// 复合管控参数设定反馈指令
|
||||
typedef struct {
|
||||
|
||||
@@ -10,7 +10,7 @@ typedef struct FSM_State
|
||||
std::string name;
|
||||
unsigned int id;
|
||||
std::map<std::string,FSM_State*> event;
|
||||
};
|
||||
}FSM_State;
|
||||
|
||||
typedef int (*FSM_Handle)(FSM_State &fsm, void *data);
|
||||
// typedef int (*FSM_EventHandle)(FSM_State &fsm,std::string event,void *data);
|
||||
|
||||
@@ -196,6 +196,57 @@ typedef struct disLowBusState
|
||||
unsigned short emergencyLithiumBatteryGroup1Current;
|
||||
unsigned short emergency1BusbarVoltage;
|
||||
}disLowBusState;
|
||||
|
||||
typedef struct disHighVolBusCmd
|
||||
{
|
||||
unsigned char fuelCellCircuitBreaker;
|
||||
unsigned char powerLithiumBatteryCircuitBreaker;
|
||||
unsigned char propulsionMotorCircuitBreaker;
|
||||
unsigned char lithiumBatteryGroupInstrumentCircuitBreaker;
|
||||
unsigned char dcDc5ModuleCircuitBreaker;
|
||||
unsigned char bowHighVoltageDistributionBoxCircuitBreaker;
|
||||
unsigned char sternFTDevice45CircuitBreaker;
|
||||
unsigned char sternRudderSwitch1CircuitBreaker;
|
||||
unsigned char sternRudderSwitch2CircuitBreaker;
|
||||
unsigned char fbReservedCircuitBreaker;
|
||||
unsigned char tyzReservedCircuitBreaker;
|
||||
unsigned char reservedCircuitBreaker;
|
||||
}disHighVolBusCmd;
|
||||
|
||||
typedef struct disHighAVolBusCmd
|
||||
{
|
||||
unsigned char bowFTDevice123CircuitBreaker;
|
||||
unsigned char actuatorCircuitBreaker;
|
||||
unsigned char mastSteeringGearControlBoxCircuitBreaker;
|
||||
unsigned char xczCircuitBreaker;
|
||||
unsigned char bowRudderControlBoxCircuitBreaker;
|
||||
unsigned char openWaterCoverStartCylinderCircuitBreaker;
|
||||
}disHighAVolBusCmd;
|
||||
|
||||
typedef struct disHighBVolBusCmd
|
||||
{
|
||||
unsigned char lithiumBatteryGroupInstrumentCircuitBreaker;
|
||||
unsigned char bowLowVoltageDistributionBoxCircuitBreaker;
|
||||
unsigned char unit4InstrumentDC48VCircuitBreaker;
|
||||
unsigned char dcC1DCDistributionPanelCircuitBreaker;
|
||||
unsigned char reservedCircuitBreaker1; // 为了区分,添加了数字后缀
|
||||
unsigned char reservedCircuitBreaker2; // 为了区分,添加了数字后缀
|
||||
unsigned char emergencyLithiumBatteryGroup2CircuitBreaker;
|
||||
}disHighBVolBusCmd;
|
||||
|
||||
typedef struct disLowBusCmd
|
||||
{
|
||||
unsigned char unit1CircuitBreaker;
|
||||
unsigned char unit2CircuitBreaker;
|
||||
unsigned char unit3CircuitBreaker;
|
||||
unsigned char unit5CircuitBreaker;
|
||||
unsigned char bowPZDeviceCircuitBreaker;
|
||||
unsigned char reservedCircuitBreaker1; // 为了区分,添加了数字后缀
|
||||
unsigned char reservedCircuitBreaker2; // 为了区分,添加了数字后缀
|
||||
unsigned char emergencyLithiumBatteryGroup1CircuitBreaker;
|
||||
}disLowBusCmd;
|
||||
|
||||
|
||||
#pragma pack (0)
|
||||
|
||||
|
||||
@@ -270,4 +321,50 @@ typedef struct pmState
|
||||
/* data */
|
||||
} disBus4Breaker;
|
||||
|
||||
|
||||
enum disBreaker{
|
||||
bus1_fuelCellCircuitBreaker,
|
||||
bus1_powerLithiumBatteryCircuitBreaker,
|
||||
bus1_propulsionMotorCircuitBreaker,
|
||||
bus1_lithiumBatteryGroupInstrumentCircuitBreaker,
|
||||
bus1_dcDc5ModuleCircuitBreaker,
|
||||
bus1_bowHighVoltageDistributionBoxCircuitBreaker,
|
||||
bus1_sternFTDevice45CircuitBreaker,
|
||||
bus1_sternRudderSwitch1CircuitBreaker,
|
||||
bus1_sternRudderSwitch2CircuitBreaker,
|
||||
bus1_fbReservedCircuitBreaker,
|
||||
bus1_tyzReservedCircuitBreaker,
|
||||
bus1_reservedCircuitBreaker,
|
||||
|
||||
bus2_bowFTDevice123CircuitBreaker,
|
||||
bus2_actuatorCircuitBreaker,
|
||||
bus2_mastSteeringGearControlBoxCircuitBreaker,
|
||||
bus2_xczCircuitBreaker,
|
||||
bus2_bowRudderControlBoxCircuitBreaker,
|
||||
bus2_openWaterCoverStartCylinderCircuitBreaker,
|
||||
|
||||
bus3_lithiumBatteryGroupInstrumentCircuitBreaker,
|
||||
bus3_bowLowVoltageDistributionBoxCircuitBreaker,
|
||||
bus3_unit4InstrumentDC48VCircuitBreaker,
|
||||
bus3_dcC1DCDistributionPanelCircuitBreaker,
|
||||
bus3_reservedCircuitBreaker1,
|
||||
bus3_reservedCircuitBreaker2,
|
||||
bus3_emergencyLithiumBatteryGroup2CircuitBreaker,
|
||||
|
||||
bus4_unit1CircuitBreaker,
|
||||
bus4_unit2CircuitBreaker,
|
||||
bus4_unit3CircuitBreaker,
|
||||
bus4_unit5CircuitBreaker,
|
||||
bus4_bowPZDeviceCircuitBreaker,
|
||||
bus4_reservedCircuitBreaker1,
|
||||
bus4_reservedCircuitBreaker2
|
||||
};
|
||||
|
||||
enum disBreakerOpt{
|
||||
hold,
|
||||
turn_off,
|
||||
turn_on
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -367,3 +367,105 @@ bool udpComm::popMsgFormQueue(double &time,msg_disLowBusFbMsg &m)
|
||||
m_qReceiveDisLowBusBuffer.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool udpComm::sendDisSysCmd(const disHighVolBusCmd cmd)
|
||||
{
|
||||
unsigned char* msgBuf;
|
||||
Checksum cc;
|
||||
msg_disHVBCmd* msg = new msg_disHVBCmd;
|
||||
msg->header.id = DIS_HVBUS_CMD_ID;
|
||||
msg->header.start1 = DIS_MSG_HEAD1;
|
||||
msg->header.start2 = DIS_MSG_HEAD2;
|
||||
msg->header.length = sizeof(disHighVolBusCmd);
|
||||
msg->data = cmd;
|
||||
msgBuf = reinterpret_cast<unsigned char *>(msg);
|
||||
cc = calculateChecksum(msgBuf,sizeof(msg_disHVBCmd));
|
||||
msg->checkCode = static_cast<cChecksum>(cc & 0xFF);
|
||||
std::cout << (int)sizeof(msg_disHVBCmd) << endl;
|
||||
try
|
||||
{
|
||||
sendMsg(msgBuf,sizeof(msg_disHVBCmd));
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
delete msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udpComm::snedDisSysCmd(const disHighAVolBusCmd cmd)
|
||||
{
|
||||
unsigned char* msgBuf;
|
||||
Checksum cc;
|
||||
msg_disHVBACmd* msg = new msg_disHVBACmd;
|
||||
msg->header.id = DIS_HVBUS_CMD_ID;
|
||||
msg->header.start1 = DIS_MSG_HEAD1;
|
||||
msg->header.start2 = DIS_MSG_HEAD2;
|
||||
msg->header.length = sizeof(disHighAVolBusCmd);
|
||||
msg->data = cmd;
|
||||
msgBuf = reinterpret_cast<unsigned char *>(msg);
|
||||
cc = calculateChecksum(msgBuf,sizeof(msg_disHVBACmd));
|
||||
msg->checkCode = static_cast<cChecksum>(cc & 0xFF);
|
||||
try
|
||||
{
|
||||
sendMsg(msgBuf,sizeof(msg_disHVBACmd));
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
delete msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udpComm::snedDisSysCmd(const disHighBVolBusCmd cmd)
|
||||
{
|
||||
unsigned char* msgBuf;
|
||||
Checksum cc;
|
||||
msg_disHVBBCmd* msg = new msg_disHVBBCmd;
|
||||
msg->header.id = DIS_HVBUS_CMD_ID;
|
||||
msg->header.start1 = DIS_MSG_HEAD1;
|
||||
msg->header.start2 = DIS_MSG_HEAD2;
|
||||
msg->header.length = sizeof(disHighBVolBusCmd);
|
||||
msg->data = cmd;
|
||||
msgBuf = reinterpret_cast<unsigned char *>(msg);
|
||||
cc = calculateChecksum(msgBuf,sizeof(msg_disHVBBCmd));
|
||||
msg->checkCode = static_cast<cChecksum>(cc & 0xFF);
|
||||
try
|
||||
{
|
||||
sendMsg(msgBuf,sizeof(msg_disHVBBCmd));
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
delete msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udpComm::sendDisSysCmd(const disLowBusCmd cmd)
|
||||
{
|
||||
unsigned char* msgBuf;
|
||||
Checksum cc;
|
||||
msg_disLVBCmd* msg = new msg_disLVBCmd;
|
||||
msg->header.id = DIS_HVBUS_CMD_ID;
|
||||
msg->header.start1 = DIS_MSG_HEAD1;
|
||||
msg->header.start2 = DIS_MSG_HEAD2;
|
||||
msg->header.length = sizeof(disLowBusCmd);
|
||||
msg->data = cmd;
|
||||
msgBuf = reinterpret_cast<unsigned char *>(msg);
|
||||
cc = calculateChecksum(msgBuf,sizeof(msg_disLVBCmd));
|
||||
msg->checkCode = static_cast<cChecksum>(cc & 0xFF);
|
||||
try
|
||||
{
|
||||
sendMsg(msgBuf,sizeof(msg_disLVBCmd));
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
delete msg;
|
||||
return true;
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
#ifndef UDPCOMM__H
|
||||
#define UDPCOMM__H
|
||||
#define UNIX
|
||||
|
||||
#include "ccuUdpMsg.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <string.h>
|
||||
#include "MOOS/libMOOS/Utils/MOOSUtilityFunctions.h"
|
||||
#include "MOOS/libMOOS/Comms/XPCUdpSocket.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <utility> // for std::pair
|
||||
|
||||
@@ -18,6 +22,10 @@ private:
|
||||
public:
|
||||
udpComm();
|
||||
~udpComm();
|
||||
XPCUdpSocket *udpScoket;
|
||||
string ccuHost;
|
||||
long int ccuPort;
|
||||
|
||||
|
||||
bool pushMsgToQueue(unsigned char *m);
|
||||
bool clearMsgQueue();
|
||||
@@ -38,6 +46,13 @@ public:
|
||||
|
||||
bool sendCcuColCmd(const msg_CcuColCmdMsg m);
|
||||
bool sendCcuSetParmCmd(const msg_CcuSetParmMsg m);
|
||||
bool sendDisSysCmd(const disHighVolBusCmd cmd);
|
||||
bool snedDisSysCmd(const disHighAVolBusCmd cmd);
|
||||
bool snedDisSysCmd(const disHighBVolBusCmd cmd);
|
||||
bool sendDisSysCmd(const disLowBusCmd cmd);
|
||||
bool sendMsg(const unsigned char* msg,unsigned int size){
|
||||
udpScoket->iSendMessageTo((void*) msg, size, ccuPort, ccuHost);
|
||||
}
|
||||
|
||||
bool getMsgId(char *m,unsigned short &id);
|
||||
Checksum calculateChecksum(const unsigned char* data, int size);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import socket
|
||||
import struct
|
||||
import tkinter as tk
|
||||
import threading
|
||||
from udpmsg import *
|
||||
from datetime import datetime
|
||||
from tkinter import font
|
||||
from guiEle import ElementDisplayApp
|
||||
from until import *
|
||||
from guiInput import InputGUI
|
||||
|
||||
# 创建UDP套接字
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server_address = ('localhost', 5001)
|
||||
sock.bind(server_address)
|
||||
|
||||
# 创建主窗口
|
||||
root = tk.Tk()
|
||||
root.title("UDP消息显示")
|
||||
eleplay = ElementDisplayApp(root)
|
||||
inp = InputGUI(root)
|
||||
|
||||
# 创建一个文本框用于显示消息
|
||||
custom_font = font.Font(family="Arial", size=12, weight="normal")
|
||||
text_box = tk.Text(root, height=10, width=50, font=custom_font)
|
||||
# .pack(side='left', fill='y', expand=True)
|
||||
text_box.grid(row=0, column=4, sticky='ne')
|
||||
|
||||
# 创建并启动接收和发送消息的线程
|
||||
thread = threading.Thread(target=receive_messages, args=(sock, text_box,eleplay))
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
thread2 = threading.Thread(target=send_messages, args=(sock, eleplay))
|
||||
thread2.daemon = True
|
||||
thread2.start()
|
||||
|
||||
# 运行主循环
|
||||
root.mainloop()
|
||||
|
||||
# 关闭套接字
|
||||
sock.close()
|
||||
@@ -0,0 +1,255 @@
|
||||
import tkinter as tk
|
||||
from tkinter import font
|
||||
from udpmsg import *
|
||||
|
||||
class ElementDisplayApp:
|
||||
def __init__(self, root):
|
||||
self.root = root
|
||||
|
||||
self.disHVB = msg_disHighVolBusFbMsg()
|
||||
self.disHVBA = msg_disHighAVolBusFbMsg()
|
||||
self.disHVBB = msg_disHighBVolBusFbMsg()
|
||||
self.disLVB = msg_disLowBusFbMsg()
|
||||
|
||||
# 定义每组的颜色
|
||||
self.colors = ["#FFC0CB", "#ADD8E6", "#90EE90", "#FFD700"]
|
||||
|
||||
# 创建自定义字体
|
||||
self.custom_font = font.Font(family="Arial", size=12, weight='bold')
|
||||
|
||||
# 创建4个Frame来分组显示元素的值
|
||||
self.frames = []
|
||||
for i in range(4):
|
||||
frame = tk.Frame(self.root, bg=self.colors[i], padx=10, pady=10)
|
||||
# frame.pack(padx=10, pady=10, expand=True, fill='both')
|
||||
frame.grid(row=0, column=i, sticky='nsew') # 使用 grid 布局管理器
|
||||
self.frames.append(frame)
|
||||
|
||||
# 定义四个字典来存储元素的值
|
||||
# self.dict1 = {f"元素{i+1}": f"Value {i+1}" for i in range(16)}
|
||||
self.dict1={'燃料电池断路器':'闭合','动力锂电池断路器':'闭合','推进电机断路器':'闭合','仪表锂电池断路器':'闭合','DC/DC5模块断路器':'闭合',
|
||||
'艏部高压配电断路器':'闭合','艏部FT4/5断路器':'闭合','艉舵1/2断路器':'闭合','艉舵3/4断路器':'闭合',
|
||||
'FB预留断路器':'闭合','TYZ预留断路器':'闭合','预留断路器':'闭合'}
|
||||
# self.dict2 = {f"元素{i+17}": f"Value {i+17}" for i in range(16)}
|
||||
self.dict2 = {'艏部FT1-3断路器':'闭合','启闭机构断路器':'闭合','桅杆舵机断路器':'闭合','XCZ断路器':'闭合',
|
||||
'艏舵断路器':'闭合','敞开电缸断路器':'闭合'}
|
||||
# self.dict3 = {f"元素{i+33}": f"Value {i+33}" for i in range(16)}
|
||||
self.dict3 = {'仪表锂电池断路器':'闭合','艏部低压断路器':'闭合','UNIT4断路器':'闭合','DC/DC1断路器':'闭合',
|
||||
'预留断路器1':'闭合', '预留断路器2':'闭合','艉部应急电池开关':'闭合'}
|
||||
# self.dict4 = {f"元素{i+49}": f"Value {i+49}" for i in range(16)}
|
||||
self.dict4 = {'UNIT1断路器':'闭合','UNIT2断路器':'闭合','UNIT3断路器':'闭合','UNIT5断路器':'闭合','艏部抛载断路器':'闭合',
|
||||
'预留断路器1':'闭合','预留断路器2':'断开','艏部应急电池开关':'闭合'}
|
||||
|
||||
# 创建Label来显示每个字典中的元素值,并应用自定义字体
|
||||
self.labels = []
|
||||
for i, dictionary in enumerate([self.dict1, self.dict2, self.dict3, self.dict4]):
|
||||
for j, (key, value) in enumerate(dictionary.items()):
|
||||
# 根据元素的值选择颜色
|
||||
if value == "闭合":
|
||||
color = "green"
|
||||
else:
|
||||
color = "red"
|
||||
label = tk.Label(self.frames[i], text=f"{key}: {value}", fg=color, font=self.custom_font, anchor="w")
|
||||
label.grid(row=j//2, column=j%2, padx=5, pady=5)
|
||||
# self.labels.append(label)
|
||||
|
||||
def update_disp(self):
|
||||
# 更新Label的文本
|
||||
for i, dictionary in enumerate([self.dict1, self.dict2, self.dict3, self.dict4]):
|
||||
for j, (key, value) in enumerate(dictionary.items()):
|
||||
# 根据元素的值选择颜色
|
||||
if value == "闭合":
|
||||
color = "green"
|
||||
else:
|
||||
color = "red"
|
||||
# self.labels[i + j].config(text=f"{key}: {value}", fg=color, font=self.custom_font, anchor="w")
|
||||
label = tk.Label(self.frames[i], text=f"{key}: {value}", fg=color, font=self.custom_font, anchor="w")
|
||||
label.grid(row=j//2, column=j%2, padx=5, pady=5)
|
||||
|
||||
def updata_data(self):
|
||||
if (self.dict1['燃料电池断路器']=='闭合'):
|
||||
self.disHVB.DCB1 = 0x55
|
||||
else:
|
||||
self.disHVB.DCB1 = 0xAA
|
||||
|
||||
if (self.dict1['动力锂电池断路器']=='闭合'):
|
||||
self.disHVB.DCB2 = 0x55
|
||||
else:
|
||||
self.disHVB.DCB2 = 0xAA
|
||||
|
||||
if (self.dict1['推进电机断路器']=='闭合'):
|
||||
self.disHVB.ZK1 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK1 = 0xAA
|
||||
|
||||
if (self.dict1['仪表锂电池断路器']=='闭合'):
|
||||
self.disHVB.ZK2 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK2 = 0xAA
|
||||
|
||||
if (self.dict1['DC/DC5模块断路器']=='闭合'):
|
||||
self.disHVB.ZK3 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK3 = 0xAA
|
||||
|
||||
if (self.dict1['艏部高压配电断路器']=='闭合'):
|
||||
self.disHVB.ZK4 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK4 = 0xAA
|
||||
|
||||
if (self.dict1['艏部FT4/5断路器']=='闭合'):
|
||||
self.disHVB.ZK5 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK5 = 0xAA
|
||||
|
||||
if (self.dict1['艉舵1/2断路器']=='闭合'):
|
||||
self.disHVB.ZK6 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK6 = 0xAA
|
||||
|
||||
if (self.dict1['艉舵3/4断路器']=='闭合'):
|
||||
self.disHVB.ZK7 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK7 = 0xAA
|
||||
|
||||
if (self.dict1['FB预留断路器']=='闭合'):
|
||||
self.disHVB.ZK8 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK8 = 0xAA
|
||||
|
||||
if (self.dict1['TYZ预留断路器']=='闭合'):
|
||||
self.disHVB.ZK9 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK9 = 0xAA
|
||||
|
||||
if (self.dict1['预留断路器']=='闭合'):
|
||||
self.disHVB.ZK10 = 0x55
|
||||
else:
|
||||
self.disHVB.ZK10 = 0xAA
|
||||
######################################################
|
||||
if (self.dict2['艏部FT1-3断路器']=='闭合'):
|
||||
self.disHVBA.bowFTDevice123CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBA.bowFTDevice123CircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict2['启闭机构断路器']=='闭合'):
|
||||
self.disHVBA.actuatorCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBA.actuatorCircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict2['桅杆舵机断路器']=='闭合'):
|
||||
self.disHVBA.mastSteeringGearControlBoxCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBA.mastSteeringGearControlBoxCircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict2['XCZ断路器']=='闭合'):
|
||||
self.disHVBA.xczCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBA.xczCircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict2['艏舵断路器']=='闭合'):
|
||||
self.disHVBA.bowRudderControlBoxCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBA.bowRudderControlBoxCircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict2['敞开电缸断路器']=='闭合'):
|
||||
self.disHVBA.openWaterCoverStartCylinderCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBA.openWaterCoverStartCylinderCircuitBreaker = 0xAA
|
||||
|
||||
####################################################################
|
||||
if (self.dict3['仪表锂电池断路器']=='闭合'):
|
||||
self.disHVBB.lithiumBatteryGroupInstrumentCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBB.lithiumBatteryGroupInstrumentCircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict3['艏部低压断路器']=='闭合'):
|
||||
self.disHVBB.bowLowVoltageDistributionCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBB.bowLowVoltageDistributionCircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict3['UNIT4断路器']=='闭合'):
|
||||
self.disHVBB.unit4CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBB.unit4CircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict3['DC/DC1断路器']=='闭合'):
|
||||
self.disHVBB.dcdc1CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBB.dcdc1CircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict3['预留断路器1']=='闭合'):
|
||||
self.disHVBB.reservedCircuitBreaker1 = 0x55
|
||||
else:
|
||||
self.disHVBB.reservedCircuitBreaker1 = 0xAA
|
||||
|
||||
if (self.dict3['预留断路器2']=='闭合'):
|
||||
self.disHVBB.reservedCircuitBreaker2 = 0x55
|
||||
else:
|
||||
self.disHVBB.reservedCircuitBreaker2 = 0xAA
|
||||
|
||||
if (self.dict3['艉部应急电池开关']=='闭合'):
|
||||
self.disHVBB.emergencyLithiumBatteryGroup2CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disHVBB.emergencyLithiumBatteryGroup2CircuitBreaker = 0xAA
|
||||
|
||||
######################################################################
|
||||
if (self.dict4['UNIT1断路器']=='闭合'):
|
||||
self.disLVB.unit1CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disLVB.unit1CircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict4['UNIT2断路器']=='闭合'):
|
||||
self.disLVB.unit2CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disLVB.unit2CircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict4['UNIT3断路器']=='闭合'):
|
||||
self.disLVB.unit3CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disLVB.unit3CircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict4['UNIT5断路器']=='闭合'):
|
||||
self.disLVB.unit5CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disLVB.unit5CircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict4['预留断路器1']=='闭合'):
|
||||
self.disLVB.reservedCircuitBreaker1 = 0x55
|
||||
else:
|
||||
self.disLVB.reservedCircuitBreaker1 = 0xAA
|
||||
|
||||
if (self.dict4['预留断路器2']=='闭合'):
|
||||
self.disLVB.reservedCircuitBreaker2 = 0x55
|
||||
else:
|
||||
self.disLVB.reservedCircuitBreaker2 = 0xAA
|
||||
|
||||
if (self.dict4['艏部抛载断路器']=='闭合'):
|
||||
self.disLVB.bowPZDeviceCircuitBreaker = 0x55
|
||||
else:
|
||||
self.disLVB.bowPZDeviceCircuitBreaker = 0xAA
|
||||
|
||||
if (self.dict4['艏部应急电池开关']=='闭合'):
|
||||
self.disLVB.emergencyLithiumBatteryGroup1CircuitBreaker = 0x55
|
||||
else:
|
||||
self.disLVB.emergencyLithiumBatteryGroup1CircuitBreaker = 0xAA
|
||||
|
||||
a = self.disHVB.pack()
|
||||
b = self.disHVBA.pack()
|
||||
c = self.disHVBB.pack()
|
||||
d = self.disLVB.pack()
|
||||
return a,b,c,d
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = tk.Tk()
|
||||
app = ElementDisplayApp(root)
|
||||
root.mainloop()
|
||||
|
||||
# # 创建主窗口
|
||||
# root = tk.Tk()
|
||||
|
||||
# # 创建应用实例并在root中显示
|
||||
# app = ElementDisplayApp(root)
|
||||
|
||||
# # 运行主循环
|
||||
# root.mainloop()
|
||||
@@ -0,0 +1,121 @@
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
from udpmsg import msg_CcuStateFbMsg
|
||||
|
||||
class msg_CcuStateFbMsg:
|
||||
def __init__(self):
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0001
|
||||
self.length = 0x0000
|
||||
self.flag = 0x00
|
||||
self.failvreCode = 0x00
|
||||
|
||||
def pack(self):
|
||||
# 初始化数据
|
||||
pass # function body is omitted
|
||||
|
||||
class InputGUI:
|
||||
def __init__(self, master):
|
||||
self.master = master
|
||||
self.printing = False
|
||||
self.msg_instance = msg_CcuStateFbMsg()
|
||||
|
||||
# 创建一个Frame来包含所有的输入框和标签
|
||||
row = 0
|
||||
column = 0
|
||||
|
||||
self.input_frame = tk.Frame(master, bg='lightgray')
|
||||
self.input_frame.grid(row=1, column=0, sticky='nsew')
|
||||
|
||||
self.title_label = tk.Label(self.input_frame, text="复合管控消息交互", font=("Arial", 16, "bold"))
|
||||
self.title_label.grid(row=0, column=0, columnspan=2, pady=(10, 20), sticky="nsew") # 调整标题的上下边距并居中显示
|
||||
|
||||
# 创建输入框和标签
|
||||
self.start1_label = tk.Label(self.input_frame, text="Start1:")
|
||||
self.start1_label.grid(row=1, column=0)
|
||||
self.start1_entry = tk.Entry(self.input_frame)
|
||||
self.start1_entry.grid(row=1, column=1)
|
||||
|
||||
self.start2_label = tk.Label(self.input_frame, text="Start2:")
|
||||
self.start2_label.grid(row=2, column=0)
|
||||
self.start2_entry = tk.Entry(self.input_frame)
|
||||
self.start2_entry.grid(row=2, column=1)
|
||||
|
||||
self.id_label = tk.Label(self.input_frame, text="ID:")
|
||||
self.id_label.grid(row=3, column=0)
|
||||
self.id_entry = tk.Entry(self.input_frame)
|
||||
self.id_entry.grid(row=3, column=1)
|
||||
|
||||
self.length_label = tk.Label(self.input_frame, text="Length:")
|
||||
self.length_label.grid(row=4, column=0)
|
||||
self.length_entry = tk.Entry(self.input_frame)
|
||||
self.length_entry.grid(row=4, column=1)
|
||||
|
||||
self.flag_label = tk.Label(self.input_frame, text="Flag:")
|
||||
self.flag_label.grid(row=5, column=0)
|
||||
self.flag_entry = tk.Entry(self.input_frame)
|
||||
self.flag_entry.grid(row=5, column=1)
|
||||
|
||||
self.failvreCode_label = tk.Label(self.input_frame, text="Failvre Code:")
|
||||
self.failvreCode_label.grid(row=6, column=0)
|
||||
self.failvreCode_entry = tk.Entry(self.input_frame)
|
||||
self.failvreCode_entry.grid(row=6, column=1)
|
||||
|
||||
# 创建更新按钮
|
||||
self.update_button = tk.Button(self.input_frame, text="Update", command=self.update_msg)
|
||||
self.update_button.grid(row=7, column=0, columnspan=2)
|
||||
|
||||
# 创建打印按钮
|
||||
self.print_button = tk.Button(self.input_frame, text="Print", command=self.start_printing)
|
||||
self.print_button.grid(row=8, column=0)
|
||||
|
||||
# 创建停止打印按钮
|
||||
self.stop_button = tk.Button(self.input_frame, text="Stop", command=self.stop_printing, state=tk.DISABLED)
|
||||
self.stop_button.grid(row=8, column=1)
|
||||
|
||||
# 创建显示打印消息数量的标签
|
||||
self.print_count_label = tk.Label(self.input_frame, text="Print Count: 0", font=("Arial", 12))
|
||||
self.print_count_label.grid(row=9, column=0, columnspan=2)
|
||||
# 创建更新按钮
|
||||
self.update_button = tk.Button(self.input_frame, text="Update", command=self.update_msg)
|
||||
self.update_button.grid(row=7, column=0, columnspan=2)
|
||||
|
||||
def update_msg(self):
|
||||
try:
|
||||
self.msg_instance.start1 = int(self.start1_entry.get(), 16)
|
||||
self.msg_instance.start2 = int(self.start2_entry.get(), 16)
|
||||
self.msg_instance.id = int(self.id_entry.get(), 16)
|
||||
self.msg_instance.length = int(self.length_entry.get(), 16)
|
||||
self.msg_instance.flag = int(self.flag_entry.get(), 16)
|
||||
self.msg_instance.failvreCode = int(self.failvreCode_entry.get(), 16)
|
||||
messagebox.showinfo("Success", "msg_CcuStateFbMsg updated successfully!")
|
||||
except ValueError:
|
||||
messagebox.showerror("Error", "Invalid input. Please enter valid hexadecimal values.")
|
||||
|
||||
def start_printing(self):
|
||||
self.printing = True
|
||||
self.print_count = 0
|
||||
self.print_count_label.config(text="Print Count: 0")
|
||||
self.print_button.config(state=tk.DISABLED)
|
||||
self.stop_button.config(state=tk.NORMAL)
|
||||
self.print_message()
|
||||
|
||||
def stop_printing(self):
|
||||
self.printing = False
|
||||
self.print_button.config(state=tk.NORMAL)
|
||||
self.stop_button.config(state=tk.DISABLED)
|
||||
|
||||
def print_message(self, callback=None):
|
||||
if self.printing:
|
||||
print("Printing message...")
|
||||
self.print_count += 1
|
||||
self.print_count_label.config(text=f"Print Count: {self.print_count}")
|
||||
if callback:
|
||||
callback()
|
||||
self.master.after(1000, self.print_message, callback) # 每秒打印一次
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = tk.Tk()
|
||||
gui = InputGUI(root)
|
||||
root.mainloop()
|
||||
@@ -20,6 +20,8 @@ print(valid_msg)
|
||||
|
||||
# 创建UDP套接字
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server_address = ('localhost', 5001)
|
||||
sock.bind(server_address)
|
||||
|
||||
# 要发送的信息
|
||||
# message = "Hello, this is a test message."
|
||||
|
||||
@@ -482,6 +482,48 @@ class msg_disLowBusFbMsg:
|
||||
data += struct.pack('<B', checkCode_L)
|
||||
return data
|
||||
|
||||
class msg_disHVBCmd:
|
||||
def __init__(self):
|
||||
self.start1 = None
|
||||
self.start2 = None
|
||||
self.id = None
|
||||
self.length = None
|
||||
self.fuelCellCircuitBreaker = None
|
||||
self.powerLithiumBatteryCircuitBreaker = None
|
||||
self.propulsionMotorCircuitBreaker = None
|
||||
self.lithiumBatteryGroupInstrumentCircuitBreaker = None
|
||||
self.dcDc5ModuleCircuitBreaker = None
|
||||
self.bowHighVoltageDistributionBoxCircuitBreaker = None
|
||||
self.sternFTDevice45CircuitBreaker = None
|
||||
self.sternRudderSwitch1CircuitBreaker = None
|
||||
self.sternRudderSwitch2CircuitBreaker = None
|
||||
self.fbReservedCircuitBreaker = None
|
||||
self.tyzReservedCircuitBreaker = None
|
||||
self.reservedCircuitBreaker = None
|
||||
self.checkCode = None
|
||||
|
||||
def unpack(self,data):
|
||||
try:
|
||||
unpacked_data = struct.unpack('<BBHHBBBBBBBBBBBBB',data)
|
||||
self.start1 = unpacked_data[0]
|
||||
self.start2 = unpacked_data[1]
|
||||
self.id = unpacked_data[2]
|
||||
self.length = unpacked_data[3]
|
||||
self.fuelCellCircuitBreaker = unpacked_data[4]
|
||||
self.powerLithiumBatteryCircuitBreaker = unpacked_data[5]
|
||||
self.propulsionMotorCircuitBreaker = unpacked_data[6]
|
||||
self.lithiumBatteryGroupInstrumentCircuitBreaker = unpacked_data[7]
|
||||
self.dcDc5ModuleCircuitBreaker = unpacked_data[8]
|
||||
self.bowHighVoltageDistributionBoxCircuitBreaker = unpacked_data[9]
|
||||
self.sternFTDevice45CircuitBreaker = unpacked_data[10]
|
||||
self.sternRudderSwitch1CircuitBreaker = unpacked_data[11]
|
||||
self.sternRudderSwitch2CircuitBreaker = unpacked_data[12]
|
||||
self.fbReservedCircuitBreaker = unpacked_data[13]
|
||||
self.tyzReservedCircuitBreaker = unpacked_data[14]
|
||||
self.reservedCircuitBreaker = unpacked_data[15]
|
||||
self.checkCode = unpacked_data[16]
|
||||
except struct.error as e:
|
||||
print(f"Error unpacking data: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
msg = msg_CcuStateFbMsg()
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import socket
|
||||
import struct
|
||||
import tkinter as tk
|
||||
import threading
|
||||
from udpmsg import *
|
||||
from datetime import datetime
|
||||
from tkinter import font
|
||||
from guiEle import ElementDisplayApp
|
||||
import threading
|
||||
|
||||
target_ip = '127.0.0.1'
|
||||
target_port = 5000
|
||||
|
||||
def receive_messages(sock, text_box,eleplay:ElementDisplayApp):
|
||||
while True:
|
||||
current_time = datetime.now()
|
||||
formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
data, address = sock.recvfrom(4096)
|
||||
headBuf = data[:6]
|
||||
header = struct.unpack('<BBHH',headBuf)
|
||||
start1 = data[0]
|
||||
start2 = data[1]
|
||||
msg_id = data[2]
|
||||
msg_len = data[3]
|
||||
if(start1==0x40 and start2==0x40):
|
||||
if(msg_id==0x0001):
|
||||
msg = msg_disHVBCmd()
|
||||
msg.unpack(data)
|
||||
text_box.insert(tk.END, f"{formatted_time}->接收到来自 {address} | 高压母线配电指令:\n")
|
||||
if(msg.fuelCellCircuitBreaker==0x55):
|
||||
eleplay.dict1['燃料电池断路器']='闭合'
|
||||
elif(msg.fuelCellCircuitBreaker==0xAA):
|
||||
eleplay.dict1['燃料电池断路器']='断开'
|
||||
|
||||
if(msg.powerLithiumBatteryCircuitBreaker==0x55):
|
||||
eleplay.dict1['动力锂电池断路器']='闭合'
|
||||
elif(msg.powerLithiumBatteryCircuitBreaker==0xAA):
|
||||
eleplay.dict1['动力锂电池断路器']='断开'
|
||||
|
||||
if(msg.propulsionMotorCircuitBreaker==0x55):
|
||||
eleplay.dict1['推进电机断路器']='闭合'
|
||||
elif(msg.propulsionMotorCircuitBreaker==0xAA):
|
||||
eleplay.dict1['推进电机断路器']='断开'
|
||||
|
||||
if(msg.lithiumBatteryGroupInstrumentCircuitBreaker==0x55):
|
||||
eleplay.dict1['仪表锂电池断路器']='闭合'
|
||||
elif(msg.lithiumBatteryGroupInstrumentCircuitBreaker==0xAA):
|
||||
eleplay.dict1['仪表锂电池断路器']='断开'
|
||||
|
||||
if(msg.dcDc5ModuleCircuitBreaker==0x55):
|
||||
eleplay.dict1['DC/DC5模块断路器']='闭合'
|
||||
elif(msg.dcDc5ModuleCircuitBreaker==0xAA):
|
||||
eleplay.dict1['DC/DC5模块断路器']='断开'
|
||||
|
||||
if(msg.bowHighVoltageDistributionBoxCircuitBreaker==0x55):
|
||||
eleplay.dict1['艏部高压配电断路器']='闭合'
|
||||
elif(msg.bowHighVoltageDistributionBoxCircuitBreaker==0xAA):
|
||||
eleplay.dict1['艏部高压配电断路器']='断开'
|
||||
|
||||
if(msg.sternFTDevice45CircuitBreaker==0x55):
|
||||
eleplay.dict1['艏部FT4/5断路器']='闭合'
|
||||
elif(msg.sternFTDevice45CircuitBreaker==0xAA):
|
||||
eleplay.dict1['艏部FT4/5断路器']='断开'
|
||||
|
||||
if(msg.sternRudderSwitch1CircuitBreaker==0x55):
|
||||
eleplay.dict1['艉舵1/2断路器']='闭合'
|
||||
elif(msg.sternRudderSwitch1CircuitBreaker==0xAA):
|
||||
eleplay.dict1['艉舵1/2断路器']='断开'
|
||||
|
||||
if(msg.sternRudderSwitch2CircuitBreaker==0x55):
|
||||
eleplay.dict1['艉舵3/4断路器']='闭合'
|
||||
elif(msg.sternRudderSwitch2CircuitBreaker==0xAA):
|
||||
eleplay.dict1['艉舵3/4断路器']='断开'
|
||||
|
||||
if(msg.fbReservedCircuitBreaker==0x55):
|
||||
eleplay.dict1['FB预留断路器']='闭合'
|
||||
elif(msg.fbReservedCircuitBreaker==0xAA):
|
||||
eleplay.dict1['FB预留断路器']='断开'
|
||||
|
||||
if(msg.tyzReservedCircuitBreaker==0x55):
|
||||
eleplay.dict1['TYZ预留断路器']='闭合'
|
||||
elif(msg.tyzReservedCircuitBreaker==0xAA):
|
||||
eleplay.dict1['TYZ预留断路器']='断开'
|
||||
|
||||
if(msg.reservedCircuitBreaker==0x55):
|
||||
eleplay.dict1['预留断路器']='闭合'
|
||||
elif(msg.reservedCircuitBreaker==0xAA):
|
||||
eleplay.dict1['预留断路器']='断开'
|
||||
eleplay.update_disp()
|
||||
text_box.see(tk.END)
|
||||
|
||||
|
||||
def send_messages(sock, eleplay:ElementDisplayApp):
|
||||
while True:
|
||||
# 配电消息反馈
|
||||
a,b,c,d = eleplay.updata_data()
|
||||
sock.sendto(a, (target_ip, target_port))
|
||||
sock.sendto(b, (target_ip, target_port))
|
||||
sock.sendto(c, (target_ip, target_port))
|
||||
sock.sendto(d, (target_ip, target_port))
|
||||
|
||||
#TODO复合管控消息反馈
|
||||
|
||||
|
||||
threading.Event().wait(1) # 每隔1秒发送一次消息
|
||||
Reference in New Issue
Block a user