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.
254 lines
17 KiB
254 lines
17 KiB
#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, readsize)", 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; };
|
|
#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)");
|
|
|
|
#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)");
|
|
}
|