#pragma once #include "commondef.h" #include #include "json.hpp" using json = nlohmann::json; class SensorConfig { private: const std::string Path = "/usr/local/huago/sensorconfig.json"; const std::string Sensor_Scan_Pwm = "Sensor_Scan_Pwm"; const std::string Sensor_Screw_1_Pwm = "Sensor_Screw_1_Pwm"; const std::string Sensor_Screw_2_Pwm = "Sensor_Screw_2_Pwm"; const std::string Sensor_ConverOpen_Pwm = "Sensor_ConverOpen_Pwm"; const std::string Sensor_PaperOut_Pwm = "Sensor_PaperOut_Pwm"; const std::string Sensor_PaperDetection_Pwm = "Sensor_PaperDetection_Pwm"; const std::string Sensor_Double_double_check_cyc = "Sensor_Double_double_check_cyc"; const std::string Sensor_Double_paper_check_cyc = "Sensor_Double_paper_check_cyc"; const std::string Sensor_Double_double_max = "Sensor_Double_double_max"; const std::string Sensor_Double_single_max = "Sensor_Double_single_max"; public: struct SensorConfig_Param { uint32_t Sensor_Scan_Pwm; //扫描传感器 uint32_t Sensor_ConverOpen_Pwm; //开盖传感器 uint32_t Sensor_Screw_1_Pwm; //歪斜_1传感器 uint32_t Sensor_Screw_2_Pwm; //歪斜_2传感器 uint32_t Sensor_PaperOut_Pwm; //出纸口传感器 uint32_t Sensor_PaperDetection_Pwm; //有无纸传感器 uint32_t Sensor_Double_double_check_cyc; //双张检测周期 uint32_t Sensor_Double_paper_check_cyc; //双张有纸检测周期 uint32_t Sensor_Double_double_max; //双张检测阈值 uint32_t Sensor_Double_single_max; //双张有纸检测阈值 }; SensorConfig(); ~SensorConfig(); SensorConfig::SensorConfig_Param get_param(); void set_param(SensorConfig::SensorConfig_Param param); SensorConfig::SensorConfig_Param get_mem_param(); private: void initconfigfile(); void reset_json(); json to_json(SensorConfig::SensorConfig_Param param); SensorConfig::SensorConfig_Param to_param(json js); std::mutex m_lock; SensorConfig::SensorConfig_Param m_param; }; extern SensorConfig m_static_sensorconfig; static SensorConfig& Get_Static_SC(){ return m_static_sensorconfig; };