Browse Source

update

change_pipette_api
zhaohe 2 years ago
parent
commit
13d7f7ad0d
  1. 3
      api/api.hpp
  2. 94
      api/errorcode.cpp
  3. 1
      api/errorcode.hpp
  4. 41
      api/state_index.hpp
  5. 1
      api/zi_xymotor.hpp
  6. 3
      cmdid.hpp
  7. 3
      protocol_parser.cpp
  8. 3
      protocol_proxy.cpp
  9. 3
      protocol_proxy.hpp
  10. 3
      zmodule_device_manager.hpp
  11. 3
      zmodule_device_script_cmder_paser.cpp

3
api/api.hpp

@ -7,4 +7,5 @@
#include "packet_interface.hpp"
#include "i_zcan_cmder.hpp"
#include "i_zcan_cmder_master.hpp"
#include "i_cmdparser.hpp"
#include "i_cmdparser.hpp"
#include "state_index.hpp"

94
api/errorcode.cpp

@ -3,6 +3,96 @@
#define ERR2STR(code) \
case code: \
return #code;
#if 0
ksucc = ERROR_CODE(0, 0),
kfail = ERROR_CODE(0, 1),
kparam_out_of_range = ERROR_CODE(0, 2), // 参数超出范围
koperation_not_support = ERROR_CODE(0, 3), // 操作不支持
kdevice_is_busy = ERROR_CODE(0, 4), // 设备忙
kdevice_is_offline = ERROR_CODE(0, 5), // 设备离线
kovertime = ERROR_CODE(0, 6),
knoack = ERROR_CODE(0, 7),
kerrorack = ERROR_CODE(0, 8),
kdevice_offline = ERROR_CODE(0, 9),
kparse_json_err = ERROR_CODE(0, 10),
ksubdevice_overtime = ERROR_CODE(0, 11),
kbuffer_not_enough = ERROR_CODE(0, 12),
kcmd_not_found = ERROR_CODE(0, 13),
kcmd_param_num_error = ERROR_CODE(0, 14),
kcheckcode_is_error = ERROR_CODE(0, 15),
/**
* @brief
*/
ksys_error = ERROR_CODE(100, 0),
ksys_create_file_error = ERROR_CODE(100, 1),
ksys_create_dir_error = ERROR_CODE(100, 2),
ksys_open_file_error = ERROR_CODE(100, 3),
ksys_open_dir_error = ERROR_CODE(100, 4),
ksys_read_file_error = ERROR_CODE(100, 5),
ksys_write_file_error = ERROR_CODE(100, 6),
ksys_close_file_error = ERROR_CODE(100, 7),
ksys_close_dir_error = ERROR_CODE(100, 8),
ksys_delete_file_error = ERROR_CODE(100, 9),
ksys_delete_dir_error = ERROR_CODE(100, 10),
ksys_copy_file_error = ERROR_CODE(100, 11),
/**
* @brief module error
*/
kmodule_not_inited = ERROR_CODE(200, 0),
kmodule_not_found = ERROR_CODE(200, 1),
kmodule_opeation_break_by_user = ERROR_CODE(200, 2), // 用户中断
kmodule_error = ERROR_CODE(200, 3), // 未知错误
kmodule_not_find_config_index = ERROR_CODE(200, 4), // 未找到配置索引
kmodule_not_find_state_index = ERROR_CODE(200, 5), // 未找到配置索引
/**
* @brief motor error
*/
kmotor_not_found_zero_point = ERROR_CODE(300, 0), // 未找到零点
kmotor_did_not_go_zero = ERROR_CODE(300, 1), // 设备未归零
kmotor_over_temperature = ERROR_CODE(300, 2), // 过温
kmotor_over_voltage = ERROR_CODE(300, 3), // 过压
kxymotor_not_found_x_zero_point = ERROR_CODE(300, 4), // 未找到零点
kxymotor_not_found_y_zero_point = ERROR_CODE(300, 5), // 未找到零点
kxymotor_x_find_zero_edge_fail = ERROR_CODE(300, 6), // 离开零点失败
kxymotor_y_find_zero_edge_fail = ERROR_CODE(300, 7), // 离开零点失败
/**
* @brief STMP2错误
*/
kSMTP2_NoError = ERROR_CODE(400, 0), // 无错误
kSMTP2_InitFail = ERROR_CODE(400, 1), // 初始化失败
kSMTP2_InvalidCmd = ERROR_CODE(400, 2), // 无效命令
kSMTP2_InvalidArg = ERROR_CODE(400, 3), // 无效参数
kSMTP2_PressureSensorError = ERROR_CODE(400, 4), // 压力传感器故障
kSMTP2_OverPressure = ERROR_CODE(400, 5), // 超过压力
kSMTP2_LLDError = ERROR_CODE(400, 6), // LLD 错误
kSMTP2_DeviceNotInit = ERROR_CODE(400, 7), // 设备未初始化
kSMTP2_TipPopError = ERROR_CODE(400, 8), // Tip 弹出错误
kSMTP2_PumpOverload = ERROR_CODE(400, 9), // 泵过载
kSMTP2_TipDrop = ERROR_CODE(400, 10), // Tip 脱落
kSMTP2_CanBusError = ERROR_CODE(400, 11), // CAN 总线故障
kSMTP2_InvalidChecksum = ERROR_CODE(400, 12), // 无效校验和
kSMTP2_EEPROMError = ERROR_CODE(400, 13), // EEPROM 故障
kSMTP2_CmdBufferEmpty = ERROR_CODE(400, 14), // 命令缓冲区为空
kSMTP2_CmdBufferOverflow = ERROR_CODE(400, 15), // 命令溢出
kSMTP2_TipBlock = ERROR_CODE(400, 16), // Tip 堵塞
kSMTP2_AirSuction = ERROR_CODE(400, 17), // 吸入空气
kSMTP2_Bubble = ERROR_CODE(400, 18), // 液体中有气泡/泡沫
kSMTP2_VolumeError = ERROR_CODE(400, 19), // 吸取/分配量不准确
kSMTP2_TipAlreadyLoad = ERROR_CODE(400, 20), // Tip已经装载
kSMTP2_TipLoadFail = ERROR_CODE(400, 21),
/**
* @brief
*/
kmicro_noErr = ERROR_CODE(500, 0), //
kmicro_uartSendFail = ERROR_CODE(500, 1), //
kmicro_uartRecvFail = ERROR_CODE(500, 2), //
#endif
namespace iflytop {
namespace err {
const char* error2str(int32_t code) {
@ -38,6 +128,9 @@ const char* error2str(int32_t code) {
ERR2STR(kmodule_not_inited);
ERR2STR(kmodule_not_found);
ERR2STR(kmodule_opeation_break_by_user);
ERR2STR(kmodule_error);
ERR2STR(kmodule_not_find_config_index);
ERR2STR(kmodule_not_find_state_index);
ERR2STR(kmotor_not_found_zero_point);
ERR2STR(kmotor_did_not_go_zero);
ERR2STR(kmotor_over_temperature);
@ -71,6 +164,7 @@ const char* error2str(int32_t code) {
ERR2STR(kmicro_noErr);
ERR2STR(kmicro_uartSendFail);
ERR2STR(kmicro_uartRecvFail);
default:
return "known";
break;

1
api/errorcode.hpp

@ -49,6 +49,7 @@ typedef enum {
kmodule_opeation_break_by_user = ERROR_CODE(200, 2), // 用户中断
kmodule_error = ERROR_CODE(200, 3), // 未知错误
kmodule_not_find_config_index = ERROR_CODE(200, 4), // 未找到配置索引
kmodule_not_find_state_index = ERROR_CODE(200, 5), // 未找到配置索引
/**
* @brief motor error

41
api/state_index.hpp

@ -7,15 +7,44 @@ using namespace std;
#define STATE_INDEX(type, subconfigindex) (type + subconfigindex)
typedef enum {
kstate_module_status = STATE_INDEX(0, 0), //
/**
* @brief
*
* 0 -> 100
* 100 -> 199 1
* 100 -> 299 2
* 1000 -> 1100 xy电机状态
*
*
*/
kstate_module_status = STATE_INDEX(0, 0), // 0idle,1busy,2error
kstate_module_errorcode = STATE_INDEX(0, 1), //
kstate_motor_x_pos = STATE_INDEX(100, 0), // x偏移
kstate_motor_y_pos = STATE_INDEX(100, 1), // y偏移
kstate_motor_z_pos = STATE_INDEX(100, 2), // z偏移
kstate_motor1_move = STATE_INDEX(100, 0), //
kstate_motor1_enable = STATE_INDEX(100, 1), //
kstate_motor1_current = STATE_INDEX(100, 2), //
kstate_motor1_vel = STATE_INDEX(100, 3), //
kstate_motor1_pos = STATE_INDEX(100, 4), //
kstate_motor1_temperature = STATE_INDEX(100, 5), //
kstate_motor1_dpos = STATE_INDEX(100, 6), //
kstate_motor2_move = STATE_INDEX(110, 0), //
kstate_motor2_enable = STATE_INDEX(110, 1), //
kstate_motor2_current = STATE_INDEX(110, 2), //
kstate_motor2_vel = STATE_INDEX(110, 3), //
kstate_motor2_pos = STATE_INDEX(110, 4), //
kstate_motor2_temperature = STATE_INDEX(110, 5), //
kstate_motor2_dpos = STATE_INDEX(110, 6), //
kstate_motor_move = STATE_INDEX(100, 3), // 电机是否移动
kstate_motor_enable = STATE_INDEX(100, 4), // 电机是否使能
kstate_xyrobot_move = STATE_INDEX(1000, 0), //
kstate_xyrobot_enable = STATE_INDEX(1000, 1), //
kstate_xyrobot_x_pos = STATE_INDEX(1000, 2), //
kstate_xyrobot_y_pos = STATE_INDEX(1000, 3), //
kstate_xyrobot_z_pos = STATE_INDEX(1000, 4), //
kstate_xyrobot_x_dpos = STATE_INDEX(1000, 5), //
kstate_xyrobot_y_dpos = STATE_INDEX(1000, 6), //
kstate_xyrobot_z_dpos = STATE_INDEX(1000, 7), //
} state_index_t;

1
api/zi_xymotor.hpp

@ -16,5 +16,6 @@ class ZIXYMotor {
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; }
};
} // namespace iflytop

3
cmdid.hpp

@ -43,12 +43,14 @@ typedef enum {
kmotor_motor_move_to_zero_backward_and_calculated_shift = CMDID(2, 14), // para:{4,4,4,4}, ack:{} //int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime
#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
kxymotor_enable = CMDID(3, 1), // para:{1}, ack:{}
kxymotor_move_by = CMDID(3, 2), // para:{4,4,4}, ack:{}
@ -56,6 +58,7 @@ typedef enum {
kxymotor_move_to_zero = CMDID(3, 4), // para:{}, ack:{}
kxymotor_move_to_zero_and_calculated_shift = CMDID(3, 5), // para:{4,4,4,4}, ack:{} //int32_t findzerospeed, int32_t findzeroedge_speed, int32_t acc, int32_t overtime
kxymotor_read_pos = CMDID(3, 6), // para:{}, ack:{4,4}
kxymotor_calculated_pos_by_move_to_zero = CMDID(3, 7), // para:{}, ack:{}
} cmdid_t;

3
protocol_parser.cpp

@ -178,12 +178,14 @@ void ZIProtocolParser::onRceivePacket(zcr_cmd_header_t* rxcmd, uint8_t* data, in
* xymotor *
*******************************************************************************/
#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_10(kxymotor_enable, ZIXYMotor, xymotor_enable);
@ -192,4 +194,5 @@ void ZIProtocolParser::onRceivePacket(zcr_cmd_header_t* rxcmd, uint8_t* data, in
PROCESS_PACKET_00(kxymotor_move_to_zero, ZIXYMotor, xymotor_move_to_zero);
PROCESS_PACKET_00(kxymotor_move_to_zero_and_calculated_shift, ZIXYMotor, xymotor_move_to_zero_and_calculated_shift);
PROCESS_PACKET_02(kxymotor_read_pos, ZIXYMotor, xymotor_read_pos);
PROCESS_PACKET_00(kxymotor_calculated_pos_by_move_to_zero, ZIXYMotor, xymotor_calculated_pos_by_move_to_zero);
}

3
protocol_proxy.cpp

@ -124,12 +124,14 @@ int32_t ZIProtocolProxy::motor_move_to_zero_backward_and_calculated_shift(int32_
* 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); }
int32_t ZIProtocolProxy::xymotor_move_by(int32_t para0, int32_t para1, int32_t para2) { PROXY_IMPL_30(kxymotor_move_by); }
@ -137,3 +139,4 @@ int32_t ZIProtocolProxy::xymotor_move_to(int32_t para0, int32_t para1, int32_t p
int32_t ZIProtocolProxy::xymotor_move_to_zero() { PROXY_IMPL_00(kxymotor_move_to_zero); }
int32_t ZIProtocolProxy::xymotor_move_to_zero_and_calculated_shift() { PROXY_IMPL_00(kxymotor_move_to_zero_and_calculated_shift); }
int32_t ZIProtocolProxy::xymotor_read_pos(int32_t *ack0, int32_t *ack1) { PROXY_IMPL_02(kxymotor_read_pos); }
int32_t ZIProtocolProxy::xymotor_calculated_pos_by_move_to_zero() { PROXY_IMPL_00(kxymotor_calculated_pos_by_move_to_zero); }

3
protocol_proxy.hpp

@ -84,12 +84,14 @@ class ZIProtocolProxy : public ZIMotor, //
* 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;
@ -97,6 +99,7 @@ class ZIProtocolProxy : public ZIMotor, //
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;
};
} // namespace iflytop

3
zmodule_device_manager.hpp

@ -113,12 +113,14 @@ class ZModuleDeviceManager {
* 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 xymotor_enable(uint16_t id, int32_t enable);
int32_t xymotor_move_by(uint16_t id, int32_t dx, int32_t dy, int32_t motor_velocity);
@ -126,6 +128,7 @@ class ZModuleDeviceManager {
int32_t xymotor_move_to_zero(uint16_t id);
int32_t xymotor_move_to_zero_and_calculated_shift(uint16_t id);
int32_t xymotor_read_pos(uint16_t id, int32_t *x, int32_t *y);
int32_t xymotor_calculated_pos_by_move_to_zero(uint16_t id);
private:

3
zmodule_device_script_cmder_paser.cpp

@ -133,12 +133,14 @@ void ZModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZModuleDevi
PROCESS_PACKET_50(motor_move_to_zero_backward_and_calculated_shift, "(mid, findzerospeed, findzeroedge_speed, acc, overtime)");
#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)");
@ -146,4 +148,5 @@ void ZModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, ZModuleDevi
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)");
}
Loading…
Cancel
Save