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.
49 lines
1.3 KiB
49 lines
1.3 KiB
#pragma once
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#include "base/config_service.hpp"
|
|
#include "stm32basic/modbus/modbus_block_host.hpp"
|
|
#include "stm32basic/zsdk.hpp"
|
|
/**
|
|
* @brief
|
|
*
|
|
* https://iflytop1.feishu.cn/wiki/GQwCwHMqFiaJRwks80ncwaYKnSe
|
|
*/
|
|
|
|
namespace iflytop {
|
|
using namespace std;
|
|
class PreportionalValveCtrl {
|
|
public:
|
|
typedef enum {
|
|
kstate_stop = 0x0,
|
|
kstate_running_forward = 0xaa,
|
|
kstate_running_backward = 0xbb,
|
|
kstate_err_state = 0xea,
|
|
} work_state_t;
|
|
|
|
private:
|
|
/* data */
|
|
ModbusBlockHost m_modbusBlockHost;
|
|
int32_t val = 0;
|
|
uint32_t m_last_set_valve_ticket = 0;
|
|
uint16_t m_targetpos[255];
|
|
|
|
public:
|
|
PreportionalValveCtrl() {};
|
|
~PreportionalValveCtrl() {};
|
|
|
|
void initialize(UART_HandleTypeDef* huart);
|
|
int32_t setValvePos(int32_t valueid, int32_t pos);
|
|
int32_t getValvePos(int32_t valueid, int32_t* pos);
|
|
int32_t getValveOrderPos(int32_t valueid, int32_t* pos);
|
|
int32_t isBusy(int32_t valueid, int32_t* busy);
|
|
int32_t getValveWorkState(int32_t valueid, int32_t* state);
|
|
|
|
private:
|
|
|
|
int32_t writeReg06(uint8_t slaveAddr, uint16_t regAddr, uint16_t regVal);
|
|
int32_t readReg03(uint8_t slaveAddr, uint16_t regAddr, uint16_t* regVal);
|
|
};
|
|
|
|
} // namespace iflytop
|