4 changed files with 218 additions and 1 deletions
-
30README.md
-
2iflytoplinuxsdk
-
94src/service/sensor_data_scan.cpp
-
93src/service/sensor_data_scan.hpp
@ -1 +1 @@ |
|||
Subproject commit 49be222386739d320e2dcfe3f1a79cd8dd71c5b2 |
|||
Subproject commit ef70ce36d2577b0f5ce3ec1d9cd2de3f7d2ec922 |
@ -0,0 +1,94 @@ |
|||
#include "sensor_data_scan.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
|
|||
SensorDataScan::SensorDataScan() {} |
|||
void SensorDataScan::initialize() { GET_TO_SERVICE(m_zcanHost); } |
|||
#if 0
|
|||
模块 板子 硬件ID ID |
|||
空压机-安全电磁阀 3 PC2 0 |
|||
空压机-通断电磁阀 3 PC3 1 |
|||
鼓风机-安全电磁阀 3 PC4 2 |
|||
-通断电磁阀 3 PC5 3 |
|||
加热片-安全电磁阀 3 PC6 4 |
|||
-通断电磁阀 3 PC7 5 |
|||
#endif
|
|||
void SensorDataScan::startScan() { |
|||
m_workThread.reset(new Thread("SensorDataScan", [this]() { |
|||
ThisThread thisThread; |
|||
uint32_t i = 0; |
|||
|
|||
int readpressuresensor_id = 1; |
|||
|
|||
while (!thisThread.getExitFlag()) { |
|||
/* code */ |
|||
thisThread.sleepForMs(1); |
|||
i++; |
|||
|
|||
if (i % 1000 == 0) { |
|||
m_zcanHost->readadc(1, m_adc_1); |
|||
m_zcanHost->readadc(2, m_adc_2); |
|||
m_zcanHost->readadc(3, m_adc_3); |
|||
m_zcanHost->readadc(4, m_adc_4); |
|||
m_zcanHost->readadc(5, m_adc_5); |
|||
} |
|||
|
|||
if (i % 1000 * 3) { |
|||
// m_hpp272_data_1
|
|||
m_zcanHost->hpp272_read_c1000(1, m_hpp272_data_1); |
|||
} |
|||
|
|||
if (i % 300 * 1) { |
|||
if (readpressuresensor_id == 5) { |
|||
readpressuresensor_id = 1; |
|||
} |
|||
m_zcanHost->huacheng_pressure_sensor_read_c1005(readpressuresensor_id, m_pressure_sensor_data[readpressuresensor_id]); |
|||
readpressuresensor_id++; |
|||
} |
|||
|
|||
if (i % 100 * 1) { |
|||
m_zcanHost->readio(1, m_waterImmersionSensor1); |
|||
m_zcanHost->readio(2, m_waterImmersionSensor2); |
|||
} |
|||
} |
|||
})); |
|||
} |
|||
|
|||
int SensorDataScan::getAirCompressor_io1() { return m_zcanHost->read_writeio_state_cache(1); } |
|||
int SensorDataScan::getAirCompressor_io2() { return m_zcanHost->read_writeio_state_cache(2); } |
|||
int SensorDataScan::getAirCompressor_currentValue() { return m_adc_1; } |
|||
|
|||
int SensorDataScan::getAirBlower_io1() { return m_zcanHost->read_writeio_state_cache(3); } |
|||
int SensorDataScan::getAirBlower_io2() { return m_zcanHost->read_writeio_state_cache(4); } |
|||
int SensorDataScan::getAirBlower_currentValue() { return m_adc_2; } |
|||
|
|||
// heatingStrip
|
|||
int SensorDataScan::getHeatingStrip_io1() { return m_zcanHost->read_writeio_state_cache(5); } |
|||
int SensorDataScan::getHeatingStrip_io2() { return m_zcanHost->read_writeio_state_cache(6); } |
|||
int SensorDataScan::getHeatingStrip_currentValue() { return m_adc_3; } |
|||
|
|||
int SensorDataScan::getSprinkler_PumpRPM() { return m_zcanHost->pumpctrl_c1004_get_speed_cache(2); } |
|||
int SensorDataScan::getChargingPump_PumpRPM() { return m_zcanHost->pumpctrl_c1004_get_speed_cache(1); } |
|||
|
|||
int SensorDataScan::getDisinfectantVolume() { |
|||
// kpa;
|
|||
int pa = m_zcanHost->huacheng_pressure_sensor_get_pa(&m_pressure_sensor_data[0]); |
|||
return pa; |
|||
} |
|||
|
|||
int SensorDataScan::getWaterImmersionSensor1() { return m_waterImmersionSensor1 ? 1 : 0; } |
|||
int SensorDataScan::getWaterImmersionSensor2() { return m_waterImmersionSensor2 ? 1 : 0; } |
|||
|
|||
SensorDataScan::h2o2sensor_data_t SensorDataScan::getH2O2SenSorData(int id) { |
|||
SensorDataScan::h2o2sensor_data_t data; |
|||
// int16_t hydrogen_peroxide_volume; // ppm 0x0100 过氧化氢浓度
|
|||
// int16_t h2o_h2o2_rs; // %RS * 100 0x0101 过氧化氢相对饱和度
|
|||
// int16_t temperature1; // °C * 100 0x0102 温度
|
|||
// int16_t relative_humidity; // %RH * 100 0x0103 相对湿度
|
|||
data.h2o2 = m_hpp272_data_1.hydrogen_peroxide_volume; |
|||
data.humid = m_hpp272_data_1.relative_humidity; |
|||
data.temp = m_hpp272_data_1.temperature1; |
|||
data.saturation = m_hpp272_data_1.h2o_h2o2_rs; |
|||
return data; |
|||
} |
@ -0,0 +1,93 @@ |
|||
//
|
|||
// Created by zwsd
|
|||
//
|
|||
|
|||
#pragma once
|
|||
#include <fstream>
|
|||
#include <iostream>
|
|||
#include <list>
|
|||
#include <map>
|
|||
#include <memory>
|
|||
#include <mutex>
|
|||
#include <set>
|
|||
#include <sstream>
|
|||
#include <string>
|
|||
#include <vector>
|
|||
|
|||
#include "iflytop/components/zcanreceiver/zcanhost.hpp"
|
|||
#include "iflytop/core/core.hpp"
|
|||
#include "zservice_container/zservice_container.hpp"
|
|||
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* service: SensorDataScan |
|||
* |
|||
* 监听事件: |
|||
* 依赖状态: |
|||
* 依赖服务: |
|||
* 作用: |
|||
* |
|||
*/ |
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace core; |
|||
|
|||
class SensorDataScan : public enable_shared_from_this<SensorDataScan> { |
|||
ENABLE_LOGGER(SensorDataScan); |
|||
|
|||
unique_ptr<Thread> m_workThread; |
|||
shared_ptr<ZCanHost> m_zcanHost; |
|||
|
|||
//
|
|||
ZCanHost::hpp272_data_t m_hpp272_data_1; |
|||
ZCanHost::huacheng_pressure_sensor_read_c1005_t m_pressure_sensor_data[4]; |
|||
|
|||
//
|
|||
bool m_waterImmersionSensor1 = false; // 漏液检测
|
|||
bool m_waterImmersionSensor2 = false; // 仓内液体检测
|
|||
|
|||
int m_adc_1 = 0; //
|
|||
int m_adc_2 = 0; |
|||
int m_adc_3 = 0; |
|||
int m_adc_4 = 0; |
|||
int m_adc_5 = 0; |
|||
|
|||
public: |
|||
SensorDataScan(); |
|||
void initialize(); |
|||
void startScan(); |
|||
|
|||
public: |
|||
int getAirCompressor_io1(); |
|||
int getAirCompressor_io2(); |
|||
int getAirCompressor_currentValue(); |
|||
|
|||
int getAirBlower_io1(); |
|||
int getAirBlower_io2(); |
|||
int getAirBlower_currentValue(); |
|||
|
|||
// heatingStrip
|
|||
int getHeatingStrip_io1(); |
|||
int getHeatingStrip_io2(); |
|||
int getHeatingStrip_currentValue(); |
|||
|
|||
int getSprinkler_PumpRPM(); |
|||
int getChargingPump_PumpRPM(); |
|||
|
|||
int getDisinfectantVolume(); |
|||
|
|||
int getWaterImmersionSensor1(); |
|||
int getWaterImmersionSensor2(); |
|||
|
|||
typedef struct { |
|||
int h2o2; // ppm
|
|||
int temp; // 温度
|
|||
int humid; // 湿度 %RS
|
|||
int saturation; // 相对饱和度 %RS
|
|||
} h2o2sensor_data_t; |
|||
|
|||
h2o2sensor_data_t getH2O2SenSorData(int id); |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue