1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // Created by lenovo on 2024-12-20.
- //
- #ifndef DEVICES_INFO_H
- #define DEVICES_INFO_H
- #include <microhttpd.h>
- #include <iostream>
- #include <nlohmann/json.hpp>
- #include <vector>
- #include <string>
- using namespace std;
- using json = nlohmann::json;
- // 模拟的数据结构
- struct Measure {
- string point;
- string value;
- };
- struct Device {
- string device_name;
- vector<Measure> measures;
- };
- struct AllowDevice {
- string device_name;
- };
- // 定义 HistoryItem 结构体
- struct HistoryItem {
- string time; // 时间戳
- map<string, float> values; // 测点名称 -> 测点值的映射
- };
- // 定义 DeviceMeasurement 结构体
- struct DeviceMeasurement {
- string name; // 测点名称(如 "湿度"、"温度" 等)
- vector<HistoryItem> historyItems; // 多个时间点的历史数据
- };
- // 定义 DeviceHistory 结构体
- struct DeviceHistory {
- string device_name; // 设备名称(如 "温湿度-1"、"烟感-1" 等)
- vector<DeviceMeasurement> measurements; // 该设备的所有测点数据
- };
- vector<Device> control_devices_status();
- json deviceInfoToJson(const vector<Device>& devices);
- vector<Device> createDeviceInfo();
- vector<AllowDevice> allowDevice();
- json createDeviceHistoryData();
- json deviceHistoryToJson(const vector<DeviceHistory>& devices_history);
- json allowDeviceInfoToJson(const vector<AllowDevice>& devices);
- #endif //DEVICES_INFO_H
|