为状态机增加了线程运行,并补充了数据库
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
// #include <nlohmann/json.hpp>
|
||||
|
||||
struct PowerData {
|
||||
int id;
|
||||
std::string timestamp;
|
||||
double voltage;
|
||||
double current;
|
||||
@@ -16,24 +15,28 @@ struct PowerData {
|
||||
double temperature;
|
||||
};
|
||||
|
||||
struct StateData {
|
||||
std::string timestamp;
|
||||
int state_id;
|
||||
std::string state_name;
|
||||
std::string event;
|
||||
int event_id;
|
||||
int fault_code;
|
||||
};
|
||||
|
||||
class SQLiteDB {
|
||||
public:
|
||||
SQLiteDB(const std::string& dbPath);
|
||||
~SQLiteDB();
|
||||
|
||||
void createTables();
|
||||
void createPowerDataTables();
|
||||
void insertPowerData(float voltage, float current, float power, float temperature);
|
||||
void createStateTables();
|
||||
void insertStateData(StateData stateData);
|
||||
std::vector<PowerData> getPowerData(int limit = 100);
|
||||
|
||||
template<typename T>
|
||||
void insertStructData(const std::string& tableName, const T& data);
|
||||
|
||||
|
||||
private:
|
||||
sqlite3* m_db;
|
||||
|
||||
template<typename T>
|
||||
std::string serializeStruct(const T& data);
|
||||
};
|
||||
|
||||
#endif // SQLITEDB_H
|
||||
|
||||
Reference in New Issue
Block a user