diff --git a/disinfection_iflytop_can_protocol b/disinfection_iflytop_can_protocol index 702ffbc..955c39e 160000 --- a/disinfection_iflytop_can_protocol +++ b/disinfection_iflytop_can_protocol @@ -1 +1 @@ -Subproject commit 702ffbcb82fa62e2cef6621ac49ede8f913273c8 +Subproject commit 955c39e8b8aa1480b0846a1ae26aaa6ba4e38ce0 diff --git a/iflytop_canbus/iflytop_canbus_master.hpp b/iflytop_canbus/iflytop_canbus_master.hpp index 7f102e1..5159ecd 100644 --- a/iflytop_canbus/iflytop_canbus_master.hpp +++ b/iflytop_canbus/iflytop_canbus_master.hpp @@ -117,11 +117,26 @@ class IflytopCanbusMaster { // int32_t pressure_sensor_bus_read_data(int boardid, int subid) { - callcmd0(boardid, kcmd_pressure_sensor_bus_read_data); - return *(int32_t *)m_rxReceiptContext.receipt; + callcmd1(boardid, kcmd_pressure_sensor_bus_read_data,subid); + return *(int32_t *)m_receipt_frame->params; } void pressure_sensor_bus_set_report_period_ms(int boardid, int periodms) { callcmd1(boardid, kcmd_pressure_sensor_bus_set_report_period_ms, periodms); } + void triple_warning_light_ctl(int boardid, int r, int g, int b, int warning) { + callcmd4(boardid, kcmd_triple_warning_light_ctl, r, g, b, warning); + } + + int evaporation_bin_water_sensor_read_state(int boardid) { + callcmd0(boardid, kcmd_evaporation_bin_water_sensor_read_state); + return *(int32_t *)m_receipt_frame->params; + } + + int device_bottom_water_sensor_read_state(int boardid) { + callcmd0(boardid, kcmd_device_bottom_water_sensor_read_state); + return *(int32_t *)m_receipt_frame->params; + } + + private: void sendframe(int32_t from, int32_t to, uint8_t *frame, size_t len); void sendsubframe(int32_t from, int32_t to, int npacket, int packetIndex, uint8_t *packet, size_t len); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 98f7152..7011c9d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -235,6 +235,9 @@ void MainWindow::processException(const zexception &e) { // } int32_t MainWindow::getDeviceId() { return PublicState_DeviceIDVal; } +/*********************************************************************************************************************** + * 泵机控制接口 * + ***********************************************************************************************************************/ void MainWindow::constructPumpControlUI(ZQFunctionListBox *box, int targetDeviceId) { // ZQFunctionListBox *box = new ZQFunctionListBox(tab, "泵机指令", 4); @@ -269,11 +272,10 @@ void MainWindow::constructPumpControlUI(ZQFunctionListBox *box, int targetDevice }); } +/*********************************************************************************************************************** + * 通用操作接口页面 * + ***********************************************************************************************************************/ void MainWindow::constructCommonOperationTab() { - /*********************************************************************************************************************** - * 模块操作 * - ***********************************************************************************************************************/ - ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "通用接口"); // static { @@ -316,32 +318,74 @@ void MainWindow::constructCommonOperationTab() { }); } } - +/*********************************************************************************************************************** + * 消毒拉杆箱界面 * + ***********************************************************************************************************************/ void MainWindow::constructDrawBarDisinfectionBoxTab() { // ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "消毒拉杆箱"); { - ZQFunctionListBox *box = new ZQFunctionListBox(tab, "MINI功率控制板", 4); - constructPumpControlUI(box, kFixBoardId_LiquidCtrl); - // 喷液MINI真空泵 - box->newFunc("喷液MINI真空泵控制", {"onoff"}, [this](int argn, const char **args) { // - IflytopCanbusMaster::ins()->sl_mini_ac_ctrl(kFixBoardId_LiquidCtrl, atoi(args[0])); - }); - // 气密性测试MINI真空泵 - box->newFunc("气密性测试MINI真空泵", {"onoff"}, [this](int argn, const char **args) { // - IflytopCanbusMaster::ins()->atta_mini_air_compressor_ctrl(kFixBoardId_LiquidCtrl, atoi(args[0])); - }); - // 压力传感器总线 - box->newFunc("压力传感器总线-读数据", {"subid"}, [this](int argn, const char **args) { // - int32_t val = IflytopCanbusMaster::ins()->pressure_sensor_bus_read_data( // - kFixBoardId_LiquidCtrl, atoi(args[0])); - ZQUI::ins()->ishow("val:%d", val); - }); - box->newFunc("压力传感器总线-设置上报周期", {"periodms"}, [this](int argn, const char **args) { // - IflytopCanbusMaster::ins()->pressure_sensor_bus_set_report_period_ms( // - kFixBoardId_LiquidCtrl, atoi(args[0])); - }); + ZQFunctionListBox *minpowerboard_box = new ZQFunctionListBox(tab, "液路板", 4); + { + /** + * @brief 泵机控制接口 + */ + constructPumpControlUI(minpowerboard_box, kFixBoardId_LiquidCtrl); + } + { + // 喷液MINI真空泵 + minpowerboard_box->newFunc("喷液MINI真空泵控制", {"onoff"}, [this](int argn, const char **args) { // + IflytopCanbusMaster::ins()->sl_mini_ac_ctrl(kFixBoardId_LiquidCtrl, atoi(args[0])); + }); + // 气密性测试MINI真空泵 + minpowerboard_box->newFunc("气密性测试MINI真空泵", {"onoff"}, [this](int argn, const char **args) { // + IflytopCanbusMaster::ins()->atta_mini_air_compressor_ctrl(kFixBoardId_LiquidCtrl, atoi(args[0])); + }); + // 压力传感器总线 + minpowerboard_box->newFunc("压力传感器总线-读数据", {"subid"}, [this](int argn, const char **args) { // + int32_t val = IflytopCanbusMaster::ins()->pressure_sensor_bus_read_data( // + kFixBoardId_LiquidCtrl, atoi(args[0])); + ZQUI::ins()->ishow("val:%d", val); + }); + minpowerboard_box->newFunc("压力传感器总线-设置上报周期", {"periodms"}, [this](int argn, const char **args) { // + IflytopCanbusMaster::ins()->pressure_sensor_bus_set_report_period_ms( // + kFixBoardId_LiquidCtrl, atoi(args[0])); + }); + } + } +} + +void MainWindow::construct_largeSpaceDisinfectionTab() { + // + + int targetId = kFixBoardId_LiquidCtrl; + + ZQVTabPage *tab = new ZQVTabPage(ui->buttonTabWidget, "大空间消毒机"); + + { + ZQFunctionListBox *minpowerboard_box = new ZQFunctionListBox(tab, "液路板", 4); + + constructPumpControlUI(minpowerboard_box, targetId); // 泵机控制接口 + minpowerboard_box->newFunc("压力传感器总线-读数据", {"subid"}, // + [this, targetId](int argn, const char **args) { + int32_t val = IflytopCanbusMaster::ins()->pressure_sensor_bus_read_data(targetId, atoi(args[0])); + ZQUI::ins()->ishow("val:%d", val); + }); + minpowerboard_box->newFunc("压力传感器总线-设置上报周期", {"periodms"}, // + [this, targetId](int argn, const char **args) { IflytopCanbusMaster::ins()->pressure_sensor_bus_set_report_period_ms(targetId, atoi(args[0])); }); + minpowerboard_box->newFunc("报警灯控制", {"r", "g", "b", "w"}, // + [this, targetId](int argn, const char **args) { IflytopCanbusMaster::ins()->triple_warning_light_ctl(targetId, atoi(args[0]), atoi(args[1]), atoi(args[2]), atoi(args[3])); }); + minpowerboard_box->newFunc("读取-蒸发桶水浸传感器-状态", {}, // + [this, targetId](int argn, const char **args) { + int state = IflytopCanbusMaster::ins()->evaporation_bin_water_sensor_read_state(targetId); + ZQUI::ins()->ishow("state:%d", state); + }); + minpowerboard_box->newFunc("读取-设备底部水浸传感器-状态", {}, // + [this, targetId](int argn, const char **args) { + int state = IflytopCanbusMaster::ins()->device_bottom_water_sensor_read_state(targetId); + ZQUI::ins()->ishow("state:%d", state); + }); } } @@ -349,6 +393,7 @@ void MainWindow::constructAppUI() { // constructCommonOperationTab(); constructDrawBarDisinfectionBoxTab(); + construct_largeSpaceDisinfectionTab(); } void MainWindow::processReportPacket(packet_type_t type, uint8_t from, uint8_t to, uint8_t *hex, uint32_t hexlen) { @@ -359,14 +404,15 @@ void MainWindow::processReportPacket(packet_type_t type, uint8_t from, uint8_t t if (frame->function_id == kreport_heatpacket_pong) { report_heatpacket_data_t *ack = (report_heatpacket_data_t *)frame->params; - ZQUI::ins()->rshow("[Heat ][FROM:%03d] HeatIndex:%x ToardType:%s flag:%x", // - from, ack->heartIndex, BoardTypeToString(ack->boardType), ack->flag); - - } else if (frame->function_id == kreport_exception_error) { + ZQUI::ins()->rshow("[Heat ][FROM:%03d] HeatIndex:%x ToardType:%s flag:%x", from, ack->heartIndex, BoardTypeToString(ack->boardType), ack->flag); + } + // + else if (frame->function_id == kreport_exception_error) { report_exeception_data_t *ack = (report_exeception_data_t *)frame->params; - ZQUI::ins()->eshow("[Exception][FROM:%03d] subid:%x ecode:%s", // - from, ack->subid, ErrorCodeToString(ack->ecode)); - } else if (frame->function_id == kreport_pressure_data) { + ZQUI::ins()->eshow("[Exception][FROM:%03d] subid:%x ecode:%s", from, ack->subid, ErrorCodeToString(ack->ecode)); + } + // + else if (frame->function_id == kreport_pressure_data) { report_pressure_data_t *ack = (report_pressure_data_t *)frame->params; QString info; info.append(fmt("[Pressure][FROM:%03d](%d)", from, ack->sensorDataNum)); @@ -375,6 +421,24 @@ void MainWindow::processReportPacket(packet_type_t type, uint8_t from, uint8_t t } ZQUI::ins()->rshow(info.toStdString().c_str()); } + // + else if (frame->function_id == kreport_h2o2_sensor_data) { + report_h2o2_data_t *ack = (report_h2o2_data_t *)frame->params; + QString info; + info.append(fmt("[H2O2 ][FROM:%03d] suid:%d,err:%d h2o2:%d (x10ppm),humid:%d (x10),temp:%d (x10),saturation:%d (x10)", // + from, ack->subid, ack->sensor_error, ack->h2o2, ack->humid, ack->temp, ack->saturation)); + ZQUI::ins()->rshow(info.toStdString().c_str()); + } + // + else if (frame->function_id == kreport_evaporation_bin_water_sensor) { + report_water_sensor_state_t *ack = (report_water_sensor_state_t *)frame->params; + ZQUI::ins()->rshow("[蒸发仓内水浸][FROM:%03d] (%d)", from, ack->state); + } + // + else if (frame->function_id == kreport_device_bottom_water_sensor) { + report_water_sensor_state_t *ack = (report_water_sensor_state_t *)frame->params; + ZQUI::ins()->rshow("[设备底部水浸][FROM:%03d] (%d)", from, ack->state); + } } void MainWindow::on_PublicState_ConfirmKey_clicked() { PublicState_DeviceIDVal = ui->PublicState_DeviceID->toPlainText().toInt(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 91849df..48c93fd 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -127,11 +127,10 @@ class MainWindow : public QMainWindow { int32_t getDeviceId(); private: - void constructPumpControlUI(iflytop::ZQFunctionListBox *box , int targetDeviceId); - - void constructCommonOperationTab(); - void constructDrawBarDisinfectionBoxTab(); - - void processReportPacket(packet_type_t type, uint8_t from, uint8_t to, uint8_t *hex, uint32_t hexlen); + void constructPumpControlUI(iflytop::ZQFunctionListBox *box, int targetDeviceId); // 泵机UI + void constructCommonOperationTab(); // 通用操作 + void constructDrawBarDisinfectionBoxTab(); // 消毒拉杆箱UI + void construct_largeSpaceDisinfectionTab(); // 构建大空间消毒UI + void processReportPacket(packet_type_t type, uint8_t from, uint8_t to, uint8_t *hex, uint32_t hexlen); // 上报报文处理 }; #endif // MAINWINDOW_H