From 6957760d0c1d69954febfeabf5e60433ca56f4d6 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 26 Dec 2023 16:25:36 +0800 Subject: [PATCH] v1.0 --- README.md | 82 ++++--------------------------- iflytoplinuxsdk | 2 +- packet.sh | 0 src/configs/gconfig.hpp | 3 +- src/main.cpp | 8 ++- src/main_control_service.cpp | 1 + src/service/chinese_gb2312.cpp | 8 +++ src/service/chinese_gb2312.hpp | 19 +++++++ src/service/device_io_control_service.cpp | 67 ++++++++++++++++--------- src/service/device_io_control_service.hpp | 15 +++--- src/service/disinfection_ctl_service.cpp | 21 ++++++-- src/version.hpp | 2 +- 12 files changed, 118 insertions(+), 110 deletions(-) mode change 100644 => 100755 packet.sh create mode 100644 src/service/chinese_gb2312.cpp create mode 100644 src/service/chinese_gb2312.hpp diff --git a/README.md b/README.md index f32e34c..b843053 100644 --- a/README.md +++ b/README.md @@ -2,84 +2,20 @@ # README ``` -1. 输入rootiflytop9973可以进入超级用户 -2. ws测试地址: ws://192.168.1.148:19000 +ws测试地址: ws://192.168.8.10:19000 ``` +# 编译说明 ``` -修改点: (OK) - 1. 用户等级分为3级别(后台不限制用户等级,前台限制用户操作)OK - 2. iflytop9973属于admin的超级密码 - 3. 修改用户密码 OK - 4. 登陆时给出提示,用户不存在,或者密码错误 - -消毒前,如果湿度太大,不允许消毒。 - -添加预设参数 OK -添加预设参数配置 OK - -添加审计数据库接口 OK -添加审计 OK - -通过getState可以获得到log,小数 OK -数据库操作加锁 OK - - - --------------------------------- -记录用户操作 (TODO) -添加U盘数据导出 -添加审计数据导出 - -排液自动停止 -水禁传感器测试 -磁盘管理(磁盘容量不足时,弹出提示,且停止记录数据) +./init.sh +./build.sh ``` -# 测试指令 - - +# 版本说明 ``` -sudo apt-get install sqlite3 libsqlite3-dev -sudo apt-get install sqlite3:arm64 libsqlite3-dev:arm64 - -sqlite可视化 -sudo apt-get install sqlitebrowser -https://www.sqlite.org/docs.html -``` - - - -``` -测试指令 - - -``` - - -``` -1. 开始消毒后 - - -``` - - -``` -液位测量压力传感器: -设备地址:01 -量程:-1~4kPa -4 kPa=407.888 毫米水柱 -传感器测量精度:0.407888 毫米水柱 -``` - -``` -1. 支持调速 -2. 液体容量进行滤波 -3. 打印日志去掉小数点 - -1. 加泵写死,速度不可修改,550g/min -2. 注射泵速率限制在30g/min - - +v1.0 + 1. 预热时间数值从配置文件获取 + 2. 支持打印机 + 3. 修改加热片等大功率设备,安全继电器打开延迟50ms->500ms ``` \ No newline at end of file diff --git a/iflytoplinuxsdk b/iflytoplinuxsdk index 45bd079..f4e805b 160000 --- a/iflytoplinuxsdk +++ b/iflytoplinuxsdk @@ -1 +1 @@ -Subproject commit 45bd079bb5f10f36ecfd610a0de0148cafc97bb5 +Subproject commit f4e805b65fa639e80318356abf965d92418dcf48 diff --git a/packet.sh b/packet.sh old mode 100644 new mode 100755 diff --git a/src/configs/gconfig.hpp b/src/configs/gconfig.hpp index f5c3ae6..ced91c8 100644 --- a/src/configs/gconfig.hpp +++ b/src/configs/gconfig.hpp @@ -19,7 +19,8 @@ marco(string /* */, iflytopSubDeviceCanIFName, "can0") /*子设备Can设备名称*/ \ marco(int32_t /* */, iflytopSubDeviceCanBitrate, 500000) /*子设备Can设备波特率*/ \ marco(string /* */, pipettingRobotCanIFName, "can1") /*移液臂Can设备名称*/ \ - marco(int32_t /* */, pipettingRobotCanBitrate, 500000) /*移液臂Can设备波特率*/ + marco(int32_t /* */, pipettingRobotCanBitrate, 500000) /*移液臂Can设备波特率*/ \ + marco(int32_t /* */, preHeatLastTimeS, 60) /*预热时间*/ configTemplateDEFILE_CONFIG_SERVICE2( // GConfig, // diff --git a/src/main.cpp b/src/main.cpp index ffcaa10..ff094df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,8 @@ #include #include +#include "iflytop/components/uart_printer/uart_printer.hpp" + using namespace iflytop; using namespace core; using namespace std; @@ -31,7 +33,7 @@ int Main::main(int argc, char *argv[]) { * @brief 解析命令行参数 */ string test_mode = "false"; - auto cli = ((required("--test_mode") & value("test_mode", test_mode)).doc("test_mode")); + auto cli = ((required("--test_mode") & value("test_mode", test_mode)).doc("test_mode")); if (!parse(argc, argv, cli)) { test_mode = "false"; // cout << make_man_page(cli, argv[0]); @@ -58,6 +60,10 @@ int Main::main(int argc, char *argv[]) { BUILD_AND_REG_SERRVICE(GConfig); GET_SERVICE(GConfig)->initialize(); + BUILD_AND_REG_SERRVICE(UartPrinter); + GET_SERVICE(UartPrinter)->initialize("/dev/ttyS5", "9600"); + + /** * @brief */ diff --git a/src/main_control_service.cpp b/src/main_control_service.cpp index 829e5a2..39ef9af 100644 --- a/src/main_control_service.cpp +++ b/src/main_control_service.cpp @@ -76,6 +76,7 @@ void MainControlService::initialize() { GET_TO_SERVICE(m_deviceIoControlService); m_deviceIoControlService->startScan(); + m_deviceIoControlService->printerTest(); BUILD_AND_REG_SERRVICE(DataExportService); GET_SERVICE(DataExportService)->initialize(); diff --git a/src/service/chinese_gb2312.cpp b/src/service/chinese_gb2312.cpp new file mode 100644 index 0000000..e75d809 --- /dev/null +++ b/src/service/chinese_gb2312.cpp @@ -0,0 +1,8 @@ +#include "chinese_gb2312.hpp" + +using namespace iflytop; +using namespace std; + +string ChineseGb2312::nihaozhongguo() { + return "й"; +} diff --git a/src/service/chinese_gb2312.hpp b/src/service/chinese_gb2312.hpp new file mode 100644 index 0000000..ab90286 --- /dev/null +++ b/src/service/chinese_gb2312.hpp @@ -0,0 +1,19 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace iflytop { +using namespace std; +class ChineseGb2312 { + public: + string nihaozhongguo(); +}; + +} // namespace iflytop \ No newline at end of file diff --git a/src/service/device_io_control_service.cpp b/src/service/device_io_control_service.cpp index 7a3dfc4..56311ef 100644 --- a/src/service/device_io_control_service.cpp +++ b/src/service/device_io_control_service.cpp @@ -1,16 +1,24 @@ #include "device_io_control_service.hpp" +#include +#include +#include +#include + +#include "chinese_gb2312.hpp" +#include "iflytop/components/uart_printer/uart_printer.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 +ģ Ӳ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) @@ -105,11 +113,11 @@ void DeviceIoControlService::airCompressor_setState(bool val) { logger->info("airCompressor_setState:{}", val); if (val) { m_zcanHost->writeio(0, 1); - usleep(500 * 100); + usleep(500 * 1000); m_zcanHost->writeio(1, 1); } else { m_zcanHost->writeio(1, 0); - usleep(500 * 100); + usleep(500 * 1000); m_zcanHost->writeio(0, 0); } } @@ -122,11 +130,11 @@ int DeviceIoControlService::airBlower_setState(bool val) { logger->info("airBlower_setState:{}", val); if (val) { m_zcanHost->writeio(2, 1); - usleep(500 * 100); + usleep(500 * 1000); m_zcanHost->writeio(3, 1); } else { m_zcanHost->writeio(3, 0); - usleep(500 * 100); + usleep(500 * 1000); m_zcanHost->writeio(2, 0); } return 0; @@ -141,11 +149,11 @@ void DeviceIoControlService::heartingPlate_setPower(bool val) { logger->info("heartingPlate_setPower:{}", val); if (val) { m_zcanHost->writeio(4, 1); - usleep(500 * 100); + usleep(500 * 1000); m_zcanHost->writeio(5, 1); } else { m_zcanHost->writeio(5, 0); - usleep(500 * 100); + usleep(500 * 1000); m_zcanHost->writeio(4, 0); } } @@ -241,7 +249,7 @@ static int filter(int data) { if (q.size() > 50) { q.pop_front(); } - // 中值滤波 + // ֵ˲ int datacache[51]; int ndata = 0; for (auto& var : q) { @@ -267,7 +275,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; @@ -296,10 +304,10 @@ int DeviceIoControlService::getWaterImmersionSensor2() { DeviceIoControlService::h2o2sensor_data_t DeviceIoControlService::getH2O2SenSorData1() { lock_guard 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; @@ -307,7 +315,7 @@ DeviceIoControlService::h2o2sensor_data_t DeviceIoControlService::getH2O2SenSorD /** * @brief - * TODO:传感器未初始化完成时,除了温度外,读取到的数据都是小于零,这里做了一个简单的处理,后续需要修改 + * TODO:δʼʱ¶⣬ȡݶС㣬һ򵥵ĴҪ޸ * */ if (data.h2o2 < 0) { @@ -334,7 +342,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++) { @@ -359,7 +367,7 @@ bool DeviceIoControlService::getAllSensorData(DeviceIoControlService::all_h2o2se } /** - * @brief 找到最大的过氧化氢相对饱和度 + * @brief ҵĹԱͶ */ data.max_saturation = -1; for (size_t i = 0; i < ZARRAYSIZE(data.h2o2sensor_data); i++) { @@ -373,7 +381,7 @@ bool DeviceIoControlService::getAllSensorData(DeviceIoControlService::all_h2o2se } /** - * @brief 找到最大的相对湿度 + * @brief ҵʪ */ data.max_humid = -1; @@ -388,3 +396,16 @@ bool DeviceIoControlService::getAllSensorData(DeviceIoControlService::all_h2o2se } return true; } + +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"); +} +void DeviceIoControlService::printerPrintf(string str) { GET_SERVICE(UartPrinter)->print(str); } diff --git a/src/service/device_io_control_service.hpp b/src/service/device_io_control_service.hpp index b75886a..ce0866e 100644 --- a/src/service/device_io_control_service.hpp +++ b/src/service/device_io_control_service.hpp @@ -65,14 +65,17 @@ class DeviceIoControlService : public enable_shared_from_thisgetSettingVal("pre_heat_time_s"); + context.m_disinfectionID = createDisinfectionID(); + // context.pre_heat_time_s = m_dbService->getSettingVal("pre_heat_time_s"); + context.pre_heat_time_s = GET_SERVICE(GConfig)->get_preHeatLastTimeS(); context.stoped_gs = stoped_gs; context.continued_gs = continued_gs; context.stoped_satur = stoped_satur; @@ -446,8 +451,16 @@ void DisinfectionCtrlService::disinfectionLoop(bool& breakflag) { logger->info("waitting for h2o2 concentration to safe value {}=>{}", m_context.h2o2data.min_h2o2, 1); if (m_context.h2o2data.min_h2o2 < 1) { logger->info("h2o2 concentration to safe value"); - breakflag = true; - forcelog = true; + breakflag = true; + forcelog = true; + + /** + * @brief 打印消毒日志信息 + */ + auto up = GET_SERVICE(UartPrinter); + up->print("===============================\n"); + up->print("Operator: %s\n"); + m_context.m_state = kfinished; } } else { diff --git a/src/version.hpp b/src/version.hpp index 025956d..8820105 100644 --- a/src/version.hpp +++ b/src/version.hpp @@ -1,2 +1,2 @@ #pragma once -#define VERSION "0.1" \ No newline at end of file +#define VERSION "1.0" \ No newline at end of file