增加了xc声纳的上电

This commit is contained in:
zjk
2025-09-12 11:35:17 +08:00
parent c2b9bccfc6
commit 481171d9ea
43 changed files with 1921 additions and 296 deletions
+36 -18
View File
@@ -3,13 +3,17 @@
#include <iostream>
#include "../logc/loguru.hpp"
SQLite::SQLite(const std::string& dbPath)
{
if (sqlite3_open(dbPath.c_str(), &m_db) != SQLITE_OK) {
LOG_F(WARNING, "Can't open database: %s", sqlite3_errmsg(m_db));
SQLite::SQLite(const std::string& dbPath) {
try {
if (sqlite3_open(dbPath.c_str(), &m_db) != SQLITE_OK) {
LOG_F(ERROR, "无法打开数据库: %s", sqlite3_errmsg(m_db));
m_db = nullptr;
}
m_dbPath = dbPath;
} catch (...) {
LOG_F(ERROR, "SQLite构造函数发生异常");
m_db = nullptr;
}
m_dbPath = dbPath;
}
SQLite::~SQLite()
@@ -71,9 +75,15 @@ bool SQLite::createTable()
o2_concentration2 INTEGER,
ch3oh_concentration1 INTEGER,
ch3oh_concentration2 INTEGER,
reserved1_1 INTEGER, reserved1_2 INTEGER, reserved1_3 INTEGER, reserved1_4 INTEGER,
reserved1_5 INTEGER, reserved1_6 INTEGER, reserved1_7 INTEGER, reserved1_8 INTEGER,
reserved1_9 INTEGER, reserved1_10 INTEGER,
reserved1_1 INTEGER, reserved1_2 INTEGER,
emergency_battery1_voltage INTEGER,
emergency_battery1_current INTEGER,
emergency_battery1_max_temp INTEGER,
emergency_battery1_fault_word INTEGER,
emergency_battery2_voltage INTEGER,
emergency_battery2_current INTEGER,
emergency_battery2_max_temp INTEGER,
emergency_battery2_fault_word INTEGER,
cabin_ox_concentration INTEGER,
cabin_temperature INTEGER,
cabin_humidity INTEGER,
@@ -269,7 +279,7 @@ bool SQLite::createTable()
workCondition INTEGER,
fcuCmd INTEGER,
fcuPowerEfficiency INTEGER,
fcuInsEfficiency INTEGER,
insChargeEnable INTEGER,
insBatCmd INTEGER,
powerBatCmd INTEGER,
powerBatEfficiency INTEGER,
@@ -375,8 +385,9 @@ bool SQLite::insertData(const ccuState data) {
h2_concentration1, h2_concentration2, h2_concentration3,
o2_concentration1, o2_concentration2,
ch3oh_concentration1, ch3oh_concentration2,
reserved1_1, reserved1_2, reserved1_3, reserved1_4, reserved1_5,
reserved1_6, reserved1_7, reserved1_8, reserved1_9, reserved1_10,
reserved1_1, reserved1_2,
emergency_battery1_voltage, emergency_battery1_current, emergency_battery1_max_temp, emergency_battery1_fault_word,
emergency_battery2_voltage, emergency_battery2_current, emergency_battery2_max_temp, emergency_battery2_fault_word,
cabin_ox_concentration, cabin_temperature, cabin_humidity, cabin_pressure,
power_cabin_ox_concentration, power_cabin_temperature,
power_cabin_humidity, power_cabin_pressure,
@@ -417,7 +428,9 @@ bool SQLite::insertData(const ccuState data) {
?, ?,
?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?,
?, ?, ?, ?,
?, ?, ?, ?,
?, ?, ?, ?,
?, ?, ?, ?,
?,
@@ -430,8 +443,6 @@ bool SQLite::insertData(const ccuState data) {
?, ?,
?, ?,
?, ?,
?, ?,
?, ?,
?, ?, ?,
?, ?,
?, ?, ?,
@@ -443,7 +454,7 @@ bool SQLite::insertData(const ccuState data) {
?, ?, ?,
?, ?,
?, ?,
?, ?
?
);
)";
@@ -497,7 +508,16 @@ bool SQLite::insertData(const ccuState data) {
BIND_16(data.ch3oh_concentration1);
BIND_16(data.ch3oh_concentration2);
for (int i = 0; i < 10; ++i) BIND_16(data.reserved1[i]);
for (int i = 0; i < 2; ++i) BIND_16(data.reserved1[i]);
BIND_16(data.emergency_battery1_voltage);
BIND_16(data.emergency_battery1_current);
BIND_16(data.emergency_battery1_max_temp);
BIND_16(data.emergency_battery1_fault_word);
BIND_16(data.emergency_battery2_voltage);
BIND_16(data.emergency_battery2_current);
BIND_16(data.emergency_battery2_max_temp);
BIND_16(data.emergency_battery2_fault_word);
BIND_16(data.cabin_ox_concentration);
BIND_16(data.cabin_temperature);
@@ -626,8 +646,6 @@ bool SQLite::insertData(const ccuColCmd cmd) {
if (!success) {
std::cerr << "执行插入失败: " << sqlite3_errmsg(m_db) << std::endl;
}
sqlite3_finalize(stmt);
return success;
}