|
|
@ -5,22 +5,11 @@ |
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "chinese_gb2312.hpp"
|
|
|
|
#include "iflytop/components/uart_printer/uart_printer.hpp"
|
|
|
|
|
|
|
|
#include "iflytoplinuxsdk/src/iflytop/components/ziconv.hpp"
|
|
|
|
using namespace iflytop; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
#if 0
|
|
|
|
模块 板子 硬件ID ID |
|
|
|
空压机-安全电磁阀 3 PC2 0 |
|
|
|
空压机-通断电磁阀 3 PC3 1 |
|
|
|
鼓风机-安全电磁阀 3 PC4 2 |
|
|
|
-通断电磁阀 3 PC5 3 |
|
|
|
加热片-安全电磁阀 3 PC6 4 |
|
|
|
-通断电磁阀 3 PC7 5 |
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GPM_TO_SPEED(gpm) (gpm * 10)
|
|
|
|
#define SPEED_TO_GPM(speed) (speed / 10)
|
|
|
|
|
|
|
@ -249,7 +238,7 @@ static int filter(int data) { |
|
|
|
if (q.size() > 50) { |
|
|
|
q.pop_front(); |
|
|
|
} |
|
|
|
// 中值滤波
|
|
|
|
// 锟斤拷值锟剿诧拷
|
|
|
|
int datacache[51]; |
|
|
|
int ndata = 0; |
|
|
|
for (auto& var : q) { |
|
|
@ -275,7 +264,7 @@ int DeviceIoControlService::getDisinfectantVolume_g() { |
|
|
|
|
|
|
|
float kpa = m_pressure_sensor_data[1].value / 1000.0; |
|
|
|
int g = 2.11 * kpa * 1000 * 1.3; |
|
|
|
if (g < 450) { /*零点*/ |
|
|
|
if (g < 450) { /*锟斤拷锟�*/ |
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
g -= 450; |
|
|
@ -304,10 +293,10 @@ int DeviceIoControlService::getWaterImmersionSensor2() { |
|
|
|
DeviceIoControlService::h2o2sensor_data_t DeviceIoControlService::getH2O2SenSorData1() { |
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
DeviceIoControlService::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 相对湿度
|
|
|
|
// 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 / 100; |
|
|
|
data.temp = m_hpp272_data_1.temperature1 / 100; |
|
|
@ -315,7 +304,7 @@ DeviceIoControlService::h2o2sensor_data_t DeviceIoControlService::getH2O2SenSorD |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* TODO:传感器未初始化完成时,除了温度外,读取到的数据都是小于零,这里做了一个简单的处理,后续需要修改 |
|
|
|
* TODO:锟斤拷锟斤拷锟斤拷未锟斤拷始锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟斤拷露锟斤拷猓�拷锟饺★拷锟斤拷锟斤拷锟斤拷荻锟斤拷锟叫★拷锟斤拷悖�拷锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷虻サ拇锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟揭�拷薷锟� |
|
|
|
* |
|
|
|
*/ |
|
|
|
if (data.h2o2 < 0) { |
|
|
@ -342,7 +331,7 @@ bool DeviceIoControlService::getAllSensorData(DeviceIoControlService::all_h2o2se |
|
|
|
data.h2o2sensor_status[2] = false; |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 找到最小的过氧化氢浓度 |
|
|
|
* @brief 锟揭碉拷锟斤拷小锟侥癸拷锟斤拷锟斤拷锟斤拷浓锟斤拷 |
|
|
|
*/ |
|
|
|
data.min_h2o2 = -1; |
|
|
|
for (size_t i = 0; i < ZARRAYSIZE(data.h2o2sensor_data); i++) { |
|
|
@ -367,7 +356,7 @@ bool DeviceIoControlService::getAllSensorData(DeviceIoControlService::all_h2o2se |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 找到最大的过氧化氢相对饱和度 |
|
|
|
* @brief 锟揭碉拷锟斤拷锟侥癸拷锟斤拷锟斤拷锟斤拷锟斤拷员锟斤拷投锟� |
|
|
|
*/ |
|
|
|
data.max_saturation = -1; |
|
|
|
for (size_t i = 0; i < ZARRAYSIZE(data.h2o2sensor_data); i++) { |
|
|
@ -381,7 +370,7 @@ bool DeviceIoControlService::getAllSensorData(DeviceIoControlService::all_h2o2se |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 找到最大的相对湿度 |
|
|
|
* @brief 锟揭碉拷锟斤拷锟斤拷锟斤拷锟绞�拷锟� |
|
|
|
*/ |
|
|
|
|
|
|
|
data.max_humid = -1; |
|
|
@ -398,14 +387,13 @@ bool DeviceIoControlService::getAllSensorData(DeviceIoControlService::all_h2o2se |
|
|
|
} |
|
|
|
|
|
|
|
void DeviceIoControlService::printerTest() { |
|
|
|
printerPrintf("* * * * * * * * * * * * * * * \n"); |
|
|
|
printerPrintf("123456789123456789\n"); |
|
|
|
printerPrintf("abcdefghijk lmnopqr\n"); |
|
|
|
printerPrintf("ABCDEF GHIJ KLMN OPQR\n"); |
|
|
|
printerPrintf(fmt::format("{}\n", ChineseGb2312().nihaozhongguo())); |
|
|
|
printerPrintf(fmt::format("{}\n", ChineseGb2312().nihaozhongguo())); |
|
|
|
printerPrintf(fmt::format("{}\n", ChineseGb2312().nihaozhongguo())); |
|
|
|
printerPrintf("\n"); |
|
|
|
printerPrintf("\n"); |
|
|
|
// printerPrintf("* * * * * * * * * * * * * * * \n");
|
|
|
|
// printerPrintf("123456789123456789\n");
|
|
|
|
// printerPrintf("abcdefghijk lmnopqr\n");
|
|
|
|
// printerPrintf("ABCDEF GHIJ KLMN OPQR\n");
|
|
|
|
// printerPrintf("鍏ㄦ€濈編鐗�");
|
|
|
|
// printerPrintf("鎵撳嵃娴嬭瘯");
|
|
|
|
// printerPrintf("\n");
|
|
|
|
// printerPrintf("\n");
|
|
|
|
} |
|
|
|
void DeviceIoControlService::printerPrintf(string str) { GET_SERVICE(UartPrinter)->print(str); } |
|
|
|
void DeviceIoControlService::printerPrintf(string str) { GET_SERVICE(UartPrinter)->print(ZIconv::utf8_to_gb2312(str)); } |