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.
150 lines
5.9 KiB
150 lines
5.9 KiB
#pragma once
|
|
#include "board/public_board.hpp"
|
|
#include "board_base/board_base.hpp"
|
|
|
|
/**
|
|
* @brief
|
|
* 大空间消毒机-功率控制板
|
|
*/
|
|
|
|
namespace iflytop {
|
|
using namespace transmit_disfection_protocol;
|
|
|
|
#define TAG "LargeSpaceDmPowerCtrlBoard"
|
|
class DisinfectionApp {
|
|
public:
|
|
HeaterController heaterCtrler;
|
|
BlowerController blowerCtrler;
|
|
AirCompressorController airComCtrler;
|
|
H2O2SensorDriver h2o2Sensor;
|
|
|
|
ZGPIO evaporationBinWS; // 蒸发仓水浸
|
|
ZGPIO deviceBottomWS; // 设备底部水浸
|
|
WarningLightDriver wlDriver; // 报警灯
|
|
TmcMotorGroup tmcPowerGroup; // TMC电机
|
|
PXXPSBus psBus; // PXX压力传感器总线
|
|
|
|
public:
|
|
static DisinfectionApp* ins() {
|
|
static DisinfectionApp instance;
|
|
return &instance;
|
|
}
|
|
|
|
virtual const char* getName() { return "DisinfectionApp"; }
|
|
|
|
void initialize() {
|
|
initializeDevice();
|
|
regProtocol();
|
|
}
|
|
|
|
void initializeDevice() {
|
|
int btid = PublicBoard::ins()->getBoardTypeId();
|
|
//
|
|
|
|
if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard, kDrawBarDMPowerCtrlBoard)) {
|
|
heaterCtrler.initialize(PC7, &hadc1, ADC_CHANNEL_2, &hadc1, ADC_CHANNEL_8);
|
|
}
|
|
|
|
if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard, kDrawBarDMPowerCtrlBoard)) {
|
|
blowerCtrler.initialize(PC5, &hadc1, ADC_CHANNEL_1);
|
|
}
|
|
|
|
if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard, kDrawBarDMPowerCtrlBoard)) {
|
|
airComCtrler.initialize(PC3, &hadc1, ADC_CHANNEL_0);
|
|
}
|
|
|
|
if (isBoardType(kLargeSpaceDMPowerCtrlBoard, kSmallSpaceDMPowerCtrlBoard, kPipeDMPowerCtrlBoard, kDrawBarDMPowerCtrlBoard)) {
|
|
h2o2Sensor.initialize(&huart3, &hadc1, ADC_CHANNEL_10);
|
|
}
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) {
|
|
evaporationBinWS.initAsInput(PC7, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
|
|
deviceBottomWS.initAsInput(PC8, kxs_gpio_nopull, kxs_gpio_no_irq, true /*mirror*/);
|
|
}
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) {
|
|
// TMC电机初始化
|
|
LargeSpaceDMLiquidCtrlBoardHal::HSPI1_INIT();
|
|
tmcPowerGroup.initialize(PB2, {&hspi1, PC4 /*cs*/, PB13 /*en*/}, {&hspi1, PA4 /*cs*/, PB12 /*en*/});
|
|
}
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) {
|
|
// 三色指示灯初始化
|
|
wlDriver.initialize(PD8, PD7, PD9, PD10);
|
|
}
|
|
|
|
if (isBoardType(kLargeSpaceDMLiquidCtrlBoard, kSmallSpaceDMLiquidCtrlBoard, kPipeDMLiquidCtrlBoard, kDrawBarDMLiquidCtrlBoard)) {
|
|
// 压力传感器初始化
|
|
osDelay(1500); // 等待传感器上电
|
|
LargeSpaceDMLiquidCtrlBoardHal::HUART3_INIT(9600, UART_STOPBITS_1);
|
|
psBus.initialize(&huart3);
|
|
}
|
|
}
|
|
|
|
void regProtocol() {
|
|
if (heaterCtrler.isInitialized()) {
|
|
BIND_FN(HeaterController, &heaterCtrler, fn_heater_ctrl);
|
|
BIND_FN(HeaterController, &heaterCtrler, fn_heater_ctrl_safe_valve);
|
|
BIND_FN(HeaterController, &heaterCtrler, fn_heater_read_electric_current);
|
|
BIND_FN(HeaterController, &heaterCtrler, fn_heater_read_temperature_data);
|
|
}
|
|
|
|
if (blowerCtrler.isInitialized()) {
|
|
BIND_FN(BlowerController, &blowerCtrler, fn_blower_ctrl);
|
|
BIND_FN(BlowerController, &blowerCtrler, fn_blower_ctrl_safe_valve);
|
|
BIND_FN(BlowerController, &blowerCtrler, fn_blower_read_electric_current);
|
|
}
|
|
|
|
if (airComCtrler.isInitialized()) {
|
|
BIND_FN(AirCompressorController, &airComCtrler, fn_air_compressor_ctrl);
|
|
BIND_FN(AirCompressorController, &airComCtrler, fn_air_compressor_ctrl_safe_valve);
|
|
BIND_FN(AirCompressorController, &airComCtrler, fn_air_compressor_read_electric_current);
|
|
}
|
|
|
|
if (h2o2Sensor.isInitialized()) {
|
|
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_calibration_date);
|
|
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_sub_ic_errorcode);
|
|
BIND_FN(H2O2SensorDriver, &h2o2Sensor, fn_h2o2_sensor_read_sub_ic_reg);
|
|
}
|
|
if (wlDriver.isInitialized()) {
|
|
BIND_FN(WarningLightDriver, wlDriver, fn_triple_warning_light_ctl);
|
|
}
|
|
|
|
if (tmcPowerGroup.isInitialized()) {
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_rotate);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_stop);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_ihold_irun_idelay);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_acc);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_ramp);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_tzw);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_set_subic_reg);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_get_subic_reg);
|
|
BIND_FN(TmcMotorGroup, tmcPowerGroup, fn_pump_ping);
|
|
}
|
|
|
|
if (psBus.isInitialized()) {
|
|
BIND_FN(PXXPSBus, psBus, fn_psbus_read_data);
|
|
BIND_FN(PXXPSBus, psBus, fn_psbus_scan);
|
|
}
|
|
|
|
if (evaporationBinWS.isInited()) {
|
|
ProtocolProcesserMgr::ins()->regCmdProcesser( //
|
|
CmdProcesser(kfn_evaporation_tank_water_sensor_read_state, //
|
|
[this](ProcessContext* cxt) {
|
|
int32_t val = evaporationBinWS.read();
|
|
zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
|
|
}));
|
|
}
|
|
|
|
if (deviceBottomWS.isInited()) {
|
|
ProtocolProcesserMgr::ins()->regCmdProcesser( //
|
|
CmdProcesser(kfn_device_bottom_water_sensor_read_state, //
|
|
[this](ProcessContext* cxt) {
|
|
int32_t val = deviceBottomWS.read();
|
|
zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val));
|
|
}));
|
|
}
|
|
}
|
|
};
|
|
#undef TAG
|
|
} // namespace iflytop
|