diff --git a/scripts/GenMOOSApp b/scripts/GenMOOSApp new file mode 100755 index 0000000..6b62d1f --- /dev/null +++ b/scripts/GenMOOSApp @@ -0,0 +1,401 @@ +#!/bin/bash + +if [ -d "$2$1" ]; then + echo "$2$1 already exists... quitting." + exit 1 +fi + +if [ -z "$1" ] ; then + echo "GenMOOSApp: usage: $0 [app-name] [prefix]" + exit 0 +fi + +if [ -z "$2" ] ; then + echo "GenMOOSApp: usage: $0 [app-name] [prefix]" + exit 0 +fi + +#if [ -z "$3" ] ; then +# $3="YOUR-NAME-HERE" +#fi + +mkdir $2$1 +cd $2$1 + +cat > CMakeLists.txt < ${1}.h < main.cpp < +#include "MBUtils.h" +#include "ColorParse.h" +#include "${1}.h" +#include "${1}_Info.h" + +using namespace std; + +int main(int argc, char *argv[]) +{ + string mission_file; + string run_command = argv[0]; + + for(int i=1; i $2${1}.moos < ${1}.cpp < +#include "MBUtils.h" +#include "${1}.h" + +using namespace std; + +//--------------------------------------------------------- +// Constructor + +${1}::${1}() +{ +} + +//--------------------------------------------------------- +// Destructor + +${1}::~${1}() +{ +} + +//--------------------------------------------------------- +// Procedure: OnNewMail + +bool ${1}::OnNewMail(MOOSMSG_LIST &NewMail) +{ + MOOSMSG_LIST::iterator p; + + for(p=NewMail.begin(); p!=NewMail.end(); p++) { + CMOOSMsg &msg = *p; + +#if 0 // Keep these around just for template + string key = msg.GetKey(); + string comm = msg.GetCommunity(); + double dval = msg.GetDouble(); + string sval = msg.GetString(); + string msrc = msg.GetSource(); + double mtime = msg.GetTime(); + bool mdbl = msg.IsDouble(); + bool mstr = msg.IsString(); +#endif + } + + return(true); +} + +//--------------------------------------------------------- +// Procedure: OnConnectToServer + +bool ${1}::OnConnectToServer() +{ + RegisterVariables(); + return(true); +} + +//--------------------------------------------------------- +// Procedure: Iterate() +// happens AppTick times per second + +bool ${1}::Iterate() +{ + return(true); +} + +//--------------------------------------------------------- +// Procedure: OnStartUp() +// happens before connection is open + +bool ${1}::OnStartUp() +{ + list sParams; + m_MissionReader.EnableVerbatimQuoting(false); + if(m_MissionReader.GetConfiguration(GetAppName(), sParams)) { + list::iterator p; + for(p=sParams.begin(); p!=sParams.end(); p++) { + string line = *p; + string param = tolower(biteStringX(line, '=')); + string value = line; + + if(param == "foo") { + //handled + } + else if(param == "bar") { + //handled + } + } + } + + RegisterVariables(); + return(true); +} + +//--------------------------------------------------------- +// Procedure: RegisterVariables + +void ${1}::RegisterVariables() +{ + // Register("FOOBAR", 0); +} + +EOF + + +cat > ${1}_Info.h < ${1}_Info.cpp < +#include +#include "${1}_Info.h" +#include "ColorParse.h" +#include "ReleaseInfo.h" + +using namespace std; + +//---------------------------------------------------------------- +// Procedure: showSynopsis + +void showSynopsis() +{ + blk("SYNOPSIS: "); + blk("------------------------------------ "); + blk(" The ${2}${1} application is used for "); + blk(" "); + blk(" "); + blk(" "); + blk(" "); +} + +//---------------------------------------------------------------- +// Procedure: showHelpAndExit + +void showHelpAndExit() +{ + blk(" "); + blu("=============================================================== "); + blu("Usage: ${2}${1} file.moos [OPTIONS] "); + blu("=============================================================== "); + blk(" "); + showSynopsis(); + blk(" "); + blk("Options: "); + mag(" --alias","= "); + blk(" Launch ${2}${1} with the given process name "); + blk(" rather than ${2}${1}. "); + mag(" --example, -e "); + blk(" Display example MOOS configuration block. "); + mag(" --help, -h "); + blk(" Display this help message. "); + mag(" --interface, -i "); + blk(" Display MOOS publications and subscriptions. "); + mag(" --version,-v "); + blk(" Display the release version of ${2}${1}. "); + blk(" "); + blk("Note: If argv[2] does not otherwise match a known option, "); + blk(" then it will be interpreted as a run alias. This is "); + blk(" to support pAntler launching conventions. "); + blk(" "); + exit(0); +} + +//---------------------------------------------------------------- +// Procedure: showExampleConfigAndExit + +void showExampleConfigAndExit() +{ + blk(" "); + blu("=============================================================== "); + blu("${2}${1} Example MOOS Configuration "); + blu("=============================================================== "); + blk(" "); + blk("ProcessConfig = ${2}${1} "); + blk("{ "); + blk(" AppTick = 4 "); + blk(" CommsTick = 4 "); + blk(" "); + blk("} "); + blk(" "); + exit(0); +} + + +//---------------------------------------------------------------- +// Procedure: showInterfaceAndExit + +void showInterfaceAndExit() +{ + blk(" "); + blu("=============================================================== "); + blu("${2}${1} INTERFACE "); + blu("=============================================================== "); + blk(" "); + showSynopsis(); + blk(" "); + blk("SUBSCRIPTIONS: "); + blk("------------------------------------ "); + blk(" NODE_MESSAGE = src_node=alpha,dest_node=bravo,var_name=FOO, "); + blk(" string_val=BAR "); + blk(" "); + blk("PUBLICATIONS: "); + blk("------------------------------------ "); + blk(" Publications are determined by the node message content. "); + blk(" "); + exit(0); +} + +//---------------------------------------------------------------- +// Procedure: showReleaseInfoAndExit + +void showReleaseInfoAndExit() +{ + showReleaseInfo("${2}${1}", "gpl"); + exit(0); +} + +EOF + + +echo "$2${1} generated" diff --git a/src/appPowerMangerGui/CMakeLists.txt b/src/appPowerMangerGui/CMakeLists.txt new file mode 100644 index 0000000..f524141 --- /dev/null +++ b/src/appPowerMangerGui/CMakeLists.txt @@ -0,0 +1,19 @@ +#-------------------------------------------------------- +# The CMakeLists.txt for: appPowerMangerGui +# Author(s): +#-------------------------------------------------------- + +SET(SRC + PowerMangerGui.cpp + PowerMangerGui_Info.cpp + main.cpp +) + +ADD_EXECUTABLE(appPowerMangerGui ${SRC}) + +TARGET_LINK_LIBRARIES(appPowerMangerGui + ${MOOS_LIBRARIES} + mbutil + m + pthread) + diff --git a/src/appPowerMangerGui/PowerMangerGui.cpp b/src/appPowerMangerGui/PowerMangerGui.cpp new file mode 100644 index 0000000..c22d29a --- /dev/null +++ b/src/appPowerMangerGui/PowerMangerGui.cpp @@ -0,0 +1,106 @@ +/************************************************************/ +/* NAME: */ +/* ORGN: MIT */ +/* FILE: PowerMangerGui.cpp */ +/* DATE: */ +/************************************************************/ + +#include +#include "MBUtils.h" +#include "PowerMangerGui.h" + +using namespace std; + +//--------------------------------------------------------- +// Constructor + +PowerMangerGui::PowerMangerGui() +{ +} + +//--------------------------------------------------------- +// Destructor + +PowerMangerGui::~PowerMangerGui() +{ +} + +//--------------------------------------------------------- +// Procedure: OnNewMail + +bool PowerMangerGui::OnNewMail(MOOSMSG_LIST &NewMail) +{ + MOOSMSG_LIST::iterator p; + + for(p=NewMail.begin(); p!=NewMail.end(); p++) { + CMOOSMsg &msg = *p; + +#if 0 // Keep these around just for template + string key = msg.GetKey(); + string comm = msg.GetCommunity(); + double dval = msg.GetDouble(); + string sval = msg.GetString(); + string msrc = msg.GetSource(); + double mtime = msg.GetTime(); + bool mdbl = msg.IsDouble(); + bool mstr = msg.IsString(); +#endif + } + + return(true); +} + +//--------------------------------------------------------- +// Procedure: OnConnectToServer + +bool PowerMangerGui::OnConnectToServer() +{ + RegisterVariables(); + return(true); +} + +//--------------------------------------------------------- +// Procedure: Iterate() +// happens AppTick times per second + +bool PowerMangerGui::Iterate() +{ + return(true); +} + +//--------------------------------------------------------- +// Procedure: OnStartUp() +// happens before connection is open + +bool PowerMangerGui::OnStartUp() +{ + list sParams; + m_MissionReader.EnableVerbatimQuoting(false); + if(m_MissionReader.GetConfiguration(GetAppName(), sParams)) { + list::iterator p; + for(p=sParams.begin(); p!=sParams.end(); p++) { + string line = *p; + string param = tolower(biteStringX(line, '=')); + string value = line; + + if(param == "foo") { + //handled + } + else if(param == "bar") { + //handled + } + } + } + + RegisterVariables(); + return(true); +} + +//--------------------------------------------------------- +// Procedure: RegisterVariables + +void PowerMangerGui::RegisterVariables() +{ + // Register("FOOBAR", 0); +} + diff --git a/src/appPowerMangerGui/PowerMangerGui.h b/src/appPowerMangerGui/PowerMangerGui.h new file mode 100644 index 0000000..9e4a53d --- /dev/null +++ b/src/appPowerMangerGui/PowerMangerGui.h @@ -0,0 +1,33 @@ +/************************************************************/ +/* NAME: */ +/* ORGN: MIT */ +/* FILE: PowerMangerGui.h */ +/* DATE: */ +/************************************************************/ + +#ifndef PowerMangerGui_HEADER +#define PowerMangerGui_HEADER + +#include "FL/Fl.H" +#include "MOOS/libMOOS/MOOSLib.h" + +class PowerMangerGui : public CMOOSApp { +public: + PowerMangerGui(); + ~PowerMangerGui(); + bool minWindows(); + +protected: // Standard MOOSApp functions to overload + bool OnNewMail(MOOSMSG_LIST &NewMail); + bool Iterate(); + bool OnConnectToServer(); + bool OnStartUp(); + +protected: + void RegisterVariables(); + +private: // Configuration variables +private: // State variables +}; + +#endif diff --git a/src/appPowerMangerGui/PowerMangerGui_Info.cpp b/src/appPowerMangerGui/PowerMangerGui_Info.cpp new file mode 100644 index 0000000..f834c52 --- /dev/null +++ b/src/appPowerMangerGui/PowerMangerGui_Info.cpp @@ -0,0 +1,115 @@ +/****************************************************************/ +/* NAME: */ +/* ORGN: MIT Cambridge MA */ +/* FILE: PowerMangerGui_Info.cpp */ +/* DATE: Dec 29th 1963 */ +/****************************************************************/ + +#include +#include +#include "PowerMangerGui_Info.h" +#include "ColorParse.h" +#include "ReleaseInfo.h" + +using namespace std; + +//---------------------------------------------------------------- +// Procedure: showSynopsis + +void showSynopsis() +{ + blk("SYNOPSIS: "); + blk("------------------------------------ "); + blk(" The appPowerMangerGui application is used for "); + blk(" "); + blk(" "); + blk(" "); + blk(" "); +} + +//---------------------------------------------------------------- +// Procedure: showHelpAndExit + +void showHelpAndExit() +{ + blk(" "); + blu("=============================================================== "); + blu("Usage: appPowerMangerGui file.moos [OPTIONS] "); + blu("=============================================================== "); + blk(" "); + showSynopsis(); + blk(" "); + blk("Options: "); + mag(" --alias","= "); + blk(" Launch appPowerMangerGui with the given process name "); + blk(" rather than appPowerMangerGui. "); + mag(" --example, -e "); + blk(" Display example MOOS configuration block. "); + mag(" --help, -h "); + blk(" Display this help message. "); + mag(" --interface, -i "); + blk(" Display MOOS publications and subscriptions. "); + mag(" --version,-v "); + blk(" Display the release version of appPowerMangerGui. "); + blk(" "); + blk("Note: If argv[2] does not otherwise match a known option, "); + blk(" then it will be interpreted as a run alias. This is "); + blk(" to support pAntler launching conventions. "); + blk(" "); + exit(0); +} + +//---------------------------------------------------------------- +// Procedure: showExampleConfigAndExit + +void showExampleConfigAndExit() +{ + blk(" "); + blu("=============================================================== "); + blu("appPowerMangerGui Example MOOS Configuration "); + blu("=============================================================== "); + blk(" "); + blk("ProcessConfig = appPowerMangerGui "); + blk("{ "); + blk(" AppTick = 4 "); + blk(" CommsTick = 4 "); + blk(" "); + blk("} "); + blk(" "); + exit(0); +} + + +//---------------------------------------------------------------- +// Procedure: showInterfaceAndExit + +void showInterfaceAndExit() +{ + blk(" "); + blu("=============================================================== "); + blu("appPowerMangerGui INTERFACE "); + blu("=============================================================== "); + blk(" "); + showSynopsis(); + blk(" "); + blk("SUBSCRIPTIONS: "); + blk("------------------------------------ "); + blk(" NODE_MESSAGE = src_node=alpha,dest_node=bravo,var_name=FOO, "); + blk(" string_val=BAR "); + blk(" "); + blk("PUBLICATIONS: "); + blk("------------------------------------ "); + blk(" Publications are determined by the node message content. "); + blk(" "); + exit(0); +} + +//---------------------------------------------------------------- +// Procedure: showReleaseInfoAndExit + +void showReleaseInfoAndExit() +{ + showReleaseInfo("appPowerMangerGui", "gpl"); + exit(0); +} + diff --git a/src/appPowerMangerGui/PowerMangerGui_Info.h b/src/appPowerMangerGui/PowerMangerGui_Info.h new file mode 100644 index 0000000..64a4576 --- /dev/null +++ b/src/appPowerMangerGui/PowerMangerGui_Info.h @@ -0,0 +1,18 @@ +/****************************************************************/ +/* NAME: */ +/* ORGN: MIT Cambridge MA */ +/* FILE: PowerMangerGui_Info.h */ +/* DATE: Dec 29th 1963 */ +/****************************************************************/ + +#ifndef PowerMangerGui_INFO_HEADER +#define PowerMangerGui_INFO_HEADER + +void showSynopsis(); +void showHelpAndExit(); +void showExampleConfigAndExit(); +void showInterfaceAndExit(); +void showReleaseInfoAndExit(); + +#endif + diff --git a/src/appPowerMangerGui/appPowerMangerGui.moos b/src/appPowerMangerGui/appPowerMangerGui.moos new file mode 100644 index 0000000..a7528fc --- /dev/null +++ b/src/appPowerMangerGui/appPowerMangerGui.moos @@ -0,0 +1,9 @@ +//------------------------------------------------ +// appPowerMangerGui config block + +ProcessConfig = appPowerMangerGui +{ + AppTick = 4 + CommsTick = 4 +} + diff --git a/src/appPowerMangerGui/main.cpp b/src/appPowerMangerGui/main.cpp new file mode 100644 index 0000000..8f97daa --- /dev/null +++ b/src/appPowerMangerGui/main.cpp @@ -0,0 +1,52 @@ +/************************************************************/ +/* NAME: */ +/* ORGN: MIT */ +/* FILE: main.cpp */ +/* DATE: */ +/************************************************************/ + +#include +#include "MBUtils.h" +#include "ColorParse.h" +#include "PowerMangerGui.h" +#include "PowerMangerGui_Info.h" + +using namespace std; + +int main(int argc, char *argv[]) +{ + string mission_file; + string run_command = argv[0]; + + for(int i=1; iiRecieveMessage(Buff,sizeof(Buff)); @@ -201,16 +202,17 @@ bool PowerManger::ListenLoopCCU() //处理消息 switch (id) { - case 0x0051: //CCU_STATE_FB 0x0051 + case CCU_STATE_FB_ID: //CCU_STATE_FB 0x0051 msg_CcuStateFbMsg s; if(m_udpComm.getCcuState((char *)Buff,s)) { cout << "------------------" << endl; - cout << "id:" << s.header.id << endl; + // cout << "id:" << s.header.id << endl; cout << "currentWorkCondition:" << (double)s.currentWorkCondition << endl; - cout << "fcuState:" << s.fcuState << endl; - cout << "fcuFaultLeve:" << s.fcuFaultLeve << endl; - cout << "powerLimit:" << s.powerLimit << endl; + cout << "fcuState:" << (double)s.fcuState << endl; + cout << "fcuFaultLeve:" << (double)s.fcuFaultLeve << endl; + cout << "powerLimit:" << (double)s.powerLimit << endl; + cout << "checkCode:" << (double)s.checkCode << endl; } else { @@ -219,7 +221,7 @@ bool PowerManger::ListenLoopCCU() m_udpComm.sError.clear(); } break; - case 0x0040: //CCU_SET_PARM_FB 0x0040 + case CCU_SET_PARM_FB_ID: //CCU_SET_PARM_FB 0x0040 msg_CcuSetParmFbMsg p; if(m_udpComm.getCcuSetParmFb((char *)Buff,p)) { diff --git a/src/pPowerManger/PowerManger.h b/src/pPowerManger/PowerManger.h index b699020..fa57f10 100644 --- a/src/pPowerManger/PowerManger.h +++ b/src/pPowerManger/PowerManger.h @@ -47,6 +47,12 @@ class PowerManger : public AppCastingMOOSApp protected: // app function // bool _ListenCB(); XPCUdpSocket* setUdpScoket(long lPort); + // + bool buildStateReport(); + bool buildEquipmentReport(); + bool buildDisributionReport(); + bool buildSubDistributionReport(); + bool buildPredictionReport(); protected: // app variables long m_lPort; diff --git a/src/pPowerManger/ccuUdpMsg.h b/src/pPowerManger/ccuUdpMsg.h index 43e7b64..c2eaf8d 100644 --- a/src/pPowerManger/ccuUdpMsg.h +++ b/src/pPowerManger/ccuUdpMsg.h @@ -1,6 +1,12 @@ #ifndef CCUUDPMSG__H #define CCUUDPMSG__H +#define CCU_UDPMSG_START1 0x20 +#define CCU_UDPMSG_START2 0x20 +#define CCU_STATE_FB_ID 0x0051 +#define CCU_SET_PARM_ID 0x0040 +#define CCU_SET_PARM_FB_ID 0x0041 +#pragma pack (1) typedef unsigned int Checksum; typedef struct { @@ -177,5 +183,6 @@ typedef struct { float placeholder5; Checksum checkCode; } msg_CcuStateFbMsg; +#pragma pack () #endif diff --git a/src/pPowerManger/udpComm.cpp b/src/pPowerManger/udpComm.cpp index dfa732f..0283aac 100644 --- a/src/pPowerManger/udpComm.cpp +++ b/src/pPowerManger/udpComm.cpp @@ -4,13 +4,24 @@ udpComm::udpComm() {} udpComm::~udpComm() {} + + +Checksum udpComm::calculateChecksum(const unsigned char* data, int size) +{ + Checksum checksum = 0; + int size_data = size - sizeof(Checksum); + for (int i = 0; i < size_data; i++) { + checksum += data[i]; + } + return checksum; +} bool udpComm::getMsgId(char *m,unsigned short &id) { m_header h; h = *reinterpret_cast(m); // 判断消息是否有效 if (h.start1!= 0x20 || h.start2!= 0x20) { - // sError.push_back("Msg Header errar"); + sError.push_back("Msg Header errar"); return false; } id = h.id; @@ -31,39 +42,13 @@ bool udpComm::getCcuState(char *m, msg_CcuStateFbMsg &s) { } if (h.id != 0x0051) { sError.push_back("CcuState Msg ID error"); - // std::cout << "-------" <currentWorkCondition + - p->fcuState + p->fcuFaultLeve + p->powerLimit + p->totalPowerGeneration + - p->ch4o + p->o2 + p->fcuVoltage + p->fcuCurrent + p->o2Level + - p->placeholder1 + p->exchangerTemperature + p->fcuOutPower + - p->fcuOutIns + p->fcuVoltageIns + p->fcuVoltagePower + p->fcuCurrentIns + - p->fcuCurrentPower + p->h2Concentration1 + p->h2Concentration2 + - p->o2Concentration1 + p->o2Concentration2 + p->ch4oConcentration1 + - p->ch4oConcentration2 + p->backpressure1 + p->backpressure2 + - p->flameDetection + p->fcuGZ_1L + p->fcuGZ_1H + p->fcuGZ_2L + - p->fcuGZ_2H + p->fcuGZ_3L + p->fcuGZ_3H + p->insPosRelayState + - p->insNegRelayState + p->powerNegRelayState + p->powerPosRelayState + - p->insBatLimit + p->powerBatLimit + p->insBatSoc + p->powerBatSoc + - p->insBatTotalElectricity + p->powerBatTotalElectricity + - p->insBatCurrentElectricity + p->powerBatCurrentElectricity + - p->insChargeState + p->powerChargeState + p->insLinkVoltage + - p->insPackVoltage + p->insCurrent + p->insPosInsulationResistance + - p->insNegInsulationResistance + p->powerLinkVoltage + - p->powerPackVoltage + p->powerCurrent + p->powerPosInsulationResistance + - p->powerNegInsulationResistance + p->insEmergencyStatusWord + - p->powerEmergencyStatusWord + p->insAlarmIdentificationWord + - p->powerAlarmIdentificationWord + p->insCurrentSocHold1 + - p->insCurrentSocHold2 + p->insCurrentSocHold3 + p->fcuCurrentToInsLimit1 + - p->fcuCurrentToinsLimit2 + p->powerCurrentSocHold1 + - p->powerCurrentSocHold2 + p->powerCurrentSocHold3 + - p->powerCurrentToInsLimit1 + p->powerCurrentToinsLimit2 + - p->placeholder2 + p->placeholder3 + p->placeholder5; + sum = calculateChecksum((unsigned char*)m, sizeof(msg_CcuStateFbMsg)); + if (sum != p->checkCode) { sError.push_back("CcuStat Msg Check error"); - //return false; TODO: 暂时不校验 + return false; } s = *p; return true; @@ -90,7 +75,7 @@ bool udpComm::getCcuSetParmFb(char *m, msg_CcuSetParmFbMsg &s) return false; } - sum = h.id + h.length + h.start1 + h.start2 + p->flag + p->failureCode; + sum = calculateChecksum((unsigned char*)m, sizeof(msg_CcuSetParmFbMsg)); if (sum!= p->checkCode) { sError.push_back("CcuSetParm Msg Check error"); diff --git a/src/pPowerManger/udpComm.h b/src/pPowerManger/udpComm.h index 04af433..10d5828 100644 --- a/src/pPowerManger/udpComm.h +++ b/src/pPowerManger/udpComm.h @@ -14,6 +14,9 @@ public: bool getCcuSetParmFb(char *m, msg_CcuSetParmFbMsg &s); bool sendCcuColCmd(const msg_CcuColCmdMsg m); bool sendCcuSetParmCmd(const msg_CcuSetParmMsg m); + + Checksum calculateChecksum(const unsigned char* data, int size); + std::vector sError; private: diff --git a/test/scripts/test.py b/test/scripts/test.py index 33798fd..a9345a0 100644 --- a/test/scripts/test.py +++ b/test/scripts/test.py @@ -33,11 +33,11 @@ for i in range(num_messages): sock.sendto(message, (target_ip, target_port)) # 打印发送的信息和目标地址 - print(f"Sent message to {target_ip}:{target_port}: {message}") + print(f"Sent message to {target_ip}:{target_port}") # 等待一段时间 time.sleep(interval) - sock.sendto(valid_msg2, (target_ip, target_port)) + # sock.sendto(valid_msg2, (target_ip, target_port)) time.sleep(interval) # 关闭套接字 diff --git a/test/scripts/udpmsg.py b/test/scripts/udpmsg.py index dae6c35..c810cbc 100644 --- a/test/scripts/udpmsg.py +++ b/test/scripts/udpmsg.py @@ -5,83 +5,83 @@ class msg_CcuStateFbMsg: self.start1 = 0x20 self.start2 = 0x20 self.id = 0x0051 - self.length = 0x5A - self.currentWorkCondition = 0x01 + self.length = 0x0000 + self.currentWorkCondition = 0x00 self.fcuState = 0x01 - self.fcuFaultLeve = 0x01 - self.powerLimit = 0x01 - self.totalPowerGeneration = 0x01 - self.ch4o = 0x01 - self.o2 = 0x01 - self.fcuVoltage = 0x01 - self.fcuCurrent = 0x01 - self.o2Level = 0x01 - self.placeholder1 = 0x01 - self.exchangerTemperature = 0x01 - self.fcuOutPower = 0x01 - self.fcuOutIns = 0x01 - self.fcuVoltageIns = 0x01 - self.fcuVoltagePower = 0x01 - self.fcuCurrentIns = 0x01 - self.fcuCurrentPower = 0x01 - self.h2Concentration1 = 0x01 - self.h2Concentration2 = 0x01 - self.o2Concentration1 = 0x01 - self.o2Concentration2 = 0x01 - self.ch4oConcentration1 = 0x01 - self.ch4oConcentration2 = 0x01 - self.backpressure1 = 0x01 - self.backpressure2 = 0x01 - self.flameDetection = 0x01 - self.fcuGZ_1L = 0x01 - self.fcuGZ_1H = 0x01 - self.fcuGZ_2L = 0x01 - self.fcuGZ_2H = 0x01 - self.fcuGZ_3L = 0x01 - self.fcuGZ_3H = 0x01 - self.insPosRelayState = 0x01 - self.insNegRelayState = 0x01 - self.powerPosRelayState = 0x01 - self.powerNegRelayState = 0x01 - self.insBatLimit = 0x01 - self.powerBatLimit = 0x01 - self.insBatSoc = 0x01 - self.powerBatSoc = 0x01 - self.insBatTotalElectricity = 0x01 - self.powerBatTotalElectricity = 0x01 - self.insBatCurrentElectricity = 0x01 - self.powerBatCurrentElectricity = 0x01 - self.insChargeState = 0x01 - self.powerChargeState = 0x01 - self.insLinkVoltage = 0x01 - self.insPackVoltage = 0x01 - self.insCurrent = 0x01 - self.insPosInsulationResistance = 0x01 - self.insNegInsulationResistance = 0x01 - self.powerLinkVoltage = 0x01 - self.powerPackVoltage = 0x01 - self.powerCurrent = 0x01 - self.powerPosInsulationResistance = 0x01 - self.powerNegInsulationResistance = 0x01 - self.insEmergencyStatusWord = 0x01 - self.powerEmergencyStatusWord = 0x01 - self.insAlarmIdentificationWord = 0x01 - self.powerAlarmIdentificationWord = 0x01 - self.insCurrentSocHold1 = 0x01 - self.insCurrentSocHold2 = 0x01 - self.insCurrentSocHold3 = 0x01 - self.fcuCurrentToInsLimit1 = 0x01 - self.fcuCurrentToinsLimit2 = 0x01 - self.powerCurrentSocHold1 = 0x01 - self.powerCurrentSocHold2 = 0x01 - self.powerCurrentSocHold3 = 0x01 - self.powerCurrentToInsLimit1 = 0x01 - self.powerCurrentToinsLimit2 = 0x01 - self.placeholder2 = 0x01 - self.placeholder3 = 0x01 - self.placeholder4 = 0x01 - self.placeholder5 = 0x01 - self.checkCode = 0x01 + self.fcuFaultLeve = 0x20 + self.powerLimit = 0x00 + self.totalPowerGeneration = 0x00 + self.ch4o = 0x00 + self.o2 = 0x00 + self.fcuVoltage = 0x00 + self.fcuCurrent = 0x00 + self.o2Level = 0x00 + self.placeholder1 = 0x00 + self.exchangerTemperature = 0x00 + self.fcuOutPower = 0x00 + self.fcuOutIns = 0x00 + self.fcuVoltageIns = 0x00 + self.fcuVoltagePower = 0x00 + self.fcuCurrentIns = 0x00 + self.fcuCurrentPower = 0x00 + self.h2Concentration1 = 0x00 + self.h2Concentration2 = 0x00 + self.o2Concentration1 = 0x00 + self.o2Concentration2 = 0x00 + self.ch4oConcentration1 = 0x00 + self.ch4oConcentration2 = 0x00 + self.backpressure1 = 0x00 + self.backpressure2 = 0x00 + self.flameDetection = 0x00 + self.fcuGZ_1L = 0x00 + self.fcuGZ_1H = 0x00 + self.fcuGZ_2L = 0x00 + self.fcuGZ_2H = 0x00 + self.fcuGZ_3L = 0x00 + self.fcuGZ_3H = 0x00 + self.insPosRelayState = 0x00 + self.insNegRelayState = 0x00 + self.powerPosRelayState = 0x00 + self.powerNegRelayState = 0x00 + self.insBatLimit = 0x00 + self.powerBatLimit = 0x00 + self.insBatSoc = 0x00 + self.powerBatSoc = 0x00 + self.insBatTotalElectricity = 0x00 + self.powerBatTotalElectricity = 0x00 + self.insBatCurrentElectricity = 0x00 + self.powerBatCurrentElectricity = 0x00 + self.insChargeState = 0x00 + self.powerChargeState = 0x00 + self.insLinkVoltage = 0x00 + self.insPackVoltage = 0x00 + self.insCurrent = 0x00 + self.insPosInsulationResistance = 0x00 + self.insNegInsulationResistance = 0x00 + self.powerLinkVoltage = 0x00 + self.powerPackVoltage = 0x00 + self.powerCurrent = 0x00 + self.powerPosInsulationResistance = 0x00 + self.powerNegInsulationResistance = 0x00 + self.insEmergencyStatusWord = 0x00 + self.powerEmergencyStatusWord = 0x00 + self.insAlarmIdentificationWord = 0x00 + self.powerAlarmIdentificationWord = 0x00 + self.insCurrentSocHold1 = 0x00 + self.insCurrentSocHold2 = 0x00 + self.insCurrentSocHold3 = 0x00 + self.fcuCurrentToInsLimit1 = 0x00 + self.fcuCurrentToinsLimit2 = 0x00 + self.powerCurrentSocHold1 = 0x00 + self.powerCurrentSocHold2 = 0x00 + self.powerCurrentSocHold3 = 0x00 + self.powerCurrentToInsLimit1 = 0x00 + self.powerCurrentToinsLimit2 = 0x00 + self.placeholder2 = 0x00 + self.placeholder3 = 0x00 + self.placeholder4 = 0x00 + self.placeholder5 = 0x00 + self.checkCode = 0x00 @@ -89,27 +89,7 @@ class msg_CcuStateFbMsg: def pack(self): # 初始化数据 self.length = 0x0000 - - self.checkCode = self.start1 + self.start2 + self.id + self.length - + self.currentWorkCondition + self.fcuState + self.fcuFaultLeve - + self.powerLimit + self.totalPowerGeneration + self.ch4o + self.o2 - + self.fcuVoltage + self.fcuCurrent + self.o2Level + self.placeholder1 - + self.exchangerTemperature + self.fcuOutPower + self.fcuOutIns + self.fcuVoltageIns - + self.fcuVoltagePower + self.fcuCurrentIns + self.fcuCurrentPower + self.h2Concentration1 - + self.h2Concentration2 + self.o2Concentration1 + self.o2Concentration2 + self.ch4oConcentration1 - + self.ch4oConcentration2 + self.backpressure1 + self.backpressure2 + self.flameDetection + self.fcuGZ_1L - + self.fcuGZ_1H + self.fcuGZ_2L + self.fcuGZ_2H + self.fcuGZ_3L + self.fcuGZ_3H + self.insPosRelayState - + self.insNegRelayState + self.powerPosRelayState + self.powerNegRelayState + self.insBatLimit - + self.powerBatLimit + self.insBatSoc + self.powerBatSoc + self.insBatTotalElectricity - + self.powerBatTotalElectricity + self.insBatCurrentElectricity + self.powerBatCurrentElectricity - + self.insChargeState + self.powerChargeState + self.insLinkVoltage + self.insPackVoltage - + self.insCurrent + self.insPosInsulationResistance + self.insNegInsulationResistance - + self.powerLinkVoltage + self.powerPackVoltage + self.powerCurrent + self.powerPosInsulationResistance - + self.powerNegInsulationResistance + self.insEmergencyStatusWord + self.powerEmergencyStatusWord - + self.insAlarmIdentificationWord + self.powerAlarmIdentificationWord + self.insCurrentSocHold1 + self.insCurrentSocHold2 - + self.insCurrentSocHold3 + self.fcuCurrentToInsLimit1 + self.fcuCurrentToinsLimit2 + self.powerCurrentSocHold1 - + self.powerCurrentSocHold2 + self.powerCurrentSocHold3 + self.powerCurrentToInsLimit1 + self.powerCurrentToinsLimit2 - + self.placeholder2 + self.placeholder3 + self.placeholder4 + self.placeholder5 + self.checkCode = 0x0000 data = struct.pack('