|
@ -99,124 +99,125 @@ void StepMotorCtrlScriptCmderModule::regmodule(int id, I_StepMotorCtrlModule* ro |
|
|
} |
|
|
} |
|
|
void StepMotorCtrlScriptCmderModule::regcmd() { //
|
|
|
void StepMotorCtrlScriptCmderModule::regcmd() { //
|
|
|
ZASSERT(m_cmdScheduler != nullptr); |
|
|
ZASSERT(m_cmdScheduler != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_is_busy", "(id)", 1, [this](CmdScheduler::Context* con) { |
|
|
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()); |
|
|
ZLOGI(TAG, "is busy:%d", module->isbusy()); |
|
|
return (int32_t)0; |
|
|
return (int32_t)0; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_get_last_exec_status", "(id)", 1, [this](CmdScheduler::Context* con) { |
|
|
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()); |
|
|
ZLOGI(TAG, "last exec status:%s(%d)", err::error2str(module->get_last_exec_status()), module->get_last_exec_status()); |
|
|
return (int32_t)0; |
|
|
return (int32_t)0; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_move_to", "(id,x,speed)", 3, [this](CmdScheduler::Context* con) { |
|
|
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); }); |
|
|
[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) { |
|
|
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); }); |
|
|
[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) { |
|
|
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); }); |
|
|
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) { |
|
|
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); }); |
|
|
[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) { |
|
|
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); }); |
|
|
[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) { |
|
|
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) { |
|
|
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) { |
|
|
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); }); |
|
|
[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) { |
|
|
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) { |
|
|
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) { |
|
|
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; |
|
|
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) { |
|
|
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; |
|
|
I_StepMotorCtrlModule::base_param_t ack; |
|
|
IMPL_READ_STATE(get_base_param, ack); |
|
|
IMPL_READ_STATE(get_base_param, ack); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_flush", "(id)", 1, [this](CmdScheduler::Context* con) { |
|
|
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); |
|
|
IMPL_CMD(flush); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_enable", "(id,en)", 2, [this](CmdScheduler::Context* con) { |
|
|
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) { |
|
|
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); |
|
|
IMPL_CMD(factory_reset); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_read_version", "(id)", 1, [this](CmdScheduler::Context* con) { |
|
|
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; |
|
|
I_StepMotorCtrlModule::version_t ack; |
|
|
IMPL_READ_STATE(read_version, ack); |
|
|
IMPL_READ_STATE(read_version, ack); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_read_status", "(id)", 1, [this](CmdScheduler::Context* con) { |
|
|
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; |
|
|
I_StepMotorCtrlModule::status_t ack; |
|
|
IMPL_READ_STATE(read_status, ack); |
|
|
IMPL_READ_STATE(read_status, ack); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_read_detailed_status", "(id)", 1, [this](CmdScheduler::Context* con) { |
|
|
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; |
|
|
I_StepMotorCtrlModule::detailed_status_t ack; |
|
|
IMPL_READ_STATE(read_detailed_status, 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) { |
|
|
m_cmdScheduler->registerCmd("step_motor_ctrl_set_base_param", "(id,paramName,val)", 3, [this](CmdScheduler::Context* con) { |
|
|
const char* paramName = con->getString(2); |
|
|
const char* paramName = con->getString(2); |
|
|
int32_t value = con->getInt(3); |
|
|
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; |
|
|
I_StepMotorCtrlModule::base_param_t param; |
|
|
DO_CMD(module->get_base_param(param)); |
|
|
DO_CMD(module->get_base_param(param)); |
|
|