为操作指令增加了数据库写入代码
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
{
|
||||
"backpressure1_fp32": 7.0,
|
||||
"backpressure2_fp32": 0.0,
|
||||
"ch4oConcent1_fp32": 35.0,
|
||||
"ch4oConcent2_fp32": 58.0,
|
||||
"backpressure1_fp32": 10.0,
|
||||
"backpressure2_fp32": 6.0,
|
||||
"ch4oConcent1_fp32": 67.0,
|
||||
"ch4oConcent2_fp32": 64.0,
|
||||
"ch4o_fp32": 0.0,
|
||||
"excTemp_fp32": 100.0,
|
||||
"excTemp_fp32": 44.0,
|
||||
"faultCode1_uint16": 0,
|
||||
"faultCode2_uint16": 0,
|
||||
"faultCode3_uint16": 0,
|
||||
"fcuCurIns_fp32": 0.0,
|
||||
"fcuCurPower_fp32": 0.0,
|
||||
"fcuCur_fp32": 81.0,
|
||||
"fcuCur_fp32": 98.0,
|
||||
"fcuFaultLeve_uint8": 0,
|
||||
"fcuOutIns_fp32": 28.0,
|
||||
"fcuOutPower_fp32": 753.0,
|
||||
"fcuOutIns_fp32": 90.0,
|
||||
"fcuOutPower_fp32": 514.0,
|
||||
"fcuState_uint8": 0,
|
||||
"fcuVolIns_fp32": 0.0,
|
||||
"fcuVolPower_fp32": 0.0,
|
||||
"fcuVol_fp32": 341.0,
|
||||
"flameDet_uint8": 1,
|
||||
"h2Concent1_fp32": 4.0,
|
||||
"h2Concent2_fp32": 69.0,
|
||||
"o2Concent1_fp32": 54.0,
|
||||
"o2Concent2_fp32": 91.0,
|
||||
"fcuVol_fp32": 380.0,
|
||||
"flameDet_uint8": 0,
|
||||
"h2Concent1_fp32": 20.0,
|
||||
"h2Concent2_fp32": 25.0,
|
||||
"o2Concent1_fp32": 63.0,
|
||||
"o2Concent2_fp32": 19.0,
|
||||
"o2Level_fp32": 0.0,
|
||||
"o2_fp32": 0.0,
|
||||
"powLimit_fp32": 21.0,
|
||||
"powerGen_fp32": 757.0
|
||||
"powLimit_fp32": 95.0,
|
||||
"powerGen_fp32": 834.0
|
||||
}
|
||||
@@ -2,37 +2,37 @@
|
||||
"fcuCurToInsLimit1_uint8": 0,
|
||||
"fcuCurToinsLimit2_uint8": 0,
|
||||
"insBatCurElect_uint16": 0,
|
||||
"insBatLimit_uint16": 6,
|
||||
"insBatSoc_uint8": 5,
|
||||
"insBatTotalElect_uint16": 529,
|
||||
"insBatLimit_uint16": 2,
|
||||
"insBatSoc_uint8": 23,
|
||||
"insBatTotalElect_uint16": 783,
|
||||
"insChargeState_uint8": 0,
|
||||
"insCurSocHold1_uint8": 0,
|
||||
"insCurSocHold2_uint8": 0,
|
||||
"insCurSocHold3_uint8": 0,
|
||||
"insCurrent_uint16": 36,
|
||||
"insCurrent_uint16": 55,
|
||||
"insLinkVol_uint16": 0,
|
||||
"insNegRelayState_uint8": 0,
|
||||
"insNegRes_uint16": 0,
|
||||
"insPackVol_uint16": 0,
|
||||
"insPosRelayState_uint8": 1,
|
||||
"insPosRelayState_uint8": 0,
|
||||
"insPosRes_uint16": 0,
|
||||
"insfaultCode_uint8": 0,
|
||||
"powBatCurElect_uint16": 0,
|
||||
"powBatSoc_uint8": 64,
|
||||
"powBatTotalElect_uint16": 70,
|
||||
"powBatSoc_uint8": 85,
|
||||
"powBatTotalElect_uint16": 513,
|
||||
"powChargeState_uint8": 0,
|
||||
"powCurSocHold1_uint8": 0,
|
||||
"powCurSocHold2_uint8": 0,
|
||||
"powCurSocHold3_uint8": 0,
|
||||
"powCurToInsLimit1_uint8": 0,
|
||||
"powCurToinsLimit2_uint8": 0,
|
||||
"powCur_uint16": 30,
|
||||
"powCur_uint16": 14,
|
||||
"powLinkVol_uint16": 0,
|
||||
"powNegRelayState_uint8": 1,
|
||||
"powNegRelayState_uint8": 0,
|
||||
"powNegRes_uint16": 0,
|
||||
"powPosRelayState_uint8": 1,
|
||||
"powPosRes_uint16": 0,
|
||||
"powerBatLimit_uint16": 10,
|
||||
"powerBatLimit_uint16": 43,
|
||||
"powerPackVol_uint16": 0,
|
||||
"powfaultCode_uint8": 0
|
||||
}
|
||||
@@ -51,7 +51,7 @@ PowerManger::PowerManger()
|
||||
connectState = 0;
|
||||
|
||||
//初始化断路器状态
|
||||
initTargetDisBreakerState();
|
||||
initControlCmd();
|
||||
|
||||
//初始化数据库
|
||||
string dbPath = "/home/zjk/project/H100/H100PowerManger/data/power_data.db";
|
||||
@@ -142,6 +142,7 @@ bool PowerManger::Iterate()
|
||||
//a. 配电系统操作
|
||||
disSysOption();
|
||||
//b. ccu操作
|
||||
ccuOption();
|
||||
//c. 输出报告
|
||||
buildPowerSysReport();
|
||||
}
|
||||
@@ -376,7 +377,12 @@ bool PowerManger::IsSkewed(double dfTimeNow, double * pdfSkew)
|
||||
return (dfSkew > SKEW_TOLERANCE) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
void PowerManger::ccuOption()
|
||||
{
|
||||
m_db->insertCcuSysCmd(m_CcuColCmd);
|
||||
if(!m_udpComm.sendCcuColCmd(m_CcuColCmd))
|
||||
cout << "send ccu col cmd failed!" << endl;
|
||||
}
|
||||
void PowerManger::disSysOption()
|
||||
{
|
||||
//1.更新断路器的状态
|
||||
@@ -481,6 +487,13 @@ void PowerManger::disSysOption()
|
||||
d.reservedCircuitBreaker2 = getBreakerOption(m_targetDisBreakerState.bus4Breaker.reservedCircuitBreaker2);
|
||||
d.emergencyLithiumBatteryGroup1CircuitBreaker = getBreakerOption(m_targetDisBreakerState.bus4Breaker.emergencyLithiumBatteryGroup1CircuitBreaker);
|
||||
m_udpComm.sendDisSysCmd(d);
|
||||
|
||||
//将指令写入数据库
|
||||
m_db->insertDisSysCmd(a);
|
||||
m_db->insertDisSysCmd(b);
|
||||
m_db->insertDisSysCmd(c);
|
||||
m_db->insertDisSysCmd(d);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -563,8 +576,8 @@ int PowerManger::handleInite_s1(FSM_State &fsm, void* pData)
|
||||
{
|
||||
pm->m_pmState = pm->m_Fault_s99;
|
||||
}
|
||||
//3. 初始化配电系统为待机状态
|
||||
pm->initTargetDisBreakerState();
|
||||
//3. 初始化系统为待机状态
|
||||
pm->initControlCmd();
|
||||
pm->m_pmState = pm->m_Standby_s2;
|
||||
return 0;
|
||||
}
|
||||
@@ -601,8 +614,9 @@ int PowerManger::handleFault_s99(FSM_State &fsm, void* pData)
|
||||
}
|
||||
|
||||
|
||||
void PowerManger::initTargetDisBreakerState()
|
||||
void PowerManger::initControlCmd()
|
||||
{
|
||||
//================初始化配电指令=============================
|
||||
m_targetDisBreakerState.bus1Breaker.fuelCellCircuitBreaker = 0;
|
||||
m_targetDisBreakerState.bus1Breaker.powerLithiumBatteryCircuitBreaker = 1; //动力锂电池默认接入
|
||||
m_targetDisBreakerState.bus1Breaker.propulsionMotorCircuitBreaker = 0;
|
||||
@@ -639,7 +653,16 @@ void PowerManger::initTargetDisBreakerState()
|
||||
m_targetDisBreakerState.bus4Breaker.reservedCircuitBreaker1 = 0;
|
||||
m_targetDisBreakerState.bus4Breaker.reservedCircuitBreaker2 = 0;
|
||||
m_targetDisBreakerState.bus4Breaker.emergencyLithiumBatteryGroup1CircuitBreaker = 1; //紧急锂电池默认接入
|
||||
|
||||
//================初始化复合管控=============================
|
||||
m_CcuColCmd.workCondition = 0x00; //默认无效
|
||||
m_CcuColCmd.fcuCmd = 0x00; //无效指令
|
||||
m_CcuColCmd.fcuPowerEfficiency = 15; //默认为15kw
|
||||
m_CcuColCmd.fcuInsEfficiency = 00; //预留指令,无效
|
||||
m_CcuColCmd.insBatCmd = 0x00; //无效指令
|
||||
m_CcuColCmd.powerBatCmd = 0x00; //无效指令
|
||||
m_CcuColCmd.powerBatEfficiency = 230; //默认为最大
|
||||
m_CcuColCmd.heartbeat = 0;
|
||||
m_CcuColCmd.masterState = 0xAA;//主站状态,运行中
|
||||
}
|
||||
|
||||
char PowerManger::getBreakerOption(char cmd)
|
||||
|
||||
@@ -98,9 +98,6 @@ class PowerManger : public AppCastingMOOSApp
|
||||
unsigned int soc;
|
||||
unsigned int sustainableTime;
|
||||
pmState m_pmCurrentState; //能源系统的当前状态
|
||||
//断路器状态
|
||||
disSysBreakerList m_currentDisBreakerState;
|
||||
disSysBreakerList m_targetDisBreakerState;
|
||||
|
||||
// 配电和CCU的反馈状态
|
||||
msg_CcuStateFbMsg m_CcuCurrentState;
|
||||
@@ -110,13 +107,15 @@ class PowerManger : public AppCastingMOOSApp
|
||||
msg_disLowBusFbMsg m_disLowBusState;
|
||||
|
||||
//下位机操作函数
|
||||
//断路器状态
|
||||
disSysBreakerList m_currentDisBreakerState;
|
||||
disSysBreakerList m_targetDisBreakerState;
|
||||
ccuColCmd m_CcuColCmd;
|
||||
void disSysOption();
|
||||
char getBreakerOption(char cmd);
|
||||
void initTargetDisBreakerState();
|
||||
|
||||
void ccuOption();
|
||||
|
||||
|
||||
char getBreakerOption(char cmd);
|
||||
void initControlCmd();
|
||||
|
||||
//上位机操作函数
|
||||
bool buildPowerSysReport();
|
||||
|
||||
@@ -216,7 +216,80 @@ bool SQLiteDB::bindParameters<disLowBusState>(sqlite3_stmt* stmt, const disLowBu
|
||||
sqlite3_bind_int(stmt, index++, data.emergency1BusbarVoltage);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool SQLiteDB::bindParameters<ccuColCmd>(sqlite3_stmt* stmt, const ccuColCmd& data) {
|
||||
int index = 1;
|
||||
sqlite3_bind_int(stmt, index++, data.workCondition);
|
||||
sqlite3_bind_int(stmt, index++, data.fcuCmd);
|
||||
sqlite3_bind_int(stmt, index++, data.fcuPowerEfficiency);
|
||||
sqlite3_bind_int(stmt, index++, data.fcuInsEfficiency);
|
||||
sqlite3_bind_int(stmt, index++, data.insBatCmd);
|
||||
sqlite3_bind_int(stmt, index++, data.powerBatCmd);
|
||||
sqlite3_bind_int(stmt, index++, data.powerBatEfficiency);
|
||||
sqlite3_bind_int(stmt, index++, data.heartbeat);
|
||||
sqlite3_bind_int(stmt, index++, data.masterState);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool SQLiteDB::bindParameters<disHighVolBusCmd>(sqlite3_stmt* stmt, const disHighVolBusCmd& data) {
|
||||
int index = 1;
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.fuelCellCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.powerLithiumBatteryCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.propulsionMotorCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.lithiumBatteryGroupInstrumentCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.dcDc5ModuleCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.bowHighVoltageDistributionBoxCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.sternFTDevice45CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.sternRudderSwitch1CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.sternRudderSwitch2CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.fbReservedCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.tyzReservedCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.reservedCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.dcdc5Module));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.inputWater));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.outputWater));
|
||||
return true;
|
||||
|
||||
}
|
||||
template<>
|
||||
bool SQLiteDB::bindParameters<disHighAVolBusCmd>(sqlite3_stmt* stmt, const disHighAVolBusCmd& data) {
|
||||
int index = 1;
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.bowFTDevice123CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.actuatorCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.mastSteeringGearControlBoxCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.xczCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.bowRudderControlBoxCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.openWaterCoverStartCylinderCircuitBreaker));
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool SQLiteDB::bindParameters<disHighBVolBusCmd>(sqlite3_stmt* stmt, const disHighBVolBusCmd& data) {
|
||||
int index = 1;
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.lithiumBatteryGroupInstrumentCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.bowLowVoltageDistributionBoxCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.unit4InstrumentDC48VCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.dcC1DCDistributionPanelCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.reservedCircuitBreaker1));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.reservedCircuitBreaker2));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.emergencyLithiumBatteryGroup2CircuitBreaker));
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
bool SQLiteDB::bindParameters<disLowBusCmd>(sqlite3_stmt* stmt, const disLowBusCmd& data) {
|
||||
int index = 1;
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.unit1CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.unit2CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.unit3CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.unit5CircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.bowPZDeviceCircuitBreaker));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.reservedCircuitBreaker1));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.reservedCircuitBreaker2));
|
||||
sqlite3_bind_int(stmt, index++, static_cast<int>(data.emergencyLithiumBatteryGroup1CircuitBreaker));
|
||||
return true;
|
||||
}
|
||||
|
||||
SQLiteDB::~SQLiteDB() {
|
||||
if (m_db) {
|
||||
@@ -498,12 +571,93 @@ bool SQLiteDB::insertDisCcuData(pmState s, bool filter) {
|
||||
|
||||
return result;
|
||||
}
|
||||
bool SQLiteDB::insertCcuSysCmd(ccuColCmd cmd)
|
||||
{
|
||||
if (!m_db) return false;
|
||||
|
||||
// 插入ccu_sys_cmd表
|
||||
const char* ccuSysCmdSql = "INSERT INTO ccu_sys_cmd ("
|
||||
"workCondition, fcuCmd, fcuPowerEfficiency, fcuInsEfficiency, "
|
||||
"insBatCmd, powerBatCmd, powerBatEfficiency, heartbeat, masterState) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
// 执行插入操作
|
||||
bool result = executeInsert(ccuSysCmdSql, cmd);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SQLiteDB::insertDisSysCmd(disHighVolBusCmd cmd)
|
||||
{
|
||||
if (!m_db) return false;
|
||||
|
||||
// 插入dis_sys_cmd表,根据结构体完善SQL语句
|
||||
const char* disSysCmdSql = "INSERT INTO dis_high_vol_bus_cmd ("
|
||||
"fuelCellCircuitBreaker, powerLithiumBatteryCircuitBreaker, propulsionMotorCircuitBreaker, "
|
||||
"lithiumBatteryGroupInstrumentCircuitBreaker, dcDc5ModuleCircuitBreaker, "
|
||||
"bowHighVoltageDistributionBoxCircuitBreaker, sternFTDevice45CircuitBreaker, "
|
||||
"sternRudderSwitch1CircuitBreaker, sternRudderSwitch2CircuitBreaker, "
|
||||
"fbReservedCircuitBreaker, tyzReservedCircuitBreaker, reservedCircuitBreaker, "
|
||||
"dcdc5Module, inputWater, outputWater) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
// 执行插入操作
|
||||
bool result = executeInsert(disSysCmdSql, cmd);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SQLiteDB::insertDisSysCmd(disHighAVolBusCmd cmd)
|
||||
{
|
||||
if (!m_db) return false;
|
||||
|
||||
// 插入dis_sys_cmd表,根据结构体完善SQL语句
|
||||
const char* disSysCmdSql = "INSERT INTO dis_high_a_vol_bus_cmd ("
|
||||
"bowFTDevice123CircuitBreaker, actuatorCircuitBreaker, mastSteeringGearControlBoxCircuitBreaker, "
|
||||
"xczCircuitBreaker, bowRudderControlBoxCircuitBreaker, openWaterCoverStartCylinderCircuitBreaker) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?);";
|
||||
|
||||
// 执行插入操作
|
||||
bool result = executeInsert(disSysCmdSql, cmd);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SQLiteDB::insertDisSysCmd(disHighBVolBusCmd cmd)
|
||||
{
|
||||
if (!m_db) return false;
|
||||
// 插入dis_sys_cmd表,根据结构体完善SQL语句
|
||||
const char* disSysCmdSql = "INSERT INTO dis_high_b_vol_bus_cmd ("
|
||||
"lithiumBatteryGroupInstrumentCircuitBreaker, "
|
||||
"bowLowVoltageDistributionBoxCircuitBreaker, "
|
||||
"unit4InstrumentDC48VCircuitBreaker, "
|
||||
"dcC1DCDistributionPanelCircuitBreaker, "
|
||||
"reservedCircuitBreaker1, "
|
||||
"reservedCircuitBreaker2, "
|
||||
"emergencyLithiumBatteryGroup2CircuitBreaker) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
// 执行插入操作
|
||||
bool result = executeInsert(disSysCmdSql, cmd);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SQLiteDB::insertDisSysCmd(disLowBusCmd cmd)
|
||||
{
|
||||
if (!m_db) return false;
|
||||
|
||||
// 插入dis_sys_cmd表,根据结构体完善SQL语句
|
||||
const char* disSysCmdSql = "INSERT INTO dis_low_bus_cmd ("
|
||||
"unit1CircuitBreaker, unit2CircuitBreaker, unit3CircuitBreaker, unit5CircuitBreaker, "
|
||||
"bowPZDeviceCircuitBreaker, reservedCircuitBreaker1, reservedCircuitBreaker2, "
|
||||
"emergencyLithiumBatteryGroup1CircuitBreaker) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
// 执行插入操作
|
||||
bool result = executeInsert(disSysCmdSql, cmd);
|
||||
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, "
|
||||
@@ -834,6 +988,71 @@ bool SQLiteDB::createDisCcuSysTables() {
|
||||
"emergencyLithiumBatteryGroup1Current INTEGER NOT NULL,"
|
||||
"emergency1BusbarVoltage INTEGER NOT NULL);";
|
||||
|
||||
|
||||
// 创建ccu命令表
|
||||
const char* ccuCmdSql = "CREATE TABLE IF NOT EXISTS ccu_sys_cmd ("
|
||||
"timestamp DATETIME DEFAULT (strftime('%Y-%m-%d %H:%M:%f', 'now')),"
|
||||
"workCondition INTEGER NOT NULL,"
|
||||
"fcuCmd INTEGER NOT NULL,"
|
||||
"fcuPowerEfficiency INTEGER NOT NULL,"
|
||||
"fcuInsEfficiency INTEGER NOT NULL,"
|
||||
"insBatCmd INTEGER NOT NULL,"
|
||||
"powerBatCmd INTEGER NOT NULL,"
|
||||
"powerBatEfficiency INTEGER NOT NULL,"
|
||||
"heartbeat INTEGER NOT NULL,"
|
||||
"masterState INTEGER NOT NULL);";
|
||||
|
||||
// 创建dis命令表
|
||||
const char* disHighVolBusCmdSql = "CREATE TABLE IF NOT EXISTS dis_high_vol_bus_cmd ("
|
||||
"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,"
|
||||
"dcdc5Module INTEGER NOT NULL,"
|
||||
"inputWater INTEGER NOT NULL,"
|
||||
"outputWater INTEGER NOT NULL);";
|
||||
|
||||
const char* disHighAVolBusCmdSql = "CREATE TABLE IF NOT EXISTS dis_high_a_vol_bus_cmd ("
|
||||
"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);";
|
||||
|
||||
const char* disHighBVolBusCmdSql = "CREATE TABLE IF NOT EXISTS dis_high_b_vol_bus_cmd ("
|
||||
"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);";
|
||||
|
||||
const char* disLowBusCmdSql = "CREATE TABLE IF NOT EXISTS dis_low_bus_cmd ("
|
||||
"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);";
|
||||
|
||||
|
||||
|
||||
char* errMsg = nullptr;
|
||||
bool result = true;
|
||||
|
||||
@@ -868,5 +1087,35 @@ bool SQLiteDB::createDisCcuSysTables() {
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (sqlite3_exec(m_db, ccuCmdSql, nullptr, nullptr, &errMsg)!= SQLITE_OK) {
|
||||
std::cerr << "SQL error creating ccu_cmd table: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (sqlite3_exec(m_db, disHighVolBusCmdSql, nullptr, nullptr, &errMsg)!= SQLITE_OK) {
|
||||
std::cerr << "SQL error creating dis_high_vol_bus_cmd table: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (sqlite3_exec(m_db, disHighAVolBusCmdSql, nullptr, nullptr, &errMsg)!= SQLITE_OK) {
|
||||
std::cerr << "SQL error creating dis_high_a_vol_bus_cmd table: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (sqlite3_exec(m_db, disHighBVolBusCmdSql, nullptr, nullptr, &errMsg)!= SQLITE_OK) {
|
||||
std::cerr << "SQL error creating dis_high_b_vol_bus_cmd table: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (sqlite3_exec(m_db, disLowBusCmdSql, nullptr, nullptr, &errMsg)!= SQLITE_OK) {
|
||||
std::cerr << "SQL error creating dis_low_bus_cmd table: " << errMsg << std::endl;
|
||||
sqlite3_free(errMsg);
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,13 @@ public:
|
||||
bool insertDisHighBVolBusData(disHighBVolBusState s);
|
||||
bool insertDisLowBusData(disLowBusState s);
|
||||
|
||||
bool insertDisCcuData(pmState s,bool filter=true);
|
||||
bool insertCcuSysCmd(ccuColCmd cmd);
|
||||
bool insertDisSysCmd(disHighVolBusCmd cmd);
|
||||
bool insertDisSysCmd(disHighAVolBusCmd cmd);
|
||||
bool insertDisSysCmd(disHighBVolBusCmd cmd);
|
||||
bool insertDisSysCmd(disLowBusCmd cmd);
|
||||
|
||||
bool insertDisCcuData(pmState s,bool filter=true);//由于信息同步原因,暂时不使用该函数
|
||||
|
||||
// 获取最新的状态数据
|
||||
bool getStateData(StateData &stateData);
|
||||
|
||||
@@ -12,7 +12,7 @@ class logWin(Frame):
|
||||
def __init__(self, root):
|
||||
super().__init__(root)
|
||||
self.root = root
|
||||
custom_font = font.Font(family="Arial", size=12, weight="normal")
|
||||
custom_font = font.Font(family="Arial", size=8)
|
||||
|
||||
# 设置 state 为 tk.DISABLED 禁用编辑功能
|
||||
self.text_box = tk.Text(root, height=10, width=50, font=custom_font, state=tk.DISABLED)
|
||||
|
||||
@@ -38,6 +38,9 @@ def receive_messages(sock, logwin:logWin, disSysWin:disSys):
|
||||
logWin.display_log(logwin,f"{formatted_time}->接收到来自 {address} | 高压汇流排B配电指令:")
|
||||
elif(msg_id==0x0004):
|
||||
logWin.display_log(logwin,f"{formatted_time}->接收到来自 {address} | 低压母线配电指令:")
|
||||
elif(start1==0x20 and start2==0x20):
|
||||
if(msg_id==0x0050):
|
||||
logWin.display_log(logwin,f"{formatted_time}->接收到来自 {address} | CCU控制指令:")
|
||||
|
||||
|
||||
def send_messages(sock, logwin:logWin, disSysWin:disSys,ccuSysWin:ccuSys):
|
||||
|
||||
Reference in New Issue
Block a user