#ifndef SQLITEDB_H #define SQLITEDB_H #include #include #include #include "json/json.h" // #include struct PowerData { std::string timestamp; double voltage; double current; double power; 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 createPowerDataTables(); void insertPowerData(float voltage, float current, float power, float temperature); void createStateTables(); void insertStateData(StateData stateData); std::vector getPowerData(int limit = 100); //使用函数 bool isDatabaseConnected(const std::string& path, const std::string& dbName); private: sqlite3* m_db; }; #endif // SQLITEDB_H