SimpleConfig.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
  3. * @Date: 2025-06-11 14:39:19
  4. * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
  5. * @LastEditTime: 2025-06-17 16:36:20
  6. * @FilePath: /yancheng/SimpleConfig.h
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. #pragma once
  10. #include <string>
  11. #include <nlohmann/json.hpp>
  12. struct NetworkConfig {
  13. struct Udp {
  14. std::string target_ip;
  15. int target_port;
  16. bool enabled;
  17. } udp;
  18. struct Zmq {
  19. int gps_publish_port;
  20. int imu_publish_port;
  21. int fused_publish_port;
  22. bool enabled;
  23. } zmq;
  24. };
  25. struct DeviceConfig {
  26. struct Gps {
  27. std::string serial_port;
  28. int timeout_ms;
  29. bool enabled;
  30. } gps;
  31. struct Imu {
  32. std::string serial_port;
  33. int polling_rate_hz;
  34. bool enabled;
  35. } imu;
  36. struct Camera {
  37. int device_index;
  38. int width;
  39. int height;
  40. int jpeg_quality;
  41. int fps;
  42. bool enabled;
  43. } camera;
  44. };
  45. class SimpleConfig {
  46. public:
  47. SimpleConfig() = default;
  48. static SimpleConfig& getInstance();
  49. bool load(const std::string& filepath);
  50. const NetworkConfig& getNetwork() const { return network_; }
  51. const DeviceConfig& getDevices() const { return devices_; }
  52. private:
  53. NetworkConfig network_;
  54. DeviceConfig devices_;
  55. };