21 changed files with 49 additions and 1483 deletions
-
11api/api.hpp
-
60api/config_index.hpp
-
94api/errorcode.cpp
-
68api/i_cmdparser.hpp
-
26api/i_zcan_cmder_master.hpp
-
7api/i_zcanreceiver.hpp
-
20api/module_type_index.hpp
-
4api/packet_interface.hpp
-
24api/reg_index_table.cpp
-
12api/state_index.hpp
-
4protocol_event_bus_sender.cpp
-
4protocol_event_bus_sender.hpp
-
2protocol_parser.cpp
-
6protocol_parser.hpp
-
239protocol_proxy.cpp
-
192protocol_proxy.hpp
-
181zmodule_device_manager.cpp
-
248zmodule_device_manager.hpp
-
257zmodule_device_script_cmder_paser.cpp
-
27zmodule_device_script_cmder_paser.hpp
@ -1,60 +0,0 @@ |
|||
#pragma once
|
|||
#include <stdint.h>
|
|||
#if 0
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
#define CONFIG_CODE(type, subconfigindex) (type + subconfigindex)
|
|||
typedef enum { |
|||
/*******************************************************************************
|
|||
* 电机相关配置和状态 * |
|||
*******************************************************************************/ |
|||
kcfg_motor_x_shift = CONFIG_CODE(100, 0), // x偏移
|
|||
kcfg_motor_y_shift = CONFIG_CODE(100, 1), // y偏移
|
|||
kcfg_motor_z_shift = CONFIG_CODE(100, 2), // z偏移
|
|||
kcfg_motor_x_shaft = CONFIG_CODE(100, 3), // x轴是否反转
|
|||
kcfg_motor_y_shaft = CONFIG_CODE(100, 4), // y轴是否反转
|
|||
kcfg_motor_z_shaft = CONFIG_CODE(100, 5), // z轴是否反转
|
|||
kcfg_motor_x_one_circle_pulse = CONFIG_CODE(100, 6), // x轴一圈脉冲数
|
|||
kcfg_motor_y_one_circle_pulse = CONFIG_CODE(100, 7), // y轴一圈脉冲数
|
|||
kcfg_motor_z_one_circle_pulse = CONFIG_CODE(100, 8), // z轴一圈脉冲数
|
|||
kcfg_motor_default_velocity = CONFIG_CODE(100, 9), // 默认速度
|
|||
kcfg_motor_default_acc = CONFIG_CODE(100, 10), // 默认加速度
|
|||
kcfg_motor_default_dec = CONFIG_CODE(100, 11), // 默认减速度
|
|||
kcfg_motor_default_break_dec = CONFIG_CODE(100, 12), // 默认减速度
|
|||
/*******************************************************************************
|
|||
* 电机找零相关配置 * |
|||
*******************************************************************************/ |
|||
kcfg_motor_run_to_zero_max_x_d = CONFIG_CODE(150, 0), // x轴回零最大距离
|
|||
kcfg_motor_run_to_zero_max_y_d = CONFIG_CODE(150, 1), // y轴回零最大距离
|
|||
kcfg_motor_run_to_zero_max_z_d = CONFIG_CODE(150, 2), // z轴回零最大距离
|
|||
kcfg_motor_look_zero_edge_max_x_d = CONFIG_CODE(150, 3), // x轴找零边缘最大距离
|
|||
kcfg_motor_look_zero_edge_max_y_d = CONFIG_CODE(150, 4), // y轴找零边缘最大距离
|
|||
kcfg_motor_look_zero_edge_max_z_d = CONFIG_CODE(150, 5), // z轴找零边缘最大距离
|
|||
kcfg_motor_run_to_zero_speed = CONFIG_CODE(150, 6), // 回零速度
|
|||
kcfg_motor_run_to_zero_dec = CONFIG_CODE(150, 7), // 回零减速度
|
|||
kcfg_motor_look_zero_edge_speed = CONFIG_CODE(150, 8), // 找零边缘速度
|
|||
kcfg_motor_look_zero_edge_dec = CONFIG_CODE(150, 9), // 找零边缘减速度
|
|||
/*******************************************************************************
|
|||
* 步进电机相关配置 * |
|||
*******************************************************************************/ |
|||
k_cfg_stepmotor_ihold = CONFIG_CODE(200, 0), |
|||
k_cfg_stepmotor_irun = CONFIG_CODE(200, 1), |
|||
k_cfg_stepmotor_iholddelay = CONFIG_CODE(200, 2), |
|||
/*******************************************************************************
|
|||
* XY_ROBOT_CONFIG * |
|||
*******************************************************************************/ |
|||
k_cfg_xyrobot_robot_type = CONFIG_CODE(300, 0), // 机器人类型 0:hbot 1:corexy
|
|||
|
|||
} config_index_t; |
|||
|
|||
} // namespace iflytop
|
|||
|
|||
#endif
|
|||
/**
|
|||
* @brief |
|||
* |
|||
* 模块通用配置和状态 0->1000 |
|||
* Robot/Motor通用配置和状态 1000->2000 |
|||
* Sensor通用配置和状态 2000->3000 |
|||
* PID通用配置和状态 4000->4100 |
|||
*/ |
@ -1,68 +0,0 @@ |
|||
//
|
|||
// Created by zwsd
|
|||
//
|
|||
|
|||
#pragma once
|
|||
#include <functional>
|
|||
|
|||
#include "config_index.hpp"
|
|||
#include "errorcode.hpp"
|
|||
#include "packet_interface.hpp"
|
|||
#include "protocol_constant.hpp"
|
|||
namespace iflytop { |
|||
using namespace zcr; |
|||
|
|||
class ICmdParserACK { |
|||
public: |
|||
typedef enum { |
|||
kAckType_none, |
|||
kAckType_int32, |
|||
kAckType_buf, |
|||
kAckType_str, |
|||
} ICmdParserACKType_t; |
|||
|
|||
public: |
|||
int32_t ecode; |
|||
ICmdParserACKType_t acktype; |
|||
uint8_t rawdata[ZCANCMD_READ_BUF_MAX_SIZE + 100]; |
|||
int32_t rawlen; |
|||
|
|||
public: |
|||
void setInt32Ack(int32_t ecode, int32_t val) { |
|||
this->ecode = ecode; |
|||
acktype = kAckType_int32; |
|||
rawlen = sizeof(int32_t); |
|||
*((int32_t *)rawdata) = val; |
|||
} |
|||
|
|||
void setNoneAck(int32_t ecode) { |
|||
this->ecode = ecode; |
|||
acktype = kAckType_none; |
|||
rawlen = 0; |
|||
rawdata[0] = 0; |
|||
} |
|||
|
|||
int32_t *getAck(int index) { |
|||
if (index < 0 || index >= (int32_t)(sizeof(rawdata) / 4)) { |
|||
return nullptr; |
|||
} |
|||
return (int32_t *)rawdata + index; |
|||
} |
|||
|
|||
int32_t getAckInt32Val(int index) { |
|||
if (index < 0 || index >= rawlen / (int)sizeof(int32_t)) { |
|||
return 0; |
|||
} |
|||
return *((int32_t *)rawdata + index); |
|||
} |
|||
int32_t getAckInt32Num() { return rawlen / (int)sizeof(int32_t); } |
|||
}; |
|||
|
|||
typedef function<void(int32_t paramN, const char **paraV, ICmdParserACK *ack)> ICmdFunction_t; |
|||
|
|||
class ICmdParser { |
|||
public: |
|||
virtual void regCMD(const char *cmdname, const char *helpinfo, int paraNum, ICmdFunction_t cmdimpl) = 0; |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -1,26 +0,0 @@ |
|||
//
|
|||
// Created by zwsd
|
|||
//
|
|||
|
|||
#pragma once
|
|||
#include <functional>
|
|||
|
|||
#include "config_index.hpp"
|
|||
#include "errorcode.hpp"
|
|||
#include "packet_interface.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
using namespace zcr; |
|||
|
|||
typedef function<void(int32_t fromboard, zcr_cmd_header_t *packet, int32_t datalen)> onpacket_t; |
|||
|
|||
class IZcanCmderMaster { |
|||
public: |
|||
virtual int32_t sendCmd(int32_t cmdid, int32_t moduleid, int32_t *param, size_t npara, int32_t *ack, size_t nack, int overtime_ms) = 0; |
|||
virtual int32_t sendCmdAndReceiveBuf(int32_t cmdid, int32_t moduleid, int32_t *param, size_t npara, uint8_t *ack, int32_t *rxsize, int overtime_ms) = 0; |
|||
|
|||
virtual void regEventPacketListener(onpacket_t on_event) = 0; |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -1,12 +0,0 @@ |
|||
#pragma once
|
|||
#include <stdint.h>
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
#define STATE_INDEX(type, subconfigindex) (type + subconfigindex)
|
|||
typedef enum { |
|||
|
|||
} state_index_t; |
|||
|
|||
} // namespace iflytop
|
@ -1,239 +0,0 @@ |
|||
#include "protocol_proxy.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
#define PROXY_IMPL_0X_PARA()
|
|||
#define PROXY_IMPL_1X_PARA() param[0] = para0;
|
|||
#define PROXY_IMPL_2X_PARA() \
|
|||
PROXY_IMPL_1X_PARA(); \ |
|||
param[1] = para1; |
|||
|
|||
#define PROXY_IMPL_3X_PARA() \
|
|||
PROXY_IMPL_2X_PARA(); \ |
|||
param[2] = para2; |
|||
|
|||
#define PROXY_IMPL_4X_PARA() \
|
|||
PROXY_IMPL_3X_PARA(); \ |
|||
param[3] = para3; |
|||
|
|||
#define PROXY_IMPL_5X_PARA() \
|
|||
PROXY_IMPL_4X_PARA(); \ |
|||
param[4] = para4; |
|||
|
|||
#define PROXY_IMPL_X0_ACK()
|
|||
#define PROXY_IMPL_X1_ACK() *ack0 = ack[0];
|
|||
#define PROXY_IMPL_X2_ACK() \
|
|||
PROXY_IMPL_X1_ACK(); \ |
|||
*ack1 = ack[1]; |
|||
|
|||
#define PROXY_IMPL_X3_ACK() \
|
|||
PROXY_IMPL_X2_ACK(); \ |
|||
*ack2 = ack[2]; |
|||
|
|||
#define PROXY_IMPL_X4_ACK() \
|
|||
PROXY_IMPL_X3_ACK(); \ |
|||
*ack3 = ack[3] |
|||
|
|||
#define PROXY_IMPL_X5_ACK() \
|
|||
PROXY_IMPL_X4_ACK(); \ |
|||
*ack4 = ack[4]; |
|||
|
|||
#define PROXY_IMPL_XX(cmdindex, paramnum, acknum, paraassign, ackassign, overtime) \
|
|||
int32_t param[1 + paramnum] = {0}; \ |
|||
int32_t ack[1 + acknum] = {0}; \ |
|||
paraassign; \ |
|||
int32_t ecode = m_cancmder->sendCmd(cmdindex, m_id, param, paramnum, ack, acknum, overtime); \ |
|||
ackassign; \ |
|||
return ecode; |
|||
|
|||
#define PROXY_IMPL_00(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 0, 0, PROXY_IMPL_0X_PARA(), PROXY_IMPL_X0_ACK(), overtime);
|
|||
#define PROXY_IMPL_01(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 0, 1, PROXY_IMPL_0X_PARA(), PROXY_IMPL_X1_ACK(), overtime);
|
|||
#define PROXY_IMPL_02(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 0, 2, PROXY_IMPL_0X_PARA(), PROXY_IMPL_X2_ACK(), overtime);
|
|||
#define PROXY_IMPL_03(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 0, 3, PROXY_IMPL_0X_PARA(), PROXY_IMPL_X3_ACK(), overtime);
|
|||
#define PROXY_IMPL_04(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 0, 4, PROXY_IMPL_0X_PARA(), PROXY_IMPL_X4_ACK(), overtime);
|
|||
|
|||
#define PROXY_IMPL_10(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 1, 0, PROXY_IMPL_1X_PARA(), PROXY_IMPL_X0_ACK(), overtime);
|
|||
#define PROXY_IMPL_11(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 1, 1, PROXY_IMPL_1X_PARA(), PROXY_IMPL_X1_ACK(), overtime);
|
|||
#define PROXY_IMPL_12(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 1, 2, PROXY_IMPL_1X_PARA(), PROXY_IMPL_X2_ACK(), overtime);
|
|||
#define PROXY_IMPL_13(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 1, 3, PROXY_IMPL_1X_PARA(), PROXY_IMPL_X3_ACK(), overtime);
|
|||
#define PROXY_IMPL_14(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 1, 4, PROXY_IMPL_1X_PARA(), PROXY_IMPL_X4_ACK(), overtime);
|
|||
|
|||
#define PROXY_IMPL_20(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 2, 0, PROXY_IMPL_2X_PARA(), PROXY_IMPL_X0_ACK(), overtime);
|
|||
#define PROXY_IMPL_21(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 2, 1, PROXY_IMPL_2X_PARA(), PROXY_IMPL_X1_ACK(), overtime);
|
|||
#define PROXY_IMPL_22(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 2, 2, PROXY_IMPL_2X_PARA(), PROXY_IMPL_X2_ACK(), overtime);
|
|||
#define PROXY_IMPL_23(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 2, 3, PROXY_IMPL_2X_PARA(), PROXY_IMPL_X3_ACK(), overtime);
|
|||
#define PROXY_IMPL_24(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 2, 4, PROXY_IMPL_2X_PARA(), PROXY_IMPL_X4_ACK(), overtime);
|
|||
|
|||
#define PROXY_IMPL_30(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 3, 0, PROXY_IMPL_3X_PARA(), PROXY_IMPL_X0_ACK(), overtime);
|
|||
#define PROXY_IMPL_31(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 3, 1, PROXY_IMPL_3X_PARA(), PROXY_IMPL_X1_ACK(), overtime);
|
|||
#define PROXY_IMPL_32(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 3, 2, PROXY_IMPL_3X_PARA(), PROXY_IMPL_X2_ACK(), overtime);
|
|||
#define PROXY_IMPL_33(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 3, 3, PROXY_IMPL_3X_PARA(), PROXY_IMPL_X3_ACK(), overtime);
|
|||
|
|||
#define PROXY_IMPL_40(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 4, 0, PROXY_IMPL_4X_PARA(), PROXY_IMPL_X0_ACK(), overtime);
|
|||
#define PROXY_IMPL_41(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 4, 1, PROXY_IMPL_4X_PARA(), PROXY_IMPL_X1_ACK(), overtime);
|
|||
#define PROXY_IMPL_42(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 4, 2, PROXY_IMPL_4X_PARA(), PROXY_IMPL_X2_ACK(), overtime);
|
|||
#define PROXY_IMPL_43(cmdindex, overtime) PROXY_IMPL_XX(cmdindex, 4, 3, PROXY_IMPL_4X_PARA(), PROXY_IMPL_X3_ACK(), overtime);
|
|||
|
|||
#define OVERTIME 300
|
|||
|
|||
int32_t ZIProtocolProxy::module_ping() { PROXY_IMPL_00(kmodule_ping, 30); } |
|||
int32_t ZIProtocolProxy::module_stop() { PROXY_IMPL_00(kmodule_stop, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_break() { PROXY_IMPL_00(kmodule_break, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_start() { PROXY_IMPL_00(kmodule_start, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::module_get_last_exec_status(int32_t *ack0) { PROXY_IMPL_01(kmodule_get_last_exec_status, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_get_status(int32_t *ack0) { PROXY_IMPL_01(kmodule_get_status, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::module_set_reg(int32_t para0, int32_t para1) { PROXY_IMPL_20(kmodule_set_reg, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_get_reg(int32_t para0, int32_t *ack0) { PROXY_IMPL_11(kmodule_get_reg, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::module_readio(int32_t *ack0) { PROXY_IMPL_01(kmodule_readio, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_writeio(int32_t para0, int32_t para1) { PROXY_IMPL_20(kmodule_writeio, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::module_read_adc(int32_t para0, int32_t *ack0) { PROXY_IMPL_11(kmodule_read_adc, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_get_error(int32_t *ack0) { PROXY_IMPL_01(kmodule_get_error, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_clear_error() { PROXY_IMPL_00(kmodule_clear_error, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::module_set_inited_flag(int32_t para0) { PROXY_IMPL_10(kmodule_set_inited_flag, OVERTIME); }; |
|||
int32_t ZIProtocolProxy::module_get_inited_flag(int32_t *ack0) { PROXY_IMPL_01(kmodule_get_inited_flag, OVERTIME); }; |
|||
|
|||
int32_t ZIProtocolProxy::module_factory_reset() { PROXY_IMPL_00(kmodule_factory_reset, OVERTIME); } |
|||
int32_t ZIProtocolProxy::module_flush_cfg() { PROXY_IMPL_00(kmodule_flush_cfg, 5000); } |
|||
int32_t ZIProtocolProxy::module_active_cfg() { PROXY_IMPL_00(kmodule_active_cfg, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::module_read_raw(int32_t startadd, uint8_t *data, int32_t *len) { |
|||
int32_t param[1 + 1] = {0}; |
|||
param[0] = startadd; |
|||
int32_t ecode = m_cancmder->sendCmdAndReceiveBuf(kmodule_read_raw, m_id, param, 1, data, len, 100); |
|||
return ecode; |
|||
} |
|||
|
|||
int32_t ZIProtocolProxy::module_enable(int32_t para0) { PROXY_IMPL_10(kmodule_enable, OVERTIME); } |
|||
|
|||
/*******************************************************************************
|
|||
* ZIMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } |
|||
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // Ò»°ãÓÃÓÚ¶æ»ú
|
|||
virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_io(int32_t ioindex, int32_t direction) { return err::koperation_not_support; }; |
|||
|
|||
#endif
|
|||
|
|||
int32_t ZIProtocolProxy::motor_enable(int32_t para0) { PROXY_IMPL_10(kmotor_enable, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_rotate(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_rotate, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_move_by(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_move_by, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_move_to(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_move_to, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_rotate_with_torque(int32_t para0, int32_t para1) { PROXY_IMPL_20(kmotor_rotate_with_torque, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::motor_rotate_acctime(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_rotate_acctime, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_move_by_acctime(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_move_by_acctime, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_move_to_acctime(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_move_to_acctime, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::motor_move_to_zero_forward(int32_t para0, int32_t para1, int32_t para2, int32_t para3) { PROXY_IMPL_40(kmotor_move_to_zero_forward, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_move_to_zero_backward(int32_t para0, int32_t para1, int32_t para2, int32_t para3) { PROXY_IMPL_40(kmotor_move_to_zero_backward, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::motor_read_pos(int32_t *ack0) { PROXY_IMPL_01(kmotor_read_pos, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_set_current_pos_by_change_shift(int32_t para0) { PROXY_IMPL_10(kmotor_set_current_pos_by_change_shift, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::motor_move_to_zero_forward_and_calculated_shift(int32_t para0, int32_t para1, int32_t para2, int32_t para3) { PROXY_IMPL_40(kmotor_motor_move_to_zero_forward_and_calculated_shift, OVERTIME); }; |
|||
int32_t ZIProtocolProxy::motor_move_to_zero_backward_and_calculated_shift(int32_t para0, int32_t para1, int32_t para2, int32_t para3) { PROXY_IMPL_40(kmotor_motor_move_to_zero_backward_and_calculated_shift, OVERTIME); }; |
|||
|
|||
int32_t ZIProtocolProxy::motor_move_to_torque(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kmotor_move_to_torque, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_calculated_pos_by_move_to_zero() { PROXY_IMPL_00(kmotor_calculated_pos_by_move_to_zero, OVERTIME); } |
|||
|
|||
int32_t ZIProtocolProxy::motor_easy_rotate(int32_t para0) { PROXY_IMPL_10(kmotor_easy_rotate, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_easy_move_by(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_by, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_easy_move_to(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_to, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_easy_move_to_zero(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_to_zero, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_easy_set_current_pos(int32_t para0) { PROXY_IMPL_10(kmotor_easy_set_current_pos, OVERTIME); } |
|||
int32_t ZIProtocolProxy::motor_easy_move_to_io(int32_t para0, int32_t para1) { PROXY_IMPL_20(kmotor_easy_move_to_io, OVERTIME); } |
|||
/*******************************************************************************
|
|||
* ZIXYMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual ~ZIXYMotor() {} |
|||
virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
#endif
|
|||
int32_t ZIProtocolProxy::xymotor_enable(int32_t para0) { PROXY_IMPL_10(kxymotor_enable, OVERTIME); } |
|||
int32_t ZIProtocolProxy::xymotor_move_by(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kxymotor_move_by, OVERTIME); } |
|||
int32_t ZIProtocolProxy::xymotor_move_to(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kxymotor_move_to, OVERTIME); } |
|||
int32_t ZIProtocolProxy::xymotor_move_to_zero() { PROXY_IMPL_00(kxymotor_move_to_zero, OVERTIME); } |
|||
int32_t ZIProtocolProxy::xymotor_move_to_zero_and_calculated_shift() { PROXY_IMPL_00(kxymotor_move_to_zero_and_calculated_shift, OVERTIME); } |
|||
int32_t ZIProtocolProxy::xymotor_read_pos(int32_t *ack0, int32_t *ack1) { PROXY_IMPL_02(kxymotor_read_pos, OVERTIME); } |
|||
int32_t ZIProtocolProxy::xymotor_calculated_pos_by_move_to_zero() { PROXY_IMPL_00(kxymotor_calculated_pos_by_move_to_zero, OVERTIME); } |
|||
|
|||
#if 0
|
|||
virtual int32_t code_scaner_start_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_stop_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_read_scaner_result(int32_t startadd, uint8_t *data, int32_t *len) { return err::koperation_not_support; } |
|||
|
|||
int32_t ZIProtocolProxy::code_scaner_start_scan() { PROXY_IMPL_00(kcode_scaner_start_scan, OVERTIME); } |
|||
int32_t ZIProtocolProxy::code_scaner_stop_scan() { PROXY_IMPL_00(kcode_scaner_stop_scan, OVERTIME); } |
|||
int32_t ZIProtocolProxy::code_scaner_read_scaner_result(int32_t para0, uint8_t *data, int32_t *len) { |
|||
int32_t param[1 + 1] = {0}; |
|||
param[0] = para0; |
|||
int32_t ecode = m_cancmder->sendCmdAndReceiveBuf(kmodule_read_raw, m_id, param, 1, data, len, 100); |
|||
return ecode; |
|||
} |
|||
#endif
|
|||
|
|||
#if 0
|
|||
virtual int32_t pipette_ctrl_init_device() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_put_tip() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_move_to_ul(int32_t ul) { return err::koperation_not_support; }; |
|||
#endif
|
|||
|
|||
int32_t ZIProtocolProxy::pipette_ctrl_init_device() { PROXY_IMPL_00(kpipette_ctrl_init_device, OVERTIME); }; |
|||
int32_t ZIProtocolProxy::pipette_ctrl_put_tip() { PROXY_IMPL_00(kpipette_ctrl_put_tip, OVERTIME); }; |
|||
int32_t ZIProtocolProxy::pipette_ctrl_move_to_ul(int32_t para0) { PROXY_IMPL_10(kpipette_ctrl_move_to_ul, OVERTIME); }; |
|||
|
|||
#if 0
|
|||
virtual int32_t a8000_optical_module_power_ctrl(int32_t state) = 0; |
|||
virtual int32_t a8000_optical_open_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_close_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_set_laster_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_set_scan_amp_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_read_scanner_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_read_laster_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_scan_current_point_amp_adc_val(int32_t type, int32_t lastergain, int32_t ampgain, int32_t* laster_fb_val, int32_t* adcval) = 0; |
|||
#endif
|
|||
|
|||
int32_t ZIProtocolProxy::a8000_optical_module_power_ctrl(int32_t para0) { PROXY_IMPL_10(ka8000_optical_module_power_ctrl, OVERTIME); } |
|||
int32_t ZIProtocolProxy::a8000_optical_open_laser(int32_t para0) { PROXY_IMPL_10(ka8000_optical_open_laser, OVERTIME); } |
|||
int32_t ZIProtocolProxy::a8000_optical_close_laser(int32_t para0) { PROXY_IMPL_10(ka8000_optical_close_laser, OVERTIME); } |
|||
int32_t ZIProtocolProxy::a8000_optical_set_laster_gain(int32_t para0, int32_t para1) { PROXY_IMPL_20(ka8000_optical_set_laster_gain, OVERTIME); } |
|||
int32_t ZIProtocolProxy::a8000_optical_set_scan_amp_gain(int32_t para0, int32_t para1) { PROXY_IMPL_20(ka8000_optical_set_scan_amp_gain, OVERTIME); } |
|||
int32_t ZIProtocolProxy::a8000_optical_read_scanner_adc_val(int32_t para0, int32_t *ack0) { PROXY_IMPL_11(ka8000_optical_read_scanner_adc_val, OVERTIME); } |
|||
int32_t ZIProtocolProxy::a8000_optical_read_laster_adc_val(int32_t para0, int32_t *ack0) { PROXY_IMPL_11(ka8000_optical_read_laster_adc_val, OVERTIME); } |
|||
int32_t ZIProtocolProxy::a8000_optical_scan_current_point_amp_adc_val(int32_t para0, int32_t para1, int32_t para2, int32_t *ack0, int32_t *ack1) { PROXY_IMPL_22(ka8000_optical_scan_current_point_amp_adc_val, OVERTIME); } |
@ -1,192 +0,0 @@ |
|||
#pragma once
|
|||
#include <map>
|
|||
|
|||
#include "api/api.hpp"
|
|||
#include "api/i_zcan_cmder_master.hpp"
|
|||
#include "cmdid.hpp"
|
|||
|
|||
namespace iflytop { |
|||
class ZIProtocolProxy : public ZIMotor, //
|
|||
public ZIXYMotor, //
|
|||
public ZIModule, |
|||
public ZIPipetteCtrlModule, |
|||
public ZIA8000OpticalModule { |
|||
private: |
|||
IZcanCmderMaster *m_cancmder; |
|||
int32_t m_id = 0; |
|||
|
|||
public: |
|||
void initialize(int32_t moduleId, IZcanCmderMaster *cancmder) { |
|||
m_cancmder = cancmder; |
|||
m_id = moduleId; |
|||
} |
|||
|
|||
virtual int32_t getid(int32_t *id) { |
|||
*id = m_id; |
|||
return 0; |
|||
}; |
|||
|
|||
/*******************************************************************************
|
|||
* ZIModule * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
#endif
|
|||
virtual int32_t module_ping() override; |
|||
|
|||
virtual int32_t module_stop() override; |
|||
virtual int32_t module_break() override; |
|||
virtual int32_t module_start() override; |
|||
virtual int32_t module_get_last_exec_status(int32_t *status) override; |
|||
virtual int32_t module_get_status(int32_t *status) override; |
|||
|
|||
virtual int32_t module_set_reg(int32_t param_id, int32_t param_value) override; |
|||
virtual int32_t module_get_reg(int32_t param_id, int32_t *param_value) override; |
|||
|
|||
virtual int32_t module_readio(int32_t *io) override; |
|||
virtual int32_t module_writeio(int32_t ioindex, int32_t io) override; |
|||
|
|||
virtual int32_t module_read_adc(int32_t adcindex, int32_t *adc) override; |
|||
|
|||
virtual int32_t module_get_error(int32_t *iserror) override; |
|||
virtual int32_t module_clear_error() override; |
|||
|
|||
virtual int32_t module_set_inited_flag(int32_t flag) override; |
|||
virtual int32_t module_get_inited_flag(int32_t *flag) override; |
|||
|
|||
virtual int32_t module_factory_reset() override; |
|||
virtual int32_t module_flush_cfg() override; |
|||
virtual int32_t module_active_cfg() override; |
|||
|
|||
virtual int32_t module_read_raw(int32_t startadd, uint8_t *data, int32_t *len) override; |
|||
virtual int32_t module_enable(int32_t enable) override; |
|||
|
|||
/*******************************************************************************
|
|||
* ZIMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } |
|||
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一锟斤拷锟斤拷锟节讹拷锟?
|
|||
virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_io(int32_t ioindex, int32_t direction) { return err::koperation_not_support; }; |
|||
|
|||
#endif
|
|||
|
|||
virtual int32_t motor_enable(int32_t enable) override; |
|||
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) override; |
|||
virtual int32_t motor_move_by(int32_t direction, int32_t motor_velocity, int32_t acc) override; |
|||
virtual int32_t motor_move_to(int32_t direction, int32_t motor_velocity, int32_t acc) override; |
|||
virtual int32_t motor_rotate_with_torque(int32_t direction, int32_t torque) override; |
|||
|
|||
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) override; |
|||
virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) override; |
|||
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) override; |
|||
|
|||
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
|
|||
virtual int32_t motor_read_pos(int32_t *pos) override; |
|||
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) override; |
|||
|
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
|
|||
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) override; |
|||
virtual int32_t motor_calculated_pos_by_move_to_zero() override; |
|||
|
|||
virtual int32_t motor_easy_rotate(int32_t direction) override; |
|||
virtual int32_t motor_easy_move_by(int32_t distance) override; |
|||
virtual int32_t motor_easy_move_to(int32_t position) override; |
|||
virtual int32_t motor_easy_move_to_zero(int32_t direction) override; |
|||
virtual int32_t motor_easy_set_current_pos(int32_t pos) override; |
|||
virtual int32_t motor_easy_move_to_io(int32_t ioindex, int32_t direction) override; |
|||
|
|||
/*******************************************************************************
|
|||
* ZIXYMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual ~ZIXYMotor() {} |
|||
virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
#endif
|
|||
virtual int32_t xymotor_enable(int32_t enable) override; |
|||
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) override; |
|||
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) override; |
|||
virtual int32_t xymotor_move_to_zero() override; |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift() override; |
|||
virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) override; |
|||
virtual int32_t xymotor_calculated_pos_by_move_to_zero() override; |
|||
|
|||
/*******************************************************************************
|
|||
* ZICodeScaner * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual int32_t code_scaner_start_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_stop_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_read_scaner_result(int32_t startadd, uint8_t *data, int32_t *len) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t code_scaner_start_scan() override; |
|||
virtual int32_t code_scaner_stop_scan() override; |
|||
virtual int32_t code_scaner_read_scaner_result(int32_t startadd, uint8_t *data, int32_t *len) override; |
|||
#endif
|
|||
|
|||
#if 0
|
|||
virtual int32_t pipette_ctrl_init_device() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_put_tip() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_move_to_ul(int32_t ul) { return err::koperation_not_support; }; |
|||
#endif
|
|||
|
|||
virtual int32_t pipette_ctrl_init_device() override; |
|||
virtual int32_t pipette_ctrl_put_tip() override; |
|||
virtual int32_t pipette_ctrl_move_to_ul(int32_t ul) override; |
|||
|
|||
#if 0
|
|||
virtual int32_t a8000_optical_module_power_ctrl(int32_t state) = 0; |
|||
virtual int32_t a8000_optical_open_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_close_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_set_laster_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_set_scan_amp_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_read_scanner_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_read_laster_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_scan_current_point_amp_adc_val(int32_t type, int32_t lastergain, int32_t ampgain, int32_t* laster_fb_val, int32_t* adcval) = 0; |
|||
#endif
|
|||
|
|||
virtual int32_t a8000_optical_module_power_ctrl(int32_t state) override; |
|||
virtual int32_t a8000_optical_open_laser(int32_t type) override; |
|||
virtual int32_t a8000_optical_close_laser(int32_t type) override; |
|||
virtual int32_t a8000_optical_set_laster_gain(int32_t type, int32_t gain) override; |
|||
virtual int32_t a8000_optical_set_scan_amp_gain(int32_t type, int32_t gain) override; |
|||
virtual int32_t a8000_optical_read_scanner_adc_val(int32_t type, int32_t *adcval) override; |
|||
virtual int32_t a8000_optical_read_laster_adc_val(int32_t type, int32_t *adcval) override; |
|||
virtual int32_t a8000_optical_scan_current_point_amp_adc_val(int32_t type, int32_t lastergain, int32_t ampgain, int32_t *laster_fb_val, int32_t *adcval) override; |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -1,181 +0,0 @@ |
|||
#include "zmodule_device_manager.hpp"
|
|||
|
|||
#include <assert.h>
|
|||
#include <stdio.h>
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
|
|||
#define PROXY_IMPL(type, functionName, ...) \
|
|||
type *module = nullptr; \ |
|||
int32_t ecode = findModule<type>(id, &module); \ |
|||
if (ecode != 0) { \ |
|||
return ecode; \ |
|||
} \ |
|||
return module->functionName(__VA_ARGS__); |
|||
|
|||
void ZModuleDeviceManager::initialize(IZcanCmderMaster *cancmder) { regCanCmder(cancmder); } |
|||
void ZModuleDeviceManager::initialize() {} |
|||
|
|||
void ZModuleDeviceManager::regCanCmder(IZcanCmderMaster *cancmder) { |
|||
m_cancmder = cancmder; |
|||
// assert(m_cancmder != nullptr);
|
|||
if (m_cancmder) { |
|||
m_cancmder->regEventPacketListener([this](int32_t fromboard, zcr_cmd_header_t *packet, int32_t datalen) { |
|||
if (CMDID(packet->cmdMainId, packet->cmdSubId) == zcr::kevent_bus_reg_change_report) { |
|||
int32_t *pdata = (int32_t *)packet->data; |
|||
int32_t regindex = pdata[0]; |
|||
int32_t regold = pdata[1]; |
|||
int32_t regnew = pdata[2]; |
|||
callOnRegValChangeEvent(packet->subModuleid, regindex, regold, regnew); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
void ZModuleDeviceManager::registerModule(ZIModule *module) { |
|||
assert(module != nullptr); |
|||
int32_t id = 0; |
|||
module->getid(&id); |
|||
uint16_t id16 = id; |
|||
m_modulers[id16] = module; |
|||
} |
|||
|
|||
/*******************************************************************************
|
|||
* ZIModule * |
|||
*******************************************************************************/ |
|||
int32_t ZModuleDeviceManager::module_ping(uint16_t id) { PROXY_IMPL(ZIModule, module_ping); } |
|||
int32_t ZModuleDeviceManager::module_stop(uint16_t id) { PROXY_IMPL(ZIModule, module_stop); } |
|||
int32_t ZModuleDeviceManager::module_break(uint16_t id) { PROXY_IMPL(ZIModule, module_break); } |
|||
int32_t ZModuleDeviceManager::module_get_last_exec_status(uint16_t id, int32_t *ack0) { PROXY_IMPL(ZIModule, module_get_last_exec_status, ack0); } |
|||
int32_t ZModuleDeviceManager::module_get_status(uint16_t id, int32_t *status) { PROXY_IMPL(ZIModule, module_get_status, status); } |
|||
int32_t ZModuleDeviceManager::module_set_reg(uint16_t id, int32_t param_id, int32_t param_value) { PROXY_IMPL(ZIModule, module_set_reg, param_id, param_value); } |
|||
int32_t ZModuleDeviceManager::module_get_reg(uint16_t id, int32_t param_id, int32_t *param_value) { PROXY_IMPL(ZIModule, module_get_reg, param_id, param_value); } |
|||
int32_t ZModuleDeviceManager::module_readio(uint16_t id, int32_t *io) { PROXY_IMPL(ZIModule, module_readio, io); } |
|||
int32_t ZModuleDeviceManager::module_writeio(uint16_t id, int32_t ioindex, int32_t io) { PROXY_IMPL(ZIModule, module_writeio, ioindex, io); } |
|||
int32_t ZModuleDeviceManager::module_read_adc(uint16_t id, int32_t adcindex, int32_t *adc) { PROXY_IMPL(ZIModule, module_read_adc, adcindex, adc); } |
|||
int32_t ZModuleDeviceManager::module_get_error(uint16_t id, int32_t *iserror) { PROXY_IMPL(ZIModule, module_get_error, iserror); } |
|||
int32_t ZModuleDeviceManager::module_clear_error(uint16_t id) { PROXY_IMPL(ZIModule, module_clear_error); } |
|||
int32_t ZModuleDeviceManager::module_set_inited_flag(uint16_t id, int32_t flag) { PROXY_IMPL(ZIModule, module_set_inited_flag, flag); } |
|||
int32_t ZModuleDeviceManager::module_get_inited_flag(uint16_t id, int32_t *flag) { PROXY_IMPL(ZIModule, module_get_inited_flag, flag); } |
|||
int32_t ZModuleDeviceManager::module_factory_reset(uint16_t id) { PROXY_IMPL(ZIModule, module_factory_reset); } |
|||
int32_t ZModuleDeviceManager::module_flush_cfg(uint16_t id) { PROXY_IMPL(ZIModule, module_flush_cfg); } |
|||
int32_t ZModuleDeviceManager::module_active_cfg(uint16_t id) { PROXY_IMPL(ZIModule, module_active_cfg); } |
|||
int32_t ZModuleDeviceManager::module_read_raw(uint16_t id, int32_t startadd, uint8_t *data, int32_t *len) { PROXY_IMPL(ZIModule, module_read_raw, startadd, data, len); } |
|||
int32_t ZModuleDeviceManager::module_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIModule, module_enable, enable); } |
|||
int32_t ZModuleDeviceManager::module_start(uint16_t id) { PROXY_IMPL(ZIModule, module_start); } |
|||
|
|||
/*******************************************************************************
|
|||
* ZIMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } |
|||
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一锟斤拷锟斤拷锟节讹拷锟?
|
|||
virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_easy_rotate(uint16_t id, int32_t direction); |
|||
virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); |
|||
virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); |
|||
virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); |
|||
virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_io(int32_t ioindex, int32_t direction) { return err::koperation_not_support; }; |
|||
|
|||
#endif
|
|||
int32_t ZModuleDeviceManager::motor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIMotor, motor_enable, enable); } |
|||
int32_t ZModuleDeviceManager::motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc) { PROXY_IMPL(ZIMotor, motor_rotate, direction, motor_velocity, acc); } |
|||
int32_t ZModuleDeviceManager::motor_move_by(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acc) { PROXY_IMPL(ZIMotor, motor_move_by, distance, motor_velocity, acc); } |
|||
int32_t ZModuleDeviceManager::motor_move_to(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acc) { PROXY_IMPL(ZIMotor, motor_move_to, position, motor_velocity, acc); } |
|||
int32_t ZModuleDeviceManager::motor_rotate_with_torque(uint16_t id, int32_t direction, int32_t torque) { PROXY_IMPL(ZIMotor, motor_rotate_with_torque, direction, torque); } |
|||
int32_t ZModuleDeviceManager::motor_rotate_acctime(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acctime) { PROXY_IMPL(ZIMotor, motor_rotate_acctime, direction, motor_velocity, acctime); } |
|||
int32_t ZModuleDeviceManager::motor_move_by_acctime(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acctime) { PROXY_IMPL(ZIMotor, motor_move_by_acctime, distance, motor_velocity, acctime); } |
|||
int32_t ZModuleDeviceManager::motor_move_to_acctime(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acctime) { PROXY_IMPL(ZIMotor, motor_move_to_acctime, position, motor_velocity, acctime); } |
|||
int32_t ZModuleDeviceManager::motor_move_to_zero_forward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { PROXY_IMPL(ZIMotor, motor_move_to_zero_forward, findzerospeed, findzeroedge_speed, acc, overtime); } |
|||
int32_t ZModuleDeviceManager::motor_move_to_zero_backward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { PROXY_IMPL(ZIMotor, motor_move_to_zero_backward, findzerospeed, findzeroedge_speed, acc, overtime); } |
|||
int32_t ZModuleDeviceManager::motor_read_pos(uint16_t id, int32_t *pos) { PROXY_IMPL(ZIMotor, motor_read_pos, pos); } |
|||
int32_t ZModuleDeviceManager::motor_set_current_pos_by_change_shift(uint16_t id, int32_t pos) { PROXY_IMPL(ZIMotor, motor_set_current_pos_by_change_shift, pos); } |
|||
int32_t ZModuleDeviceManager::motor_move_to_zero_forward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { PROXY_IMPL(ZIMotor, motor_move_to_zero_forward_and_calculated_shift, findzerospeed, findzeroedge_speed, acc, overtime); } |
|||
int32_t ZModuleDeviceManager::motor_move_to_zero_backward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { PROXY_IMPL(ZIMotor, motor_move_to_zero_backward_and_calculated_shift, findzerospeed, findzeroedge_speed, acc, overtime); } |
|||
int32_t ZModuleDeviceManager::motor_move_to_torque(uint16_t id, int32_t pos, int32_t torque, int32_t overtime) { PROXY_IMPL(ZIMotor, motor_move_to_torque, pos, torque, overtime); } |
|||
int32_t ZModuleDeviceManager::motor_calculated_pos_by_move_to_zero(uint16_t id) { PROXY_IMPL(ZIMotor, motor_calculated_pos_by_move_to_zero); } |
|||
int32_t ZModuleDeviceManager::motor_easy_rotate(uint16_t id, int32_t direction) { PROXY_IMPL(ZIMotor, motor_easy_rotate, direction); } |
|||
int32_t ZModuleDeviceManager::motor_easy_move_by(uint16_t id, int32_t distance) { PROXY_IMPL(ZIMotor, motor_easy_move_by, distance); } |
|||
int32_t ZModuleDeviceManager::motor_easy_move_to(uint16_t id, int32_t position) { PROXY_IMPL(ZIMotor, motor_easy_move_to, position); } |
|||
int32_t ZModuleDeviceManager::motor_easy_move_to_zero(uint16_t id, int32_t direction) { PROXY_IMPL(ZIMotor, motor_easy_move_to_zero, direction); } |
|||
int32_t ZModuleDeviceManager::motor_easy_set_current_pos(uint16_t id, int32_t pos) { PROXY_IMPL(ZIMotor, motor_easy_set_current_pos, pos); } |
|||
int32_t ZModuleDeviceManager::motor_easy_move_to_io(uint16_t id, int32_t ioindex, int32_t direction) { PROXY_IMPL(ZIMotor, motor_easy_move_to_io, ioindex, direction); } |
|||
/*******************************************************************************
|
|||
* ZIXYMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) { return err::koperation_not_support; } |
|||
#endif
|
|||
int32_t ZModuleDeviceManager::xymotor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIXYMotor, xymotor_enable, enable); } |
|||
int32_t ZModuleDeviceManager::xymotor_move_by(uint16_t id, int32_t dx, int32_t dy, int32_t motor_velocity) { PROXY_IMPL(ZIXYMotor, xymotor_move_by, dx, dy, motor_velocity); } |
|||
int32_t ZModuleDeviceManager::xymotor_move_to(uint16_t id, int32_t x, int32_t y, int32_t motor_velocity) { PROXY_IMPL(ZIXYMotor, xymotor_move_to, x, y, motor_velocity); } |
|||
int32_t ZModuleDeviceManager::xymotor_move_to_zero(uint16_t id) { PROXY_IMPL(ZIXYMotor, xymotor_move_to_zero); } |
|||
int32_t ZModuleDeviceManager::xymotor_move_to_zero_and_calculated_shift(uint16_t id) { PROXY_IMPL(ZIXYMotor, xymotor_move_to_zero_and_calculated_shift); } |
|||
int32_t ZModuleDeviceManager::xymotor_read_pos(uint16_t id, int32_t *x, int32_t *y) { PROXY_IMPL(ZIXYMotor, xymotor_read_pos, x, y); } |
|||
int32_t ZModuleDeviceManager::xymotor_calculated_pos_by_move_to_zero(uint16_t id) { PROXY_IMPL(ZIXYMotor, xymotor_calculated_pos_by_move_to_zero); } |
|||
|
|||
#if 0
|
|||
virtual int32_t code_scaner_start_scan(uint16_t id); |
|||
virtual int32_t code_scaner_stop_scan(uint16_t id); |
|||
virtual int32_t code_scaner_read_scaner_result(uint16_t id, int32_t startadd, uint8_t *data, int32_t *len); |
|||
int32_t ZModuleDeviceManager::code_scaner_start_scan(uint16_t id) { PROXY_IMPL(ZICodeScaner, code_scaner_start_scan); } |
|||
int32_t ZModuleDeviceManager::code_scaner_stop_scan(uint16_t id) { PROXY_IMPL(ZICodeScaner, code_scaner_stop_scan); } |
|||
int32_t ZModuleDeviceManager::code_scaner_read_scaner_result(uint16_t id, int32_t startadd, uint8_t *data, int32_t *len) { PROXY_IMPL(ZICodeScaner, code_scaner_read_scaner_result, startadd, data, len); } |
|||
#endif
|
|||
|
|||
#if 0
|
|||
virtual int32_t pipette_ctrl_init_device() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_put_tip() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_move_to_ul(int32_t ul) { return err::koperation_not_support; }; |
|||
#endif
|
|||
|
|||
int32_t ZModuleDeviceManager::pipette_ctrl_init_device(uint16_t id) { PROXY_IMPL(ZIPipetteCtrlModule, pipette_ctrl_init_device); } |
|||
int32_t ZModuleDeviceManager::pipette_ctrl_put_tip(uint16_t id) { PROXY_IMPL(ZIPipetteCtrlModule, pipette_ctrl_put_tip); } |
|||
int32_t ZModuleDeviceManager::pipette_ctrl_move_to_ul(uint16_t id, int32_t ul) { PROXY_IMPL(ZIPipetteCtrlModule, pipette_ctrl_move_to_ul, ul); } |
|||
|
|||
#if 0
|
|||
virtual int32_t a8000_optical_module_power_ctrl(int32_t state) = 0; |
|||
virtual int32_t a8000_optical_open_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_close_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_set_laster_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_set_scan_amp_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_read_scanner_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_read_laster_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_scan_current_point_amp_adc_val(int32_t type, int32_t lastergain, int32_t ampgain, int32_t* laster_fb_val, int32_t* adcval) = 0; |
|||
#endif
|
|||
|
|||
int32_t ZModuleDeviceManager::a8000_optical_module_power_ctrl(uint16_t id, int32_t state) { PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_module_power_ctrl, state); } |
|||
int32_t ZModuleDeviceManager::a8000_optical_open_laser(uint16_t id, int32_t type) { PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_open_laser, type); } |
|||
int32_t ZModuleDeviceManager::a8000_optical_close_laser(uint16_t id, int32_t type) { PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_close_laser, type); } |
|||
int32_t ZModuleDeviceManager::a8000_optical_set_laster_gain(uint16_t id, int32_t type, int32_t gain) { PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_set_laster_gain, type, gain); } |
|||
int32_t ZModuleDeviceManager::a8000_optical_set_scan_amp_gain(uint16_t id, int32_t type, int32_t gain) { PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_set_scan_amp_gain, type, gain); } |
|||
int32_t ZModuleDeviceManager::a8000_optical_read_scanner_adc_val(uint16_t id, int32_t type, int32_t *adcval) { PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_read_scanner_adc_val, type, adcval); } |
|||
int32_t ZModuleDeviceManager::a8000_optical_read_laster_adc_val(uint16_t id, int32_t type, int32_t *adcval) { PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_read_laster_adc_val, type, adcval); } |
|||
int32_t ZModuleDeviceManager::a8000_optical_scan_current_point_amp_adc_val(uint16_t id, int32_t type, int32_t lastergain, int32_t ampgain, int32_t *laster_fb_val, int32_t *adcval) { |
|||
PROXY_IMPL(ZIA8000OpticalModule, a8000_optical_scan_current_point_amp_adc_val, type, lastergain, ampgain, laster_fb_val, adcval); |
|||
} |
@ -1,248 +0,0 @@ |
|||
#pragma once
|
|||
#include <list>
|
|||
#include <map>
|
|||
|
|||
#include "api/api.hpp"
|
|||
#include "api/i_zcan_cmder_master.hpp"
|
|||
#include "cmdid.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
class ZModuleDeviceManager { |
|||
private: |
|||
map<uint16_t, ZIModule *> m_modulers; |
|||
IZcanCmderMaster *m_cancmder = nullptr; |
|||
|
|||
typedef function<void(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval)> regval_change_event_t; |
|||
|
|||
regval_change_event_t m_on_reg_val_change_event_cb; |
|||
list<regval_change_event_t> m_on_reg_val_change_event_cbs; |
|||
|
|||
public: |
|||
void initialize(IZcanCmderMaster *m_cancmder); |
|||
void initialize(); |
|||
|
|||
void regCanCmder(IZcanCmderMaster *m_cancmder); |
|||
void registerModule(ZIModule *module); |
|||
|
|||
void regOnRegValChangeEvent(regval_change_event_t on_regval_change_event) { m_on_reg_val_change_event_cbs.push_back(on_regval_change_event); } |
|||
void callOnRegValChangeEvent(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval) { |
|||
for (auto &cb : m_on_reg_val_change_event_cbs) |
|||
if (cb) cb(moduleid, regindex, oldval, toval); |
|||
} |
|||
|
|||
void for_each_module(function<void(int32_t moduleid)> cb) { |
|||
for (auto &it : m_modulers) { |
|||
if (cb) cb(it.first); |
|||
} |
|||
} |
|||
/*******************************************************************************
|
|||
* ZIModule * |
|||
*******************************************************************************/ |
|||
|
|||
#if 0
|
|||
virtual ~ZIModule() {} |
|||
|
|||
virtual int32_t getid(int32_t *id) = 0; |
|||
|
|||
virtual int32_t module_stop() = 0; |
|||
virtual int32_t module_break() = 0; |
|||
virtual int32_t module_get_last_exec_status(int32_t *status) = 0; |
|||
virtual int32_t module_get_status(int32_t *status) = 0; |
|||
virtual int32_t module_get_error(int32_t *iserror) = 0; |
|||
virtual int32_t module_clear_error() = 0; |
|||
|
|||
virtual int32_t module_set_reg(int32_t param_id, int32_t param_value) { return err::koperation_not_support; } |
|||
virtual int32_t module_get_reg(int32_t param_id, int32_t *param_value) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t module_readio(int32_t *io) { return err::koperation_not_support; } |
|||
virtual int32_t module_writeio(int32_t io) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t module_read_adc(int32_t adcindex, int32_t *adc) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t module_set_inited_flag(int32_t flag) { |
|||
m_inited_flag = flag; |
|||
return 0; |
|||
} |
|||
virtual int32_t module_get_inited_flag(int32_t *flag) { |
|||
*flag = m_inited_flag; |
|||
return 0; |
|||
} |
|||
// kmodule_factory_reset = CMDID(1, 14), // para:{}, ack:{}
|
|||
// kmodule_flush_cfg = CMDID(1, 15), // para:{}, ack:{}
|
|||
// kmodule_active_cfg = CMDID(1, 16), // para:{}, ack:{}
|
|||
|
|||
virtual int32_t module_factory_reset() { return err::koperation_not_support; } |
|||
virtual int32_t module_flush_cfg() { return err::koperation_not_support; } |
|||
virtual int32_t module_active_cfg() { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t module_enable(int32_t enable) override; |
|||
#endif
|
|||
virtual int32_t module_ping(uint16_t id); |
|||
virtual int32_t module_stop(uint16_t id); |
|||
virtual int32_t module_break(uint16_t id); |
|||
|
|||
virtual int32_t module_get_last_exec_status(uint16_t id, int32_t *status); |
|||
virtual int32_t module_get_status(uint16_t id, int32_t *status); |
|||
|
|||
virtual int32_t module_set_reg(uint16_t id, int32_t param_id, int32_t param_value); |
|||
virtual int32_t module_get_reg(uint16_t id, int32_t param_id, int32_t *param_value); |
|||
|
|||
virtual int32_t module_readio(uint16_t id, int32_t *io); |
|||
virtual int32_t module_writeio(uint16_t id, int32_t ioindex, int32_t io); |
|||
|
|||
virtual int32_t module_read_adc(uint16_t id, int32_t adcindex, int32_t *adc); |
|||
|
|||
virtual int32_t module_get_error(uint16_t id, int32_t *iserror); |
|||
virtual int32_t module_clear_error(uint16_t id); |
|||
|
|||
virtual int32_t module_set_inited_flag(uint16_t id, int32_t flag); |
|||
virtual int32_t module_get_inited_flag(uint16_t id, int32_t *flag); |
|||
|
|||
virtual int32_t module_factory_reset(uint16_t id); |
|||
virtual int32_t module_flush_cfg(uint16_t id); |
|||
virtual int32_t module_active_cfg(uint16_t id); |
|||
|
|||
virtual int32_t module_read_raw(uint16_t id, int32_t startadd, uint8_t *data, int32_t *len); |
|||
virtual int32_t module_enable(uint16_t id, int32_t enable); |
|||
|
|||
virtual int32_t module_start(uint16_t id); |
|||
|
|||
/*******************************************************************************
|
|||
* ZIMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } |
|||
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // 一锟斤拷锟斤拷锟节讹拷锟?
|
|||
virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_easy_rotate(int32_t direction) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_io(int32_t ioindex, int32_t direction) { return err::koperation_not_support; }; |
|||
|
|||
#endif
|
|||
virtual int32_t motor_enable(uint16_t id, int32_t enable); |
|||
virtual int32_t motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc); |
|||
virtual int32_t motor_move_by(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acc); |
|||
virtual int32_t motor_move_to(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acc); |
|||
virtual int32_t motor_rotate_acctime(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acctime); |
|||
virtual int32_t motor_move_by_acctime(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acctime); |
|||
virtual int32_t motor_move_to_acctime(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acctime); |
|||
virtual int32_t motor_move_to_zero_forward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime); |
|||
virtual int32_t motor_move_to_zero_backward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime); |
|||
virtual int32_t motor_rotate_with_torque(uint16_t id, int32_t direction, int32_t torque); |
|||
virtual int32_t motor_read_pos(uint16_t id, int32_t *pos); |
|||
virtual int32_t motor_set_current_pos_by_change_shift(uint16_t id, int32_t pos); |
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime); |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime); |
|||
virtual int32_t motor_move_to_torque(uint16_t id, int32_t pos, int32_t torque, int32_t overtime); |
|||
virtual int32_t motor_calculated_pos_by_move_to_zero(uint16_t id); |
|||
|
|||
virtual int32_t motor_easy_rotate(uint16_t id, int32_t direction); |
|||
virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); |
|||
virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); |
|||
virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); |
|||
virtual int32_t motor_easy_set_current_pos(uint16_t id, int32_t pos); |
|||
virtual int32_t motor_easy_move_to_io(uint16_t id, int32_t ioindex, int32_t direction); |
|||
|
|||
/*******************************************************************************
|
|||
* ZIXYMotor * |
|||
*******************************************************************************/ |
|||
#if 0
|
|||
virtual ~ZIXYMotor() {} |
|||
virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
#endif
|
|||
virtual int32_t xymotor_enable(uint16_t id, int32_t enable); |
|||
virtual int32_t xymotor_move_by(uint16_t id, int32_t dx, int32_t dy, int32_t motor_velocity); |
|||
virtual int32_t xymotor_move_to(uint16_t id, int32_t x, int32_t y, int32_t motor_velocity); |
|||
virtual int32_t xymotor_move_to_zero(uint16_t id); |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift(uint16_t id); |
|||
virtual int32_t xymotor_read_pos(uint16_t id, int32_t *x, int32_t *y); |
|||
virtual int32_t xymotor_calculated_pos_by_move_to_zero(uint16_t id); |
|||
|
|||
#if 0
|
|||
virtual int32_t code_scaner_start_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_stop_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_read_scaner_result(int32_t startadd, uint8_t *data, int32_t *len) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t code_scaner_start_scan(uint16_t id); |
|||
virtual int32_t code_scaner_stop_scan(uint16_t id); |
|||
virtual int32_t code_scaner_read_scaner_result(uint16_t id, int32_t startadd, uint8_t *data, int32_t *len); |
|||
#endif
|
|||
|
|||
#if 0
|
|||
virtual int32_t pipette_ctrl_init_device() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_put_tip() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_move_to_ul(int32_t ul) { return err::koperation_not_support; }; |
|||
#endif
|
|||
|
|||
virtual int32_t pipette_ctrl_init_device(uint16_t id); |
|||
virtual int32_t pipette_ctrl_put_tip(uint16_t id); |
|||
virtual int32_t pipette_ctrl_move_to_ul(uint16_t id, int32_t ul); |
|||
|
|||
#if 0
|
|||
virtual int32_t a8000_optical_module_power_ctrl(int32_t state) = 0; |
|||
virtual int32_t a8000_optical_open_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_close_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_set_laster_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_set_scan_amp_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_read_scanner_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_read_laster_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_scan_current_point_amp_adc_val(int32_t type, int32_t lastergain, int32_t ampgain, int32_t* laster_fb_val, int32_t* adcval) = 0; |
|||
#endif
|
|||
|
|||
virtual int32_t a8000_optical_module_power_ctrl(uint16_t id, int32_t state); |
|||
virtual int32_t a8000_optical_open_laser(uint16_t id, int32_t type); |
|||
virtual int32_t a8000_optical_close_laser(uint16_t id, int32_t type); |
|||
virtual int32_t a8000_optical_set_laster_gain(uint16_t id, int32_t type, int32_t gain); |
|||
virtual int32_t a8000_optical_set_scan_amp_gain(uint16_t id, int32_t type, int32_t gain); |
|||
virtual int32_t a8000_optical_read_scanner_adc_val(uint16_t id, int32_t type, int32_t *adcval); |
|||
virtual int32_t a8000_optical_read_laster_adc_val(uint16_t id, int32_t type, int32_t *adcval); |
|||
virtual int32_t a8000_optical_scan_current_point_amp_adc_val(uint16_t id, int32_t type, int32_t lastergain, int32_t ampgain, int32_t *laster_fb_val, int32_t *adcval); |
|||
|
|||
virtual ~ZModuleDeviceManager() {} |
|||
|
|||
private: |
|||
template <typename T> |
|||
int32_t findModule(uint16_t id, T **module) { |
|||
auto it = m_modulers.find(id); |
|||
if (it == m_modulers.end()) { |
|||
return err::kmodule_not_found; |
|||
} |
|||
T *_module = dynamic_cast<T *>(it->second); |
|||
if (_module == nullptr) { |
|||
return err::koperation_not_support; |
|||
} |
|||
*module = _module; |
|||
return 0; |
|||
} |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -1,257 +0,0 @@ |
|||
#include "zmodule_device_script_cmder_paser.hpp"
|
|||
|
|||
#include <stdio.h>
|
|||
#include <stdlib.h>
|
|||
#include <string.h>
|
|||
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
#define PROCESS_PACKET_XX(var_funcname, cmdhelp, XP, XACK, ...) \
|
|||
m_cmdParser->regCMD(#var_funcname, cmdhelp, XP, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { \ |
|||
ack->ecode = m_deviceManager->var_funcname(__VA_ARGS__); \ |
|||
ack->acktype = ICmdParserACK::kAckType_int32; \ |
|||
ack->rawlen = XACK * 4; \ |
|||
}); |
|||
|
|||
#define PROCESS_PACKET_00(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 0, 0)
|
|||
#define PROCESS_PACKET_01(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 0, 1, ack->getAck(0))
|
|||
#define PROCESS_PACKET_02(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 0, 2, ack->getAck(0), ack->getAck(1))
|
|||
#define PROCESS_PACKET_03(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 0, 3, ack->getAck(0), ack->getAck(1), ack->getAck(2))
|
|||
|
|||
#define PROCESS_PACKET_10(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 1, 0, atoi(paraV[0]))
|
|||
#define PROCESS_PACKET_11(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 1, 1, atoi(paraV[0]), ack->getAck(0))
|
|||
#define PROCESS_PACKET_12(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 1, 2, atoi(paraV[0]), ack->getAck(0), ack->getAck(1))
|
|||
#define PROCESS_PACKET_13(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 1, 3, atoi(paraV[0]), ack->getAck(0), ack->getAck(1), ack->getAck(2))
|
|||
|
|||
#define PROCESS_PACKET_20(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 2, 0, atoi(paraV[0]), atoi(paraV[1]))
|
|||
#define PROCESS_PACKET_21(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 2, 1, atoi(paraV[0]), atoi(paraV[1]), ack->getAck(0))
|
|||
#define PROCESS_PACKET_22(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 2, 2, atoi(paraV[0]), atoi(paraV[1]), ack->getAck(0), ack->getAck(1))
|
|||
#define PROCESS_PACKET_23(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 2, 3, atoi(paraV[0]), atoi(paraV[1]), ack->getAck(0), ack->getAck(1), ack->getAck(2))
|
|||
|
|||
#define PROCESS_PACKET_30(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 3, 0, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]))
|
|||
#define PROCESS_PACKET_31(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 3, 1, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), ack->getAck(0))
|
|||
#define PROCESS_PACKET_32(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 3, 2, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), ack->getAck(0), ack->getAck(1))
|
|||
#define PROCESS_PACKET_33(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 3, 3, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), ack->getAck(0), ack->getAck(1), ack->getAck(2))
|
|||
|
|||
#define PROCESS_PACKET_40(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 4, 0, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]))
|
|||
#define PROCESS_PACKET_41(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 4, 1, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]), ack->getAck(0))
|
|||
#define PROCESS_PACKET_42(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 4, 2, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]), ack->getAck(0), ack->getAck(1))
|
|||
#define PROCESS_PACKET_43(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 4, 3, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]), ack->getAck(0), ack->getAck(1), ack->getAck(2))
|
|||
|
|||
#define PROCESS_PACKET_50(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 5, 0, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]), atoi(paraV[4]))
|
|||
#define PROCESS_PACKET_51(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 5, 1, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]), atoi(paraV[4]), ack->getAck(0))
|
|||
#define PROCESS_PACKET_52(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 5, 2, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]), atoi(paraV[4]), ack->getAck(0), ack->getAck(1))
|
|||
#define PROCESS_PACKET_53(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 5, 3, atoi(paraV[0]), atoi(paraV[1]), atoi(paraV[2]), atoi(paraV[3]), atoi(paraV[4]), ack->getAck(0), ack->getAck(1), ack->getAck(2))
|
|||
|
|||
void ZModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZModuleDeviceManager* deviceManager) { |
|||
m_cmdParser = cancmder; |
|||
m_deviceManager = deviceManager; |
|||
regfn(); |
|||
} |
|||
|
|||
void ZModuleDeviceScriptCmderPaser::regfn() { |
|||
#if 0
|
|||
/*******************************************************************************
|
|||
* ZIModule * |
|||
*******************************************************************************/ |
|||
int32_t module_stop(uint16_t id); |
|||
int32_t module_break(uint16_t id); |
|||
|
|||
int32_t module_get_last_exec_status(uint16_t id, int32_t *status); |
|||
int32_t module_get_status(uint16_t id, int32_t *status); |
|||
|
|||
int32_t module_set_reg(uint16_t id, int32_t param_id, int32_t param_value); |
|||
int32_t module_get_reg(uint16_t id, int32_t param_id, int32_t *param_value); |
|||
|
|||
int32_t module_readio(uint16_t id, int32_t *io); |
|||
int32_t module_writeio(uint16_t id, int32_t io); |
|||
|
|||
int32_t module_read_adc(uint16_t id, int32_t adcindex, int32_t *adc); |
|||
|
|||
int32_t module_get_error(uint16_t id, int32_t *iserror); |
|||
int32_t module_clear_error(uint16_t id); |
|||
|
|||
int32_t module_set_inited_flag(uint16_t id, int32_t flag); |
|||
int32_t module_get_inited_flag(uint16_t id, int32_t *flag); |
|||
|
|||
int32_t module_factory_reset(uint16_t id); |
|||
int32_t module_flush_cfg(uint16_t id); |
|||
int32_t module_active_cfg(uint16_t id); |
|||
|
|||
virtual int32_t module_read_raw(uint16_t id, int32_t startadd, int32_t readlen, uint8_t *data, int32_t *len); |
|||
|
|||
/*******************************************************************************
|
|||
* ZIMotor * |
|||
*******************************************************************************/ |
|||
|
|||
int32_t motor_enable(uint16_t id, int32_t enable); |
|||
int32_t motor_rotate(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acc); |
|||
int32_t motor_move_by(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acc); |
|||
int32_t motor_move_to(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acc); |
|||
int32_t motor_rotate_acctime(uint16_t id, int32_t direction, int32_t motor_velocity, int32_t acctime); |
|||
int32_t motor_move_by_acctime(uint16_t id, int32_t distance, int32_t motor_velocity, int32_t acctime); |
|||
int32_t motor_move_to_acctime(uint16_t id, int32_t position, int32_t motor_velocity, int32_t acctime); |
|||
int32_t motor_move_to_zero_forward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime); |
|||
int32_t motor_move_to_zero_backward(uint16_t id, int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime); |
|||
int32_t motor_rotate_with_torque(uint16_t id, int32_t pos, int32_t torque); |
|||
int32_t motor_read_pos(uint16_t id, int32_t *pos); |
|||
int32_t motor_set_current_pos_by_change_shift(uint16_t id, int32_t pos); |
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) override; |
|||
virtual int32_t module_enable(uint16_t id, int32_t enable); |
|||
|
|||
#endif
|
|||
PROCESS_PACKET_10(module_ping, "(mid)"); |
|||
PROCESS_PACKET_10(module_stop, "(mid)"); |
|||
PROCESS_PACKET_10(module_start, "(mid)"); |
|||
PROCESS_PACKET_10(module_break, "(mid)"); |
|||
PROCESS_PACKET_11(module_get_last_exec_status, "(mid)"); |
|||
PROCESS_PACKET_11(module_get_status, "(mid)"); |
|||
PROCESS_PACKET_30(module_set_reg, "(mid, param_id, param_value)"); |
|||
PROCESS_PACKET_21(module_get_reg, "(mid, param_id)"); |
|||
PROCESS_PACKET_11(module_readio, "(mid)"); |
|||
PROCESS_PACKET_30(module_writeio, "(mid,ioindex,io)"); |
|||
PROCESS_PACKET_21(module_read_adc, "(mid,adc_id, adcindex)"); |
|||
PROCESS_PACKET_11(module_get_error, "(mid)"); |
|||
PROCESS_PACKET_10(module_clear_error, "(mid)"); |
|||
PROCESS_PACKET_20(module_set_inited_flag, "(mid, flag)"); |
|||
PROCESS_PACKET_11(module_get_inited_flag, "(mid)"); |
|||
PROCESS_PACKET_10(module_factory_reset, "(mid)"); |
|||
PROCESS_PACKET_10(module_flush_cfg, "(mid)"); |
|||
PROCESS_PACKET_10(module_active_cfg, "(mid)"); |
|||
m_cmdParser->regCMD("module_read_raw", "(mid, startindex)", 2, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { |
|||
if (atoi(paraV[2]) > (int32_t)sizeof(ack->rawdata)) { |
|||
ack->ecode = err::kbuffer_not_enough; |
|||
return; |
|||
} |
|||
ack->rawlen = sizeof(ack->rawdata); |
|||
ack->ecode = m_deviceManager->module_read_raw(atoi(paraV[0]), atoi(paraV[1]), ack->rawdata, &ack->rawlen); |
|||
ack->acktype = ICmdParserACK::kAckType_buf; |
|||
}); |
|||
PROCESS_PACKET_20(module_enable, "(mid, enable)"); |
|||
#if 0
|
|||
virtual int32_t motor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t motor_rotate(int32_t direction, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by(int32_t distance, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to(int32_t position, int32_t motor_velocity, int32_t acc) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_acctime(int32_t direction, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_by_acctime(int32_t distance, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_acctime(int32_t position, int32_t motor_velocity, int32_t acctime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_rotate_with_torque(int32_t direction, int32_t torque) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_torque(int32_t pos, int32_t torque, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_move_to_zero_forward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
virtual int32_t motor_move_to_zero_backward_and_calculated_shift(int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime) { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_read_pos(int32_t* pos) { return err::koperation_not_support; } |
|||
virtual int32_t motor_set_current_pos_by_change_shift(int32_t pos) { return err::koperation_not_support; } // Ò»°ãÓÃÓÚ¶æ»ú
|
|||
virtual int32_t motor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
|
|||
virtual int32_t motor_easy_rotate(uint16_t id, int32_t direction); |
|||
virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); |
|||
virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); |
|||
virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; |
|||
virtual int32_t motor_easy_move_to_io(uint16_t id, int32_t ioindex, int32_t direction); |
|||
|
|||
#endif
|
|||
|
|||
PROCESS_PACKET_20(motor_enable, "(mid, enable)"); |
|||
PROCESS_PACKET_40(motor_rotate, "(mid, direction, motor_velocity, acc)"); |
|||
PROCESS_PACKET_40(motor_move_by, "(mid, distance, motor_velocity, acc)"); |
|||
PROCESS_PACKET_40(motor_move_to, "(mid, position, motor_velocity, acc)"); |
|||
|
|||
PROCESS_PACKET_40(motor_rotate_acctime, "(mid, direction, motor_velocity, acctime)"); |
|||
PROCESS_PACKET_40(motor_move_by_acctime, "(mid, distance, motor_velocity, acctime)"); |
|||
PROCESS_PACKET_40(motor_move_to_acctime, "(mid, position, motor_velocity, acctime)"); |
|||
|
|||
PROCESS_PACKET_30(motor_rotate_with_torque, "(mid, pos, torque)"); |
|||
PROCESS_PACKET_40(motor_move_to_torque, "(mid, pos, torque, overtime)"); |
|||
|
|||
PROCESS_PACKET_50(motor_move_to_zero_forward, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); |
|||
PROCESS_PACKET_50(motor_move_to_zero_backward, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); |
|||
|
|||
PROCESS_PACKET_11(motor_read_pos, "(mid)"); |
|||
PROCESS_PACKET_20(motor_set_current_pos_by_change_shift, "(mid, pos)"); |
|||
|
|||
PROCESS_PACKET_50(motor_move_to_zero_forward_and_calculated_shift, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); |
|||
PROCESS_PACKET_50(motor_move_to_zero_backward_and_calculated_shift, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)"); |
|||
PROCESS_PACKET_10(motor_calculated_pos_by_move_to_zero, "(mid)"); |
|||
|
|||
PROCESS_PACKET_20(motor_easy_rotate, "(mid, direction)"); |
|||
PROCESS_PACKET_20(motor_easy_move_by, "(mid, distance)"); |
|||
PROCESS_PACKET_20(motor_easy_move_to, "(mid, position)"); |
|||
PROCESS_PACKET_20(motor_easy_move_to_zero, "(mid, direction)"); |
|||
PROCESS_PACKET_20(motor_easy_set_current_pos, "(mid, pos)"); |
|||
PROCESS_PACKET_30(motor_easy_move_to_io, "(mid, ioindex, direction)"); |
|||
|
|||
#if 0
|
|||
virtual ~ZIXYMotor() {} |
|||
virtual int32_t xymotor_enable(int32_t enable) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_by(int32_t dx, int32_t dy, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to(int32_t x, int32_t y, int32_t motor_velocity) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_move_to_zero_and_calculated_shift() { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_read_pos(int32_t *x, int32_t *y) { return err::koperation_not_support; } |
|||
virtual int32_t xymotor_calculated_pos_by_move_to_zero() { return err::koperation_not_support; } |
|||
#endif
|
|||
PROCESS_PACKET_20(xymotor_enable, "(mid, enable)"); |
|||
PROCESS_PACKET_40(xymotor_move_by, "(mid, dx, dy, motor_velocity)"); |
|||
PROCESS_PACKET_40(xymotor_move_to, "(mid, x, y, motor_velocity)"); |
|||
PROCESS_PACKET_10(xymotor_move_to_zero, "(mid)"); |
|||
PROCESS_PACKET_10(xymotor_move_to_zero_and_calculated_shift, "(mid)"); |
|||
PROCESS_PACKET_12(xymotor_read_pos, "(mid)"); |
|||
PROCESS_PACKET_10(xymotor_calculated_pos_by_move_to_zero, "(mid)"); |
|||
|
|||
#if 0
|
|||
virtual int32_t code_scaner_start_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_stop_scan() { return err::koperation_not_support; } |
|||
virtual int32_t code_scaner_read_scaner_result(int32_t startadd, uint8_t *data, int32_t *len) { return err::koperation_not_support; } |
|||
|
|||
PROCESS_PACKET_10(code_scaner_start_scan, "(mid)"); |
|||
PROCESS_PACKET_10(code_scaner_stop_scan, "(mid)"); |
|||
m_cmdParser->regCMD("code_scaner_read_scaner_result", "(mid, pad0)", 2, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { |
|||
if (atoi(paraV[2]) > (int32_t)sizeof(ack->rawdata)) { |
|||
ack->ecode = err::kbuffer_not_enough; |
|||
return; |
|||
} |
|||
ack->rawlen = sizeof(ack->rawdata); |
|||
ack->ecode = m_deviceManager->module_read_raw(atoi(paraV[0]), atoi(paraV[1]), ack->rawdata, &ack->rawlen); |
|||
ack->acktype = ICmdParserACK::kAckType_buf; |
|||
}); |
|||
#endif
|
|||
|
|||
#if 0
|
|||
virtual int32_t pipette_ctrl_init_device() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_put_tip() { return err::koperation_not_support; }; |
|||
virtual int32_t pipette_ctrl_move_to_ul(int32_t ul) { return err::koperation_not_support; }; |
|||
#endif
|
|||
PROCESS_PACKET_10(pipette_ctrl_init_device, "(mid)"); |
|||
PROCESS_PACKET_10(pipette_ctrl_put_tip, "(mid)"); |
|||
PROCESS_PACKET_20(pipette_ctrl_move_to_ul, "(mid, ul)"); |
|||
|
|||
#if 0
|
|||
virtual int32_t a8000_optical_module_power_ctrl(int32_t state) = 0; |
|||
virtual int32_t a8000_optical_open_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_close_laser(int32_t type) = 0; |
|||
virtual int32_t a8000_optical_set_laster_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_set_scan_amp_gain(int32_t type, int32_t gain) = 0; |
|||
virtual int32_t a8000_optical_read_scanner_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_read_laster_adc_val(int32_t type, int32_t* adcval) = 0; |
|||
virtual int32_t a8000_optical_scan_current_point_amp_adc_val(int32_t type, int32_t lastergain, int32_t ampgain, int32_t* laster_fb_val, int32_t* adcval) = 0; |
|||
#endif
|
|||
|
|||
PROCESS_PACKET_20(a8000_optical_module_power_ctrl, "(mid,state)"); |
|||
PROCESS_PACKET_20(a8000_optical_open_laser, "(mid,type)"); |
|||
PROCESS_PACKET_20(a8000_optical_close_laser, "(mid,type)"); |
|||
PROCESS_PACKET_30(a8000_optical_set_laster_gain, "(type,mid,gain)"); |
|||
PROCESS_PACKET_30(a8000_optical_set_scan_amp_gain, "(type,mid,gain)"); |
|||
PROCESS_PACKET_21(a8000_optical_read_scanner_adc_val, "(type,mid)"); |
|||
PROCESS_PACKET_21(a8000_optical_read_laster_adc_val, "(type,mid)"); |
|||
PROCESS_PACKET_42(a8000_optical_scan_current_point_amp_adc_val, "(type,mid,lastergain,ampgain)"); |
|||
} |
@ -1,27 +0,0 @@ |
|||
#pragma once
|
|||
|
|||
#include <list>
|
|||
|
|||
#include "api/api.hpp"
|
|||
#include "api/i_cmdparser.hpp"
|
|||
#include "cmdid.hpp"
|
|||
#include "zmodule_device_manager.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
class ZModuleDeviceScriptCmderPaser { |
|||
private: |
|||
ICmdParser* m_cmdParser = nullptr; |
|||
ZModuleDeviceManager* m_deviceManager; |
|||
|
|||
|
|||
public: |
|||
void initialize(ICmdParser* cancmder, ZModuleDeviceManager* deviceManager); |
|||
|
|||
ICmdParser* getCmdParser() { return m_cmdParser; } |
|||
ZModuleDeviceManager* getDeviceManager() { return m_deviceManager; } |
|||
private: |
|||
void regfn(); |
|||
}; |
|||
|
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue