增加了状态机代码
This commit is contained in:
Vendored
+2
-1
@@ -54,5 +54,6 @@
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
},
|
||||
"C_Cpp.errorSquiggles": "disabled"
|
||||
"C_Cpp.errorSquiggles": "disabled",
|
||||
"marscode.chatLanguage": "cn"
|
||||
}
|
||||
@@ -1,47 +1,47 @@
|
||||
{
|
||||
"HVABactuatorCurrent_uint16": 0,
|
||||
"HVABbowFTDevice123Current_uint16": 0,
|
||||
"HVABbowRudderControlBoxCurrent_uint16": 0,
|
||||
"HVABbusbarBCurrent_uint16": 0,
|
||||
"HVABbusbarBVoltage_uint16": 0,
|
||||
"HVABmastSteeringGearControlBoxCurrent_uint16": 0,
|
||||
"HVABopenWaterCoverStartCylinderCurrent_uint16": 0,
|
||||
"HVABxczCurrent_uint16": 1,
|
||||
"HVBBbowLowVoltageDistributionBoxCurrent_uint16": 0,
|
||||
"HVBBcompositeEnergyManagementSystemEmergencyDC48VCurrent_uint16": 0,
|
||||
"HVBBdcC1InstrumentDC48VCurrent_uint16": 0,
|
||||
"HVBBemergency2BusbarVoltage_uint16": 0,
|
||||
"HVBBemergencyLithiumBatteryGroup2Current_uint16": 0,
|
||||
"HVBBfuelCellSecuritySystemEmergencyDC48VCurrent_uint16": 0,
|
||||
"HVBBinstrumentBusbarVoltage_uint16": 0,
|
||||
"HVBBlithiumBatteryGroupInstrumentCurrent_uint16": 0,
|
||||
"HVBBplcControlPowerCurrent_uint16": 0,
|
||||
"HVBBreservedCurrent1_uint16": 0,
|
||||
"HVBBreservedCurrent2_uint16": 0,
|
||||
"HVBBunit4InstrumentDC48VCurrent_uint16": 0,
|
||||
"HVBbowHighVoltageDistributionBoxCurrent_uint16": 0,
|
||||
"HVBbusbarACurrent_uint16": 0,
|
||||
"HVBbusbarAVoltage_uint16": 6,
|
||||
"HVBdcDc5ModuleCurrent_uint16": 0,
|
||||
"HVBfbReservedSwitchCurrent_uint16": 0,
|
||||
"HVBlithiumBatteryGroupMeterCurrent_uint16": 0,
|
||||
"HVBpowerBusCurrent_uint16": 0,
|
||||
"HVBpowerBusVoltage_uint16": 0,
|
||||
"HVBpropulsionMotorControlBoxCurrent_uint16": 0,
|
||||
"HVBreservedCurrent1_uint16": 0,
|
||||
"HVBreservedCurrent2_uint16": 0,
|
||||
"HVBreservedCurrent3_uint16": 0,
|
||||
"HVBsternFTDevice45Current_uint16": 0,
|
||||
"HVBsternRudderSwitch1Current_uint16": 0,
|
||||
"HVBsternRudderSwitch2Current_uint16": 0,
|
||||
"HVBtyzReservedSwitchCurrent_uint16": 0,
|
||||
"LVBBbowPZDeviceCurrent_uint16": 0,
|
||||
"LVBBemergency1BusbarVoltage_uint16": 0,
|
||||
"LVBBemergencyLithiumBatteryGroup1Current_uint16": 0,
|
||||
"LVBBinstrumentBusbarCurrent_uint16": 0,
|
||||
"LVBBunit1Current_uint16": 0,
|
||||
"LVBBunit2Current_uint16": 0,
|
||||
"LVBBunit3Current_uint16": 0,
|
||||
"LVBBunit5Current_uint16": 0,
|
||||
"LVBinstrumentBusbarVoltage_uint16": 0
|
||||
"HVABFTDev123Cur_uint16": 0,
|
||||
"HVABactCur_uint16": 0,
|
||||
"HVABbowRudCur_uint16": 0,
|
||||
"HVABbusBCur_uint16": 0,
|
||||
"HVABbusBVol_uint16": 255,
|
||||
"HVABmastSteGeaCur_uint16": 0,
|
||||
"HVABopenWaterCur_uint16": 0,
|
||||
"HVABxczCur_uint16": 0,
|
||||
"HVBBCCUCur_uint16": 276,
|
||||
"HVBBFCSSecurSysCur_uint16": 43016,
|
||||
"HVBBbatInsCur_uint16": 275,
|
||||
"HVBBbowLowVolDisBoxCur_uint16": 275,
|
||||
"HVBBdcC1InsCur_uint16": 43016,
|
||||
"HVBBemer2BusVol_uint16": 6144,
|
||||
"HVBBemerBatCur_uint16": 61440,
|
||||
"HVBBinsBusVol_uint16": 47104,
|
||||
"HVBBplcCur_uint16": 127,
|
||||
"HVBBreservedCur1_uint16": 127,
|
||||
"HVBBreservedCur2_uint16": 127,
|
||||
"HVBBunit4Cur_uint16": 43016,
|
||||
"HVBFTDev45Cur_uint16": 32680,
|
||||
"HVBbatGroupCur_uint16": 5104,
|
||||
"HVBbowHVolDisBoxCur_uint16": 2049,
|
||||
"HVBbusACur_uint16": 0,
|
||||
"HVBbusAVol_uint16": 2049,
|
||||
"HVBdcDc5Cur_uint16": 0,
|
||||
"HVBfbCur_uint16": 51236,
|
||||
"HVBmotorCur_uint16": 32680,
|
||||
"HVBpowerBusCur_uint16": 5048,
|
||||
"HVBpowerBusVol_uint16": 32680,
|
||||
"HVBreservedCur1_uint16": 2049,
|
||||
"HVBreservedCur2_uint16": 0,
|
||||
"HVBreservedCur3_uint16": 2041,
|
||||
"HVBsternRud1Cur_uint16": 5144,
|
||||
"HVBsternRud2Cur_uint16": 32680,
|
||||
"HVBtyzCur_uint16": 0,
|
||||
"LVBBbowPZDevCur_uint16": 0,
|
||||
"LVBBemerBatCur_uint16": 0,
|
||||
"LVBBemerBusVol_uint16": 0,
|
||||
"LVBBinsBusCur_uint16": 43016,
|
||||
"LVBBunit1Cur_uint16": 127,
|
||||
"LVBBunit2Cur_uint16": 0,
|
||||
"LVBBunit3Cur_uint16": 0,
|
||||
"LVBBunit5Cur_uint16": 0,
|
||||
"LVBinsBusVol_uint16": 276
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"HightVoltageABusBreaker_unit16": 0,
|
||||
"HightVoltageBBusBreaker_unit16": 0,
|
||||
"HightVoltageBusBreaker_uint16": 0,
|
||||
"LowVoltageBusBreaker_uint16": 0,
|
||||
"HVolABusBreaker_unit16": 0,
|
||||
"HVolBBusBreaker_unit16": 0,
|
||||
"HVolBusBreaker_uint16": 0,
|
||||
"LVolBusBreaker_uint16": 0,
|
||||
"faultCode_array":
|
||||
[
|
||||
0
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
{
|
||||
"backpressure1_fp32": 0.0,
|
||||
"backpressure2_fp32": 0.0,
|
||||
"ch4oConcentration1_fp32": 0.0,
|
||||
"ch4oConcentration2_fp32": 0.0,
|
||||
"backpressure1_fp32": -5.4051763149612203e-28,
|
||||
"backpressure2_fp32": 7.0480565570603022e-25,
|
||||
"ch4oConcent1_fp32": 5.7198690228688065e-12,
|
||||
"ch4oConcent2_fp32": 1.172338626680628e-38,
|
||||
"ch4o_fp32": 0.0,
|
||||
"exchangerTemperature_fp32": 0.0,
|
||||
"fcuCurrentIns_fp32": 0.0,
|
||||
"fcuCurrentPower_fp32": 0.0,
|
||||
"fcuCurrent_fp32": 0.0,
|
||||
"fcuFaultLeve_uint8": 32,
|
||||
"fcuOutIns_fp32": 0.0,
|
||||
"fcuOutPower_fp32": 0.0,
|
||||
"fcuState_uint8": 86,
|
||||
"fcuVoltageIns_fp32": 0.0,
|
||||
"fcuVoltagePower_fp32": 0.0,
|
||||
"fcuVoltage_fp32": 0.0,
|
||||
"h2Concentration1_fp32": 0.0,
|
||||
"h2Concentration2_fp32": 0.0,
|
||||
"o2Concentration1_fp32": 0.0,
|
||||
"o2Concentration2_fp32": 0.0,
|
||||
"o2Level_fp32": 0.0,
|
||||
"o2_fp32": 0.0,
|
||||
"powerLimit_fp32": 0.0,
|
||||
"totalPowerGeneration_fp32": 0.0
|
||||
"excTemp_fp32": 7.8389743120117084e-39,
|
||||
"faultCode1_uint16": 22608,
|
||||
"faultCode2_uint16": 34680,
|
||||
"faultCode3_uint16": 32767,
|
||||
"fcuCurIns_fp32": 3.5873240686715317e-43,
|
||||
"fcuCurPower_fp32": 0.0,
|
||||
"fcuCur_fp32": 1.7600060933568737e+34,
|
||||
"fcuFaultLeve_uint8": 43,
|
||||
"fcuOutIns_fp32": 1.172338626680628e-38,
|
||||
"fcuOutPower_fp32": 5.8264504332328215e-11,
|
||||
"fcuState_uint8": 84,
|
||||
"fcuVolIns_fp32": 3.1653568655087838e-12,
|
||||
"fcuVolPower_fp32": 1.172338626680628e-38,
|
||||
"fcuVol_fp32": 1.1723384865507816e-38,
|
||||
"flameDet_uint8": 170,
|
||||
"h2Concent1_fp32": 0.0,
|
||||
"h2Concent2_fp32": 0.0,
|
||||
"o2Concent1_fp32": 8.2589490801865395e-13,
|
||||
"o2Concent2_fp32": 1.172338626680628e-38,
|
||||
"o2Level_fp32": 1.1754773951108692e-38,
|
||||
"o2_fp32": -1.049113533195957e+19,
|
||||
"powLimit_fp32": 1.172338626680628e-38,
|
||||
"powerGen_fp32": 4.6635212892729912e-42
|
||||
}
|
||||
@@ -1,36 +1,38 @@
|
||||
{
|
||||
"fcuCurrentToInsLimit1_uint8": 0,
|
||||
"fcuCurrentToinsLimit2_uint8": 0,
|
||||
"insBatCurrentElectricity_uint16": 0,
|
||||
"fcuCurToInsLimit1_uint8": 85,
|
||||
"fcuCurToinsLimit2_uint8": 0,
|
||||
"insBatCurElect_uint16": 0,
|
||||
"insBatLimit_uint16": 0,
|
||||
"insBatSoc_uint8": 0,
|
||||
"insBatTotalElectricity_uint16": 0,
|
||||
"insChargeState_uint8": 0,
|
||||
"insCurrentSocHold1_uint8": 0,
|
||||
"insCurrentSocHold2_uint8": 0,
|
||||
"insCurrentSocHold3_uint8": 0,
|
||||
"insBatTotalElect_uint16": 0,
|
||||
"insChargeState_uint8": 240,
|
||||
"insCurSocHold1_uint8": 23,
|
||||
"insCurSocHold2_uint8": 223,
|
||||
"insCurSocHold3_uint8": 91,
|
||||
"insCurrent_uint16": 0,
|
||||
"insLinkVoltage_uint16": 0,
|
||||
"insNegInsulationResistance_uint16": 0,
|
||||
"insLinkVol_uint16": 34680,
|
||||
"insNegRelayState_uint8": 0,
|
||||
"insPackVoltage_uint16": 0,
|
||||
"insPosInsulationResistance_uint16": 0,
|
||||
"insNegRes_uint16": 2092,
|
||||
"insPackVol_uint16": 32767,
|
||||
"insPosRelayState_uint8": 0,
|
||||
"powerBatCurrentElectricity_uint16": 0,
|
||||
"insPosRes_uint16": 33210,
|
||||
"insfaultCode_uint8": 80,
|
||||
"powBatCurElect_uint16": 0,
|
||||
"powBatSoc_uint8": 0,
|
||||
"powBatTotalElect_uint16": 0,
|
||||
"powChargeState_uint8": 88,
|
||||
"powCurSocHold1_uint8": 0,
|
||||
"powCurSocHold2_uint8": 76,
|
||||
"powCurSocHold3_uint8": 43,
|
||||
"powCurToInsLimit1_uint8": 146,
|
||||
"powCurToinsLimit2_uint8": 117,
|
||||
"powCur_uint16": 55776,
|
||||
"powLinkVol_uint16": 32680,
|
||||
"powNegRelayState_uint8": 0,
|
||||
"powNegRes_uint16": 21851,
|
||||
"powPosRelayState_uint8": 2,
|
||||
"powPosRes_uint16": 57111,
|
||||
"powerBatLimit_uint16": 0,
|
||||
"powerBatSoc_uint8": 0,
|
||||
"powerBatTotalElectricity_uint16": 0,
|
||||
"powerChargeState_uint8": 0,
|
||||
"powerCurrentSocHold1_uint8": 0,
|
||||
"powerCurrentSocHold2_uint8": 0,
|
||||
"powerCurrentSocHold3_uint8": 0,
|
||||
"powerCurrentToInsLimit1_uint8": 0,
|
||||
"powerCurrentToinsLimit2_uint8": 0,
|
||||
"powerCurrent_uint16": 0,
|
||||
"powerLinkVoltage_uint16": 0,
|
||||
"powerNegInsulationResistance_uint16": 0,
|
||||
"powerNegRelayState_uint8": 0,
|
||||
"powerPackVoltage_uint16": 0,
|
||||
"powerPosInsulationResistance_uint16": 0,
|
||||
"powerPosRelayState_uint8": 0
|
||||
"powerPackVol_uint16": 0,
|
||||
"powfaultCode_uint8": 175
|
||||
}
|
||||
@@ -19,6 +19,7 @@ SET(SRC
|
||||
PowerManger.cpp
|
||||
PowerManger_Info.cpp
|
||||
udpComm.cpp
|
||||
fsm.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -33,6 +33,24 @@ PowerManger::PowerManger()
|
||||
soc = 0;
|
||||
sustainableTime = 0;
|
||||
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.RegisterHandleFunction(&m_state1,handleState1);
|
||||
m_fsm.RegisterHandleFunction(&m_state2,handleState2);
|
||||
m_fsm.RegisterHandleFunction(&m_state3,handleState3);
|
||||
|
||||
// 注册状态机转换条件
|
||||
// m_fsm.RegisterEvent()
|
||||
|
||||
// 初始化状态机
|
||||
m_pmState = m_state1;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
@@ -89,6 +107,7 @@ bool PowerManger::OnConnectToServer()
|
||||
|
||||
bool PowerManger::Iterate()
|
||||
{
|
||||
m_fsm.run(m_pmState,this);
|
||||
AppCastingMOOSApp::Iterate();
|
||||
// 更新当前状态
|
||||
updatePmState();
|
||||
@@ -352,10 +371,10 @@ bool PowerManger::buildPowerSysReport()
|
||||
fcs[VAR_TO_STR(fcuFaultLeve)+suffix] = m_pmCurrentState.ccustate.fcuFaultLeve;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerLimit).name());
|
||||
fcs[VAR_TO_STR(powerLimit)+suffix] = m_pmCurrentState.ccustate.powerLimit;
|
||||
fcs[VAR_TO_STR(powLimit)+suffix] = m_pmCurrentState.ccustate.powerLimit;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.totalPowerGeneration).name());
|
||||
fcs[VAR_TO_STR(totalPowerGeneration)+suffix] = m_pmCurrentState.ccustate.totalPowerGeneration;
|
||||
fcs[VAR_TO_STR(powerGen)+suffix] = m_pmCurrentState.ccustate.totalPowerGeneration;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.ch4o).name());
|
||||
fcs[VAR_TO_STR(ch4o)+suffix] = m_pmCurrentState.ccustate.ch4o;
|
||||
@@ -364,16 +383,16 @@ bool PowerManger::buildPowerSysReport()
|
||||
fcs[VAR_TO_STR(o2)+suffix] = m_pmCurrentState.ccustate.o2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuVoltage).name());
|
||||
fcs[VAR_TO_STR(fcuVoltage)+suffix] = m_pmCurrentState.ccustate.fcuVoltage;
|
||||
fcs[VAR_TO_STR(fcuVol)+suffix] = m_pmCurrentState.ccustate.fcuVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuCurrent).name());
|
||||
fcs[VAR_TO_STR(fcuCurrent)+suffix] = m_pmCurrentState.ccustate.fcuCurrent;
|
||||
fcs[VAR_TO_STR(fcuCur)+suffix] = m_pmCurrentState.ccustate.fcuCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.o2Level).name());
|
||||
fcs[VAR_TO_STR(o2Level)+suffix] = m_pmCurrentState.ccustate.o2Level;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.exchangerTemperature).name());
|
||||
fcs[VAR_TO_STR(exchangerTemperature)+suffix] = m_pmCurrentState.ccustate.exchangerTemperature;
|
||||
fcs[VAR_TO_STR(excTemp)+suffix] = m_pmCurrentState.ccustate.exchangerTemperature;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuOutPower).name());
|
||||
fcs[VAR_TO_STR(fcuOutPower)+suffix] = m_pmCurrentState.ccustate.fcuOutPower;
|
||||
@@ -382,34 +401,34 @@ bool PowerManger::buildPowerSysReport()
|
||||
fcs[VAR_TO_STR(fcuOutIns)+suffix] = m_pmCurrentState.ccustate.fcuOutIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuVoltageIns).name());
|
||||
fcs[VAR_TO_STR(fcuVoltageIns)+suffix] = m_pmCurrentState.ccustate.fcuVoltageIns;
|
||||
fcs[VAR_TO_STR(fcuVolIns)+suffix] = m_pmCurrentState.ccustate.fcuVoltageIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuVoltagePower).name());
|
||||
fcs[VAR_TO_STR(fcuVoltagePower)+suffix] = m_pmCurrentState.ccustate.fcuVoltagePower;
|
||||
fcs[VAR_TO_STR(fcuVolPower)+suffix] = m_pmCurrentState.ccustate.fcuVoltagePower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuCurrentIns).name());
|
||||
fcs[VAR_TO_STR(fcuCurrentIns)+suffix] = m_pmCurrentState.ccustate.fcuCurrentIns;
|
||||
fcs[VAR_TO_STR(fcuCurIns)+suffix] = m_pmCurrentState.ccustate.fcuCurrentIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuCurrentPower).name());
|
||||
fcs[VAR_TO_STR(fcuCurrentPower)+suffix] = m_pmCurrentState.ccustate.fcuCurrentPower;
|
||||
fcs[VAR_TO_STR(fcuCurPower)+suffix] = m_pmCurrentState.ccustate.fcuCurrentPower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.h2Concentration1).name());
|
||||
fcs[VAR_TO_STR(h2Concentration1)+suffix] = m_pmCurrentState.ccustate.h2Concentration1;
|
||||
fcs[VAR_TO_STR(h2Concent1)+suffix] = m_pmCurrentState.ccustate.h2Concentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.h2Concentration2).name());
|
||||
fcs[VAR_TO_STR(h2Concentration2)+suffix] = m_pmCurrentState.ccustate.h2Concentration2;
|
||||
fcs[VAR_TO_STR(h2Concent2)+suffix] = m_pmCurrentState.ccustate.h2Concentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.o2Concentration1).name());
|
||||
fcs[VAR_TO_STR(o2Concentration1)+suffix] = m_pmCurrentState.ccustate.o2Concentration1;
|
||||
fcs[VAR_TO_STR(o2Concent1)+suffix] = m_pmCurrentState.ccustate.o2Concentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.o2Concentration2).name());
|
||||
fcs[VAR_TO_STR(o2Concentration2)+suffix] = m_pmCurrentState.ccustate.o2Concentration2;
|
||||
fcs[VAR_TO_STR(o2Concent2)+suffix] = m_pmCurrentState.ccustate.o2Concentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.ch4oConcentration1).name());
|
||||
fcs[VAR_TO_STR(ch4oConcentration1)+suffix] = m_pmCurrentState.ccustate.ch4oConcentration1;
|
||||
fcs[VAR_TO_STR(ch4oConcent1)+suffix] = m_pmCurrentState.ccustate.ch4oConcentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.ch4oConcentration2).name());
|
||||
fcs[VAR_TO_STR(ch4oConcentration2)+suffix] = m_pmCurrentState.ccustate.ch4oConcentration2;
|
||||
fcs[VAR_TO_STR(ch4oConcent2)+suffix] = m_pmCurrentState.ccustate.ch4oConcentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.backpressure1).name());
|
||||
fcs[VAR_TO_STR(backpressure1)+suffix] = m_pmCurrentState.ccustate.backpressure1;
|
||||
@@ -418,6 +437,27 @@ bool PowerManger::buildPowerSysReport()
|
||||
fcs[VAR_TO_STR(backpressure2)+suffix] = m_pmCurrentState.ccustate.backpressure2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.flameDetection).name());
|
||||
fcs[VAR_TO_STR(flameDet)+suffix] = m_pmCurrentState.ccustate.flameDetection;
|
||||
|
||||
// unsigned char fcuGZ_1L;
|
||||
// unsigned char fcuGZ_1H;
|
||||
// unsigned char fcuGZ_2L;
|
||||
// unsigned char fcuGZ_2H;
|
||||
// unsigned char fcuGZ_3L;
|
||||
// unsigned char fcuGZ_3H;
|
||||
unsigned short faultCode1;
|
||||
unsigned short faultCode2;
|
||||
unsigned short faultCode3;
|
||||
faultCode1 = (m_pmCurrentState.ccustate.fcuGZ_1H << 8) | m_pmCurrentState.ccustate.fcuGZ_1L;
|
||||
faultCode2 = (m_pmCurrentState.ccustate.fcuGZ_2H << 8) | m_pmCurrentState.ccustate.fcuGZ_2L;
|
||||
faultCode3 = (m_pmCurrentState.ccustate.fcuGZ_3H << 8) | m_pmCurrentState.ccustate.fcuGZ_3L;
|
||||
|
||||
suffix = getTypeName(typeid(faultCode1).name());
|
||||
fcs[VAR_TO_STR(faultCode1)+suffix] = faultCode1;
|
||||
suffix = getTypeName(typeid(faultCode2).name());
|
||||
fcs[VAR_TO_STR(faultCode2)+suffix] = faultCode2;
|
||||
suffix = getTypeName(typeid(faultCode3).name());
|
||||
fcs[VAR_TO_STR(faultCode3)+suffix] = faultCode3;
|
||||
|
||||
//4.构建动力锂电池状态报告
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insPosRelayState).name());
|
||||
@@ -427,10 +467,10 @@ bool PowerManger::buildPowerSysReport()
|
||||
lbs[VAR_TO_STR(insNegRelayState)+suffix] = m_pmCurrentState.ccustate.insNegRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerPosRelayState).name());
|
||||
lbs[VAR_TO_STR(powerPosRelayState)+suffix] = m_pmCurrentState.ccustate.powerPosRelayState;
|
||||
lbs[VAR_TO_STR(powPosRelayState)+suffix] = m_pmCurrentState.ccustate.powerPosRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerNegRelayState).name());
|
||||
lbs[VAR_TO_STR(powerNegRelayState)+suffix] = m_pmCurrentState.ccustate.powerNegRelayState;
|
||||
lbs[VAR_TO_STR(powNegRelayState)+suffix] = m_pmCurrentState.ccustate.powerNegRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insBatLimit).name());
|
||||
lbs[VAR_TO_STR(insBatLimit)+suffix] = m_pmCurrentState.ccustate.insBatLimit;
|
||||
@@ -442,86 +482,91 @@ bool PowerManger::buildPowerSysReport()
|
||||
lbs[VAR_TO_STR(insBatSoc)+suffix] = m_pmCurrentState.ccustate.insBatSoc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerBatSoc).name());
|
||||
lbs[VAR_TO_STR(powerBatSoc)+suffix] = m_pmCurrentState.ccustate.powerBatSoc;
|
||||
lbs[VAR_TO_STR(powBatSoc)+suffix] = m_pmCurrentState.ccustate.powerBatSoc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insBatTotalElectricity).name());
|
||||
lbs[VAR_TO_STR(insBatTotalElectricity)+suffix] = m_pmCurrentState.ccustate.insBatTotalElectricity;
|
||||
lbs[VAR_TO_STR(insBatTotalElect)+suffix] = m_pmCurrentState.ccustate.insBatTotalElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerBatTotalElectricity).name());
|
||||
lbs[VAR_TO_STR(powerBatTotalElectricity)+suffix] = m_pmCurrentState.ccustate.powerBatTotalElectricity;
|
||||
lbs[VAR_TO_STR(powBatTotalElect)+suffix] = m_pmCurrentState.ccustate.powerBatTotalElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insBatCurrentElectricity).name());
|
||||
lbs[VAR_TO_STR(insBatCurrentElectricity)+suffix] = m_pmCurrentState.ccustate.insBatCurrentElectricity;
|
||||
lbs[VAR_TO_STR(insBatCurElect)+suffix] = m_pmCurrentState.ccustate.insBatCurrentElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerBatCurrentElectricity).name());
|
||||
lbs[VAR_TO_STR(powerBatCurrentElectricity)+suffix] = m_pmCurrentState.ccustate.powerBatCurrentElectricity;
|
||||
lbs[VAR_TO_STR(powBatCurElect)+suffix] = m_pmCurrentState.ccustate.powerBatCurrentElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insChargeState).name());
|
||||
lbs[VAR_TO_STR(insChargeState)+suffix] = m_pmCurrentState.ccustate.insChargeState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerChargeState).name());
|
||||
lbs[VAR_TO_STR(powerChargeState)+suffix] = m_pmCurrentState.ccustate.powerChargeState;
|
||||
lbs[VAR_TO_STR(powChargeState)+suffix] = m_pmCurrentState.ccustate.powerChargeState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insLinkVoltage).name());
|
||||
lbs[VAR_TO_STR(insLinkVoltage)+suffix] = m_pmCurrentState.ccustate.insLinkVoltage;
|
||||
lbs[VAR_TO_STR(insLinkVol)+suffix] = m_pmCurrentState.ccustate.insLinkVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insPackVoltage).name());
|
||||
lbs[VAR_TO_STR(insPackVoltage)+suffix] = m_pmCurrentState.ccustate.insPackVoltage;
|
||||
lbs[VAR_TO_STR(insPackVol)+suffix] = m_pmCurrentState.ccustate.insPackVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insCurrent).name());
|
||||
lbs[VAR_TO_STR(insCurrent)+suffix] = m_pmCurrentState.ccustate.insCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insPosInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(insPosInsulationResistance)+suffix] = m_pmCurrentState.ccustate.insPosInsulationResistance;
|
||||
lbs[VAR_TO_STR(insPosRes)+suffix] = m_pmCurrentState.ccustate.insPosInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insNegInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(insNegInsulationResistance)+suffix] = m_pmCurrentState.ccustate.insNegInsulationResistance;
|
||||
lbs[VAR_TO_STR(insNegRes)+suffix] = m_pmCurrentState.ccustate.insNegInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerLinkVoltage).name());
|
||||
lbs[VAR_TO_STR(powerLinkVoltage)+suffix] = m_pmCurrentState.ccustate.powerLinkVoltage;
|
||||
lbs[VAR_TO_STR(powLinkVol)+suffix] = m_pmCurrentState.ccustate.powerLinkVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerPackVoltage).name());
|
||||
lbs[VAR_TO_STR(powerPackVoltage)+suffix] = m_pmCurrentState.ccustate.powerPackVoltage;
|
||||
lbs[VAR_TO_STR(powerPackVol)+suffix] = m_pmCurrentState.ccustate.powerPackVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerCurrent).name());
|
||||
lbs[VAR_TO_STR(powerCurrent)+suffix] = m_pmCurrentState.ccustate.powerCurrent;
|
||||
lbs[VAR_TO_STR(powCur)+suffix] = m_pmCurrentState.ccustate.powerCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerPosInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(powerPosInsulationResistance)+suffix] = m_pmCurrentState.ccustate.powerPosInsulationResistance;
|
||||
lbs[VAR_TO_STR(powPosRes)+suffix] = m_pmCurrentState.ccustate.powerPosInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerNegInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(powerNegInsulationResistance)+suffix] = m_pmCurrentState.ccustate.powerNegInsulationResistance;
|
||||
lbs[VAR_TO_STR(powNegRes)+suffix] = m_pmCurrentState.ccustate.powerNegInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insCurrentSocHold1).name());
|
||||
lbs[VAR_TO_STR(insCurrentSocHold1)+suffix] = m_pmCurrentState.ccustate.insCurrentSocHold1;
|
||||
lbs[VAR_TO_STR(insCurSocHold1)+suffix] = m_pmCurrentState.ccustate.insCurrentSocHold1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insCurrentSocHold2).name());
|
||||
lbs[VAR_TO_STR(insCurrentSocHold2)+suffix] = m_pmCurrentState.ccustate.insCurrentSocHold2;
|
||||
lbs[VAR_TO_STR(insCurSocHold2)+suffix] = m_pmCurrentState.ccustate.insCurrentSocHold2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insCurrentSocHold3).name());
|
||||
lbs[VAR_TO_STR(insCurrentSocHold3)+suffix] = m_pmCurrentState.ccustate.insCurrentSocHold3;
|
||||
lbs[VAR_TO_STR(insCurSocHold3)+suffix] = m_pmCurrentState.ccustate.insCurrentSocHold3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuCurrentToInsLimit1).name());
|
||||
lbs[VAR_TO_STR(fcuCurrentToInsLimit1)+suffix] = m_pmCurrentState.ccustate.fcuCurrentToInsLimit1;
|
||||
lbs[VAR_TO_STR(fcuCurToInsLimit1)+suffix] = m_pmCurrentState.ccustate.fcuCurrentToInsLimit1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.fcuCurrentToinsLimit2).name());
|
||||
lbs[VAR_TO_STR(fcuCurrentToinsLimit2)+suffix] = m_pmCurrentState.ccustate.fcuCurrentToinsLimit2;
|
||||
lbs[VAR_TO_STR(fcuCurToinsLimit2)+suffix] = m_pmCurrentState.ccustate.fcuCurrentToinsLimit2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerCurrentSocHold1).name());
|
||||
lbs[VAR_TO_STR(powerCurrentSocHold1)+suffix] = m_pmCurrentState.ccustate.powerCurrentSocHold1;
|
||||
lbs[VAR_TO_STR(powCurSocHold1)+suffix] = m_pmCurrentState.ccustate.powerCurrentSocHold1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerCurrentSocHold2).name());
|
||||
lbs[VAR_TO_STR(powerCurrentSocHold2)+suffix] = m_pmCurrentState.ccustate.powerCurrentSocHold2;
|
||||
lbs[VAR_TO_STR(powCurSocHold2)+suffix] = m_pmCurrentState.ccustate.powerCurrentSocHold2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerCurrentSocHold3).name());
|
||||
lbs[VAR_TO_STR(powerCurrentSocHold3)+suffix] = m_pmCurrentState.ccustate.powerCurrentSocHold3;
|
||||
lbs[VAR_TO_STR(powCurSocHold3)+suffix] = m_pmCurrentState.ccustate.powerCurrentSocHold3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerCurrentToInsLimit1).name());
|
||||
lbs[VAR_TO_STR(powerCurrentToInsLimit1)+suffix] = m_pmCurrentState.ccustate.powerCurrentToInsLimit1;
|
||||
lbs[VAR_TO_STR(powCurToInsLimit1)+suffix] = m_pmCurrentState.ccustate.powerCurrentToInsLimit1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerCurrentToinsLimit2).name());
|
||||
lbs[VAR_TO_STR(powerCurrentToinsLimit2)+suffix] = m_pmCurrentState.ccustate.powerCurrentToinsLimit2;
|
||||
|
||||
lbs[VAR_TO_STR(powCurToinsLimit2)+suffix] = m_pmCurrentState.ccustate.powerCurrentToinsLimit2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.insAlarmIdentificationWord).name());
|
||||
lbs[VAR_TO_STR(insfaultCode)+suffix] = m_pmCurrentState.ccustate.insAlarmIdentificationWord;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.ccustate.powerAlarmIdentificationWord).name());
|
||||
lbs[VAR_TO_STR(powfaultCode)+suffix] = m_pmCurrentState.ccustate.powerAlarmIdentificationWord;
|
||||
|
||||
//5.构建配电系统状态报告
|
||||
|
||||
disBus1Breaker* pdis1=new disBus1Breaker;
|
||||
@@ -569,10 +614,10 @@ bool PowerManger::buildPowerSysReport()
|
||||
(m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1CircuitBreaker == BREAK_ON)? pdis4 -> emergencyLithiumBatteryGroup1CircuitBreaker = 1 : pdis4 -> emergencyLithiumBatteryGroup1CircuitBreaker = 0;
|
||||
pdis4 -> paceholder = 0;
|
||||
|
||||
dis["HightVoltageBusBreaker_uint16"] = *(unsigned short*) pdis1;
|
||||
dis["HightVoltageABusBreaker_unit16"] = *(unsigned short*) pdis2;
|
||||
dis["HightVoltageBBusBreaker_unit16"] = *(unsigned short*) pdis3;
|
||||
dis["LowVoltageBusBreaker_uint16"] = *(unsigned short*) pdis3;
|
||||
dis["HVolBusBreaker_uint16"] = *(unsigned short*) pdis1;
|
||||
dis["HVolABusBreaker_unit16"] = *(unsigned short*) pdis2;
|
||||
dis["HVolBBusBreaker_unit16"] = *(unsigned short*) pdis3;
|
||||
dis["LVolBusBreaker_uint16"] = *(unsigned short*) pdis3;
|
||||
|
||||
delete pdis1;
|
||||
delete pdis2;
|
||||
@@ -590,98 +635,98 @@ bool PowerManger::buildPowerSysReport()
|
||||
|
||||
Json::Value currentBusState;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.powerBusVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusVoltage)+suffix] = m_pmCurrentState.bus1State.powerBusVoltage;
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusVol)+suffix] = m_pmCurrentState.bus1State.powerBusVoltage;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.dcDc5ModuleCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBdcDc5ModuleCurrent)+suffix] = m_pmCurrentState.bus1State.dcDc5ModuleCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBdcDc5Cur)+suffix] = m_pmCurrentState.bus1State.dcDc5ModuleCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.powerBusCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusCurrent)+suffix] = m_pmCurrentState.bus1State.powerBusCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusCur)+suffix] = m_pmCurrentState.bus1State.powerBusCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.busbarAVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBbusbarAVoltage)+suffix] = m_pmCurrentState.bus1State.busbarAVoltage;
|
||||
currentBusState[VAR_TO_STR(HVBbusAVol)+suffix] = m_pmCurrentState.bus1State.busbarAVoltage;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.propulsionMotorControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBpropulsionMotorControlBoxCurrent)+suffix] = m_pmCurrentState.bus1State.propulsionMotorControlBoxCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBmotorCur)+suffix] = m_pmCurrentState.bus1State.propulsionMotorControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.busbarACurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbusbarACurrent)+suffix] = m_pmCurrentState.bus1State.busbarACurrent;
|
||||
currentBusState[VAR_TO_STR(HVBbusACur)+suffix] = m_pmCurrentState.bus1State.busbarACurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.lithiumBatteryGroupMeterCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBlithiumBatteryGroupMeterCurrent)+suffix] = m_pmCurrentState.bus1State.lithiumBatteryGroupMeterCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBbatGroupCur)+suffix] = m_pmCurrentState.bus1State.lithiumBatteryGroupMeterCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.bowHighVoltageDistributionBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbowHighVoltageDistributionBoxCurrent)+suffix] = m_pmCurrentState.bus1State.bowHighVoltageDistributionBoxCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBbowHVolDisBoxCur)+suffix] = m_pmCurrentState.bus1State.bowHighVoltageDistributionBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.sternFTDevice45Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBsternFTDevice45Current)+suffix] = m_pmCurrentState.bus1State.sternFTDevice45Current;
|
||||
currentBusState[VAR_TO_STR(HVBFTDev45Cur)+suffix] = m_pmCurrentState.bus1State.sternFTDevice45Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.tyzReservedSwitchCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBtyzReservedSwitchCurrent)+suffix] = m_pmCurrentState.bus1State.tyzReservedSwitchCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBtyzCur)+suffix] = m_pmCurrentState.bus1State.tyzReservedSwitchCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.sternRudderSwitch1Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBsternRudderSwitch1Current)+suffix] = m_pmCurrentState.bus1State.sternRudderSwitch1Current;
|
||||
currentBusState[VAR_TO_STR(HVBsternRud1Cur)+suffix] = m_pmCurrentState.bus1State.sternRudderSwitch1Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.reservedCurrent1).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCurrent1)+suffix] = m_pmCurrentState.bus1State.reservedCurrent1;
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur1)+suffix] = m_pmCurrentState.bus1State.reservedCurrent1;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.sternRudderSwitch2Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBsternRudderSwitch2Current)+suffix] = m_pmCurrentState.bus1State.sternRudderSwitch2Current;
|
||||
currentBusState[VAR_TO_STR(HVBsternRud2Cur)+suffix] = m_pmCurrentState.bus1State.sternRudderSwitch2Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.reservedCurrent2).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCurrent2)+suffix] = m_pmCurrentState.bus1State.reservedCurrent2;
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur2)+suffix] = m_pmCurrentState.bus1State.reservedCurrent2;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.fbReservedSwitchCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBfbReservedSwitchCurrent)+suffix] = m_pmCurrentState.bus1State.fbReservedSwitchCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBfbCur)+suffix] = m_pmCurrentState.bus1State.fbReservedSwitchCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus1State.reservedCurrent3).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCurrent3)+suffix] = m_pmCurrentState.bus1State.reservedCurrent3;
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur3)+suffix] = m_pmCurrentState.bus1State.reservedCurrent3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.busbarBVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVABbusbarBVoltage)+suffix] = m_pmCurrentState.bus2State.busbarBVoltage;
|
||||
currentBusState[VAR_TO_STR(HVABbusBVol)+suffix] = m_pmCurrentState.bus2State.busbarBVoltage;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.busbarBCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABbusbarBCurrent)+suffix] = m_pmCurrentState.bus2State.busbarBCurrent;
|
||||
currentBusState[VAR_TO_STR(HVABbusBCur)+suffix] = m_pmCurrentState.bus2State.busbarBCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.bowFTDevice123Current).name());
|
||||
currentBusState[VAR_TO_STR(HVABbowFTDevice123Current)+suffix] = m_pmCurrentState.bus2State.bowFTDevice123Current;
|
||||
currentBusState[VAR_TO_STR(HVABFTDev123Cur)+suffix] = m_pmCurrentState.bus2State.bowFTDevice123Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.actuatorCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABactuatorCurrent)+suffix] = m_pmCurrentState.bus2State.actuatorCurrent;
|
||||
currentBusState[VAR_TO_STR(HVABactCur)+suffix] = m_pmCurrentState.bus2State.actuatorCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.mastSteeringGearControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABmastSteeringGearControlBoxCurrent)+suffix] = m_pmCurrentState.bus2State.mastSteeringGearControlBoxCurrent;
|
||||
currentBusState[VAR_TO_STR(HVABmastSteGeaCur)+suffix] = m_pmCurrentState.bus2State.mastSteeringGearControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.xczCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABxczCurrent)+suffix] = m_pmCurrentState.bus2State.xczCurrent;
|
||||
currentBusState[VAR_TO_STR(HVABxczCur)+suffix] = m_pmCurrentState.bus2State.xczCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.bowRudderControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABbowRudderControlBoxCurrent)+suffix] = m_pmCurrentState.bus2State.bowRudderControlBoxCurrent;
|
||||
currentBusState[VAR_TO_STR(HVABbowRudCur)+suffix] = m_pmCurrentState.bus2State.bowRudderControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus2State.openWaterCoverStartCylinderCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABopenWaterCoverStartCylinderCurrent)+suffix] = m_pmCurrentState.bus2State.openWaterCoverStartCylinderCurrent;
|
||||
currentBusState[VAR_TO_STR(HVABopenWaterCur)+suffix] = m_pmCurrentState.bus2State.openWaterCoverStartCylinderCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.instrumentBusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBBinstrumentBusbarVoltage)+suffix] = m_pmCurrentState.bus3State.instrumentBusbarVoltage;
|
||||
currentBusState[VAR_TO_STR(HVBBinsBusVol)+suffix] = m_pmCurrentState.bus3State.instrumentBusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.bowLowVoltageDistributionBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBbowLowVoltageDistributionBoxCurrent)+suffix] = m_pmCurrentState.bus3State.bowLowVoltageDistributionBoxCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBBbowLowVolDisBoxCur)+suffix] = m_pmCurrentState.bus3State.bowLowVoltageDistributionBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.dcC1InstrumentDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBdcC1InstrumentDC48VCurrent)+suffix] = m_pmCurrentState.bus3State.dcC1InstrumentDC48VCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBBdcC1InsCur)+suffix] = m_pmCurrentState.bus3State.dcC1InstrumentDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.reservedCurrent1).name());
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCurrent1)+suffix] = m_pmCurrentState.bus3State.reservedCurrent1;
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCur1)+suffix] = m_pmCurrentState.bus3State.reservedCurrent1;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.emergencyLithiumBatteryGroup2Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBBemergencyLithiumBatteryGroup2Current)+suffix] = m_pmCurrentState.bus3State.emergencyLithiumBatteryGroup2Current;
|
||||
currentBusState[VAR_TO_STR(HVBBemerBatCur)+suffix] = m_pmCurrentState.bus3State.emergencyLithiumBatteryGroup2Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.lithiumBatteryGroupInstrumentCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBlithiumBatteryGroupInstrumentCurrent)+suffix] = m_pmCurrentState.bus3State.lithiumBatteryGroupInstrumentCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBBbatInsCur)+suffix] = m_pmCurrentState.bus3State.lithiumBatteryGroupInstrumentCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.unit4InstrumentDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBunit4InstrumentDC48VCurrent)+suffix] = m_pmCurrentState.bus3State.unit4InstrumentDC48VCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBBunit4Cur)+suffix] = m_pmCurrentState.bus3State.unit4InstrumentDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.reservedCurrent2).name());
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCurrent2)+suffix] = m_pmCurrentState.bus3State.reservedCurrent2;
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCur2)+suffix] = m_pmCurrentState.bus3State.reservedCurrent2;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.emergency2BusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBBemergency2BusbarVoltage)+suffix] = m_pmCurrentState.bus3State.emergency2BusbarVoltage;
|
||||
currentBusState[VAR_TO_STR(HVBBemer2BusVol)+suffix] = m_pmCurrentState.bus3State.emergency2BusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBcompositeEnergyManagementSystemEmergencyDC48VCurrent)+suffix] = m_pmCurrentState.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBBCCUCur)+suffix] = m_pmCurrentState.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBfuelCellSecuritySystemEmergencyDC48VCurrent)+suffix] = m_pmCurrentState.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBBFCSSecurSysCur)+suffix] = m_pmCurrentState.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus3State.plcControlPowerCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBplcControlPowerCurrent)+suffix] = m_pmCurrentState.bus3State.plcControlPowerCurrent;
|
||||
currentBusState[VAR_TO_STR(HVBBplcCur)+suffix] = m_pmCurrentState.bus3State.plcControlPowerCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.instrumentBusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(LVBinstrumentBusbarVoltage)+suffix] = m_pmCurrentState.bus4State.instrumentBusbarVoltage;
|
||||
currentBusState[VAR_TO_STR(LVBinsBusVol)+suffix] = m_pmCurrentState.bus4State.instrumentBusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.instrumentBusbarCurrent).name());
|
||||
currentBusState[VAR_TO_STR(LVBBinstrumentBusbarCurrent)+suffix] = m_pmCurrentState.bus4State.instrumentBusbarCurrent;
|
||||
currentBusState[VAR_TO_STR(LVBBinsBusCur)+suffix] = m_pmCurrentState.bus4State.instrumentBusbarCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.unit1Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit1Current)+suffix] = m_pmCurrentState.bus4State.unit1Current;
|
||||
currentBusState[VAR_TO_STR(LVBBunit1Cur)+suffix] = m_pmCurrentState.bus4State.unit1Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.unit2Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit2Current)+suffix] = m_pmCurrentState.bus4State.unit2Current;
|
||||
currentBusState[VAR_TO_STR(LVBBunit2Cur)+suffix] = m_pmCurrentState.bus4State.unit2Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.unit3Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit3Current)+suffix] = m_pmCurrentState.bus4State.unit3Current;
|
||||
currentBusState[VAR_TO_STR(LVBBunit3Cur)+suffix] = m_pmCurrentState.bus4State.unit3Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.unit5Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit5Current)+suffix] = m_pmCurrentState.bus4State.unit5Current;
|
||||
currentBusState[VAR_TO_STR(LVBBunit5Cur)+suffix] = m_pmCurrentState.bus4State.unit5Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.bowPZDeviceCurrent).name());
|
||||
currentBusState[VAR_TO_STR(LVBBbowPZDeviceCurrent)+suffix] = m_pmCurrentState.bus4State.bowPZDeviceCurrent;
|
||||
currentBusState[VAR_TO_STR(LVBBbowPZDevCur)+suffix] = m_pmCurrentState.bus4State.bowPZDeviceCurrent;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBemergencyLithiumBatteryGroup1Current)+suffix] = m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1Current;
|
||||
currentBusState[VAR_TO_STR(LVBBemerBatCur)+suffix] = m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1Current;
|
||||
suffix = getTypeName(typeid(m_pmCurrentState.bus4State.emergency1BusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(LVBBemergency1BusbarVoltage)+suffix] = m_pmCurrentState.bus4State.emergency1BusbarVoltage;
|
||||
currentBusState[VAR_TO_STR(LVBBemerBusVol)+suffix] = m_pmCurrentState.bus4State.emergency1BusbarVoltage;
|
||||
|
||||
// dis["currentBusState"] = currentBusState;
|
||||
|
||||
@@ -733,4 +778,26 @@ bool PowerManger::saveStringToJsonFile(const string &strJson, const string &file
|
||||
std::cerr << "无法打开文件!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int PowerManger::handleState1(FSM_State &fsm,void* pData)
|
||||
{
|
||||
cout << fsm.name << endl;
|
||||
PowerManger* pm = (PowerManger*)pData;
|
||||
fsm = pm->m_fsm.getState("PM_STATE2");
|
||||
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");
|
||||
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");
|
||||
return 0;
|
||||
}
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "json/json.h"
|
||||
#include "udpComm.h"
|
||||
#include "pmSysvariable.h"
|
||||
#include "fsm.h"
|
||||
|
||||
#define VAR_TO_STR(var) #var
|
||||
|
||||
@@ -101,6 +102,20 @@ class PowerManger : public AppCastingMOOSApp
|
||||
// CMOOSThread m_SendThread;
|
||||
private: //
|
||||
bool inline saveStringToJsonFile(const string &strJson, const string &strFileName);
|
||||
|
||||
|
||||
public: //状态实现
|
||||
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);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
#include "fsm.h"
|
||||
|
||||
|
||||
|
||||
FSM::FSM(/* args */)
|
||||
{
|
||||
idStateMap.clear();
|
||||
handleMap.clear();
|
||||
stateMap.clear();
|
||||
};
|
||||
|
||||
FSM::~FSM()
|
||||
{
|
||||
};
|
||||
|
||||
int FSM::run(FSM_State &fsm,void* data)
|
||||
{
|
||||
FSM_Handle handle = handleMap[fsm.id];
|
||||
return handle(fsm,data);
|
||||
}
|
||||
int FSM::RegisterHandleFunction(FSM_State* fsm, FSM_Handle handle)
|
||||
{
|
||||
if(fsm == NULL)
|
||||
return -1;
|
||||
if(handleMap.count(fsm->id) > 0)
|
||||
return -1;
|
||||
handleMap[fsm->id] = handle;
|
||||
return 0;
|
||||
}
|
||||
int FSM::unRegisterHandleFunction(FSM_State* fsm)
|
||||
{
|
||||
if(fsm == NULL)
|
||||
return -1;
|
||||
if(handleMap.count(fsm->id) <= 0)
|
||||
return -1;
|
||||
handleMap.erase(fsm->id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FSM::RegisterState(std::string name, unsigned int id,FSM_State &state)
|
||||
{
|
||||
if(stateMap.count(name) > 0)
|
||||
return -1;
|
||||
if(idStateMap.count(id) > 0)
|
||||
return -1;
|
||||
state.name = name;
|
||||
state.id = id;
|
||||
stateMap[name] = state;
|
||||
idStateMap[id] = state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int FSM::getStateId(std::string name)
|
||||
{
|
||||
return stateMap[name].id;
|
||||
}
|
||||
|
||||
FSM_State FSM::getState(std::string name)
|
||||
{
|
||||
return stateMap[name];
|
||||
}
|
||||
|
||||
|
||||
// int FSM::RegisterEvent(FSM_State* fsm, std::string event, FSM_State state)
|
||||
// {
|
||||
// if(fsm == NULL)
|
||||
// return -1;
|
||||
// fsm->event[event] = state;
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// int FSM::unRegisterEvent(FSM_State* fsm, std::string event)
|
||||
// {
|
||||
// if(fsm == NULL)
|
||||
// return -1;
|
||||
// if(fsm->event.count(event) <= 0)
|
||||
// return -1;
|
||||
// fsm->event.erase(event);
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// int FSM::run(FSM_State &fsm,void* data, std::string event)
|
||||
// {
|
||||
// if(fsm.event.count(event) <= 0)
|
||||
// {
|
||||
// return run(fsm,data);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// fsm = fsm.event[event];
|
||||
// return run(fsm,data);
|
||||
// }
|
||||
|
||||
// }
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef FSM_H
|
||||
#define FSM_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
|
||||
typedef struct FSM_State
|
||||
{
|
||||
std::string name;
|
||||
unsigned int id;
|
||||
std::map<std::string,FSM_State*> event;
|
||||
};
|
||||
|
||||
typedef int (*FSM_Handle)(FSM_State &fsm, void *data);
|
||||
// typedef int (*FSM_EventHandle)(FSM_State &fsm,std::string event,void *data);
|
||||
|
||||
class FSM
|
||||
{
|
||||
public:
|
||||
FSM();
|
||||
~FSM();
|
||||
std::map<unsigned int, FSM_Handle> handleMap;
|
||||
std::map<std::string, FSM_State> stateMap;
|
||||
std::map<unsigned int, FSM_State> idStateMap;
|
||||
|
||||
int run(FSM_State &fsm,void* data);
|
||||
int run(FSM_State &fsm,void* data, std::string event);
|
||||
|
||||
//TODO: 事件注册机制实现
|
||||
int RegisterEvent(FSM_State* fsm, std::string event, FSM_State &state);
|
||||
int unRegisterEvent(FSM_State* fsm, std::string event);
|
||||
|
||||
int RegisterState(std::string name, unsigned int id,FSM_State &state);
|
||||
FSM_State getState(std::string name);
|
||||
unsigned int getStateId(std::string name);
|
||||
int RegisterHandleFunction(FSM_State* fsm, FSM_Handle handle);
|
||||
int unRegisterHandleFunction(FSM_State* fsm);
|
||||
};
|
||||
#endif
|
||||
@@ -44,22 +44,10 @@ bool udpComm::getMsgId(char *m,unsigned short &id)
|
||||
sError.push_back("Msg Header errar");
|
||||
return false;
|
||||
}
|
||||
bool udpComm::getCcuState(char *m, msg_CcuStateFbMsg &s) {
|
||||
m_header h;
|
||||
bool udpComm::getMsgFromBuff(char *m, msg_CcuStateFbMsg &s) {
|
||||
Checksum sum;
|
||||
msg_CcuStateFbMsg *p;
|
||||
p = reinterpret_cast<msg_CcuStateFbMsg *>(m);
|
||||
h = p->header;
|
||||
|
||||
// 判断消息是否有效
|
||||
// if (h.start1 != 0x20 || h.start2 != 0x20) {
|
||||
// sError.push_back("CcuState Msg Header errar");
|
||||
// return false;
|
||||
// }
|
||||
// if (h.id != 0x0051) {
|
||||
// sError.push_back("CcuState Msg ID error");
|
||||
// return false;
|
||||
// }
|
||||
sum = calculateChecksum((unsigned char*)m, sizeof(msg_CcuStateFbMsg));
|
||||
|
||||
if (sum != p->checkCode) {
|
||||
@@ -70,26 +58,11 @@ bool udpComm::getCcuState(char *m, msg_CcuStateFbMsg &s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udpComm::getCcuSetParmFb(char *m, msg_CcuSetParmFbMsg &s)
|
||||
bool udpComm::getMsgFromBuff(char *m, msg_CcuSetParmFbMsg &s)
|
||||
{
|
||||
m_header h;
|
||||
Checksum sum;
|
||||
msg_CcuSetParmFbMsg *p;
|
||||
p = reinterpret_cast<msg_CcuSetParmFbMsg *>(m);
|
||||
|
||||
h = p->header;
|
||||
|
||||
// 判断消息是否有效
|
||||
// if (h.start1!= 0x20 || h.start2!= 0x20) {
|
||||
// sError.push_back("CcuSetParm Msg Header errar");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (h.id!= 0x0040)
|
||||
// {
|
||||
// sError.push_back("CcuSetParm Msg ID error");
|
||||
// return false;
|
||||
// }
|
||||
sum = calculateChecksum((unsigned char*)m, sizeof(msg_CcuSetParmFbMsg));
|
||||
|
||||
if (sum!= p->checkCode) {
|
||||
@@ -101,22 +74,11 @@ bool udpComm::getCcuSetParmFb(char *m, msg_CcuSetParmFbMsg &s)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udpComm::getDisSysHVBusFb(char *m, msg_disHighVolBusFbMsg &s)
|
||||
bool udpComm::getMsgFromBuff(char *m, msg_disHighVolBusFbMsg &s)
|
||||
{
|
||||
m_header h;
|
||||
cChecksum sum;
|
||||
msg_disHighVolBusFbMsg *p;
|
||||
p = reinterpret_cast<msg_disHighVolBusFbMsg *>(m);
|
||||
h = p->header;
|
||||
// 判断消息是否有效
|
||||
// if (h.start1!= 0x20 || h.start2!= 0x20) {
|
||||
// sError.push_back("DisSys HVBus Msg Header errar");
|
||||
// return false;
|
||||
// }
|
||||
// if (h.id!= DIS_HVBUS_FB_ID) {
|
||||
// sError.push_back("DisSys HVBus Msg ID error");
|
||||
// return false;
|
||||
// }
|
||||
sum = calculateChecksum((unsigned char*)m, sizeof(msg_disHighVolBusFbMsg), sizeof(cChecksum)) & 0xFF;
|
||||
if (sum != p->checkCode) {
|
||||
sError.push_back("DisSys HVBus Msg Check error");
|
||||
@@ -127,22 +89,11 @@ bool udpComm::getDisSysHVBusFb(char *m, msg_disHighVolBusFbMsg &s)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udpComm::getDisSysHVABusFb(char *m, msg_disHighAVolBusFbMsg &s)
|
||||
bool udpComm::getMsgFromBuff(char *m, msg_disHighAVolBusFbMsg &s)
|
||||
{
|
||||
m_header h;
|
||||
cChecksum sum;
|
||||
msg_disHighAVolBusFbMsg *p;
|
||||
p = reinterpret_cast<msg_disHighAVolBusFbMsg *>(m);
|
||||
h = p->header;
|
||||
// 判断消息是否有效
|
||||
// if (h.start1!= 0x20 || h.start2!= 0x20) {
|
||||
// sError.push_back("DisSys HVABus Msg Header errar");
|
||||
// return false;
|
||||
// }
|
||||
// if (h.id!= DIS_HVBUSA_FB_ID) {
|
||||
// sError.push_back("DisSys HVABus Msg ID error");
|
||||
// return false;
|
||||
// }
|
||||
sum = calculateChecksum((unsigned char*)m, sizeof(msg_disHighAVolBusFbMsg), sizeof(cChecksum)) & 0xFF;
|
||||
if (sum!= p->checkCode) {
|
||||
sError.push_back("DisSys HVABus Msg Check error");
|
||||
@@ -151,22 +102,11 @@ bool udpComm::getDisSysHVABusFb(char *m, msg_disHighAVolBusFbMsg &s)
|
||||
s = *p;
|
||||
return true;
|
||||
}
|
||||
bool udpComm::getDisSysHVBBusFb(char *m, msg_disHighBVolBusFbMsg &s)
|
||||
bool udpComm::getMsgFromBuff(char *m, msg_disHighBVolBusFbMsg &s)
|
||||
{
|
||||
m_header h;
|
||||
cChecksum sum;
|
||||
msg_disHighBVolBusFbMsg *p;
|
||||
p = reinterpret_cast<msg_disHighBVolBusFbMsg *>(m);
|
||||
h = p->header;
|
||||
// 判断消息是否有效
|
||||
// if (h.start1!= 0x20 || h.start2!= 0x20) {
|
||||
// sError.push_back("DisSys HVBBus Msg Header errar");
|
||||
// return false;
|
||||
// }
|
||||
// if (h.id!= DIS_HVBUSB_FB_ID) {
|
||||
// sError.push_back("DisSys HVBBus Msg ID error");
|
||||
// return false;
|
||||
// }
|
||||
sum = calculateChecksum((unsigned char*)m, sizeof(msg_disHighBVolBusFbMsg), sizeof(cChecksum)) & 0xFF;
|
||||
if (sum!= p->checkCode) {
|
||||
sError.push_back("DisSys HVBBus Msg Check error");
|
||||
@@ -176,22 +116,11 @@ bool udpComm::getDisSysHVBBusFb(char *m, msg_disHighBVolBusFbMsg &s)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udpComm::getDisSysLVBusFb(char *m, msg_disLowBusFbMsg &s)
|
||||
bool udpComm::getMsgFromBuff(char *m, msg_disLowBusFbMsg &s)
|
||||
{
|
||||
m_header h;
|
||||
cChecksum sum;
|
||||
msg_disLowBusFbMsg *p;
|
||||
p = reinterpret_cast<msg_disLowBusFbMsg *>(m);
|
||||
h = p->header;
|
||||
// 判断消息是否有效
|
||||
// if (h.start1!= 0x20 || h.start2!= 0x20) {
|
||||
// sError.push_back("DisSys LVBus Msg Header errar");
|
||||
// return false;
|
||||
// }
|
||||
// if (h.id!= DIS_LVBUS_FB_ID) {
|
||||
// sError.push_back("DisSys LVBus Msg ID error");
|
||||
// return false;
|
||||
// }
|
||||
sum = calculateChecksum((unsigned char*)m, sizeof(msg_disLowBusFbMsg), sizeof(cChecksum)) & 0xFF;
|
||||
if (sum!= p->checkCode) {
|
||||
sError.push_back("DisSys LVBus Msg Check error");
|
||||
@@ -208,8 +137,9 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
sError.push_back("pushMsgToQueue faile,Msg is NULL");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned char* Buff = m;
|
||||
//判断消息
|
||||
//消息头鉴定
|
||||
char *header = new char[sizeof(m_header)];
|
||||
unsigned short id;
|
||||
memcpy(header,Buff,sizeof(m_header));
|
||||
@@ -224,7 +154,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
{
|
||||
case CCU_STATE_FB_ID: //CCU_STATE_FB 0x0051
|
||||
{ msg_CcuStateFbMsg s;
|
||||
if(getCcuState((char *)Buff,s))
|
||||
if(getMsgFromBuff((char *)Buff,s))
|
||||
{
|
||||
if(m_qReceiveCcuStateBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
@@ -247,7 +177,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
case CCU_SET_PARM_FB_ID: //CCU_SET_PARM_FB 0x0040
|
||||
{
|
||||
msg_CcuSetParmFbMsg s;
|
||||
if(getCcuSetParmFb((char *)Buff,s))
|
||||
if(getMsgFromBuff((char *)Buff,s))
|
||||
{
|
||||
if(m_qReceiveCcuSetParmBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
@@ -269,7 +199,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
case DIS_HVBUS_FB_ID: //DIS_HVBUS_FB 0x0020
|
||||
{
|
||||
msg_disHighVolBusFbMsg s;
|
||||
if(getDisSysHVBusFb((char *)Buff,s))
|
||||
if(getMsgFromBuff((char *)Buff,s))
|
||||
{
|
||||
if(m_qReceiveDisHighVolBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
@@ -291,7 +221,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
case DIS_HVBUSA_FB_ID: //DIS_HVBUSA_FB 0x0006
|
||||
{
|
||||
msg_disHighAVolBusFbMsg s;
|
||||
if(getDisSysHVABusFb((char *)Buff,s))
|
||||
if(getMsgFromBuff((char *)Buff,s))
|
||||
{
|
||||
if(m_qReceiveDisHighAVolBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
@@ -313,7 +243,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
case DIS_HVBUSB_FB_ID: //DIS_HVBUSB_FB 0x0007
|
||||
{
|
||||
msg_disHighBVolBusFbMsg s;
|
||||
if(getDisSysHVBBusFb((char *)Buff,s))
|
||||
if(getMsgFromBuff((char *)Buff,s))
|
||||
{
|
||||
if(m_qReceiveDisHighBVolBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
@@ -335,7 +265,7 @@ bool udpComm::pushMsgToQueue(unsigned char *m)
|
||||
case DIS_LVBUS_FB_ID: //DIS_LVBUS_FB 0x0008
|
||||
{
|
||||
msg_disLowBusFbMsg s;
|
||||
if(getDisSysLVBusFb((char *)Buff,s))
|
||||
if(getMsgFromBuff((char *)Buff,s))
|
||||
{
|
||||
if(m_qReceiveDisLowBusBuffer.size()<QUENUE_SIZE)
|
||||
{
|
||||
|
||||
+14
-16
@@ -20,22 +20,15 @@ public:
|
||||
~udpComm();
|
||||
|
||||
bool pushMsgToQueue(unsigned char *m);
|
||||
|
||||
bool getCcuState(char *m, msg_CcuStateFbMsg &s);
|
||||
bool getCcuSetParmFb(char *m, msg_CcuSetParmFbMsg &s);
|
||||
|
||||
bool getDisSysHVBusFb(char *m, msg_disHighVolBusFbMsg &s);
|
||||
bool getDisSysHVABusFb(char *m, msg_disHighAVolBusFbMsg &s);
|
||||
bool getDisSysHVBBusFb(char *m, msg_disHighBVolBusFbMsg &s);
|
||||
bool getDisSysLVBusFb(char *m, msg_disLowBusFbMsg &s);
|
||||
|
||||
bool sendCcuColCmd(const msg_CcuColCmdMsg m);
|
||||
bool sendCcuSetParmCmd(const msg_CcuSetParmMsg m);
|
||||
|
||||
bool clearMsgQueue();
|
||||
bool getMsgId(char *m,unsigned short &id);
|
||||
Checksum calculateChecksum(const unsigned char* data, int size);
|
||||
Checksum calculateChecksum(const unsigned char* data, int dataSize, int checkSize);
|
||||
|
||||
bool getMsgFromBuff(char *m, msg_CcuStateFbMsg &s);
|
||||
bool getMsgFromBuff(char *m, msg_CcuSetParmFbMsg &s);
|
||||
bool getMsgFromBuff(char *m, msg_disHighVolBusFbMsg &s);
|
||||
bool getMsgFromBuff(char *m, msg_disHighAVolBusFbMsg &s);
|
||||
bool getMsgFromBuff(char *m, msg_disHighBVolBusFbMsg &s);
|
||||
bool getMsgFromBuff(char *m, msg_disLowBusFbMsg &s);
|
||||
|
||||
bool popMsgFormQueue(double &time,msg_CcuStateFbMsg &m);
|
||||
bool popMsgFormQueue(double &time,msg_CcuSetParmFbMsg &m);
|
||||
bool popMsgFormQueue(double &time,msg_disHighVolBusFbMsg &m);
|
||||
@@ -43,9 +36,14 @@ public:
|
||||
bool popMsgFormQueue(double &time,msg_disHighBVolBusFbMsg &m);
|
||||
bool popMsgFormQueue(double &time,msg_disLowBusFbMsg &m);
|
||||
|
||||
bool sendCcuColCmd(const msg_CcuColCmdMsg m);
|
||||
bool sendCcuSetParmCmd(const msg_CcuSetParmMsg m);
|
||||
|
||||
bool getMsgId(char *m,unsigned short &id);
|
||||
Checksum calculateChecksum(const unsigned char* data, int size);
|
||||
Checksum calculateChecksum(const unsigned char* data, int dataSize, int checkSize);
|
||||
|
||||
std::vector<std::string> sError;
|
||||
|
||||
std::pair<int, std::string> getError();
|
||||
|
||||
// std::queue<msgWithTime> m_qReceiveCcuStateBuffer;
|
||||
|
||||
Reference in New Issue
Block a user