8 changed files with 259 additions and 24 deletions
-
2app_protocols/transmit_disfection_protocol
-
19usrc/board/liquid_ctrl_board.cpp
-
9usrc/board/liquid_ctrl_board.hpp
-
192usrc/protocol_processer_impl/liquid_ctrl_board_cmd_processer.cpp
-
41usrc/protocol_processer_impl/liquid_ctrl_board_cmd_processer.hpp
-
4usrc/protocol_processer_impl/public_cmd_processer.cpp
-
14usrc/protocol_processer_mgr/i_protocol_processer.hpp
-
2zsdk
@ -1 +1 @@ |
|||
Subproject commit 7ec8b89424ab02856d3c48a77dfb11e790db4693 |
|||
Subproject commit 591e174e21072cc71d6288d6c5cfa00f34952e9b |
@ -0,0 +1,192 @@ |
|||
#include "liquid_ctrl_board_cmd_processer.hpp"
|
|||
|
|||
#include "board/liquid_ctrl_board.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
static osTimerId MotorMonitorTimerId; // 压力传感器数值上报
|
|||
static bool motorErrorFlagCache[10]; // 电机异常状态上报标志位
|
|||
static zmutex motorErrorFlagCacheLock; |
|||
|
|||
static bool motorErrorFlag_get(int subindex) { |
|||
bool ret; |
|||
{ |
|||
zlock_guard guard(motorErrorFlagCacheLock); |
|||
ret = motorErrorFlagCache[subindex]; |
|||
} |
|||
return ret; |
|||
} |
|||
|
|||
static void motorErrorFlag_set(int subindex, bool val) { |
|||
{ |
|||
zlock_guard guard(motorErrorFlagCacheLock); |
|||
motorErrorFlagCache[subindex] = val; |
|||
} |
|||
} |
|||
|
|||
#define DEVICE LiquidCtrlBoard::ins()
|
|||
|
|||
void LiquidCtrlBoardCmdProcesser::initialize() { motorErrorFlagCacheLock.init(); } |
|||
bool LiquidCtrlBoardCmdProcesser::isSupportThisCmd(ProcessContext* cxt) { return false; } |
|||
|
|||
/***********************************************************************************************************************
|
|||
* PUMP * |
|||
***********************************************************************************************************************/ |
|||
|
|||
void LiquidCtrlBoardCmdProcesser::pump_rotate(ProcessContext* cxt) { |
|||
CHECK_PARAM_LEN(PRAAM_LEN(), 2); |
|||
|
|||
int32_t subindex = GET_PARAM(0); |
|||
int32_t velocity = GET_PARAM(1); |
|||
|
|||
if (subindex >= DEVICE->motorNum()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_invalid_param); |
|||
return; |
|||
} |
|||
if (!DEVICE->motor(subindex)->ping()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_motor_subdevice_offline); |
|||
return; |
|||
} |
|||
|
|||
DEVICE->motor(subindex)->enable(false); |
|||
DEVICE->motor(subindex)->enable(true); |
|||
DEVICE->motor(subindex)->moveToEnd(velocity > 0 ? 1 : -1, abs(velocity)); |
|||
|
|||
zcanbus_send_ack(cxt->packet, NULL, 0); |
|||
motorErrorFlag_set(subindex, false); |
|||
} |
|||
void LiquidCtrlBoardCmdProcesser::pump_stop(ProcessContext* cxt) { |
|||
CHECK_PARAM_LEN(PRAAM_LEN(), 1); |
|||
|
|||
int32_t subindex = GET_PARAM(0); |
|||
|
|||
if (subindex >= DEVICE->motorNum()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_invalid_param); |
|||
return; |
|||
} |
|||
|
|||
if (!DEVICE->motor(subindex)->ping()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_motor_subdevice_offline); |
|||
return; |
|||
} |
|||
|
|||
DEVICE->motor(subindex)->stop(); |
|||
zcanbus_send_ack(cxt->packet, NULL, 0); |
|||
} |
|||
void LiquidCtrlBoardCmdProcesser::pump_set_ihold_irun_idelay(ProcessContext* cxt) { |
|||
CHECK_PARAM_LEN(PRAAM_LEN(), 4); |
|||
|
|||
int32_t subindex = GET_PARAM(0); |
|||
int32_t ihold = GET_PARAM(1); |
|||
int32_t irun = GET_PARAM(2); |
|||
int32_t idelay = GET_PARAM(3); |
|||
|
|||
if (subindex >= DEVICE->motorNum()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_invalid_param); |
|||
return; |
|||
} |
|||
|
|||
if (!DEVICE->motor(subindex)->ping()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_motor_subdevice_offline); |
|||
return; |
|||
} |
|||
|
|||
DEVICE->motor(subindex)->setIHOLD_IRUN(ihold, irun, idelay); |
|||
zcanbus_send_ack(cxt->packet, NULL, 0); |
|||
} |
|||
void LiquidCtrlBoardCmdProcesser::pump_set_acc(ProcessContext* cxt) { |
|||
CHECK_PARAM_LEN(PRAAM_LEN(), 2); |
|||
|
|||
int32_t subindex = GET_PARAM(0); |
|||
int32_t acc = GET_PARAM(1); |
|||
|
|||
if (subindex >= DEVICE->motorNum()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_invalid_param); |
|||
return; |
|||
} |
|||
|
|||
if (!DEVICE->motor(subindex)->ping()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_motor_subdevice_offline); |
|||
return; |
|||
} |
|||
|
|||
DEVICE->motor(subindex)->setAmax(acc); |
|||
DEVICE->motor(subindex)->setDmax(acc); |
|||
zcanbus_send_ack(cxt->packet, NULL, 0); |
|||
} |
|||
void LiquidCtrlBoardCmdProcesser::pump_set_subic_reg(ProcessContext* cxt) { |
|||
CHECK_PARAM_LEN(PRAAM_LEN(), 3); |
|||
|
|||
int32_t subindex = GET_PARAM(0); |
|||
int32_t regadd = GET_PARAM(1); |
|||
int32_t regval = GET_PARAM(2); |
|||
|
|||
if (subindex >= DEVICE->motorNum()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_invalid_param); |
|||
return; |
|||
} |
|||
|
|||
if (!DEVICE->motor(subindex)->ping()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_motor_subdevice_offline); |
|||
return; |
|||
} |
|||
|
|||
DEVICE->motor(subindex)->writeIntExt(regadd, regval); |
|||
} |
|||
void LiquidCtrlBoardCmdProcesser::pump_get_subic_reg(ProcessContext* cxt) { |
|||
CHECK_PARAM_LEN(PRAAM_LEN(), 2); |
|||
|
|||
int32_t subindex = GET_PARAM(0); |
|||
int32_t regadd = GET_PARAM(1); |
|||
|
|||
if (subindex >= DEVICE->motorNum()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_invalid_param); |
|||
return; |
|||
} |
|||
|
|||
if (!DEVICE->motor(subindex)->ping()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_motor_subdevice_offline); |
|||
return; |
|||
} |
|||
|
|||
int32_t val = DEVICE->motor(subindex)->readIntExt(regadd); |
|||
zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val)); |
|||
} |
|||
void LiquidCtrlBoardCmdProcesser::pump_ping(ProcessContext* cxt) { |
|||
CHECK_PARAM_LEN(PRAAM_LEN(), 1); |
|||
|
|||
int32_t subindex = GET_PARAM(0); |
|||
|
|||
if (subindex >= DEVICE->motorNum()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_invalid_param); |
|||
return; |
|||
} |
|||
|
|||
if (!DEVICE->motor(subindex)->ping()) { |
|||
zcanbus_send_errorack(cxt->packet, kerr_motor_subdevice_offline); |
|||
return; |
|||
} |
|||
zcanbus_send_ack(cxt->packet, NULL, 0); |
|||
} |
|||
|
|||
/***********************************************************************************************************************
|
|||
* WS * |
|||
***********************************************************************************************************************/ |
|||
void LiquidCtrlBoardCmdProcesser::evaporation_bin_water_sensor_read_state(ProcessContext* cxt) { |
|||
int32_t val = DEVICE->m_evaporation_bin_water_sensor.read(); |
|||
zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val)); |
|||
} |
|||
void LiquidCtrlBoardCmdProcesser::device_bottom_water_sensor_read_state(ProcessContext* cxt) { |
|||
int32_t val = DEVICE->m_device_bottom_water_sensor.read(); |
|||
zcanbus_send_ack(cxt->packet, (uint8_t*)&val, sizeof(val)); |
|||
} |
|||
|
|||
/***********************************************************************************************************************
|
|||
* PRESSURE * |
|||
***********************************************************************************************************************/ |
|||
void LiquidCtrlBoardCmdProcesser::pressure_sensor_bus_read_data(ProcessContext* cxt) {} |
|||
void LiquidCtrlBoardCmdProcesser::pressure_sensor_bus_set_report_period_ms(ProcessContext* cxt) {} |
|||
|
|||
/***********************************************************************************************************************
|
|||
* WARNING LIGHT * |
|||
***********************************************************************************************************************/ |
|||
void LiquidCtrlBoardCmdProcesser::triple_warning_light_ctl(ProcessContext* cxt) {} |
@ -0,0 +1,41 @@ |
|||
#pragma once
|
|||
|
|||
#include "protocol_processer_mgr/i_protocol_processer.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace zscanprotocol; |
|||
using namespace transmit_disfection_protocol; |
|||
|
|||
class LiquidCtrlBoardCmdProcesser : public IProtocolProcesser { |
|||
list<CmdProcesser> cmdprocesser; |
|||
uint8_t boardResetFlag; // 0: 重启标志
|
|||
|
|||
public: |
|||
static LiquidCtrlBoardCmdProcesser* ins() { |
|||
static LiquidCtrlBoardCmdProcesser ins; |
|||
return &ins; |
|||
} |
|||
|
|||
virtual void initialize() override; |
|||
virtual const char* getName() override { return "LiquidCtrlBoardCmdProcesser"; }; |
|||
virtual bool isSupportThisCmd(ProcessContext* cxt) override; |
|||
|
|||
virtual void process(ProcessContext* cxt) override; |
|||
|
|||
private: |
|||
void evaporation_bin_water_sensor_read_state(ProcessContext* cxt); |
|||
void device_bottom_water_sensor_read_state(ProcessContext* cxt); |
|||
void pump_rotate(ProcessContext* cxt); |
|||
void pump_stop(ProcessContext* cxt); |
|||
void pump_set_ihold_irun_idelay(ProcessContext* cxt); |
|||
void pump_set_acc(ProcessContext* cxt); |
|||
void pump_set_subic_reg(ProcessContext* cxt); |
|||
void pump_get_subic_reg(ProcessContext* cxt); |
|||
void pump_ping(ProcessContext* cxt); |
|||
void triple_warning_light_ctl(ProcessContext* cxt); |
|||
void pressure_sensor_bus_read_data(ProcessContext* cxt); |
|||
void pressure_sensor_bus_set_report_period_ms(ProcessContext* cxt); |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -1 +1 @@ |
|||
Subproject commit c7d515f2180f0ce961f7b61794544d8ea01ec586 |
|||
Subproject commit c2a0f4d846f416a48f7cd6d4a22e2e7a8649ab40 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue