📄 command.c
字号:
break; } else { SET_MOTION_ERROR_FLAG(0); /* set flag that indicates all axes need rehoming, if any axis is moved in joint mode, for machines with no forward kins */ rehomeAll = 1; } break; case EMCMOT_SET_CIRCLE: /* emcmotDebug->queue up a circular move */ /* requires coordinated mode, enable on, not on limits */ rtapi_print_msg(RTAPI_MSG_DBG, "SET_CIRCLE"); if (!GET_MOTION_COORD_FLAG() || !GET_MOTION_ENABLE_FLAG()) { reportError ("need to be enabled, in coord mode for circular move"); emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND; SET_MOTION_ERROR_FLAG(1); break; } else if (!inRange(emcmotCommand->pos)) { reportError("circular move %d out of range", emcmotCommand->id); emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotDebug->queue); SET_MOTION_ERROR_FLAG(1); break; } else if (!checkLimits()) { reportError("can't do circular move with limits exceeded"); emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotDebug->queue); SET_MOTION_ERROR_FLAG(1); break; } /* append it to the emcmotDebug->queue */ tpSetId(&emcmotDebug->queue, emcmotCommand->id); if (-1 == tpAddCircle(&emcmotDebug->queue, emcmotCommand->pos, emcmotCommand->center, emcmotCommand->normal, emcmotCommand->turn, emcmotCommand->motion_type)) { reportError("can't add circular move"); emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC; tpAbort(&emcmotDebug->queue); SET_MOTION_ERROR_FLAG(1); break; } else { SET_MOTION_ERROR_FLAG(0); /* set flag that indicates all axes need rehoming, if any axis is moved in joint mode, for machines with no forward kins */ rehomeAll = 1; } break; case EMCMOT_SET_VEL: /* set the velocity for subsequent moves */ /* can do it at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "SET_VEL"); emcmotStatus->vel = emcmotCommand->vel; tpSetVmax(&emcmotDebug->queue, emcmotStatus->vel, emcmotCommand->ini_maxvel); break; case EMCMOT_SET_VEL_LIMIT: rtapi_print_msg(RTAPI_MSG_DBG, "SET_VEL_LIMIT"); emcmot_config_change(); /* set the absolute max velocity for all subsequent moves */ /* can do it at any time */ emcmotConfig->limitVel = emcmotCommand->vel; tpSetVlimit(&emcmotDebug->queue, emcmotConfig->limitVel); break; case EMCMOT_SET_JOINT_VEL_LIMIT: rtapi_print_msg(RTAPI_MSG_DBG, "SET_JOINT_VEL_LIMIT"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); emcmot_config_change(); /* check axis range */ if (joint == 0) { break; } joint->vel_limit = emcmotCommand->vel; joint->big_vel = 10 * emcmotCommand->vel; break; case EMCMOT_SET_JOINT_ACC_LIMIT: rtapi_print_msg(RTAPI_MSG_DBG, "SET_JOINT_ACC_LIMIT"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); emcmot_config_change(); /* check axis range */ if (joint == 0) { break; } joint->acc_limit = emcmotCommand->acc; break; case EMCMOT_SET_ACC: /* set the max acceleration */ /* can do it at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "SET_ACCEL"); emcmotStatus->acc = emcmotCommand->acc; tpSetAmax(&emcmotDebug->queue, emcmotStatus->acc); break; case EMCMOT_PAUSE: /* pause the motion */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "PAUSE"); tpPause(&emcmotDebug->queue); emcmotStatus->paused = 1; break; case EMCMOT_RESUME: /* resume paused motion */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "RESUME"); emcmotDebug->stepping = 0; tpResume(&emcmotDebug->queue); emcmotStatus->paused = 0; break; case EMCMOT_STEP: /* resume paused motion until id changes */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "STEP"); emcmotDebug->idForStep = emcmotStatus->id; emcmotDebug->stepping = 1; tpResume(&emcmotDebug->queue); emcmotStatus->paused = 0; break; case EMCMOT_SCALE: /* override speed */ /* can happen at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "SCALE"); if (emcmotCommand->scale < 0.0) { emcmotCommand->scale = 0.0; /* clamp it */ } emcmotStatus->qVscale = emcmotCommand->scale; tpSetVscale(&emcmotDebug->queue, emcmotCommand->scale); break; case EMCMOT_DISABLE: /* go into disable */ /* can happen at any time */ /* reset the emcmotDebug->enabling flag to defer disable until controller cycle (it *will* be honored) */ rtapi_print_msg(RTAPI_MSG_DBG, "DISABLE"); emcmotDebug->enabling = 0; if (kinType == KINEMATICS_INVERSE_ONLY) { emcmotDebug->teleoperating = 0; emcmotDebug->coordinating = 0; } break; case EMCMOT_ENABLE: /* come out of disable */ /* can happen at any time */ /* set the emcmotDebug->enabling flag to defer enable until controller cycle */ rtapi_print_msg(RTAPI_MSG_DBG, "ENABLE"); if ( *(emcmot_hal_data->enable) == 0 ) { reportError("can't enable motion, enable input is false"); } else { emcmotDebug->enabling = 1; if (kinType == KINEMATICS_INVERSE_ONLY) { emcmotDebug->teleoperating = 0; emcmotDebug->coordinating = 0; } } break; case EMCMOT_ACTIVATE_JOINT: /* make axis active, so that amps will be enabled when system is enabled or disabled */ /* can be done at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "ACTIVATE_JOINT"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); if (joint == 0) { break; } SET_JOINT_ACTIVE_FLAG(joint, 1); break; case EMCMOT_DEACTIVATE_JOINT: /* make axis inactive, so that amps won't be affected when system is enabled or disabled */ /* can be done at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "DEACTIVATE_AXIS"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); if (joint == 0) { break; } SET_JOINT_ACTIVE_FLAG(joint, 0); break;/*! \todo FIXME - need to replace the ext function */ case EMCMOT_ENABLE_AMPLIFIER: /* enable the amplifier directly, but don't enable calculations */ /* can be done at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "ENABLE_AMP"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); if (joint == 0) { break; }/*! \todo Another #if 0 */#if 0 extAmpEnable(axis, 1);#endif break; case EMCMOT_DISABLE_AMPLIFIER: /* disable the axis calculations and amplifier, but don't disable calculations */ /* can be done at any time */ rtapi_print_msg(RTAPI_MSG_DBG, "DISABLE_AMP"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); if (joint == 0) { break; }/*! \todo Another #if 0 */#if 0 extAmpEnable(axis, 0);#endif break; case EMCMOT_HOME: /* home the specified axis */ /* need to be in free mode, enable on */ /* this just sets the initial state, then the state machine in control.c does the rest */ rtapi_print_msg(RTAPI_MSG_DBG, "HOME"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); if (joint == 0) { break; } if (GET_MOTION_COORD_FLAG() || !GET_MOTION_ENABLE_FLAG()) { break; } /* abort any movememt (jog, etc) that is in progress */ joint->free_tp_enable = 0; /* prime the homing state machine */ joint->home_state = HOME_START; break; case EMCMOT_ENABLE_WATCHDOG: rtapi_print_msg(RTAPI_MSG_DBG, "ENABLE_WATCHDOG");/*! \todo Another #if 0 */#if 0 emcmotDebug->wdEnabling = 1; emcmotDebug->wdWait = emcmotCommand->wdWait; if (emcmotDebug->wdWait < 0) { emcmotDebug->wdWait = 0; }#endif break; case EMCMOT_DISABLE_WATCHDOG: rtapi_print_msg(RTAPI_MSG_DBG, "DISABLE_WATCHDOG");/*! \todo Another #if 0 */#if 0 emcmotDebug->wdEnabling = 0;#endif break; case EMCMOT_CLEAR_PROBE_FLAGS: rtapi_print_msg(RTAPI_MSG_DBG, "CLEAR_PROBE_FLAGS"); emcmotStatus->probeTripped = 0; emcmotStatus->probing = 1; break; case EMCMOT_PROBE: /* most of this is taken from EMCMOT_SET_LINE */ /* emcmotDebug->queue up a linear move */ /* requires coordinated mode, enable off, not on limits */ rtapi_print_msg(RTAPI_MSG_DBG, "PROBE"); if (!GET_MOTION_COORD_FLAG() || !GET_MOTION_ENABLE_FLAG()) { reportError ("need to be enabled, in coord mode for probe move"); emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_COMMAND; SET_MOTION_ERROR_FLAG(1); break; } else if (!inRange(emcmotCommand->pos)) { reportError("probe move %d out of range", emcmotCommand->id); emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotDebug->queue); SET_MOTION_ERROR_FLAG(1); break; } else if (!checkLimits()) { reportError("can't do probe move with limits exceeded"); emcmotStatus->commandStatus = EMCMOT_COMMAND_INVALID_PARAMS; tpAbort(&emcmotDebug->queue); SET_MOTION_ERROR_FLAG(1); break; } /* append it to the emcmotDebug->queue */ tpSetId(&emcmotDebug->queue, emcmotCommand->id); if (-1 == tpAddLine(&emcmotDebug->queue, emcmotCommand->pos, emcmotCommand->motion_type)) { reportError("can't add probe move"); emcmotStatus->commandStatus = EMCMOT_COMMAND_BAD_EXEC; tpAbort(&emcmotDebug->queue); SET_MOTION_ERROR_FLAG(1); break; } else { emcmotStatus->probeTripped = 0; emcmotStatus->probing = 1; SET_MOTION_ERROR_FLAG(0); /* set flag that indicates all axes need rehoming, if any axis is moved in joint mode, for machines with no forward kins */ rehomeAll = 1; } break; case EMCMOT_SET_TELEOP_VECTOR: rtapi_print_msg(RTAPI_MSG_DBG, "SET_TELEOP_VECTOR"); if (!GET_MOTION_TELEOP_FLAG() || !GET_MOTION_ENABLE_FLAG()) { reportError ("need to be enabled, in teleop mode for teleop move"); } else { double velmag; emcmotDebug->teleop_data.desiredVel = emcmotCommand->pos; pmCartMag(emcmotDebug->teleop_data.desiredVel.tran, &velmag); if (emcmotDebug->teleop_data.desiredVel.a > velmag) { velmag = emcmotDebug->teleop_data.desiredVel.a; } if (emcmotDebug->teleop_data.desiredVel.b > velmag) { velmag = emcmotDebug->teleop_data.desiredVel.b; } if (emcmotDebug->teleop_data.desiredVel.c > velmag) { velmag = emcmotDebug->teleop_data.desiredVel.c; } if (velmag > emcmotConfig->limitVel) { pmCartScalMult(emcmotDebug->teleop_data.desiredVel.tran, emcmotConfig->limitVel / velmag, &emcmotDebug->teleop_data.desiredVel.tran); emcmotDebug->teleop_data.desiredVel.a *= emcmotConfig->limitVel / velmag; emcmotDebug->teleop_data.desiredVel.b *= emcmotConfig->limitVel / velmag; emcmotDebug->teleop_data.desiredVel.c *= emcmotConfig->limitVel / velmag; } /* flag that all joints need to be homed, if any joint is jogged individually later */ rehomeAll = 1; } break; case EMCMOT_SET_DEBUG: rtapi_print_msg(RTAPI_MSG_DBG, "SET_DEBUG"); emcmotConfig->debug = emcmotCommand->debug; emcmot_config_change(); break; /* needed for synchronous I/O */ case EMCMOT_SET_AOUT: if (emcmotCommand->now) { //we set it right away emcmotAioWrite(emcmotCommand->out, emcmotCommand->minLimit); } else { // we put it on the TP queue, warning: only room for one in there, any new ones will overwrite tpSetAout(&emcmotDebug->queue, emcmotCommand->out, emcmotCommand->start, emcmotCommand->end); } break; case EMCMOT_SET_DOUT: rtapi_print_msg(RTAPI_MSG_DBG, "SET_DOUT"); if (emcmotCommand->now) { //we set it right away emcmotDioWrite(emcmotCommand->out, emcmotCommand->start); } else { // we put it on the TP queue, warning: only room for one in there, any new ones will overwrite tpSetDout(&emcmotDebug->queue, emcmotCommand->out, emcmotCommand->start, emcmotCommand->end); } break; default: rtapi_print_msg(RTAPI_MSG_DBG, "UNKNOWN"); reportError("unrecognized command %d", emcmotCommand->command); emcmotStatus->commandStatus = EMCMOT_COMMAND_UNKNOWN_COMMAND; break; } /* end of: command switch */ if (emcmotStatus->commandStatus != EMCMOT_COMMAND_OK) { rtapi_print_msg(RTAPI_MSG_DBG, "ERRROR: %d", emcmotStatus->commandStatus); } rtapi_print_msg(RTAPI_MSG_DBG, "\n"); /* synch tail count */ emcmotStatus->tail = emcmotStatus->head; emcmotConfig->tail = emcmotConfig->head; emcmotDebug->tail = emcmotDebug->head; } /* end of: if-new-command */check_stuff ( "after command_handler()" ); return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -