Browse Source

Merge branch 'master' of 192.168.1.3:p_transmit_disinfection_v3/transmit_disinfection_micro

moveToEndTestVersion
haoran 11 months ago
parent
commit
da5a565b2f
  1. 7
      README.md
  2. 2
      app_protocols/zscanprotocol
  3. 2
      stm32components
  4. 33
      ucomponents/preportional_valve/preportional_valve_ctrl.cpp
  5. 2
      usrc/module/blower_controller.hpp
  6. 44
      usrc/module/proportional_valve_ctrl.cpp
  7. 43
      usrc/module/proportional_valve_ctrl.hpp
  8. 2
      usrc/project_configs.h

7
README.md

@ -3,7 +3,12 @@
``` ```
``` ```
V103:增加比例阀超时判定阈值
V103:增加比例阀超时判定
V104:
1. 添加子设备超时错误码
2. 主控直接下发指令控制子设备时候,增加超时判定,超时后返回子设备超时错误码。
3. 上位机指令超时时间建议设置成500ms
``` ```

2
app_protocols/zscanprotocol

@ -1 +1 @@
Subproject commit d11d41c1062568f629d5ec2bc6435319b7ea83e3
Subproject commit 8a3aeaf8883a3c7d01594e0399fbe96bf8b9cf72

2
stm32components

@ -1 +1 @@
Subproject commit 03d9638ccbc69971524957a68e51842da0960940
Subproject commit b3cae2e4945639f0148a5e3034b039f5679151e3

33
ucomponents/preportional_valve/preportional_valve_ctrl.cpp

@ -7,26 +7,23 @@ using namespace zscanprotocol;
#define WORK_STATE_REG 0x0000 #define WORK_STATE_REG 0x0000
#define CTRL_STATE_REG 0x0001 #define CTRL_STATE_REG 0x0001
#define POS_STATE_REG 0x0013 #define POS_STATE_REG 0x0013
#define OVERTIME 1000
#define OVERTIME 100
#define TAG "PreportionalValveCtrl" #define TAG "PreportionalValveCtrl"
void PreportionalValveCtrl::initialize(UART_HandleTypeDef* huart) { m_modbusBlockHost.initialize(huart); }
void PreportionalValveCtrl::initialize(UART_HandleTypeDef* huart) {//
m_modbusBlockHost.initialize(huart);
m_modbusBlockHost.enableDump(true);
}
int32_t PreportionalValveCtrl::writeReg06(uint8_t slaveAddr, uint16_t regAddr, uint16_t regVal) { int32_t PreportionalValveCtrl::writeReg06(uint8_t slaveAddr, uint16_t regAddr, uint16_t regVal) {
// 重发三次
for (size_t i = 0; i < 5; i++) {
int32_t err = m_modbusBlockHost.writeReg06(slaveAddr, regAddr, regVal, OVERTIME);
if (err == 0) return 0;
}
return err::kerr_subdevice_offline;
int32_t err = m_modbusBlockHost.writeReg06(slaveAddr, regAddr, regVal, OVERTIME);
if (err == 0) return 0;
return err::kerr_subdevice_overtime;
} }
int32_t PreportionalValveCtrl::readReg03(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal) { int32_t PreportionalValveCtrl::readReg03(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal) {
// 重发三次
for (size_t i = 0; i < 5; i++) {
int32_t err = m_modbusBlockHost.readReg03(slaveAddr, regAddr, regVal, OVERTIME);
if (err == 0) return 0;
}
return err::kerr_subdevice_offline;
int32_t err = m_modbusBlockHost.readReg03(slaveAddr, regAddr, regVal, OVERTIME);
if (err == 0) return 0;
return err::kerr_subdevice_overtime;
} }
int32_t PreportionalValveCtrl::setValvePos(int32_t valueid, int32_t pos) { // int32_t PreportionalValveCtrl::setValvePos(int32_t valueid, int32_t pos) { //
@ -35,7 +32,7 @@ int32_t PreportionalValveCtrl::setValvePos(int32_t valueid, int32_t pos) { //
return err::kerr_invalid_param; return err::kerr_invalid_param;
} }
ret = writeReg06(valueid, CTRL_STATE_REG, pos); ret = writeReg06(valueid, CTRL_STATE_REG, pos);
if (!ret) return err::kerr_subdevice_offline;
if (!ret) return err::kerr_subdevice_overtime;
m_last_set_valve_ticket = HAL_GetTick(); m_last_set_valve_ticket = HAL_GetTick();
m_targetpos[valueid] = pos; m_targetpos[valueid] = pos;
@ -50,7 +47,7 @@ int32_t PreportionalValveCtrl::getValvePos(int32_t valueid, int32_t* pos) {
uint16_t pos16 = 0; uint16_t pos16 = 0;
ret = readReg03(valueid, POS_STATE_REG, &pos16); ret = readReg03(valueid, POS_STATE_REG, &pos16);
if (!ret) return err::kerr_subdevice_offline;
if (!ret) return err::kerr_subdevice_overtime;
*pos = pos16; *pos = pos16;
return 0; return 0;
@ -63,7 +60,7 @@ int32_t PreportionalValveCtrl::getValveOrderPos(int32_t valueid, int32_t* pos) {
uint16_t pos16 = 0; uint16_t pos16 = 0;
ret = readReg03(valueid, CTRL_STATE_REG, &pos16); ret = readReg03(valueid, CTRL_STATE_REG, &pos16);
if (!ret) return err::kerr_subdevice_offline;
if (!ret) return err::kerr_subdevice_overtime;
*pos = pos16; *pos = pos16;
return 0; return 0;
@ -101,7 +98,7 @@ int32_t PreportionalValveCtrl::getValveWorkState(int32_t valueid, int32_t* state
uint16_t state16 = 0; uint16_t state16 = 0;
ret = readReg03(valueid, WORK_STATE_REG, &state16); ret = readReg03(valueid, WORK_STATE_REG, &state16);
if (!ret) return err::kerr_subdevice_offline;
if (!ret) return err::kerr_subdevice_overtime;
*state = state16; *state = state16;
return 0; return 0;
} }

2
usrc/module/blower_controller.hpp

@ -116,7 +116,7 @@ class BlowerController {
zcanbus_send_ack(cxt->packet, NULL, 0); zcanbus_send_ack(cxt->packet, NULL, 0);
isopen = GET_PARAM(0) > 0 ? true : false; isopen = GET_PARAM(0) > 0 ? true : false;
} else { } else {
zcanbus_send_errorack(cxt->packet, err::kerr_overtime);
zcanbus_send_errorack(cxt->packet, err::kerr_subdevice_overtime);
} }
} else if (m_blowerType == kMiniPwmBlower) { } else if (m_blowerType == kMiniPwmBlower) {

44
usrc/module/proportional_valve_ctrl.cpp

@ -0,0 +1,44 @@
#include "proportional_valve_ctrl.hpp"
using namespace iflytop;
using namespace transmit_disfection_protocol;
void ProportionalValveCtrl::initialize(UART_HandleTypeDef* huart) {
valve.initialize(huart);
m_isInitialized = true;
BIND_FN(ProportionalValveCtrl, this, fn_proportional_set_valve);
BIND_FN(ProportionalValveCtrl, this, fn_proportional_read_pos);
BIND_FN(ProportionalValveCtrl, this, fn_proportional_is_busy);
}
bool ProportionalValveCtrl::isInitialized() { return m_isInitialized; }
void ProportionalValveCtrl::fn_proportional_set_valve(ProcessContext* cxt) {
int32_t err = valve.setValvePos(GET_PARAM(0), GET_PARAM(1));
if (err) {
zcanbus_send_errorack(cxt->packet, err);
} else {
zcanbus_send_ack(cxt->packet, NULL, 0);
}
}
void ProportionalValveCtrl::fn_proportional_read_pos(ProcessContext* cxt) {
int32_t pos = 0;
int32_t err = valve.getValvePos(GET_PARAM(0), &pos);
if (err) {
zcanbus_send_errorack(cxt->packet, err);
} else {
zcanbus_send_ack(cxt->packet, (uint8_t*)&pos, sizeof(pos));
}
}
void ProportionalValveCtrl::fn_proportional_is_busy(ProcessContext* cxt) {
int32_t busy = 0;
int32_t err = valve.isBusy(GET_PARAM(0), &busy);
if (err) {
zcanbus_send_errorack(cxt->packet, err);
} else {
zcanbus_send_ack(cxt->packet, (uint8_t*)&busy, sizeof(busy));
}
}

43
usrc/module/proportional_valve_ctrl.hpp

@ -9,46 +9,13 @@ class ProportionalValveCtrl {
bool m_isInitialized = false; bool m_isInitialized = false;
public: public:
void initialize(UART_HandleTypeDef* huart) {
valve.initialize(huart);
m_isInitialized = true;
BIND_FN(ProportionalValveCtrl, this, fn_proportional_set_valve);
BIND_FN(ProportionalValveCtrl, this, fn_proportional_read_pos);
BIND_FN(ProportionalValveCtrl, this, fn_proportional_is_busy);
}
bool isInitialized() { return m_isInitialized; }
void initialize(UART_HandleTypeDef* huart);
bool isInitialized();
private: private:
void fn_proportional_set_valve(ProcessContext* cxt) {
int32_t err = valve.setValvePos(GET_PARAM(0), GET_PARAM(1));
if (err) {
zcanbus_send_errorack(cxt->packet, err);
} else {
zcanbus_send_ack(cxt->packet, NULL, 0);
}
}
void fn_proportional_read_pos(ProcessContext* cxt) {
int32_t pos = 0;
int32_t err = valve.getValvePos(GET_PARAM(0), &pos);
if (err) {
zcanbus_send_errorack(cxt->packet, err);
} else {
zcanbus_send_ack(cxt->packet, (uint8_t*)&pos, sizeof(pos));
}
}
void fn_proportional_is_busy(ProcessContext* cxt) {
int32_t busy = 0;
int32_t err = valve.isBusy(GET_PARAM(0), &busy);
if (err) {
zcanbus_send_errorack(cxt->packet, err);
} else {
zcanbus_send_ack(cxt->packet, (uint8_t*)&busy, sizeof(busy));
}
}
void fn_proportional_set_valve(ProcessContext* cxt);
void fn_proportional_read_pos(ProcessContext* cxt);
void fn_proportional_is_busy(ProcessContext* cxt);
private: private:
}; };

2
usrc/project_configs.h

@ -15,7 +15,7 @@
* @brief * @brief
* *
*/ */
#define SOFTWARE_VERSION 103 // 软件版本
#define SOFTWARE_VERSION 104 // 软件版本
#define HARDWARE_VERSION 1 // 硬件版本 #define HARDWARE_VERSION 1 // 硬件版本
#define PROJECT "transmit_disinfection_micro_re" // 工程名称 #define PROJECT "transmit_disinfection_micro_re" // 工程名称
#define SN_HEADER "SN" // SN号前缀 #define SN_HEADER "SN" // SN号前缀

Loading…
Cancel
Save