You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
229 lines
11 KiB
229 lines
11 KiB
#include "dmapp.hpp"
|
|
|
|
#include "board/hal/zhal_initer.hpp"
|
|
/**
|
|
* @brief
|
|
* 小空间和大空间硬件一样
|
|
* 管道式-----
|
|
* 液路控制板
|
|
* 相比于大空间消毒机,不同的点:
|
|
* 1.增加比例阀控制
|
|
* 2.空压机通道控制
|
|
* 功率板
|
|
* 相比于大空间消毒机,不同的点:
|
|
* 1. 风机改成鼓风机(可控风速)
|
|
* 拉杆箱------
|
|
* 液路控制板
|
|
* 功率板
|
|
*/
|
|
|
|
using namespace iflytop;
|
|
using namespace transmit_disfection_protocol;
|
|
#define TAG "DMAPP"
|
|
|
|
DisinfectionApp* DisinfectionApp::ins() {
|
|
static DisinfectionApp instance;
|
|
return &instance;
|
|
}
|
|
|
|
const char* DisinfectionApp::getName() { return "DisinfectionApp"; }
|
|
|
|
void DisinfectionApp::initialize() {
|
|
int btid = PublicBoard::ins()->getBoardTypeId();
|
|
// only support
|
|
// large space disinfection machine,
|
|
// small space disinfection machine,
|
|
// pipe disinfection machine,
|
|
// DT600B,
|
|
ZASSERT(PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM() || PORT::isDT600B());
|
|
|
|
/***********************************************************************************************************************
|
|
* 加热片 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isPowerCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM() || PORT::isDT600B())) {
|
|
LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
|
|
heaterCtrler.initialize(PC7, &hadc1, ADC_CHANNEL_2, &hadc1, ADC_CHANNEL_9);
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* 风机 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isPowerCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isDT600B())) {
|
|
LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
|
|
blowerCtrler.initialize(PC5, &hadc1, ADC_CHANNEL_1);
|
|
} //
|
|
else if (PORT::isPowerCtrlBoard() && (PORT::isPipeDM())) {
|
|
LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
|
|
LargeSpaceDmPowerCtrlBoardHal::HUART2_INIT(9600, UART_STOPBITS_1);
|
|
blowerCtrler.initializeAsHighPowerUartBlower(PC5, &huart2, &hadc1, ADC_CHANNEL_1);
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* 空压机 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isPowerCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM() || PORT::isDT600B())) {
|
|
LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
|
|
airComCtrler.initialize(PC3, &hadc1, ADC_CHANNEL_0);
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* 气密性测试空压机 *
|
|
***********************************************************************************************************************/
|
|
// null
|
|
|
|
//
|
|
/***********************************************************************************************************************
|
|
* H2O2传感器 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isPowerCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM() || PORT::isDT600B())) {
|
|
LargeSpaceDmPowerCtrlBoardHal::HUART3_INIT(19200, UART_STOPBITS_2);
|
|
LargeSpaceDmPowerCtrlBoardHal::HADC1_INIT();
|
|
osDelay(3000);
|
|
h2o2Sensor.initialize(&huart3, &hadc1, ADC_CHANNEL_3);
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* 水浸传感器 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM() || PORT::isDT600B())) {
|
|
ZLOGI(TAG, "WaterSensor init");
|
|
evaporationBinWS.initAsInput(PC7, kxs_gpio_nopull, kxs_gpio_no_irq, false /*mirror*/);
|
|
deviceBottomWS.initAsInput(PC8, kxs_gpio_nopull, kxs_gpio_no_irq, false /*mirror*/);
|
|
|
|
REG_LAMADA_FN(kfn_device_bottom_water_sensor_read_state, [&](ProcessContext* cxt) { zcanbus_send_ack(cxt->packet, deviceBottomWS.read()); });
|
|
REG_LAMADA_FN(kfn_evaporation_tank_water_sensor_read_state, [&](ProcessContext* cxt) { zcanbus_send_ack(cxt->packet, evaporationBinWS.read()); });
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* TMC电机初始化 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM() || PORT::isDT600B())) {
|
|
// TMC电机初始化
|
|
ZLOGI(TAG, "TMCMotorGroup init");
|
|
LargeSpaceDMLiquidCtrlBoardHal::HSPI1_INIT();
|
|
tmcPowerGroup.initialize(PB2, {&hspi1, PA4 /*cs*/, PB12 /*en*/}, {&hspi1, PC4 /*cs*/, PB13 /*en*/});
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* 三色指示灯 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM() || PORT::isDT600B())) {
|
|
// 三色指示灯初始化
|
|
ZLOGI(TAG, "WarningLightDriver init");
|
|
wlDriver.initialize(PD8, PD7, PD9, PD10);
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* 压力传感器初始化 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM())) {
|
|
ZLOGI(TAG, "PXXPSBus init");
|
|
osDelay(1500); // 等待传感器上电
|
|
LargeSpaceDMLiquidCtrlBoardHal::HUART3_INIT(9600, UART_STOPBITS_1);
|
|
psBus.initialize(&huart3);
|
|
}
|
|
/***********************************************************************************************************************
|
|
* 比例阀初始化 *
|
|
***********************************************************************************************************************/
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isPipeDM())) {
|
|
ZLOGI(TAG, "ProportionalValveCtrl init");
|
|
ZHALIniter::HUART2_INIT(PD5, PD6, 9600, UART_STOPBITS_1);
|
|
proportionalValveCtrl.initialize(&huart2);
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* 气密性测试通道 *
|
|
***********************************************************************************************************************/
|
|
|
|
// kAirLeakTestMode_disinfection
|
|
// kAirLeakTestMode_inflation
|
|
// kAirLeakTestMode_leakTest
|
|
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isPipeDM())) {
|
|
static air_leak_test_mode_t airLeakTestMode = kAirLeakTestMode_disinfection;
|
|
|
|
static ZGPIO eValve0;
|
|
static ZGPIO eValve1;
|
|
static ZGPIO eValve2;
|
|
eValve0.initAsOutput(PD14, kxs_gpio_nopull, true, false);
|
|
eValve1.initAsOutput(PD15, kxs_gpio_nopull, true, false);
|
|
eValve2.initAsOutput(PC6, kxs_gpio_nopull, true, false); // 空气通道电磁阀
|
|
|
|
REG_LAMADA_FN(kfn_air_leak_test_set_mode, [&](ProcessContext* cxt) {
|
|
if (GET_PARAM(0) == kAirLeakTestMode_disinfection) {
|
|
eValve2.write(0); // 内管路
|
|
eValve0.write(0); // 联通
|
|
eValve1.write(0); // 联通
|
|
} else if (GET_PARAM(0) == kAirLeakTestMode_inflation) {
|
|
eValve2.write(1); // 联通空气
|
|
eValve0.write(0); // 联通
|
|
eValve1.write(0); // 联通
|
|
} else if (GET_PARAM(0) == kAirLeakTestMode_leakTest) {
|
|
eValve2.write(0); // 内管路
|
|
eValve0.write(1); // 封闭
|
|
eValve1.write(1); // 封闭
|
|
}
|
|
airLeakTestMode = (air_leak_test_mode_t)GET_PARAM(0);
|
|
zcanbus_send_ack(cxt->packet, NULL, 0);
|
|
});
|
|
REG_LAMADA_FN(kfn_air_leak_test_get_mode, [&](ProcessContext* cxt) {
|
|
int32_t mode = airLeakTestMode;
|
|
zcanbus_send_ack(cxt->packet, mode);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @brief
|
|
* 小空间低配版 和 拉杆箱 均不支持排液功能
|
|
*/
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isLargeSpaceDM() || PORT::isSamllSpaceDM() || PORT::isPipeDM())) {
|
|
static ZGPIO valve;
|
|
valve.initAsOutput(PB3, kxs_gpio_nopull, true, false);
|
|
REG_LAMADA_FN(kfn_set_add_fluid_channel_selector_valve, [&](ProcessContext* cxt) {
|
|
if (GET_PARAM(0) == 0) {
|
|
valve.write(0);
|
|
} else {
|
|
valve.write(1);
|
|
}
|
|
zcanbus_send_ack(cxt->packet, NULL, 0);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @brief 液位状态
|
|
*/
|
|
if (PORT::isLiquidCtrlBoard() && (PORT::isDT600B())) {
|
|
// 初始化
|
|
static ZGPIO io0;
|
|
static bool io0enable = false;
|
|
static ZGPIO io1;
|
|
static bool io1enable = false;
|
|
static ZGPIO io2;
|
|
static bool io2enable = false;
|
|
|
|
if (PORT::isDT600B()) {
|
|
io0.initAsInput(PD11, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
|
|
io0enable = true;
|
|
}
|
|
|
|
if (io0enable || io1enable || io2enable) {
|
|
REG_LAMADA_FN(kfn_liquid_level_read_io_state, [&](ProcessContext* cxt) {
|
|
int32_t liquid_level_state = 0;
|
|
if (io0enable) {
|
|
liquid_level_state |= (io0.read() ? 0 : 1) << 0; // bit0:低液位置
|
|
}
|
|
if (io1enable) {
|
|
liquid_level_state |= (io1.read() ? 0 : 1) << 1; // bit1:中液位
|
|
}
|
|
if (io2enable) {
|
|
liquid_level_state |= (io2.read() ? 0 : 1) << 2; // bit2:高液位
|
|
}
|
|
zcanbus_send_ack(cxt->packet, liquid_level_state);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************************************************************
|
|
* PROTOCOL_BIND *
|
|
***********************************************************************************************************************/
|