devices_info.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // Created by lenovo on 2024-12-20.
  3. //
  4. #ifndef DEVICES_INFO_H
  5. #define DEVICES_INFO_H
  6. #include <microhttpd.h>
  7. #include <iostream>
  8. #include <nlohmann/json.hpp>
  9. #include <vector>
  10. #include <string>
  11. using namespace std;
  12. using json = nlohmann::json;
  13. // 模拟的数据结构
  14. struct Measure {
  15. string point;
  16. string value;
  17. };
  18. struct Device {
  19. string device_name;
  20. vector<Measure> measures;
  21. };
  22. struct AllowDevice {
  23. string device_name;
  24. };
  25. // 定义 HistoryItem 结构体
  26. struct HistoryItem {
  27. string time; // 时间戳
  28. map<string, float> values; // 测点名称 -> 测点值的映射
  29. };
  30. // 定义 DeviceMeasurement 结构体
  31. struct DeviceMeasurement {
  32. string name; // 测点名称(如 "湿度"、"温度" 等)
  33. vector<HistoryItem> historyItems; // 多个时间点的历史数据
  34. };
  35. // 定义 DeviceHistory 结构体
  36. struct DeviceHistory {
  37. string device_name; // 设备名称(如 "温湿度-1"、"烟感-1" 等)
  38. vector<DeviceMeasurement> measurements; // 该设备的所有测点数据
  39. };
  40. vector<Device> control_devices_status();
  41. json deviceInfoToJson(const vector<Device>& devices);
  42. vector<Device> createDeviceInfo();
  43. vector<AllowDevice> allowDevice();
  44. json createDeviceHistoryData();
  45. json deviceHistoryToJson(const vector<DeviceHistory>& devices_history);
  46. json allowDeviceInfoToJson(const vector<AllowDevice>& devices);
  47. #endif //DEVICES_INFO_H