From 335439f03173e575f3c1613cc3989cf812a83454 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 15 Oct 2023 11:32:42 +0800 Subject: [PATCH 1/2] update --- components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp | 2 +- components/xy_robot_ctrl_module/xy_robot_script_cmder_module.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp b/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp index 1ebef56..b2d90de 100644 --- a/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp +++ b/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.cpp @@ -63,7 +63,7 @@ static void cmd_dump_ack(I_XYRobotCtrlModule::base_param_t& ack) { ZLOGI(TAG, " run_to_zero_dec :%d", ack.run_to_zero_dec); } -void XYRobotScriptCmderModule::regXYRobot(int id, I_XYRobotCtrlModule* robot) { +void XYRobotScriptCmderModule::regmodule(int id, I_XYRobotCtrlModule* robot) { ZASSERT(moduler.find(id) == moduler.end()); ZASSERT(robot != nullptr); moduler[id] = robot; diff --git a/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.hpp b/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.hpp index 5aa826a..34cfeae 100644 --- a/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.hpp +++ b/components/xy_robot_ctrl_module/xy_robot_script_cmder_module.hpp @@ -13,7 +13,7 @@ class XYRobotScriptCmderModule { public: void initialize(CmdScheduler* cmdScheduler); - void regXYRobot(int id, I_XYRobotCtrlModule* robot); + void regmodule(int id, I_XYRobotCtrlModule* robot); void regcmd(); private: From dc5fe41e28d47dd96b92b5cb35fd42f0bbf984cc Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 15 Oct 2023 11:43:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../step_motor_ctrl_script_cmder_module.cpp | 67 +++++++++++----------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.cpp index 6939c0d..22b74bf 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_script_cmder_module.cpp @@ -99,124 +99,125 @@ void StepMotorCtrlScriptCmderModule::regmodule(int id, I_StepMotorCtrlModule* ro } void StepMotorCtrlScriptCmderModule::regcmd() { // ZASSERT(m_cmdScheduler != nullptr); - +#if 1 m_cmdScheduler->registerCmd("step_motor_ctrl_is_busy", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); ZLOGI(TAG, "is busy:%d", module->isbusy()); return (int32_t)0; }); m_cmdScheduler->registerCmd("step_motor_ctrl_get_last_exec_status", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); ZLOGI(TAG, "last exec status:%s(%d)", err::error2str(module->get_last_exec_status()), module->get_last_exec_status()); return (int32_t)0; }); m_cmdScheduler->registerCmd("step_motor_ctrl_move_to", "(id,x,speed)", 3, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(move_to, con->getInt(1), con->getInt(2), // + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(move_to, con->getInt(2), con->getInt(3), // [this](int32_t status) { ZLOGI(TAG, "move to exec end status:%s(%d)", err::error2str(status), status); }); }); m_cmdScheduler->registerCmd("step_motor_ctrl_move_by", "(id,dx,speed)", 3, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(move_by, con->getInt(1), con->getInt(2), // + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(move_by, con->getInt(2), con->getInt(3), // [this](int32_t status) { ZLOGI(TAG, "move by exec end status:%s(%d)", err::error2str(status), status); }); }); m_cmdScheduler->registerCmd("step_motor_ctrl_move_to_zero", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); IMPL_CMD(move_to_zero, [this](int32_t status) { ZLOGI(TAG, "move to zero exec end status:%s(%d)", err::error2str(status), status); }); }); m_cmdScheduler->registerCmd("step_motor_ctrl_move_to_zero_with_calibrate", "(id,x)", 2, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(move_to_zero_with_calibrate, con->getInt(1), // + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(move_to_zero_with_calibrate, con->getInt(2), // [this](int32_t status) { ZLOGI(TAG, "move to zero with calibrate exec end status:%s(%d)", err::error2str(status), status); }); }); m_cmdScheduler->registerCmd("step_motor_ctrl_rotate", "(id,speed,lastforms)", 3, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(rotate, con->getInt(1), con->getInt(2), // + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(rotate, con->getInt(2), con->getInt(3), // [this](int32_t status) { ZLOGI(TAG, "rotate exec end status:%s(%d)", err::error2str(status), status); }); }); m_cmdScheduler->registerCmd("step_motor_ctrl_stop", "(id,stop_type)", 2, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(stop, con->getInt(1)); + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(stop, con->getInt(2)); }); m_cmdScheduler->registerCmd("step_motor_ctrl_force_change_current_pos", "(id,x)", 2, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(force_change_current_pos, con->getInt(1)); + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(force_change_current_pos, con->getInt(2)); }); m_cmdScheduler->registerCmd("step_motor_ctrl_move_to_logic_point", "(id,logic_point_id)", 2, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(move_to_logic_point, con->getInt(1), // + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(move_to_logic_point, con->getInt(2), // [this](int32_t status) { ZLOGI(TAG, "move to logic point exec end status:%s(%d)", err::error2str(status), status); }); }); m_cmdScheduler->registerCmd("step_motor_ctrl_set_logic_point", "(id,logic_point_id,x,vel,acc,dec)", 6, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(set_logic_point, con->getInt(1), con->getInt(2), con->getInt(3), con->getInt(4), con->getInt(5)); + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(set_logic_point, con->getInt(2), con->getInt(3), con->getInt(4), con->getInt(5), con->getInt(6)); }); m_cmdScheduler->registerCmd("step_motor_ctrl_set_logic_point_simplify", "(id,logic_point_id)", 2, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(set_logic_point, con->getInt(1), module->read_pos(), 0, 0, 0); + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(set_logic_point, con->getInt(2), module->read_pos(), 0, 0, 0); }); m_cmdScheduler->registerCmd("step_motor_ctrl_get_logic_point", "(id,logic_point_id)", 2, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); I_StepMotorCtrlModule::logic_point_t ack; - IMPL_READ_STATE(get_logic_point, con->getInt(1), ack); + IMPL_READ_STATE(get_logic_point, con->getInt(2), ack); }); m_cmdScheduler->registerCmd("step_motor_ctrl_get_base_param", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); I_StepMotorCtrlModule::base_param_t ack; IMPL_READ_STATE(get_base_param, ack); }); m_cmdScheduler->registerCmd("step_motor_ctrl_flush", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); IMPL_CMD(flush); }); m_cmdScheduler->registerCmd("step_motor_ctrl_enable", "(id,en)", 2, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); - IMPL_CMD(enable, con->getBool(1)); + DO_CMD(findmodule(con->getInt(1), &module)); + IMPL_CMD(enable, con->getBool(2)); }); m_cmdScheduler->registerCmd("step_motor_ctrl_factory_reset", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); IMPL_CMD(factory_reset); }); m_cmdScheduler->registerCmd("step_motor_ctrl_read_version", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); I_StepMotorCtrlModule::version_t ack; IMPL_READ_STATE(read_version, ack); }); m_cmdScheduler->registerCmd("step_motor_ctrl_read_status", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); I_StepMotorCtrlModule::status_t ack; IMPL_READ_STATE(read_status, ack); }); m_cmdScheduler->registerCmd("step_motor_ctrl_read_detailed_status", "(id)", 1, [this](CmdScheduler::Context* con) { - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); I_StepMotorCtrlModule::detailed_status_t ack; IMPL_READ_STATE(read_detailed_status, ack); }); +#endif m_cmdScheduler->registerCmd("step_motor_ctrl_set_base_param", "(id,paramName,val)", 3, [this](CmdScheduler::Context* con) { const char* paramName = con->getString(2); int32_t value = con->getInt(3); - DO_CMD(findmodule(con->getInt(0), &module)); + DO_CMD(findmodule(con->getInt(1), &module)); I_StepMotorCtrlModule::base_param_t param; DO_CMD(module->get_base_param(param));