Browse Source

update

master
zhaohe 2 years ago
parent
commit
3ff04012ff
  1. 25
      src/service/a8000_scirpt_processer.cpp

25
src/service/a8000_scirpt_processer.cpp

@ -139,6 +139,7 @@ void A8000ScriptProcesser::step_motor_move_by(shared_ptr<ScriptProcesser::Contex
return; return;
} }
} }
void A8000ScriptProcesser::step_motor_move_to_zero(shared_ptr<ScriptProcesser::Context> context, int32_t targetStepMotorId) { void A8000ScriptProcesser::step_motor_move_to_zero(shared_ptr<ScriptProcesser::Context> context, int32_t targetStepMotorId) {
A8000ScriptProcesser::CtrlPointConfig cpcfg = getStepMotorConfig(targetStepMotorId, SAMC_REG_ACT_RUN_TO_HOME); A8000ScriptProcesser::CtrlPointConfig cpcfg = getStepMotorConfig(targetStepMotorId, SAMC_REG_ACT_RUN_TO_HOME);
writeReg(cpcfg.m_deviceId, cpcfg.m_ctrlPointId, 0, context); writeReg(cpcfg.m_deviceId, cpcfg.m_ctrlPointId, 0, context);
@ -164,6 +165,7 @@ void A8000ScriptProcesser::step_motor_wait_for_idle(shared_ptr<ScriptProcesser::
while (state != 0) { while (state != 0) {
thisThread.sleepForMs(300); thisThread.sleepForMs(300);
step_motor_is_idle(context, targetStepMotorId, state); step_motor_is_idle(context, targetStepMotorId, state);
logger->info("step_motor({}) wait_for_idle:{}", targetStepMotorId, state);
} }
} }
@ -205,7 +207,7 @@ void A8000ScriptProcesser::tube_rotate_zero(shared_ptr<ScriptProcesser::Context>
#define CHECK_CMD_PARAMETER(expectParaNum) \ #define CHECK_CMD_PARAMETER(expectParaNum) \
if (cmdandvar.size() - 1 != expectParaNum) { \ if (cmdandvar.size() - 1 != expectParaNum) { \
context->printfInfo = fmt::format("error:do {} error,parameter num error", cmd, cmdandvar.size()); \
context->printfInfo = fmt::format("error:do {} error,parameter num error,{}", cmd, cmdandvar.size()); \
logger->error("{}", context->printfInfo); \ logger->error("{}", context->printfInfo); \
return; \ return; \
} }
@ -236,38 +238,33 @@ void A8000ScriptProcesser::docmd(shared_ptr<ScriptProcesser::Context> context) {
int32_t direction = atoi(context->cmd_and_var[2].c_str()); int32_t direction = atoi(context->cmd_and_var[2].c_str());
step_motor_rotate(context, motorId, direction); step_motor_rotate(context, motorId, direction);
} else if (cmd == "step_motor_move_to") { } else if (cmd == "step_motor_move_to") {
// stepMotorRotate motorId direction
CHECK_CMD_PARAMETER(2); CHECK_CMD_PARAMETER(2);
step_motor_move_to(context, context->getvarInt(1), context->getvarInt(2)); step_motor_move_to(context, context->getvarInt(1), context->getvarInt(2));
} else if (cmd == "step_motor_move_by") { } else if (cmd == "step_motor_move_by") {
// stepMotorRotate motorId direction
CHECK_CMD_PARAMETER(2); CHECK_CMD_PARAMETER(2);
step_motor_move_by(context, context->getvarInt(1), context->getvarInt(2)); step_motor_move_by(context, context->getvarInt(1), context->getvarInt(2));
} else if (cmd == "step_motor_move_to_zero") { } else if (cmd == "step_motor_move_to_zero") {
// stepMotorRotate motorId direction
CHECK_CMD_PARAMETER(1); CHECK_CMD_PARAMETER(1);
step_motor_move_to_zero(context, context->getvarInt(1)); step_motor_move_to_zero(context, context->getvarInt(1));
} else if (cmd == "step_motor_read_pos") { } else if (cmd == "step_motor_read_pos") {
// stepMotorRotate motorId direction
CHECK_CMD_PARAMETER(2);
CHECK_CMD_PARAMETER(1);
int32_t retval = 0; int32_t retval = 0;
step_motor_read_pos(context, context->getvarInt(1), retval); step_motor_read_pos(context, context->getvarInt(1), retval);
} else if (cmd == "step_motor_read_state") { } else if (cmd == "step_motor_read_state") {
// stepMotorRotate motorId direction
CHECK_CMD_PARAMETER(2);
CHECK_CMD_PARAMETER(1);
int32_t retval = 0; int32_t retval = 0;
step_motor_read_state(context, context->getvarInt(1), retval); step_motor_read_state(context, context->getvarInt(1), retval);
} else if (cmd == "step_motor_is_idle") { } else if (cmd == "step_motor_is_idle") {
// stepMotorRotate motorId direction
CHECK_CMD_PARAMETER(2);
CHECK_CMD_PARAMETER(1);
int32_t retval = 0; int32_t retval = 0;
step_motor_is_idle(context, context->getvarInt(1), retval); step_motor_is_idle(context, context->getvarInt(1), retval);
} else if (cmd == "step_motor_stop") { } else if (cmd == "step_motor_stop") {
// stepMotorRotate motorId direction
CHECK_CMD_PARAMETER(2);
CHECK_CMD_PARAMETER(1);
step_motor_stop(context, context->getvarInt(1)); step_motor_stop(context, context->getvarInt(1));
} else if (cmd == "step_motor_wait_for_idle") {
CHECK_CMD_PARAMETER(1);
step_motor_wait_for_idle(context, context->getvarInt(1));
} }
else if (cmd == "duoji_move_to") { else if (cmd == "duoji_move_to") {
CHECK_CMD_PARAMETER(2); CHECK_CMD_PARAMETER(2);
duoji_move_to(context, context->getvarInt(1), context->getvarInt(2)); duoji_move_to(context, context->getvarInt(1), context->getvarInt(2));
@ -275,7 +272,7 @@ void A8000ScriptProcesser::docmd(shared_ptr<ScriptProcesser::Context> context) {
CHECK_CMD_PARAMETER(1); CHECK_CMD_PARAMETER(1);
duoji_stop(context, context->getvarInt(1)); duoji_stop(context, context->getvarInt(1));
} else if (cmd == "duoji_is_idle") { } else if (cmd == "duoji_is_idle") {
CHECK_CMD_PARAMETER(2);
CHECK_CMD_PARAMETER(1);
int32_t retval = 0; int32_t retval = 0;
duoji_is_idle(context, context->getvarInt(1), retval); duoji_is_idle(context, context->getvarInt(1), retval);
} else if (cmd == "tube_rotate") { } else if (cmd == "tube_rotate") {

Loading…
Cancel
Save