#ifndef U_POWER_CURRENTSTATE_ST_H #define U_POWER_CURRENTSTATE_ST_H #include "../driver.h" #include "string" #include "json/json.h" #include class uPower_currentStateMsg { private: /* data */ public: uPower_currentStateMsg() { memset(&state, 0, sizeof(state)); }; ~uPower_currentStateMsg() {}; std::string key = "uPower_currentState_st"; pmState state; std::string buildMsg(pmState state) { // 状态赋值 Json::Value currentBusState; currentBusState["HVBpowerBusVol_uint16"] = state.bus1State.powerBusVoltage; currentBusState["HVBdcDc5Cur_uint16"] = state.bus1State.dcDc5ModuleCurrent; currentBusState["HVBpowerBusCur_uint16"] = state.bus1State.powerBusCurrent; currentBusState["HVBbusAVol_uint16"] = state.bus1State.busbarAVoltage; currentBusState["HVBmotorCur_uint16"] = state.bus1State.propulsionMotorControlBoxCurrent; currentBusState["HVBbusACur_uint16"] = state.bus1State.busbarACurrent; currentBusState["HVBbatGroupCur_uint16"] = state.bus1State.lithiumBatteryGroupMeterCurrent; currentBusState["HVBbowHVolDisBoxCur_uint16"] = state.bus1State.bowHighVoltageDistributionBoxCurrent; currentBusState["HVBFTDev45Cur_uint16"] = state.bus1State.sternFTDevice45Current; currentBusState["HVBtyzCur_uint16"] = state.bus1State.tyzReservedSwitchCurrent; currentBusState["HVBsternRud1Cur_uint16"] = state.bus1State.sternRudderSwitch1Current; currentBusState["HVBreservedCur1_uint16"] = state.bus1State.reservedCurrent1; currentBusState["HVBsternRud2Cur_uint16"] = state.bus1State.sternRudderSwitch2Current; currentBusState["HVBreservedCur2_uint16"] = state.bus1State.reservedCurrent2; currentBusState["HVBfbCur_uint16"] = state.bus1State.fbReservedSwitchCurrent; currentBusState["HVBreservedCur3_uint16"] = state.bus1State.reservedCurrent3; currentBusState["HVABbusBVol_uint16"] = state.bus2State.busbarBVoltage; currentBusState["HVABbusBCur_uint16"] = state.bus2State.busbarBCurrent; currentBusState["HVABFTDev123Cur_uint16"] = state.bus2State.bowFTDevice123Current; currentBusState["HVABactCur_uint16"] = state.bus2State.actuatorCurrent; currentBusState["HVABmastSteGeaCur_uint16"] = state.bus2State.mastSteeringGearControlBoxCurrent; currentBusState["HVABxczCur_uint16"] = state.bus2State.xczCurrent; currentBusState["HVABbowRudCur_uint16"] = state.bus2State.bowRudderControlBoxCurrent; currentBusState["HVABopenWaterCur_uint16"] = state.bus2State.openWaterCoverStartCylinderCurrent; currentBusState["HVBBinsBusVol_uint16"] = state.bus3State.instrumentBusbarVoltage; currentBusState["HVBBbowLowVolDisBoxCur_uint16"] = state.bus3State.bowLowVoltageDistributionBoxCurrent; currentBusState["HVBBdcC1InsCur_uint16"] = state.bus3State.dcC1InstrumentDC48VCurrent; currentBusState["HVBBreservedCur1_uint16"] = state.bus3State.reservedCurrent1; currentBusState["HVBBemerBatCur_uint16"] = state.bus3State.emergencyLithiumBatteryGroup2Current; currentBusState["HVBBbatInsCur_uint16"] = state.bus3State.lithiumBatteryGroupInstrumentCurrent; currentBusState["HVBBunit4Cur_uint16"] = state.bus3State.unit4InstrumentDC48VCurrent; currentBusState["HVBBreservedCur2_uint16"] = state.bus3State.reservedCurrent2; currentBusState["HVBBemer2BusVol_uint16"] = state.bus3State.emergency2BusbarVoltage; currentBusState["HVBBCCUCur_uint16"] = state.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent; currentBusState["HVBBFCSSecurSysCur_uint16"] = state.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent; currentBusState["HVBBplcCur_uint16"] = state.bus3State.plcControlPowerCurrent; currentBusState["LVBinsBusVol_uint16"] = state.bus4State.instrumentBusbarVoltage; currentBusState["LVBBinsBusCur_uint16"] = state.bus4State.instrumentBusbarCurrent; currentBusState["LVBBunit1Cur_uint16"] = state.bus4State.unit1Current; currentBusState["LVBBunit2Cur_uint16"] = state.bus4State.unit2Current; currentBusState["LVBBunit3Cur_uint16"] = state.bus4State.unit3Current; currentBusState["LVBBunit5Cur_uint16"] = state.bus4State.unit5Current; currentBusState["LVBBbowPZDevCur_uint16"] = state.bus4State.bowPZDeviceCurrent; currentBusState["LVBBemerBatCur_uint16"] = state.bus4State.emergencyLithiumBatteryGroup1Current; currentBusState["LVBBemerBusVol_uint16"] = state.bus4State.emergency1BusbarVoltage; // 转化为json格式 Json::StreamWriterBuilder writerBuilder; writerBuilder.settings_["indentation"] = ""; return Json::writeString(writerBuilder, currentBusState); } }; #endif