Files
H100PowerManger/src/pPowerManger/SQLiteDB.h
T
2025-02-13 09:34:12 +08:00

46 lines
942 B
C++

#ifndef SQLITEDB_H
#define SQLITEDB_H
#include <sqlite3.h>
#include <string>
#include <vector>
#include "json/json.h"
// #include <nlohmann/json.hpp>
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<PowerData> getPowerData(int limit = 100);
//使用函数
bool isDatabaseConnected(const std::string& path, const std::string& dbName);
private:
sqlite3* m_db;
};
#endif // SQLITEDB_H