24 changed files with 148 additions and 729 deletions
-
165components/step_motor_ctrl_module/zcan_master_step_motor_ctrl_module.cpp
-
10components/step_motor_ctrl_module/zcan_master_step_motor_ctrl_module.hpp
-
92components/step_motor_ctrl_module/zcan_step_motor_ctrl_module.cpp
-
17components/step_motor_ctrl_module/zcan_step_motor_ctrl_module.hpp
-
100components/xy_robot_ctrl_module/zcan_xy_robot_master_module.cpp
-
10components/xy_robot_ctrl_module/zcan_xy_robot_master_module.hpp
-
126components/xy_robot_ctrl_module/zcan_xy_robot_module.cpp
-
19components/xy_robot_ctrl_module/zcan_xy_robot_module.hpp
-
27components/zcancmder/basic.cpp
-
6components/zcancmder/basic.hpp
-
85components/zcancmder/zcanreceiver.cpp
-
31components/zcancmder/zcanreceiver.hpp
-
93components/zcancmder/zcanreceiver_master.cpp
-
46components/zcancmder/zcanreceiver_master.hpp
-
3components/zcancmder_module/zcan_basic_order_module.cpp
-
2components/zcancmder_module/zcan_basic_order_module.hpp
-
2components/zcancmder_module/zcan_eeprom_module.cpp
-
2components/zcancmder_module/zcan_eeprom_module.hpp
-
4components/zcancmder_module/zcan_mini_servo_ctrl_module.cpp
-
3components/zcancmder_module/zcan_mini_servo_ctrl_module.hpp
-
2components/zcancmder_module/zcan_motor_laser_code_scanner_scan_module.cpp
-
3components/zcancmder_module/zcan_motor_laser_code_scanner_scan_module.hpp
-
2components/zcancmder_module/zcan_pipette_module.cpp
-
3components/zcancmder_module/zcan_pipette_module.hpp
@ -1,165 +0,0 @@ |
|||
#include "zcan_master_step_motor_ctrl_module.hpp"
|
|||
|
|||
#include "sdk\components\zprotocols\errorcode\errorcode.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
|
|||
#define TAG "StepMotorCtrlModule"
|
|||
|
|||
#define OVERTIME 30
|
|||
|
|||
namespace iflytop { |
|||
namespace zcancmder_master { |
|||
|
|||
class StepMotorCtrlModule : public I_StepMotorCtrlModule { |
|||
int m_id = 0; |
|||
uint8_t m_txbuf[128] = {0}; |
|||
ZCanCommnaderMaster* m_cancmder; |
|||
map<int, uint16_t> indexcache; |
|||
|
|||
public: |
|||
void initialize(ZCanCommnaderMaster* cancmder, int id) { |
|||
m_cancmder = cancmder; |
|||
m_id = id; |
|||
} |
|||
uint16_t& getindexcache(int cmdid) { |
|||
auto it = indexcache.find(cmdid); |
|||
if (it == indexcache.end()) { |
|||
indexcache[cmdid] = 0; |
|||
return indexcache[cmdid]; |
|||
} else { |
|||
return it->second; |
|||
} |
|||
} |
|||
virtual int32_t move_to(int32_t x, action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_move_to, OVERTIME, cmd->x = x;); |
|||
} |
|||
virtual int32_t move_by(int32_t dx, action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_move_by, OVERTIME, cmd->dx = dx;); |
|||
} |
|||
virtual int32_t move_to(int32_t x, int32_t velocity, action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_move_to, OVERTIME, cmd->x = x; cmd->speed = velocity;); |
|||
} |
|||
virtual int32_t move_by(int32_t dx, int32_t velocity, action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_move_by, OVERTIME, cmd->dx = dx; cmd->speed = velocity;); |
|||
} |
|||
virtual int32_t move_to_zero(action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_move_to_zero, OVERTIME); |
|||
} |
|||
virtual int32_t move_to_zero_with_calibrate(int32_t x, action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_move_to_zero_with_calibrate, OVERTIME, cmd->x = x;); |
|||
} |
|||
virtual int32_t rotate(int32_t speed, int32_t lastforms, action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_rotate, OVERTIME, cmd->speed = speed; cmd->run_time = lastforms;); |
|||
} |
|||
virtual int32_t enable(bool venable) { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_step_motor_ctrl_enable, OVERTIME, cmd->enable = venable;); |
|||
} |
|||
virtual int32_t stop(uint8_t stopType) { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_step_motor_ctrl_stop, OVERTIME, cmd->stop_type = stopType;); |
|||
} |
|||
virtual int32_t force_change_current_pos(int32_t x) { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_step_motor_ctrl_force_change_current_pos, OVERTIME, cmd->x = x;); |
|||
} |
|||
|
|||
virtual int32_t move_to_logic_point(int32_t logic_point_num, action_cb_status_t status_cb) { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_step_motor_ctrl_move_to_logic_point, OVERTIME, cmd->logic_point_num = logic_point_num;); |
|||
} |
|||
virtual int32_t set_logic_point(int logic_point_num, int32_t x, int32_t vel, s32 acc, s32 dec) { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_step_motor_ctrl_set_logic_point, OVERTIME, cmd->index = logic_point_num; cmd->x = x; cmd->velocity = vel; cmd->acc = acc; cmd->dec = dec;); |
|||
} |
|||
virtual int32_t get_logic_point(int logic_point_num, logic_point_t& logic_point) { //
|
|||
ZCAN_SEND_CMD(kcmd_step_motor_ctrl_get_logic_point, logic_point, OVERTIME, cmd->logic_point_num = logic_point_num;); |
|||
} |
|||
|
|||
virtual int32_t flush() { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_step_motor_ctrl_flush, 3000); |
|||
} |
|||
virtual int32_t factory_reset() { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_step_motor_ctrl_factory_reset, 3000); |
|||
} |
|||
|
|||
virtual int32_t read_version(version_t& version) { //
|
|||
ZCAN_SEND_CMD(kcmd_step_motor_ctrl_read_version, version, OVERTIME); |
|||
} |
|||
virtual int32_t read_status(status_t& status) { //
|
|||
ZCAN_SEND_CMD(kcmd_step_motor_ctrl_read_status, status, OVERTIME); |
|||
} |
|||
virtual int32_t read_detailed_status(detailed_status_t& debug_info) { //
|
|||
ZCAN_SEND_CMD(kcmd_step_motor_ctrl_read_detailed_status, debug_info, OVERTIME); |
|||
} |
|||
virtual int32_t set_base_param(const base_param_t& param) { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_step_motor_ctrl_set_base_param, OVERTIME, cmd->param = param;); |
|||
} |
|||
virtual int32_t get_base_param(base_param_t& param) { //
|
|||
ZCAN_SEND_CMD(kcmd_step_motor_ctrl_get_base_param, param, OVERTIME); |
|||
} |
|||
|
|||
virtual bool isbusy() { //
|
|||
status_t status; |
|||
int32_t err = read_status(status); |
|||
if (err != 0) { |
|||
return status.status != 0; |
|||
} |
|||
return false; |
|||
} |
|||
virtual int32_t get_last_exec_status() { //
|
|||
detailed_status_t status; |
|||
int32_t err = read_detailed_status(status); |
|||
if (err != 0) { |
|||
return status.last_exec_status; |
|||
} |
|||
return err; |
|||
} |
|||
|
|||
virtual int32_t read_pos(int32_t& pos) { //
|
|||
status_t status; |
|||
int32_t err = read_status(status); |
|||
if (err == 0) { |
|||
pos = status.x; |
|||
} |
|||
return err; |
|||
} |
|||
virtual int32_t read_pos() { //
|
|||
int32_t pos = 0; |
|||
read_pos(pos); |
|||
return pos; |
|||
} |
|||
|
|||
virtual bool read_zero_io_state() { //
|
|||
status_t status; |
|||
int32_t err = read_status(status); |
|||
if (err != 0) { |
|||
return status.io_state & 0x01; |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
virtual int32_t move_to_block(int32_t tox, int overtime) { //
|
|||
return err::kovertime; |
|||
} |
|||
virtual int32_t move_by_block(int32_t dx, int overtime) { //
|
|||
return err::kovertime; |
|||
} |
|||
virtual int32_t move_to_block(int32_t tox, int32_t velocity, int overtime) { //
|
|||
return err::kovertime; |
|||
} |
|||
virtual int32_t move_by_block(int32_t dx, int32_t velocity, int overtime) { //
|
|||
return err::kovertime; |
|||
} |
|||
virtual int32_t move_to_zero_block(int overtime) { //
|
|||
return err::kovertime; |
|||
} |
|||
virtual int32_t move_to_zero_with_calibrate_block(int32_t x, int overtime) { //
|
|||
return err::kovertime; |
|||
} |
|||
}; |
|||
|
|||
I_StepMotorCtrlModule* create_zcan_master_step_motor_ctrl_module(ZCanCommnaderMaster* cancmder, int id) { |
|||
StepMotorCtrlModule* module = new StepMotorCtrlModule(); |
|||
ZASSERT(module); |
|||
module->initialize(cancmder, id); |
|||
return module; |
|||
} |
|||
} // namespace zcancmder_master
|
|||
} // namespace iflytop
|
@ -1,10 +0,0 @@ |
|||
#pragma once
|
|||
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder\api\i_step_motor_ctrl_module.hpp"
|
|||
#if 1
|
|||
namespace iflytop { |
|||
namespace zcancmder_master { |
|||
I_StepMotorCtrlModule* create_zcan_master_step_motor_ctrl_module(ZCanCommnaderMaster* cancmder, int id); |
|||
} // namespace zcancmder_master
|
|||
} // namespace iflytop
|
|||
#endif
|
@ -1,92 +0,0 @@ |
|||
#include "zcan_step_motor_ctrl_module.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
#define TAG "ZCanStepMotorCtrlModule"
|
|||
#if 1
|
|||
void ZCanStepMotorCtrlModule::initialize(ZCanCmder* cancmder, int id, I_StepMotorCtrlModule* module) { |
|||
m_cancmder = cancmder; |
|||
m_id = id; |
|||
m_module = module; |
|||
// m_lock.init();
|
|||
cancmder->registerListener(this); |
|||
} |
|||
void ZCanStepMotorCtrlModule::onRceivePacket(CanPacketRxBuffer* rxcmd) { |
|||
// zlock_guard l(m_lock);
|
|||
ZLOGI(TAG, "onRceivePacket %d %d", rxcmd->get_cmdheader()->cmdid, rxcmd->get_cmdheader()->subcmdid); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_enable, m_id) { errorcode = m_module->enable(cmd->enable); } |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_stop, m_id) { errorcode = m_module->stop(cmd->stop_type); } |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_to_zero, m_id) { |
|||
errorcode = m_module->move_to_zero([this, cmdheader](int32_t status) { PROCESS_REPORT(kcmd_step_motor_ctrl_move_to_zero); }); |
|||
} |
|||
END_PP(); |
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_to_zero_with_calibrate, m_id) { |
|||
errorcode = m_module->move_to_zero_with_calibrate(cmd->x, [this, cmdheader](int32_t status) { PROCESS_REPORT(kcmd_step_motor_ctrl_move_to_zero_with_calibrate); }); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_to, m_id) { |
|||
errorcode = m_module->move_to(cmd->x, cmd->speed, [this, cmdheader](int32_t status) { PROCESS_REPORT(kcmd_step_motor_ctrl_move_to); }); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_by, m_id) { |
|||
errorcode = m_module->move_by(cmd->dx, cmd->speed, [this, cmdheader](int32_t status) { PROCESS_REPORT(kcmd_step_motor_ctrl_move_by); }); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_force_change_current_pos, m_id) { errorcode = m_module->force_change_current_pos(cmd->x); } |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_rotate, m_id) { |
|||
errorcode = m_module->rotate(cmd->speed, cmd->run_time, [this, cmdheader](int32_t status) { PROCESS_REPORT(kcmd_step_motor_ctrl_rotate); }); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_read_version, m_id) { //
|
|||
errorcode = m_module->read_version(ack->ack); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_read_status, m_id) { //
|
|||
errorcode = m_module->read_status(ack->ack); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_read_detailed_status, m_id) { //
|
|||
errorcode = m_module->read_detailed_status(ack->ack); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_set_base_param, m_id) { //
|
|||
errorcode = m_module->set_base_param(cmd->param); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_get_base_param, m_id) { //
|
|||
errorcode = m_module->get_base_param(ack->ack); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_to_logic_point, m_id) { |
|||
errorcode = m_module->move_to_logic_point(cmd->logic_point_num, [this, cmdheader](int32_t status) { PROCESS_REPORT(kcmd_step_motor_ctrl_move_to_logic_point); }); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_set_logic_point, m_id) { errorcode = m_module->set_logic_point(cmd->index, cmd->x, cmd->velocity, cmd->acc, cmd->dec); } |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_get_logic_point, m_id) { errorcode = m_module->get_logic_point(cmd->logic_point_num, ack->ack); } |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_flush, m_id) { errorcode = m_module->flush(); } |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_factory_reset, m_id) { errorcode = m_module->factory_reset(); } |
|||
END_PP(); |
|||
} |
|||
#endif
|
@ -1,17 +0,0 @@ |
|||
#pragma once
|
|||
#include "sdk/components/zprotocols/zcancmder/api/i_step_motor_ctrl_module.hpp"
|
|||
#include "sdk\components\zcancmder\zcanreceiver.hpp"
|
|||
namespace iflytop { |
|||
class ZCanStepMotorCtrlModule : public ZCanCmderListener { |
|||
ZCanCmder* m_cancmder = nullptr; |
|||
int m_id = 0; |
|||
I_StepMotorCtrlModule* m_module; |
|||
|
|||
uint8_t m_txbuf[128] = {0}; |
|||
// zmutex m_lock;
|
|||
|
|||
public: |
|||
void initialize(ZCanCmder* cancmder, int id, I_StepMotorCtrlModule* m_module); |
|||
virtual void onRceivePacket(CanPacketRxBuffer* rxcmd); |
|||
}; |
|||
} // namespace iflytop
|
@ -1,100 +0,0 @@ |
|||
#include "zcan_xy_robot_master_module.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
#define TAG "ZCANXYRobotCtrlMasterModule"
|
|||
|
|||
#define OVERTIME 30
|
|||
|
|||
namespace iflytop { |
|||
namespace zcancmder_master { |
|||
|
|||
class ZCANXYRobotCtrlMasterModule : public I_XYRobotCtrlModule { |
|||
int m_id = 0; |
|||
uint8_t m_txbuf[128] = {0}; |
|||
ZCanCommnaderMaster* m_cancmder; |
|||
map<int, uint16_t> indexcache; |
|||
|
|||
public: |
|||
void initialize(ZCanCommnaderMaster* cancmder, int id) { |
|||
m_cancmder = cancmder; |
|||
m_id = id; |
|||
} |
|||
uint16_t& getindexcache(int cmdid) { |
|||
auto it = indexcache.find(cmdid); |
|||
if (it == indexcache.end()) { |
|||
indexcache[cmdid] = 0; |
|||
return indexcache[cmdid]; |
|||
} else { |
|||
return it->second; |
|||
} |
|||
} |
|||
|
|||
virtual int32_t move_to(int32_t x, int32_t y, int speed, action_cb_status_t status_cb) override { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_xy_robot_ctrl_move_to, OVERTIME, cmd->x = x; cmd->y = y; cmd->speed = speed;); |
|||
} |
|||
|
|||
virtual int32_t move_by(int32_t dx, int32_t dy, int speed, action_cb_status_t status_cb) override { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_xy_robot_ctrl_move_by, OVERTIME, cmd->dx = dx; cmd->dy = dy; cmd->speed = speed;); |
|||
} |
|||
virtual int32_t move_by_no_limit(int32_t dx, int32_t dy, int speed, action_cb_status_t status_cb) override { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_xy_robot_ctrl_move_by_no_limit, OVERTIME, cmd->dx = dx; cmd->dy = dy; cmd->speed = speed;); |
|||
} |
|||
|
|||
virtual int32_t move_to_zero(action_cb_status_t status_cb) override { |
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_xy_robot_ctrl_move_to_zero, OVERTIME); //
|
|||
} |
|||
|
|||
virtual int32_t move_to_zero_with_calibrate(int32_t nowx, int32_t nowxy, action_cb_status_t status_cb) override { //
|
|||
ZCAN_SEND_CMD_WITH_STATUS_CB(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, OVERTIME, cmd->nowx = nowx; cmd->nowy = nowxy;); |
|||
} |
|||
|
|||
virtual int32_t enable(bool venable) override { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_enable, OVERTIME, cmd->enable = venable;); |
|||
} |
|||
virtual int32_t stop(uint8_t stop_type) override { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_stop, OVERTIME, cmd->stop_type = stop_type;); |
|||
} |
|||
virtual int32_t force_change_current_pos(int32_t x, int32_t y) override { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_force_change_current_pos, OVERTIME, cmd->x = x; cmd->y = y;); |
|||
} |
|||
virtual int32_t read_version(version_t& version) override { //
|
|||
ZCAN_SEND_CMD(kcmd_xy_robot_ctrl_read_version, version, OVERTIME); |
|||
} |
|||
virtual int32_t read_status(status_t& status) override { //
|
|||
// ZCAN_SEND_CMD(kcmd_xy_robot_ctrl_read_status, status, OVERTIME);
|
|||
|
|||
auto* cmdheader = (Cmdheader_t*)m_txbuf; |
|||
auto* cmd = (kcmd_xy_robot_ctrl_read_status_cmd_t*)cmdheader->data; |
|||
cmdheader->cmdid = (kcmd_xy_robot_ctrl_read_status >> 8); |
|||
cmdheader->subcmdid = (kcmd_xy_robot_ctrl_read_status & 0xff); |
|||
cmdheader->packetType = zcr::kpt_cmd; |
|||
static_assert(sizeof(kcmd_xy_robot_ctrl_read_status_cmd_t) <= sizeof(m_txbuf), "m_txbuf is too small"); |
|||
cmd->id = m_id; |
|||
int32_t errorcode = m_cancmder->sendCmd((uint8_t*)m_txbuf, sizeof(*cmdheader) + sizeof(*cmd), (uint8_t*)&status, sizeof(status), 30); |
|||
return errorcode; |
|||
} |
|||
virtual int32_t read_detailed_status(detailed_status_t& debug_info) override { //
|
|||
ZCAN_SEND_CMD(kcmd_xy_robot_ctrl_read_detailed_status, debug_info, OVERTIME); |
|||
} |
|||
virtual int32_t set_base_param(const base_param_t& param) override { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_set_base_param, OVERTIME, cmd->param = param;); |
|||
} |
|||
virtual int32_t get_base_param(base_param_t& ack) override { //
|
|||
ZCAN_SEND_CMD(kcmd_xy_robot_ctrl_get_base_param, ack, OVERTIME); |
|||
} |
|||
virtual int32_t flush() override { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_flush, 3000); |
|||
} |
|||
virtual int32_t factory_reset() override { //
|
|||
ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_factory_reset, 3000); |
|||
} |
|||
}; |
|||
|
|||
I_XYRobotCtrlModule* create_xyrobot_ctrl_module(ZCanCommnaderMaster* cancmder, int id) { |
|||
ZCANXYRobotCtrlMasterModule* module = new ZCANXYRobotCtrlMasterModule(); |
|||
ZASSERT(module); |
|||
module->initialize(cancmder, id); |
|||
return module; |
|||
} |
|||
} // namespace zcancmder_master
|
|||
} // namespace iflytop
|
@ -1,10 +0,0 @@ |
|||
#pragma once
|
|||
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder\api\i_xyrobot_ctrl_module.hpp"
|
|||
#if 1
|
|||
namespace iflytop { |
|||
namespace zcancmder_master { |
|||
I_XYRobotCtrlModule* create_xyrobot_ctrl_module(ZCanCommnaderMaster* cancmder, int id); |
|||
} // namespace zcancmder_master
|
|||
} // namespace iflytop
|
|||
#endif
|
@ -1,126 +0,0 @@ |
|||
#include "zcan_xy_robot_module.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
#define TAG "ZCANXYRobotCtrlModule"
|
|||
#if 1
|
|||
void ZCANXYRobotCtrlModule::initialize(ZCanCmder* cancmder, int id, I_XYRobotCtrlModule* xyRobotCtrlModule) { |
|||
m_cancmder = cancmder; |
|||
m_id = id; |
|||
m_xyRobotCtrlModule = xyRobotCtrlModule; |
|||
m_lock.init(); |
|||
cancmder->registerListener(this); |
|||
} |
|||
void ZCANXYRobotCtrlModule::onRceivePacket(CanPacketRxBuffer* rxcmd) { |
|||
zlock_guard l(m_lock); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_enable, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->enable(cmd->enable); |
|||
} |
|||
END_PP(); |
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_stop, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->stop(cmd->stop_type); |
|||
} |
|||
END_PP(); |
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_move_to_zero, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->move_to_zero([this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_xy_robot_ctrl_move_to_zero_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_xy_robot_ctrl_move_to_zero exec_status:%d", status); |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_move_to_zero_with_calibrate, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->move_to_zero_with_calibrate(cmd->nowx, cmd->nowy, [this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_xy_robot_ctrl_move_to_zero_with_calibrate_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_xy_robot_ctrl_move_to_zero_with_calibrate exec_status:%d", status); |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_move_to, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->move_to(cmd->x, cmd->y, cmd->speed, [this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_xy_robot_ctrl_move_to_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_xy_robot_ctrl_move_to exec_status:%d", status); |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_move_by, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->move_by(cmd->dx, cmd->dy, cmd->speed, [this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_xy_robot_ctrl_move_by_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_xy_robot_ctrl_move_by exec_status:%d", status); |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_move_by_no_limit, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->move_by(cmd->dx, cmd->dy, cmd->speed, [this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_xy_robot_ctrl_move_by_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_xy_robot_ctrl_move_by exec_status:%d", status); |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_force_change_current_pos, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->force_change_current_pos(cmd->x, cmd->y); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_read_version, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->read_version(ack->ack); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_read_status, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->read_status(ack->ack); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_read_detailed_status, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->read_detailed_status(ack->ack); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_set_base_param, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->set_base_param(cmd->param); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_get_base_param, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->get_base_param(ack->ack); |
|||
} |
|||
END_PP(); |
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_flush, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->flush(); |
|||
} |
|||
END_PP(); |
|||
PROCESS_PACKET(kcmd_xy_robot_ctrl_factory_reset, m_id) { //
|
|||
errorcode = m_xyRobotCtrlModule->factory_reset(); |
|||
} |
|||
END_PP(); |
|||
|
|||
// PROCESS_PACKET(kcmd_xy_robot_ctrl_set_warning_limit_param, m_id) { //
|
|||
// errorcode = m_xyRobotCtrlModule->set_warning_limit_param(cmd->opt_type, cmd->param, ack->ack);
|
|||
// }
|
|||
// END_PP();
|
|||
|
|||
// PROCESS_PACKET(kcmd_xy_robot_ctrl_set_run_to_zero_param, m_id) { //
|
|||
// errorcode = m_xyRobotCtrlModule->set_run_to_zero_param(cmd->opt_type, cmd->param, ack->ack);
|
|||
// }
|
|||
// END_PP();
|
|||
} |
|||
#endif
|
@ -1,19 +0,0 @@ |
|||
#pragma once
|
|||
#include "sdk\components\xy_robot_ctrl_module\xy_robot_ctrl_module.hpp"
|
|||
#include "sdk\components\zcancmder\zcanreceiver.hpp"
|
|||
#if 1
|
|||
namespace iflytop { |
|||
class ZCANXYRobotCtrlModule : public ZCanCmderListener { |
|||
ZCanCmder* m_cancmder = nullptr; |
|||
int m_id = 0; |
|||
I_XYRobotCtrlModule* m_xyRobotCtrlModule; |
|||
|
|||
uint8_t m_txbuf[128] = {0}; |
|||
zmutex m_lock; |
|||
|
|||
public: |
|||
void initialize(ZCanCmder* cancmder, int id, I_XYRobotCtrlModule* xyRobotCtrlModule); |
|||
virtual void onRceivePacket(CanPacketRxBuffer* rxcmd); |
|||
}; |
|||
} // namespace iflytop
|
|||
#endif
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue