5 changed files with 213 additions and 106 deletions
-
122components/pipette_module/pipette_ctrl_module.cpp
-
37components/pipette_module/pipette_ctrl_module.hpp
-
140components/zcancmder_module/zcan_pipette_module.cpp
-
18components/zcancmder_module/zcan_pipette_module.hpp
-
2components/zprotocols/zcancmder
@ -0,0 +1,140 @@ |
|||
#include "zcan_pipette_module.hpp"
|
|||
using namespace iflytop; |
|||
|
|||
#define TAG "ZcanPipetteModule"
|
|||
#if 1
|
|||
void ZcanPipetteModule::initialize(ZCanCmder* cancmder, int id, I_PipetteModule* module) { |
|||
m_cancmder = cancmder; |
|||
m_id = id; |
|||
m_module = module; |
|||
cancmder->registerListener(this); |
|||
} |
|||
void ZcanPipetteModule::onRceivePacket(CanPacketRxBuffer* rxcmd) { |
|||
// printf("ZcanPipetteModule::onRceivePacket %d %d\n", rxcmd->get_cmdheader()->cmdid, rxcmd->get_cmdheader()->subcmdid);
|
|||
|
|||
#if 0
|
|||
kcmd_pipette_module_z_motor_enable = CMDID(1016, 0), // 使能
|
|||
kcmd_pipette_module_z_motor_move_to = CMDID(1016, 1), // 移动到
|
|||
kcmd_pipette_module_z_motor_move_to_zero = CMDID(1016, 2), // 归零
|
|||
kcmd_pipette_module_z_motor_move_to_zero_with_calibrate = CMDID(1016, 3), // 归零并校准
|
|||
kcmd_pipette_module_z_motor_stop = CMDID(1016, 4), // 停止
|
|||
|
|||
kcmd_pipette_module_take_liquid = CMDID(1016, 4), // 取液体
|
|||
kcmd_pipette_module_split_liquid = CMDID(1016, 5), // 吐液体
|
|||
kcmd_pipette_module_take_tip = CMDID(1016, 6), // 取tip
|
|||
kcmd_pipette_module_remove_tip = CMDID(1016, 7), // 移除tip
|
|||
|
|||
kcmd_pipette_module_read_version = CMDID(1016, 50), // 读取模块型号版本信息
|
|||
kcmd_pipette_module_read_status = CMDID(1016, 51), // 读取模块精简状态信息
|
|||
kcmd_pipette_module_read_detailed_status = CMDID(1016, 52), // 读取模块详细状态信息
|
|||
|
|||
kcmd_pipette_module_set_run_param = CMDID(1016, 100), // 设置运行参数
|
|||
kcmd_pipette_module_set_warning_limit_param = CMDID(1016, 101), // 设置限制参数
|
|||
kcmd_pipette_module_set_run_to_zero_param = CMDID(1016, 102), // 设置归零参数
|
|||
#endif
|
|||
|
|||
|
|||
|
|||
#if 0
|
|||
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) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_step_motor_ctrl_move_to_zero_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_step_motor_ctrl_move_to_zero exec_status:%d", status); |
|||
|
|||
report.id = m_id; |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_to_zero_with_calibrate, m_id) { |
|||
errorcode = m_module->move_to_zero_with_calibrate(cmd->nowx, [this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_step_motor_ctrl_move_to_zero_with_calibrate_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_step_motor_ctrl_move_to_zero_with_calibrate exec_status:%d", status); |
|||
|
|||
report.id = m_id; |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_to, m_id) { |
|||
errorcode = m_module->move_to(cmd->x, [this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_step_motor_ctrl_move_to_report_t report = {0}; |
|||
ZLOGI(TAG, "kcmd_step_motor_ctrl_move_to exec_status:%d ", status); |
|||
|
|||
report.id = m_id; |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
END_PP(); |
|||
|
|||
PROCESS_PACKET(kcmd_step_motor_ctrl_move_by, m_id) { |
|||
errorcode = m_module->move_by(cmd->dx, [this, cmdheader](int32_t status) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_step_motor_ctrl_move_by_report_t report = {0}; |
|||
// ZLOGI(TAG, "kcmd_step_motor_ctrl_move_by exec_status:%d %d", status.exec_status, status.dx);
|
|||
ZLOGI(TAG, "kcmd_step_motor_ctrl_move_by exec_status:%d ", status); |
|||
|
|||
report.id = m_id; |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
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) { |
|||
osDelay(5); // 用来保证回执消息在前面
|
|||
kcmd_step_motor_ctrl_rotate_report_t report = {0}; |
|||
// ZLOGI(TAG, "kcmd_step_motor_ctrl_rotate exec_status:%d %d", status.exec_status, status.lastforms);
|
|||
ZLOGI(TAG, "kcmd_step_motor_ctrl_rotate exec_status:%d ", status); |
|||
|
|||
report.id = m_id; |
|||
report.exec_status = status; |
|||
m_cancmder->sendExecStatusReport(cmdheader, (uint8_t*)&report, sizeof(report)); |
|||
}); |
|||
} |
|||
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(); |
|||
#endif
|
|||
} |
|||
#endif
|
@ -0,0 +1,18 @@ |
|||
#pragma once
|
|||
// #include "sdk/components/zprotocols/zcancmder/api/i_step_motor_ctrl_module.hpp"
|
|||
#include "sdk/components/zprotocols/zcancmder/api/i_pipette_module.hpp"
|
|||
#include "sdk\components\zcancmder\zcanreceiver.hpp"
|
|||
namespace iflytop { |
|||
|
|||
class ZcanPipetteModule : public ZCanCmderListener { |
|||
ZCanCmder* m_cancmder = nullptr; |
|||
int m_id = 0; |
|||
I_PipetteModule* m_module; |
|||
|
|||
uint8_t m_txbuf[128] = {0}; |
|||
|
|||
public: |
|||
void initialize(ZCanCmder* cancmder, int id, I_PipetteModule* module); |
|||
virtual void onRceivePacket(CanPacketRxBuffer* rxcmd); |
|||
}; |
|||
} // namespace iflytop
|
@ -1 +1 @@ |
|||
Subproject commit fc4340666e8afc748a8adb759439c561b62afa5d |
|||
Subproject commit eff35f5c915ddaa15cced3796ce2ba7c93ea5029 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue