|
|
|
@@ -11,6 +11,213 @@ SQLiteDB::SQLiteDB(const std::string& dbPath) {
|
|
|
|
|
m_dbPath = dbPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
bool SQLiteDB::bindParameters(sqlite3_stmt* stmt, const T& data) {
|
|
|
|
|
// 需要为每个具体类型特化实现
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 为ccuState特化实现
|
|
|
|
|
template<>
|
|
|
|
|
bool SQLiteDB::bindParameters<ccuState>(sqlite3_stmt* stmt, const ccuState& data) {
|
|
|
|
|
int index = 1;
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.currentWorkCondition);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuState);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuFaultLeve);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.powerLimit);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.totalPowerGeneration);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.ch4o);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.o2);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuVoltage);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuCurrent);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.o2Level);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.placeholder1);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.exchangerTemperature);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuOutPower);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuOutIns);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuVoltageIns);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuVoltagePower);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuCurrentIns);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.fcuCurrentPower);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.h2Concentration1);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.h2Concentration2);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.o2Concentration1);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.o2Concentration2);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.ch4oConcentration1);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.ch4oConcentration2);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.backpressure1);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.backpressure2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.flameDetection);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuGZ_1L);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuGZ_1H);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuGZ_2L);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuGZ_2H);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuGZ_3L);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuGZ_3H);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insPosRelayState);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insNegRelayState);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerPosRelayState);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerNegRelayState);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insBatLimit);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerBatLimit);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insBatSoc);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerBatSoc);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insBatTotalElectricity);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerBatTotalElectricity);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insBatCurrentElectricity);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerBatCurrentElectricity);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insChargeState);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerChargeState);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insLinkVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insPackVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insPosInsulationResistance);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insNegInsulationResistance);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerLinkVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerPackVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerPosInsulationResistance);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerNegInsulationResistance);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insEmergencyStatusWord);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerEmergencyStatusWord);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insAlarmIdentificationWord);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerAlarmIdentificationWord);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insCurrentSocHold1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insCurrentSocHold2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.insCurrentSocHold3);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuCurrentToInsLimit1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fcuCurrentToinsLimit2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerCurrentSocHold1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerCurrentSocHold2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerCurrentSocHold3);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerCurrentToInsLimit1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerCurrentToinsLimit2);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.placeholder2);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.placeholder3);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.placeholder4);
|
|
|
|
|
sqlite3_bind_double(stmt, index++, data.placeholder5);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 为disHighVolBusState特化实现
|
|
|
|
|
template<>
|
|
|
|
|
bool SQLiteDB::bindParameters<disHighVolBusState>(sqlite3_stmt* stmt, const disHighVolBusState& data) {
|
|
|
|
|
int index = 1;
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fuelCellCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerLithiumBatteryCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.propulsionMotorCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.lithiumBatteryGroupInstrumentCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.dcDc5ModuleCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowHighVoltageDistributionBoxCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.sternFTDevice45CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.sternRudderSwitch1CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.sternRudderSwitch2CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fbReservedCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.tyzReservedCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.busInsulationLow);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.busAInsulationHigh);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.lostPower);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.lostEmerPower);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerBusVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.dcDc5ModuleCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerBusCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.busbarAVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.propulsionMotorControlBoxCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.busbarACurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.lithiumBatteryGroupMeterCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowHighVoltageDistributionBoxCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.sternFTDevice45Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.tyzReservedSwitchCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.sternRudderSwitch1Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCurrent1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.sternRudderSwitch2Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCurrent2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fbReservedSwitchCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCurrent3);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 为disHighAVolBusState特化实现
|
|
|
|
|
template<>
|
|
|
|
|
bool SQLiteDB::bindParameters<disHighAVolBusState>(sqlite3_stmt* stmt, const disHighAVolBusState& data) {
|
|
|
|
|
int index = 1;
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowFTDevice123CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.actuatorCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.mastSteeringGearControlBoxCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.xczCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowRudderControlBoxCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.openWaterCoverStartCylinderCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.instrumentPowerFailureSignal);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergencyPowerFailureSignal);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.waterIngressionAlarm);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.busbarBVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.busbarBCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowFTDevice123Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.actuatorCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.mastSteeringGearControlBoxCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.xczCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowRudderControlBoxCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.openWaterCoverStartCylinderCurrent);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 为disHighBVolBusState特化实现
|
|
|
|
|
template<>
|
|
|
|
|
bool SQLiteDB::bindParameters<disHighBVolBusState>(sqlite3_stmt* stmt, const disHighBVolBusState& data) {
|
|
|
|
|
int index = 1;
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.lithiumBatteryGroupInstrumentCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowLowVoltageDistributionBoxCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit4InstrumentDC48VCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.dcC1DCDistributionPanelCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCircuitBreaker1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCircuitBreaker2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergencyLithiumBatteryGroup2CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.instrumentPowerFailureSignal);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergencyPowerFailureSignal);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.instrumentBusbarInsulationLow);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.instrumentBusbarVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowLowVoltageDistributionBoxCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.dcC1InstrumentDC48VCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCurrent1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergencyLithiumBatteryGroup2Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.lithiumBatteryGroupInstrumentCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit4InstrumentDC48VCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCurrent2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergency2BusbarVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.compositeEnergyManagementSystemEmergencyDC48VCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.fuelCellSecuritySystemEmergencyDC48VCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.plcControlPowerCurrent);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 为disLowBusState特化实现
|
|
|
|
|
template<>
|
|
|
|
|
bool SQLiteDB::bindParameters<disLowBusState>(sqlite3_stmt* stmt, const disLowBusState& data) {
|
|
|
|
|
int index = 1;
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit1CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit2CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit3CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit5CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowPZDeviceCircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCircuitBreaker1);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.reservedCircuitBreaker2);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergencyLithiumBatteryGroup1CircuitBreaker);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.powerFailureSignal);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.waterIngressionAlarm);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.instrumentBusbarVoltage);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.instrumentBusbarCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit1Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit2Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit3Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.unit5Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.bowPZDeviceCurrent);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergencyLithiumBatteryGroup1Current);
|
|
|
|
|
sqlite3_bind_int(stmt, index++, data.emergency1BusbarVoltage);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQLiteDB::~SQLiteDB() {
|
|
|
|
|
if (m_db) {
|
|
|
|
|
sqlite3_close(m_db);
|
|
|
|
@@ -201,3 +408,465 @@ bool SQLiteDB::clearStateData() {
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SQLiteDB::insertDisCcuData(pmState s, bool filter) {
|
|
|
|
|
if (!m_db) return false;
|
|
|
|
|
|
|
|
|
|
// 检查是否需要过滤
|
|
|
|
|
if (filter) {
|
|
|
|
|
// TODO: 实现过滤逻辑,检查是否与上一条记录相同
|
|
|
|
|
}
|
|
|
|
|
// 插入ccu_state表
|
|
|
|
|
const char* ccuSql = "INSERT INTO ccu_state ("
|
|
|
|
|
"currentWorkCondition, fcuState, fcuFaultLeve, powerLimit, totalPowerGeneration, "
|
|
|
|
|
"ch4o, o2, fcuVoltage, fcuCurrent, o2Level, placeholder1, exchangerTemperature, "
|
|
|
|
|
"fcuOutPower, fcuOutIns, fcuVoltageIns, fcuVoltagePower, fcuCurrentIns, fcuCurrentPower, "
|
|
|
|
|
"h2Concentration1, h2Concentration2, o2Concentration1, o2Concentration2, "
|
|
|
|
|
"ch4oConcentration1, ch4oConcentration2, backpressure1, backpressure2, flameDetection, "
|
|
|
|
|
"fcuGZ_1L, fcuGZ_1H, fcuGZ_2L, fcuGZ_2H, fcuGZ_3L, fcuGZ_3H, insPosRelayState, "
|
|
|
|
|
"insNegRelayState, powerPosRelayState, powerNegRelayState, insBatLimit, powerBatLimit, "
|
|
|
|
|
"insBatSoc, powerBatSoc, insBatTotalElectricity, powerBatTotalElectricity, "
|
|
|
|
|
"insBatCurrentElectricity, powerBatCurrentElectricity, insChargeState, powerChargeState, "
|
|
|
|
|
"insLinkVoltage, insPackVoltage, insCurrent, insPosInsulationResistance, "
|
|
|
|
|
"insNegInsulationResistance, powerLinkVoltage, powerPackVoltage, powerCurrent, "
|
|
|
|
|
"powerPosInsulationResistance, powerNegInsulationResistance, insEmergencyStatusWord, "
|
|
|
|
|
"powerEmergencyStatusWord, insAlarmIdentificationWord, powerAlarmIdentificationWord, "
|
|
|
|
|
"insCurrentSocHold1, insCurrentSocHold2, insCurrentSocHold3, fcuCurrentToInsLimit1, "
|
|
|
|
|
"fcuCurrentToinsLimit2, powerCurrentSocHold1, powerCurrentSocHold2, powerCurrentSocHold3, "
|
|
|
|
|
"powerCurrentToInsLimit1, powerCurrentToinsLimit2, placeholder2, placeholder3, "
|
|
|
|
|
"placeholder4, placeholder5) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
|
|
|
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
|
|
|
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
// 插入dis_high_vol_bus_state表
|
|
|
|
|
const char* bus1Sql = "INSERT INTO dis_high_vol_bus_state ("
|
|
|
|
|
"fuelCellCircuitBreaker, powerLithiumBatteryCircuitBreaker, propulsionMotorCircuitBreaker, "
|
|
|
|
|
"lithiumBatteryGroupInstrumentCircuitBreaker, dcDc5ModuleCircuitBreaker, "
|
|
|
|
|
"bowHighVoltageDistributionBoxCircuitBreaker, sternFTDevice45CircuitBreaker, "
|
|
|
|
|
"sternRudderSwitch1CircuitBreaker, sternRudderSwitch2CircuitBreaker, fbReservedCircuitBreaker, "
|
|
|
|
|
"tyzReservedCircuitBreaker, reservedCircuitBreaker, busInsulationLow, busAInsulationHigh, "
|
|
|
|
|
"lostPower, lostEmerPower, powerBusVoltage, dcDc5ModuleCurrent, powerBusCurrent, "
|
|
|
|
|
"busbarAVoltage, propulsionMotorControlBoxCurrent, busbarACurrent, "
|
|
|
|
|
"lithiumBatteryGroupMeterCurrent, bowHighVoltageDistributionBoxCurrent, "
|
|
|
|
|
"sternFTDevice45Current, tyzReservedSwitchCurrent, sternRudderSwitch1Current, "
|
|
|
|
|
"reservedCurrent1, sternRudderSwitch2Current, reservedCurrent2, fbReservedSwitchCurrent, "
|
|
|
|
|
"reservedCurrent3) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
|
|
|
|
"?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
// 插入dis_high_a_vol_bus_state表
|
|
|
|
|
const char* bus2Sql = "INSERT INTO dis_high_a_vol_bus_state ("
|
|
|
|
|
"bowFTDevice123CircuitBreaker, actuatorCircuitBreaker, mastSteeringGearControlBoxCircuitBreaker, "
|
|
|
|
|
"xczCircuitBreaker, bowRudderControlBoxCircuitBreaker, openWaterCoverStartCylinderCircuitBreaker, "
|
|
|
|
|
"instrumentPowerFailureSignal, emergencyPowerFailureSignal, waterIngressionAlarm, "
|
|
|
|
|
"busbarBVoltage, busbarBCurrent, bowFTDevice123Current, actuatorCurrent, "
|
|
|
|
|
"mastSteeringGearControlBoxCurrent, xczCurrent, bowRudderControlBoxCurrent, "
|
|
|
|
|
"openWaterCoverStartCylinderCurrent) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
// 插入dis_high_b_vol_bus_state表
|
|
|
|
|
const char* bus3Sql = "INSERT INTO dis_high_b_vol_bus_state ("
|
|
|
|
|
"lithiumBatteryGroupInstrumentCircuitBreaker, bowLowVoltageDistributionBoxCircuitBreaker, "
|
|
|
|
|
"unit4InstrumentDC48VCircuitBreaker, dcC1DCDistributionPanelCircuitBreaker, "
|
|
|
|
|
"reservedCircuitBreaker1, reservedCircuitBreaker2, emergencyLithiumBatteryGroup2CircuitBreaker, "
|
|
|
|
|
"instrumentPowerFailureSignal, emergencyPowerFailureSignal, instrumentBusbarInsulationLow, "
|
|
|
|
|
"instrumentBusbarVoltage, bowLowVoltageDistributionBoxCurrent, dcC1InstrumentDC48VCurrent, "
|
|
|
|
|
"reservedCurrent1, emergencyLithiumBatteryGroup2Current, lithiumBatteryGroupInstrumentCurrent, "
|
|
|
|
|
"unit4InstrumentDC48VCurrent, reservedCurrent2, emergency2BusbarVoltage, "
|
|
|
|
|
"compositeEnergyManagementSystemEmergencyDC48VCurrent, fuelCellSecuritySystemEmergencyDC48VCurrent, "
|
|
|
|
|
"plcControlPowerCurrent) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?);";
|
|
|
|
|
|
|
|
|
|
// 插入dis_low_bus_state表
|
|
|
|
|
const char* bus4Sql = "INSERT INTO dis_low_bus_state ("
|
|
|
|
|
"unit1CircuitBreaker, unit2CircuitBreaker, unit3CircuitBreaker, unit5CircuitBreaker, "
|
|
|
|
|
"bowPZDeviceCircuitBreaker, reservedCircuitBreaker1, reservedCircuitBreaker2, "
|
|
|
|
|
"emergencyLithiumBatteryGroup1CircuitBreaker, powerFailureSignal, waterIngressionAlarm, "
|
|
|
|
|
"instrumentBusbarVoltage, instrumentBusbarCurrent, unit1Current, unit2Current, "
|
|
|
|
|
"unit3Current, unit5Current, bowPZDeviceCurrent, emergencyLithiumBatteryGroup1Current, "
|
|
|
|
|
"emergency1BusbarVoltage) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
// 执行所有插入操作
|
|
|
|
|
bool result = true;
|
|
|
|
|
result = result && executeInsert(ccuSql, s.ccustate);
|
|
|
|
|
result = result && executeInsert(bus1Sql, s.bus1State);
|
|
|
|
|
result = result && executeInsert(bus2Sql, s.bus2State);
|
|
|
|
|
result = result && executeInsert(bus3Sql, s.bus3State);
|
|
|
|
|
result = result && executeInsert(bus4Sql, s.bus4State);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SQLiteDB::insertCcuData(ccuState s)
|
|
|
|
|
{
|
|
|
|
|
if (!m_db) return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 插入ccu_state表
|
|
|
|
|
const char* ccuSql = "INSERT INTO ccu_state ("
|
|
|
|
|
"currentWorkCondition, fcuState, fcuFaultLeve, powerLimit, totalPowerGeneration, "
|
|
|
|
|
"ch4o, o2, fcuVoltage, fcuCurrent, o2Level, placeholder1, exchangerTemperature, "
|
|
|
|
|
"fcuOutPower, fcuOutIns, fcuVoltageIns, fcuVoltagePower, fcuCurrentIns, fcuCurrentPower, "
|
|
|
|
|
"h2Concentration1, h2Concentration2, o2Concentration1, o2Concentration2, "
|
|
|
|
|
"ch4oConcentration1, ch4oConcentration2, backpressure1, backpressure2, flameDetection, "
|
|
|
|
|
"fcuGZ_1L, fcuGZ_1H, fcuGZ_2L, fcuGZ_2H, fcuGZ_3L, fcuGZ_3H, insPosRelayState, "
|
|
|
|
|
"insNegRelayState, powerPosRelayState, powerNegRelayState, insBatLimit, powerBatLimit, "
|
|
|
|
|
"insBatSoc, powerBatSoc, insBatTotalElectricity, powerBatTotalElectricity, "
|
|
|
|
|
"insBatCurrentElectricity, powerBatCurrentElectricity, insChargeState, powerChargeState, "
|
|
|
|
|
"insLinkVoltage, insPackVoltage, insCurrent, insPosInsulationResistance, "
|
|
|
|
|
"insNegInsulationResistance, powerLinkVoltage, powerPackVoltage, powerCurrent, "
|
|
|
|
|
"powerPosInsulationResistance, powerNegInsulationResistance, insEmergencyStatusWord, "
|
|
|
|
|
"powerEmergencyStatusWord, insAlarmIdentificationWord, powerAlarmIdentificationWord, "
|
|
|
|
|
"insCurrentSocHold1, insCurrentSocHold2, insCurrentSocHold3, fcuCurrentToInsLimit1, "
|
|
|
|
|
"fcuCurrentToinsLimit2, powerCurrentSocHold1, powerCurrentSocHold2, powerCurrentSocHold3, "
|
|
|
|
|
"powerCurrentToInsLimit1, powerCurrentToinsLimit2, placeholder2, placeholder3, "
|
|
|
|
|
"placeholder4, placeholder5) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
|
|
|
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
|
|
|
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
|
|
|
|
// 执行所有插入操作
|
|
|
|
|
bool result = true;
|
|
|
|
|
result = executeInsert(ccuSql, s);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
bool SQLiteDB::insertDisHighVolBusData(disHighVolBusState s)
|
|
|
|
|
{
|
|
|
|
|
if (!m_db) return false;
|
|
|
|
|
|
|
|
|
|
// 插入dis_high_vol_bus_state表
|
|
|
|
|
const char* bus1Sql = "INSERT INTO dis_high_vol_bus_state ("
|
|
|
|
|
"fuelCellCircuitBreaker, powerLithiumBatteryCircuitBreaker, propulsionMotorCircuitBreaker, "
|
|
|
|
|
"lithiumBatteryGroupInstrumentCircuitBreaker, dcDc5ModuleCircuitBreaker, "
|
|
|
|
|
"bowHighVoltageDistributionBoxCircuitBreaker, sternFTDevice45CircuitBreaker, "
|
|
|
|
|
"sternRudderSwitch1CircuitBreaker, sternRudderSwitch2CircuitBreaker, fbReservedCircuitBreaker, "
|
|
|
|
|
"tyzReservedCircuitBreaker, reservedCircuitBreaker, busInsulationLow, busAInsulationHigh, "
|
|
|
|
|
"lostPower, lostEmerPower, powerBusVoltage, dcDc5ModuleCurrent, powerBusCurrent, "
|
|
|
|
|
"busbarAVoltage, propulsionMotorControlBoxCurrent, busbarACurrent, "
|
|
|
|
|
"lithiumBatteryGroupMeterCurrent, bowHighVoltageDistributionBoxCurrent, "
|
|
|
|
|
"sternFTDevice45Current, tyzReservedSwitchCurrent, sternRudderSwitch1Current, "
|
|
|
|
|
"reservedCurrent1, sternRudderSwitch2Current, reservedCurrent2, fbReservedSwitchCurrent, "
|
|
|
|
|
"reservedCurrent3) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
|
|
|
|
"?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
// 执行所有插入操作
|
|
|
|
|
bool result = true;
|
|
|
|
|
result = executeInsert(bus1Sql, s);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
bool SQLiteDB::insertDisHighAVolBusData(disHighAVolBusState s)
|
|
|
|
|
{
|
|
|
|
|
if (!m_db) return false;
|
|
|
|
|
|
|
|
|
|
// 插入dis_high_a_vol_bus_state表
|
|
|
|
|
const char* bus2Sql = "INSERT INTO dis_high_a_vol_bus_state ("
|
|
|
|
|
"bowFTDevice123CircuitBreaker, actuatorCircuitBreaker, mastSteeringGearControlBoxCircuitBreaker, "
|
|
|
|
|
"xczCircuitBreaker, bowRudderControlBoxCircuitBreaker, openWaterCoverStartCylinderCircuitBreaker, "
|
|
|
|
|
"instrumentPowerFailureSignal, emergencyPowerFailureSignal, waterIngressionAlarm, "
|
|
|
|
|
"busbarBVoltage, busbarBCurrent, bowFTDevice123Current, actuatorCurrent, "
|
|
|
|
|
"mastSteeringGearControlBoxCurrent, xczCurrent, bowRudderControlBoxCurrent, "
|
|
|
|
|
"openWaterCoverStartCylinderCurrent) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
// 执行所有插入操作
|
|
|
|
|
bool result = true;
|
|
|
|
|
result = executeInsert(bus2Sql, s);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
bool SQLiteDB::insertDisHighBVolBusData(disHighBVolBusState s)
|
|
|
|
|
{
|
|
|
|
|
if (!m_db) return false;
|
|
|
|
|
|
|
|
|
|
const char* bus3Sql = "INSERT INTO dis_high_b_vol_bus_state ("
|
|
|
|
|
"lithiumBatteryGroupInstrumentCircuitBreaker, bowLowVoltageDistributionBoxCircuitBreaker, "
|
|
|
|
|
"unit4InstrumentDC48VCircuitBreaker, dcC1DCDistributionPanelCircuitBreaker, "
|
|
|
|
|
"reservedCircuitBreaker1, reservedCircuitBreaker2, emergencyLithiumBatteryGroup2CircuitBreaker, "
|
|
|
|
|
"instrumentPowerFailureSignal, emergencyPowerFailureSignal, instrumentBusbarInsulationLow, "
|
|
|
|
|
"instrumentBusbarVoltage, bowLowVoltageDistributionBoxCurrent, dcC1InstrumentDC48VCurrent, "
|
|
|
|
|
"reservedCurrent1, emergencyLithiumBatteryGroup2Current, lithiumBatteryGroupInstrumentCurrent, "
|
|
|
|
|
"unit4InstrumentDC48VCurrent, reservedCurrent2, emergency2BusbarVoltage, "
|
|
|
|
|
"compositeEnergyManagementSystemEmergencyDC48VCurrent, fuelCellSecuritySystemEmergencyDC48VCurrent, "
|
|
|
|
|
"plcControlPowerCurrent) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?);";
|
|
|
|
|
|
|
|
|
|
// 执行所有插入操作
|
|
|
|
|
bool result = true;
|
|
|
|
|
result = executeInsert(bus3Sql, s);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
bool SQLiteDB::insertDisLowBusData(disLowBusState s)
|
|
|
|
|
{
|
|
|
|
|
if (!m_db) return false;
|
|
|
|
|
|
|
|
|
|
// 插入dis_low_bus_state表
|
|
|
|
|
const char* bus4Sql = "INSERT INTO dis_low_bus_state ("
|
|
|
|
|
"unit1CircuitBreaker, unit2CircuitBreaker, unit3CircuitBreaker, unit5CircuitBreaker, "
|
|
|
|
|
"bowPZDeviceCircuitBreaker, reservedCircuitBreaker1, reservedCircuitBreaker2, "
|
|
|
|
|
"emergencyLithiumBatteryGroup1CircuitBreaker, powerFailureSignal, waterIngressionAlarm, "
|
|
|
|
|
"instrumentBusbarVoltage, instrumentBusbarCurrent, unit1Current, unit2Current, "
|
|
|
|
|
"unit3Current, unit5Current, bowPZDeviceCurrent, emergencyLithiumBatteryGroup1Current, "
|
|
|
|
|
"emergency1BusbarVoltage) "
|
|
|
|
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
// 执行所有插入操作
|
|
|
|
|
bool result = true;
|
|
|
|
|
result = executeInsert(bus4Sql, s);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
bool SQLiteDB::executeInsert(const char* sql, const T& data) {
|
|
|
|
|
sqlite3_stmt* stmt;
|
|
|
|
|
if (sqlite3_prepare_v2(m_db, sql, -1, &stmt, nullptr) != SQLITE_OK) {
|
|
|
|
|
std::cerr << "Error preparing statement: " << sqlite3_errmsg(m_db) << std::endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 绑定参数
|
|
|
|
|
if (!bindParameters(stmt, data)) {
|
|
|
|
|
sqlite3_finalize(stmt);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sqlite3_step(stmt) != SQLITE_DONE) {
|
|
|
|
|
std::cerr << "Error inserting data: " << sqlite3_errmsg(m_db) << std::endl;
|
|
|
|
|
sqlite3_finalize(stmt);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sqlite3_finalize(stmt);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool SQLiteDB::createDisCcuSysTables() {
|
|
|
|
|
if (!m_db) return false;
|
|
|
|
|
|
|
|
|
|
// 创建ccu_state表
|
|
|
|
|
const char* ccuStateSql = "CREATE TABLE IF NOT EXISTS ccu_state ("
|
|
|
|
|
"timestamp DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),"
|
|
|
|
|
"currentWorkCondition INTEGER NOT NULL,"
|
|
|
|
|
"fcuState INTEGER NOT NULL,"
|
|
|
|
|
"fcuFaultLeve INTEGER NOT NULL,"
|
|
|
|
|
"powerLimit REAL NOT NULL,"
|
|
|
|
|
"totalPowerGeneration REAL NOT NULL,"
|
|
|
|
|
"ch4o REAL NOT NULL,"
|
|
|
|
|
"o2 REAL NOT NULL,"
|
|
|
|
|
"fcuVoltage REAL NOT NULL,"
|
|
|
|
|
"fcuCurrent REAL NOT NULL,"
|
|
|
|
|
"o2Level REAL NOT NULL,"
|
|
|
|
|
"placeholder1 REAL NOT NULL,"
|
|
|
|
|
"exchangerTemperature REAL NOT NULL,"
|
|
|
|
|
"fcuOutPower REAL NOT NULL,"
|
|
|
|
|
"fcuOutIns REAL NOT NULL,"
|
|
|
|
|
"fcuVoltageIns REAL NOT NULL,"
|
|
|
|
|
"fcuVoltagePower REAL NOT NULL,"
|
|
|
|
|
"fcuCurrentIns REAL NOT NULL,"
|
|
|
|
|
"fcuCurrentPower REAL NOT NULL,"
|
|
|
|
|
"h2Concentration1 REAL NOT NULL,"
|
|
|
|
|
"h2Concentration2 REAL NOT NULL,"
|
|
|
|
|
"o2Concentration1 REAL NOT NULL,"
|
|
|
|
|
"o2Concentration2 REAL NOT NULL,"
|
|
|
|
|
"ch4oConcentration1 REAL NOT NULL,"
|
|
|
|
|
"ch4oConcentration2 REAL NOT NULL,"
|
|
|
|
|
"backpressure1 REAL NOT NULL,"
|
|
|
|
|
"backpressure2 REAL NOT NULL,"
|
|
|
|
|
"flameDetection INTEGER NOT NULL,"
|
|
|
|
|
"fcuGZ_1L INTEGER NOT NULL,"
|
|
|
|
|
"fcuGZ_1H INTEGER NOT NULL,"
|
|
|
|
|
"fcuGZ_2L INTEGER NOT NULL,"
|
|
|
|
|
"fcuGZ_2H INTEGER NOT NULL,"
|
|
|
|
|
"fcuGZ_3L INTEGER NOT NULL,"
|
|
|
|
|
"fcuGZ_3H INTEGER NOT NULL,"
|
|
|
|
|
"insPosRelayState INTEGER NOT NULL,"
|
|
|
|
|
"insNegRelayState INTEGER NOT NULL,"
|
|
|
|
|
"powerPosRelayState INTEGER NOT NULL,"
|
|
|
|
|
"powerNegRelayState INTEGER NOT NULL,"
|
|
|
|
|
"insBatLimit INTEGER NOT NULL,"
|
|
|
|
|
"powerBatLimit INTEGER NOT NULL,"
|
|
|
|
|
"insBatSoc INTEGER NOT NULL,"
|
|
|
|
|
"powerBatSoc INTEGER NOT NULL,"
|
|
|
|
|
"insBatTotalElectricity INTEGER NOT NULL,"
|
|
|
|
|
"powerBatTotalElectricity INTEGER NOT NULL,"
|
|
|
|
|
"insBatCurrentElectricity INTEGER NOT NULL,"
|
|
|
|
|
"powerBatCurrentElectricity INTEGER NOT NULL,"
|
|
|
|
|
"insChargeState INTEGER NOT NULL,"
|
|
|
|
|
"powerChargeState INTEGER NOT NULL,"
|
|
|
|
|
"insLinkVoltage INTEGER NOT NULL,"
|
|
|
|
|
"insPackVoltage INTEGER NOT NULL,"
|
|
|
|
|
"insCurrent INTEGER NOT NULL,"
|
|
|
|
|
"insPosInsulationResistance INTEGER NOT NULL,"
|
|
|
|
|
"insNegInsulationResistance INTEGER NOT NULL,"
|
|
|
|
|
"powerLinkVoltage INTEGER NOT NULL,"
|
|
|
|
|
"powerPackVoltage INTEGER NOT NULL,"
|
|
|
|
|
"powerCurrent INTEGER NOT NULL,"
|
|
|
|
|
"powerPosInsulationResistance INTEGER NOT NULL,"
|
|
|
|
|
"powerNegInsulationResistance INTEGER NOT NULL,"
|
|
|
|
|
"insEmergencyStatusWord INTEGER NOT NULL,"
|
|
|
|
|
"powerEmergencyStatusWord INTEGER NOT NULL,"
|
|
|
|
|
"insAlarmIdentificationWord INTEGER NOT NULL,"
|
|
|
|
|
"powerAlarmIdentificationWord INTEGER NOT NULL,"
|
|
|
|
|
"insCurrentSocHold1 INTEGER NOT NULL,"
|
|
|
|
|
"insCurrentSocHold2 INTEGER NOT NULL,"
|
|
|
|
|
"insCurrentSocHold3 INTEGER NOT NULL,"
|
|
|
|
|
"fcuCurrentToInsLimit1 INTEGER NOT NULL,"
|
|
|
|
|
"fcuCurrentToinsLimit2 INTEGER NOT NULL,"
|
|
|
|
|
"powerCurrentSocHold1 INTEGER NOT NULL,"
|
|
|
|
|
"powerCurrentSocHold2 INTEGER NOT NULL,"
|
|
|
|
|
"powerCurrentSocHold3 INTEGER NOT NULL,"
|
|
|
|
|
"powerCurrentToInsLimit1 INTEGER NOT NULL,"
|
|
|
|
|
"powerCurrentToinsLimit2 INTEGER NOT NULL,"
|
|
|
|
|
"placeholder2 REAL NOT NULL,"
|
|
|
|
|
"placeholder3 REAL NOT NULL,"
|
|
|
|
|
"placeholder4 REAL NOT NULL,"
|
|
|
|
|
"placeholder5 REAL NOT NULL);";
|
|
|
|
|
|
|
|
|
|
// 创建dis_high_vol_bus_state表
|
|
|
|
|
const char* disHighVolBusStateSql = "CREATE TABLE IF NOT EXISTS dis_high_vol_bus_state ("
|
|
|
|
|
"timestamp DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),"
|
|
|
|
|
"fuelCellCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"powerLithiumBatteryCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"propulsionMotorCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"lithiumBatteryGroupInstrumentCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"dcDc5ModuleCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"bowHighVoltageDistributionBoxCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"sternFTDevice45CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"sternRudderSwitch1CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"sternRudderSwitch2CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"fbReservedCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"tyzReservedCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"reservedCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"busInsulationLow INTEGER NOT NULL,"
|
|
|
|
|
"busAInsulationHigh INTEGER NOT NULL,"
|
|
|
|
|
"lostPower INTEGER NOT NULL,"
|
|
|
|
|
"lostEmerPower INTEGER NOT NULL,"
|
|
|
|
|
"powerBusVoltage INTEGER NOT NULL,"
|
|
|
|
|
"dcDc5ModuleCurrent INTEGER NOT NULL,"
|
|
|
|
|
"powerBusCurrent INTEGER NOT NULL,"
|
|
|
|
|
"busbarAVoltage INTEGER NOT NULL,"
|
|
|
|
|
"propulsionMotorControlBoxCurrent INTEGER NOT NULL,"
|
|
|
|
|
"busbarACurrent INTEGER NOT NULL,"
|
|
|
|
|
"lithiumBatteryGroupMeterCurrent INTEGER NOT NULL,"
|
|
|
|
|
"bowHighVoltageDistributionBoxCurrent INTEGER NOT NULL,"
|
|
|
|
|
"sternFTDevice45Current INTEGER NOT NULL,"
|
|
|
|
|
"tyzReservedSwitchCurrent INTEGER NOT NULL,"
|
|
|
|
|
"sternRudderSwitch1Current INTEGER NOT NULL,"
|
|
|
|
|
"reservedCurrent1 INTEGER NOT NULL,"
|
|
|
|
|
"sternRudderSwitch2Current INTEGER NOT NULL,"
|
|
|
|
|
"reservedCurrent2 INTEGER NOT NULL,"
|
|
|
|
|
"fbReservedSwitchCurrent INTEGER NOT NULL,"
|
|
|
|
|
"reservedCurrent3 INTEGER NOT NULL);";
|
|
|
|
|
|
|
|
|
|
// 创建dis_high_a_vol_bus_state表
|
|
|
|
|
const char* disHighAVolBusStateSql = "CREATE TABLE IF NOT EXISTS dis_high_a_vol_bus_state ("
|
|
|
|
|
"timestamp DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),"
|
|
|
|
|
"bowFTDevice123CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"actuatorCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"mastSteeringGearControlBoxCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"xczCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"bowRudderControlBoxCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"openWaterCoverStartCylinderCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"instrumentPowerFailureSignal INTEGER NOT NULL,"
|
|
|
|
|
"emergencyPowerFailureSignal INTEGER NOT NULL,"
|
|
|
|
|
"waterIngressionAlarm INTEGER NOT NULL,"
|
|
|
|
|
"busbarBVoltage INTEGER NOT NULL,"
|
|
|
|
|
"busbarBCurrent INTEGER NOT NULL,"
|
|
|
|
|
"bowFTDevice123Current INTEGER NOT NULL,"
|
|
|
|
|
"actuatorCurrent INTEGER NOT NULL,"
|
|
|
|
|
"mastSteeringGearControlBoxCurrent INTEGER NOT NULL,"
|
|
|
|
|
"xczCurrent INTEGER NOT NULL,"
|
|
|
|
|
"bowRudderControlBoxCurrent INTEGER NOT NULL,"
|
|
|
|
|
"openWaterCoverStartCylinderCurrent INTEGER NOT NULL);";
|
|
|
|
|
|
|
|
|
|
// 创建dis_high_b_vol_bus_state表
|
|
|
|
|
const char* disHighBVolBusStateSql = "CREATE TABLE IF NOT EXISTS dis_high_b_vol_bus_state ("
|
|
|
|
|
"timestamp DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),"
|
|
|
|
|
"lithiumBatteryGroupInstrumentCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"bowLowVoltageDistributionBoxCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"unit4InstrumentDC48VCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"dcC1DCDistributionPanelCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"reservedCircuitBreaker1 INTEGER NOT NULL,"
|
|
|
|
|
"reservedCircuitBreaker2 INTEGER NOT NULL,"
|
|
|
|
|
"emergencyLithiumBatteryGroup2CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"instrumentPowerFailureSignal INTEGER NOT NULL,"
|
|
|
|
|
"emergencyPowerFailureSignal INTEGER NOT NULL,"
|
|
|
|
|
"instrumentBusbarInsulationLow INTEGER NOT NULL,"
|
|
|
|
|
"instrumentBusbarVoltage INTEGER NOT NULL,"
|
|
|
|
|
"bowLowVoltageDistributionBoxCurrent INTEGER NOT NULL,"
|
|
|
|
|
"dcC1InstrumentDC48VCurrent INTEGER NOT NULL,"
|
|
|
|
|
"reservedCurrent1 INTEGER NOT NULL,"
|
|
|
|
|
"emergencyLithiumBatteryGroup2Current INTEGER NOT NULL,"
|
|
|
|
|
"lithiumBatteryGroupInstrumentCurrent INTEGER NOT NULL,"
|
|
|
|
|
"unit4InstrumentDC48VCurrent INTEGER NOT NULL,"
|
|
|
|
|
"reservedCurrent2 INTEGER NOT NULL,"
|
|
|
|
|
"emergency2BusbarVoltage INTEGER NOT NULL,"
|
|
|
|
|
"compositeEnergyManagementSystemEmergencyDC48VCurrent INTEGER NOT NULL,"
|
|
|
|
|
"fuelCellSecuritySystemEmergencyDC48VCurrent INTEGER NOT NULL,"
|
|
|
|
|
"plcControlPowerCurrent INTEGER NOT NULL);";
|
|
|
|
|
|
|
|
|
|
// 创建dis_low_bus_state表
|
|
|
|
|
const char* disLowBusStateSql = "CREATE TABLE IF NOT EXISTS dis_low_bus_state ("
|
|
|
|
|
"timestamp DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),"
|
|
|
|
|
"unit1CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"unit2CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"unit3CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"unit5CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"bowPZDeviceCircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"reservedCircuitBreaker1 INTEGER NOT NULL,"
|
|
|
|
|
"reservedCircuitBreaker2 INTEGER NOT NULL,"
|
|
|
|
|
"emergencyLithiumBatteryGroup1CircuitBreaker INTEGER NOT NULL,"
|
|
|
|
|
"powerFailureSignal INTEGER NOT NULL,"
|
|
|
|
|
"waterIngressionAlarm INTEGER NOT NULL,"
|
|
|
|
|
"instrumentBusbarVoltage INTEGER NOT NULL,"
|
|
|
|
|
"instrumentBusbarCurrent INTEGER NOT NULL,"
|
|
|
|
|
"unit1Current INTEGER NOT NULL,"
|
|
|
|
|
"unit2Current INTEGER NOT NULL,"
|
|
|
|
|
"unit3Current INTEGER NOT NULL,"
|
|
|
|
|
"unit5Current INTEGER NOT NULL,"
|
|
|
|
|
"bowPZDeviceCurrent INTEGER NOT NULL,"
|
|
|
|
|
"emergencyLithiumBatteryGroup1Current INTEGER NOT NULL,"
|
|
|
|
|
"emergency1BusbarVoltage INTEGER NOT NULL);";
|
|
|
|
|
|
|
|
|
|
char* errMsg = nullptr;
|
|
|
|
|
bool result = true;
|
|
|
|
|
|
|
|
|
|
// 执行所有表创建语句
|
|
|
|
|
if (sqlite3_exec(m_db, ccuStateSql, nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
|
|
|
|
std::cerr << "SQL error creating ccu_state table: " << errMsg << std::endl;
|
|
|
|
|
sqlite3_free(errMsg);
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sqlite3_exec(m_db, disHighVolBusStateSql, nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
|
|
|
|
std::cerr << "SQL error creating dis_high_vol_bus_state table: " << errMsg << std::endl;
|
|
|
|
|
sqlite3_free(errMsg);
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sqlite3_exec(m_db, disHighAVolBusStateSql, nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
|
|
|
|
std::cerr << "SQL error creating dis_high_a_vol_bus_state table: " << errMsg << std::endl;
|
|
|
|
|
sqlite3_free(errMsg);
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sqlite3_exec(m_db, disHighBVolBusStateSql, nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
|
|
|
|
std::cerr << "SQL error creating dis_high_b_vol_bus_state table: " << errMsg << std::endl;
|
|
|
|
|
sqlite3_free(errMsg);
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sqlite3_exec(m_db, disLowBusStateSql, nullptr, nullptr, &errMsg) != SQLITE_OK) {
|
|
|
|
|
std::cerr << "SQL error creating dis_low_bus_state table: " << errMsg << std::endl;
|
|
|
|
|
sqlite3_free(errMsg);
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|