rk3399_arm_lvds/motorboard/SensorConfig.h

63 lines
2.6 KiB
C
Raw Normal View History

2024-03-05 03:46:18 +00:00
#pragma once
#include "commondef.h"
#include <mutex>
#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";
2024-03-18 06:31:20 +00:00
const std::string Sensor_enable_config = "Sensor_enable_config";
2024-03-05 03:46:18 +00:00
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";
2024-03-18 06:31:20 +00:00
const std::string Sensor_Double_enable_config = "Sensor_double_enable_config";
2024-03-05 03:46:18 +00:00
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; //双张有纸检测阈值
2024-03-18 06:31:20 +00:00
uint32_t Sensor_enable_config; //对射传感器配置生效
uint32_t Sensor_Double_enable_config; //超声波配置生效
2024-03-05 03:46:18 +00:00
};
SensorConfig();
~SensorConfig();
SensorConfig::SensorConfig_Param get_param();
void set_param(SensorConfig::SensorConfig_Param param);
2024-03-18 06:31:20 +00:00
SensorConfig::SensorConfig_Param& get_mem_param();
json get_mem_param_js();
SensorConfig_Param get_default_param();
2024-03-05 03:46:18 +00:00
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;
};