优化了上位机的通信函数
This commit is contained in:
@@ -32,14 +32,442 @@ bool UpperCommManager::processUpperMsg(const string& key, const string& strJson)
|
||||
}
|
||||
|
||||
void UpperCommManager::processPeriodicTasks() {
|
||||
buildPowerSysReport();
|
||||
Notify(PM_TO_DB_SUBDISCMD,
|
||||
m_pm->m_driver.saveDriverTableToJson(&m_pm->m_subDisSysCmd));
|
||||
Notify(PM_TO_DB_EQUIPMENTSTATE,
|
||||
m_pm->m_driver.saveDriverTableToJson(&m_pm->m_currentDriverState));
|
||||
buildSystemReport();
|
||||
// m_pm->Notify(PM_TO_DB_SUBDISCMD, m_pm->m_driver.saveDriverTableToJson(&m_pm->m_subDisSysCmd));
|
||||
// m_pm->Notify(PM_TO_DB_EQUIPMENTSTATE, m_pm->m_driver.saveDriverTableToJson(&m_pm->m_currentDriverState));
|
||||
}
|
||||
|
||||
void UpperCommManager::buildPowerSysReport() {
|
||||
// 原有buildPowerSysReport实现
|
||||
// 需要从PowerManger.cpp迁移过来
|
||||
void UpperCommManager::buildSystemReport() {
|
||||
//TODO: 构建能源系统报告
|
||||
string suffix;
|
||||
Json::Value pms;
|
||||
Json::Value fcs;
|
||||
Json::Value lbs;
|
||||
Json::Value dis;
|
||||
// 构建能源系统报告
|
||||
//1.构建系统状态报告
|
||||
suffix = getTypeName(typeid(m_pm->workCondition).name());
|
||||
pms[VAR_TO_STR(workCondition)+suffix] = m_pm->workCondition;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->currentMod).name());
|
||||
pms[VAR_TO_STR(currentMod)+suffix] = m_pm->currentMod;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->powerState).name());
|
||||
pms[VAR_TO_STR(powerState)+suffix] = m_pm->powerState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->falutLevel).name());
|
||||
pms[VAR_TO_STR(falutLevel)+suffix] = m_pm->falutLevel;
|
||||
|
||||
Json::Value faultCode_array;
|
||||
for(auto val : m_pm->faultCode)
|
||||
{
|
||||
faultCode_array.append(val);
|
||||
}
|
||||
pms[VAR_TO_STR(faultCode_array)] = faultCode_array;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->soc).name());
|
||||
pms[VAR_TO_STR(soc)+suffix] = m_pm->soc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->sustainableTime).name());
|
||||
pms[VAR_TO_STR(sustainableTime)+suffix] = m_pm->sustainableTime;
|
||||
|
||||
//2.构建燃料电池状态报告
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuState).name());
|
||||
fcs[VAR_TO_STR(fcuState)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuFaultLeve).name());
|
||||
fcs[VAR_TO_STR(fcuFaultLeve)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuFaultLeve;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerLimit).name());
|
||||
fcs[VAR_TO_STR(powLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.powerLimit;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.totalPowerGeneration).name());
|
||||
fcs[VAR_TO_STR(powerGen)+suffix] = m_pm->m_pmCurrentState.ccustate.totalPowerGeneration;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.ch4o).name());
|
||||
fcs[VAR_TO_STR(ch4o)+suffix] = m_pm->m_pmCurrentState.ccustate.ch4o;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2).name());
|
||||
fcs[VAR_TO_STR(o2)+suffix] = m_pm->m_pmCurrentState.ccustate.o2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuVoltage).name());
|
||||
fcs[VAR_TO_STR(fcuVol)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrent).name());
|
||||
fcs[VAR_TO_STR(fcuCur)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2Level).name());
|
||||
fcs[VAR_TO_STR(o2Level)+suffix] = m_pm->m_pmCurrentState.ccustate.o2Level;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.exchangerTemperature).name());
|
||||
fcs[VAR_TO_STR(excTemp)+suffix] = m_pm->m_pmCurrentState.ccustate.exchangerTemperature;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuOutPower).name());
|
||||
fcs[VAR_TO_STR(fcuOutPower)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuOutPower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuOutIns).name());
|
||||
fcs[VAR_TO_STR(fcuOutIns)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuOutIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuVoltageIns).name());
|
||||
fcs[VAR_TO_STR(fcuVolIns)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuVoltageIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuVoltagePower).name());
|
||||
fcs[VAR_TO_STR(fcuVolPower)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuVoltagePower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentIns).name());
|
||||
fcs[VAR_TO_STR(fcuCurIns)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentPower).name());
|
||||
fcs[VAR_TO_STR(fcuCurPower)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentPower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.h2Concentration1).name());
|
||||
fcs[VAR_TO_STR(h2Concent1)+suffix] = m_pm->m_pmCurrentState.ccustate.h2Concentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.h2Concentration2).name());
|
||||
fcs[VAR_TO_STR(h2Concent2)+suffix] = m_pm->m_pmCurrentState.ccustate.h2Concentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2Concentration1).name());
|
||||
fcs[VAR_TO_STR(o2Concent1)+suffix] = m_pm->m_pmCurrentState.ccustate.o2Concentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2Concentration2).name());
|
||||
fcs[VAR_TO_STR(o2Concent2)+suffix] = m_pm->m_pmCurrentState.ccustate.o2Concentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.ch4oConcentration1).name());
|
||||
fcs[VAR_TO_STR(ch4oConcent1)+suffix] = m_pm->m_pmCurrentState.ccustate.ch4oConcentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.ch4oConcentration2).name());
|
||||
fcs[VAR_TO_STR(ch4oConcent2)+suffix] = m_pm->m_pmCurrentState.ccustate.ch4oConcentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.backpressure1).name());
|
||||
fcs[VAR_TO_STR(backpressure1)+suffix] = m_pm->m_pmCurrentState.ccustate.backpressure1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.backpressure2).name());
|
||||
fcs[VAR_TO_STR(backpressure2)+suffix] = m_pm->m_pmCurrentState.ccustate.backpressure2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.flameDetection).name());
|
||||
fcs[VAR_TO_STR(flameDet)+suffix] = m_pm->m_pmCurrentState.ccustate.flameDetection;
|
||||
|
||||
unsigned short faultCode1;
|
||||
unsigned short faultCode2;
|
||||
unsigned short faultCode3;
|
||||
faultCode1 = (m_pm->m_pmCurrentState.ccustate.fcuGZ_1H << 8) | m_pm->m_pmCurrentState.ccustate.fcuGZ_1L;
|
||||
faultCode2 = (m_pm->m_pmCurrentState.ccustate.fcuGZ_2H << 8) | m_pm->m_pmCurrentState.ccustate.fcuGZ_2L;
|
||||
faultCode3 = (m_pm->m_pmCurrentState.ccustate.fcuGZ_3H << 8) | m_pm->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_pm->m_pmCurrentState.ccustate.insPosRelayState).name());
|
||||
lbs[VAR_TO_STR(insPosRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.insPosRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insNegRelayState).name());
|
||||
lbs[VAR_TO_STR(insNegRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.insNegRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPosRelayState).name());
|
||||
lbs[VAR_TO_STR(powPosRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPosRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerNegRelayState).name());
|
||||
lbs[VAR_TO_STR(powNegRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerNegRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatLimit).name());
|
||||
lbs[VAR_TO_STR(insBatLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatLimit;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatLimit).name());
|
||||
lbs[VAR_TO_STR(powerBatLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatLimit;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatSoc).name());
|
||||
lbs[VAR_TO_STR(insBatSoc)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatSoc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatSoc).name());
|
||||
lbs[VAR_TO_STR(powBatSoc)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatSoc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatTotalElectricity).name());
|
||||
lbs[VAR_TO_STR(insBatTotalElect)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatTotalElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatTotalElectricity).name());
|
||||
lbs[VAR_TO_STR(powBatTotalElect)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatTotalElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatCurrentElectricity).name());
|
||||
lbs[VAR_TO_STR(insBatCurElect)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatCurrentElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatCurrentElectricity).name());
|
||||
lbs[VAR_TO_STR(powBatCurElect)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatCurrentElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insChargeState).name());
|
||||
lbs[VAR_TO_STR(insChargeState)+suffix] = m_pm->m_pmCurrentState.ccustate.insChargeState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerChargeState).name());
|
||||
lbs[VAR_TO_STR(powChargeState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerChargeState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insLinkVoltage).name());
|
||||
lbs[VAR_TO_STR(insLinkVol)+suffix] = m_pm->m_pmCurrentState.ccustate.insLinkVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPackVoltage).name());
|
||||
lbs[VAR_TO_STR(insPackVol)+suffix] = m_pm->m_pmCurrentState.ccustate.insPackVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrent).name());
|
||||
lbs[VAR_TO_STR(insCurrent)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPosInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(insPosRes)+suffix] = m_pm->m_pmCurrentState.ccustate.insPosInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insNegInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(insNegRes)+suffix] = m_pm->m_pmCurrentState.ccustate.insNegInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerLinkVoltage).name());
|
||||
lbs[VAR_TO_STR(powLinkVol)+suffix] = m_pm->m_pmCurrentState.ccustate.powerLinkVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPackVoltage).name());
|
||||
lbs[VAR_TO_STR(powerPackVol)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPackVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrent).name());
|
||||
lbs[VAR_TO_STR(powCur)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPosInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(powPosRes)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPosInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerNegInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(powNegRes)+suffix] = m_pm->m_pmCurrentState.ccustate.powerNegInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold1).name());
|
||||
lbs[VAR_TO_STR(insCurSocHold1)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold2).name());
|
||||
lbs[VAR_TO_STR(insCurSocHold2)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold3).name());
|
||||
lbs[VAR_TO_STR(insCurSocHold3)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentToInsLimit1).name());
|
||||
lbs[VAR_TO_STR(fcuCurToInsLimit1)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentToInsLimit1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentToinsLimit2).name());
|
||||
lbs[VAR_TO_STR(fcuCurToinsLimit2)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentToinsLimit2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold1).name());
|
||||
lbs[VAR_TO_STR(powCurSocHold1)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold2).name());
|
||||
lbs[VAR_TO_STR(powCurSocHold2)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold3).name());
|
||||
lbs[VAR_TO_STR(powCurSocHold3)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentToInsLimit1).name());
|
||||
lbs[VAR_TO_STR(powCurToInsLimit1)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentToInsLimit1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentToinsLimit2).name());
|
||||
lbs[VAR_TO_STR(powCurToinsLimit2)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentToinsLimit2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insAlarmIdentificationWord).name());
|
||||
lbs[VAR_TO_STR(insfaultCode)+suffix] = m_pm->m_pmCurrentState.ccustate.insAlarmIdentificationWord;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerAlarmIdentificationWord).name());
|
||||
lbs[VAR_TO_STR(powfaultCode)+suffix] = m_pm->m_pmCurrentState.ccustate.powerAlarmIdentificationWord;
|
||||
|
||||
//5.构建配电系统状态报告
|
||||
disBus1Breaker* pdis1=new disBus1Breaker;
|
||||
disBus2Breaker* pdis2=new disBus2Breaker;
|
||||
disBus3Breaker* pdis3=new disBus3Breaker;
|
||||
disBus4Breaker* pdis4=new disBus4Breaker;
|
||||
|
||||
*pdis1 = m_pm->m_currentDisBreakerState.bus1Breaker;
|
||||
*pdis2 = m_pm->m_currentDisBreakerState.bus2Breaker;
|
||||
*pdis3 = m_pm->m_currentDisBreakerState.bus3Breaker;
|
||||
*pdis4 = m_pm->m_currentDisBreakerState.bus4Breaker;
|
||||
|
||||
dis["HVolBusBreaker_uint16"] = *(unsigned short*)pdis1;
|
||||
dis["HVolABusBreaker_unit16"] = *(unsigned short*)pdis2;
|
||||
dis["HVolBBusBreaker_unit16"] = *(unsigned short*)pdis3;
|
||||
dis["LVolBusBreaker_uint16"] = *(unsigned short*)pdis4;
|
||||
|
||||
//TODO: 构建配电系统故障码
|
||||
Json::Value faultCodeDis_array;
|
||||
for(auto val : m_pm->faultCode)
|
||||
{
|
||||
faultCodeDis_array.append(val);
|
||||
}
|
||||
dis[VAR_TO_STR(faultCode_array)] = faultCodeDis_array;
|
||||
|
||||
|
||||
Json::Value currentBusState;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.powerBusVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusVol)+suffix] = m_pm->m_pmCurrentState.bus1State.powerBusVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.dcDc5ModuleCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBdcDc5Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.dcDc5ModuleCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.powerBusCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusCur)+suffix] = m_pm->m_pmCurrentState.bus1State.powerBusCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.busbarAVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBbusAVol)+suffix] = m_pm->m_pmCurrentState.bus1State.busbarAVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.propulsionMotorControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBmotorCur)+suffix] = m_pm->m_pmCurrentState.bus1State.propulsionMotorControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.busbarACurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbusACur)+suffix] = m_pm->m_pmCurrentState.bus1State.busbarACurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.lithiumBatteryGroupMeterCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbatGroupCur)+suffix] = m_pm->m_pmCurrentState.bus1State.lithiumBatteryGroupMeterCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.bowHighVoltageDistributionBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbowHVolDisBoxCur)+suffix] = m_pm->m_pmCurrentState.bus1State.bowHighVoltageDistributionBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.sternFTDevice45Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBFTDev45Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.sternFTDevice45Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.tyzReservedSwitchCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBtyzCur)+suffix] = m_pm->m_pmCurrentState.bus1State.tyzReservedSwitchCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.sternRudderSwitch1Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBsternRud1Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.sternRudderSwitch1Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.reservedCurrent1).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur1)+suffix] = m_pm->m_pmCurrentState.bus1State.reservedCurrent1;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.sternRudderSwitch2Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBsternRud2Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.sternRudderSwitch2Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.reservedCurrent2).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur2)+suffix] = m_pm->m_pmCurrentState.bus1State.reservedCurrent2;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.fbReservedSwitchCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBfbCur)+suffix] = m_pm->m_pmCurrentState.bus1State.fbReservedSwitchCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.reservedCurrent3).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur3)+suffix] = m_pm->m_pmCurrentState.bus1State.reservedCurrent3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.busbarBVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVABbusBVol)+suffix] = m_pm->m_pmCurrentState.bus2State.busbarBVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.busbarBCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABbusBCur)+suffix] = m_pm->m_pmCurrentState.bus2State.busbarBCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.bowFTDevice123Current).name());
|
||||
currentBusState[VAR_TO_STR(HVABFTDev123Cur)+suffix] = m_pm->m_pmCurrentState.bus2State.bowFTDevice123Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.actuatorCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABactCur)+suffix] = m_pm->m_pmCurrentState.bus2State.actuatorCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.mastSteeringGearControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABmastSteGeaCur)+suffix] = m_pm->m_pmCurrentState.bus2State.mastSteeringGearControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.xczCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABxczCur)+suffix] = m_pm->m_pmCurrentState.bus2State.xczCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.bowRudderControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABbowRudCur)+suffix] = m_pm->m_pmCurrentState.bus2State.bowRudderControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.openWaterCoverStartCylinderCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABopenWaterCur)+suffix] = m_pm->m_pmCurrentState.bus2State.openWaterCoverStartCylinderCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.instrumentBusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBBinsBusVol)+suffix] = m_pm->m_pmCurrentState.bus3State.instrumentBusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.bowLowVoltageDistributionBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBbowLowVolDisBoxCur)+suffix] = m_pm->m_pmCurrentState.bus3State.bowLowVoltageDistributionBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.dcC1InstrumentDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBdcC1InsCur)+suffix] = m_pm->m_pmCurrentState.bus3State.dcC1InstrumentDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.reservedCurrent1).name());
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCur1)+suffix] = m_pm->m_pmCurrentState.bus3State.reservedCurrent1;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.emergencyLithiumBatteryGroup2Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBBemerBatCur)+suffix] = m_pm->m_pmCurrentState.bus3State.emergencyLithiumBatteryGroup2Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.lithiumBatteryGroupInstrumentCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBbatInsCur)+suffix] = m_pm->m_pmCurrentState.bus3State.lithiumBatteryGroupInstrumentCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.unit4InstrumentDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBunit4Cur)+suffix] = m_pm->m_pmCurrentState.bus3State.unit4InstrumentDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.reservedCurrent2).name());
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCur2)+suffix] = m_pm->m_pmCurrentState.bus3State.reservedCurrent2;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.emergency2BusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBBemer2BusVol)+suffix] = m_pm->m_pmCurrentState.bus3State.emergency2BusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBCCUCur)+suffix] = m_pm->m_pmCurrentState.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBFCSSecurSysCur)+suffix] = m_pm->m_pmCurrentState.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.plcControlPowerCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBplcCur)+suffix] = m_pm->m_pmCurrentState.bus3State.plcControlPowerCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.instrumentBusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(LVBinsBusVol)+suffix] = m_pm->m_pmCurrentState.bus4State.instrumentBusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.instrumentBusbarCurrent).name());
|
||||
currentBusState[VAR_TO_STR(LVBBinsBusCur)+suffix] = m_pm->m_pmCurrentState.bus4State.instrumentBusbarCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit1Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit1Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit1Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit2Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit2Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit2Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit3Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit3Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit3Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit5Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit5Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit5Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.bowPZDeviceCurrent).name());
|
||||
currentBusState[VAR_TO_STR(LVBBbowPZDevCur)+suffix] = m_pm->m_pmCurrentState.bus4State.bowPZDeviceCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBemerBatCur)+suffix] = m_pm->m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.emergency1BusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(LVBBemerBusVol)+suffix] = m_pm->m_pmCurrentState.bus4State.emergency1BusbarVoltage;
|
||||
|
||||
// dis["currentBusState"] = currentBusState;
|
||||
|
||||
// pms[VAR_TO_STR(fcs_obj)] = fcs;
|
||||
// pms[VAR_TO_STR(lbs_obj)] = lbs;
|
||||
// pms[VAR_TO_STR(dis_obj)] = dis;
|
||||
|
||||
m_pm->sendNotification(PM_TO_DB_STATE, pms.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_FCSSTATE, fcs.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_LIBATSTATE, lbs.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_DISSTATE, dis.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_CURRENTSTATE, currentBusState.toStyledString());
|
||||
|
||||
// 使用StreamWriterBuilder来设置保持插入顺序
|
||||
Json::StreamWriterBuilder builder;
|
||||
builder["indentation"] = " "; // 设置不缩进,保持紧凑格式
|
||||
builder["enableYAMLCompatibility"] = true; // 保持插入顺序
|
||||
|
||||
// 将Json::Value对象转换为字符串
|
||||
string pathFile = "/home/zjk/project/H100/H100PowerManger/data/msg/";
|
||||
string jsonStr = Json::writeString(builder, pms);
|
||||
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_STATE+".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, fcs);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_FCSSTATE+".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, lbs);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_LIBATSTATE+".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, dis);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_DISSTATE + ".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, currentBusState);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_CURRENTSTATE + ".json");
|
||||
|
||||
// return true;
|
||||
}
|
||||
bool UpperCommManager::saveStringToJsonFile(const string &strJson, const string &filePath)
|
||||
{
|
||||
std::ofstream file(filePath, std::ios::trunc);
|
||||
if (file.is_open()) {
|
||||
file << strJson;
|
||||
file.close();
|
||||
// std::cout << "字符串已成功保存到文件中。" << std::endl;
|
||||
return true;
|
||||
} else {
|
||||
std::cerr << "无法打开文件!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
string UpperCommManager::getTypeName(const string typeName)
|
||||
{
|
||||
// 映射类型名称到指定的字符串
|
||||
if (typeName == "i" || typeName == "c") {
|
||||
return "_int8";
|
||||
} else if (typeName == "h" || typeName == "C") {
|
||||
return "_uint8";
|
||||
} else if (typeName == "s" || typeName == "S") {
|
||||
return "_int16";
|
||||
} else if (typeName == "t" || typeName == "T") {
|
||||
return "_uint16";
|
||||
} else if (typeName == "i" || typeName == "I") {
|
||||
return "_int32";
|
||||
} else if (typeName == "j" || typeName == "J") {
|
||||
return "_uint32";
|
||||
} else if (typeName == "x" || typeName == "X") {
|
||||
return "_int64";
|
||||
} else if (typeName == "f" || typeName == "F") {
|
||||
return "_fp32";
|
||||
} else if (typeName == "d" || typeName == "D") {
|
||||
return "_fp64";
|
||||
} else if (typeName == "b" || typeName == "B") {
|
||||
return "_bool";
|
||||
} else if (typeName == "NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE") {
|
||||
return "_str";
|
||||
} else if (typeName == "St6vector" || typeName == "St5deque" || typeName == "St4list" || typeName == "St4pair") {
|
||||
return "_array";
|
||||
} else {
|
||||
// 默认情况
|
||||
return "_obj";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user