📄 emctaskmain.cc
字号:
*/ ) { // end of file emcStatus->task.interpState = EMC_TASK_INTERP_WAITING; } else if (execRetval == 2 /* INTERP_EXECUTE_FINISH */ ) { // INTERP_EXECUTE_FINISH signifies // that no more reading should be done until // everything // outstanding is completed emcTaskPlanSetWait(); if (EMC_DEBUG & EMC_DEBUG_INTERP) { rcs_print ("emcTaskPlanSetWait() called\n"); } // and resynch interp WM emcTaskQueueCommand(&taskPlanSynchCmd); } else if (execRetval != 0) { // end of file emcStatus->task.interpState = EMC_TASK_INTERP_WAITING; } else { // executed a good line } // throw the results away if we're supposed to // read // through it if (programStartLine < 0 || emcStatus->task.readLine < programStartLine) { // we're stepping over lines, so check them // for // limits, etc. and clear then out if (0 != checkInterpList(&interp_list, emcStatus)) { // problem with actions, so do same as we // did // for a bad read from emcTaskPlanRead() // above emcStatus->task.interpState = EMC_TASK_INTERP_WAITING; } // and clear it regardless interp_list.clear(); } } // else read was OK, so execute } // else not emcTaskPlanIsWait } // if interp len is less than max break; // EMC_TASK_INTERP_READING case EMC_TASK_INTERP_PAUSED: // ON, AUTO, PAUSED switch (type) { case 0: case EMC_NULL_TYPE: // no command break; // immediate commands case EMC_AXIS_SET_CYCLE_TIME_TYPE: case EMC_AXIS_SET_GAINS_TYPE: case EMC_AXIS_SET_BACKLASH_TYPE: case EMC_AXIS_SET_HOMING_PARAMS_TYPE: case EMC_AXIS_SET_OUTPUT_SCALE_TYPE: case EMC_AXIS_SET_FERROR_TYPE: case EMC_AXIS_SET_MIN_FERROR_TYPE: case EMC_AXIS_SET_OUTPUT_TYPE: case EMC_AXIS_ALTER_TYPE: case EMC_AXIS_SET_STEP_PARAMS_TYPE: case EMC_TRAJ_PAUSE_TYPE: case EMC_TRAJ_RESUME_TYPE: case EMC_TRAJ_ABORT_TYPE: case EMC_TRAJ_SET_SCALE_TYPE: case EMC_SPINDLE_ON_TYPE: case EMC_SPINDLE_OFF_TYPE: case EMC_SPINDLE_BRAKE_RELEASE_TYPE: case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: case EMC_SPINDLE_INCREASE_TYPE: case EMC_SPINDLE_DECREASE_TYPE: case EMC_SPINDLE_CONSTANT_TYPE: case EMC_COOLANT_MIST_ON_TYPE: case EMC_COOLANT_MIST_OFF_TYPE: case EMC_COOLANT_FLOOD_ON_TYPE: case EMC_COOLANT_FLOOD_OFF_TYPE: case EMC_LUBE_ON_TYPE: case EMC_LUBE_OFF_TYPE: case EMC_TASK_SET_MODE_TYPE: case EMC_TASK_SET_STATE_TYPE: case EMC_TASK_ABORT_TYPE: case EMC_TASK_PLAN_EXECUTE_TYPE: case EMC_TASK_PLAN_PAUSE_TYPE: case EMC_TASK_PLAN_RESUME_TYPE: case EMC_TRAJ_SET_PROBE_INDEX_TYPE: case EMC_TRAJ_SET_PROBE_POLARITY_TYPE: case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: case EMC_TRAJ_PROBE_TYPE: case EMC_SET_DEBUG_TYPE: retval = emcTaskIssueCommand(emcCommand); break; case EMC_TASK_PLAN_STEP_TYPE: if (emcStatus->motion.traj.paused && emcStatus->motion.traj.queue > 0) { // there are pending motions paused; step them emcTrajStep(); } else { // motion is not paused, or it is but there is no // queue, // so we can resume normal interpretation in step // mode emcTrajResume(); stepping = 1; // set stepping mode in case it's not steppingWait = 0; // clear the wait emcStatus->task.interpState = (enum EMC_TASK_INTERP_ENUM) interpResumeState; } break; // otherwise we can't handle it default: sprintf(errstring, _ ("can't do that (%s) in auto mode with the interpreter paused"), emc_symbol_lookup(type)); emcOperatorError(0, errstring); retval = -1; break; } // switch (type) in ON, AUTO, PAUSED break; // EMC_TASK_INTERP_PAUSED case EMC_TASK_INTERP_WAITING: // interpreter ran to end // handle input commands switch (type) { case 0: case EMC_NULL_TYPE: // no command break; // immediate commands case EMC_AXIS_SET_CYCLE_TIME_TYPE: case EMC_AXIS_SET_GAINS_TYPE: case EMC_AXIS_SET_BACKLASH_TYPE: case EMC_AXIS_SET_HOMING_PARAMS_TYPE: case EMC_AXIS_SET_OUTPUT_SCALE_TYPE: case EMC_AXIS_SET_FERROR_TYPE: case EMC_AXIS_SET_MIN_FERROR_TYPE: case EMC_AXIS_SET_OUTPUT_TYPE: case EMC_AXIS_ALTER_TYPE: case EMC_AXIS_SET_STEP_PARAMS_TYPE: case EMC_TRAJ_PAUSE_TYPE: case EMC_TRAJ_RESUME_TYPE: case EMC_TRAJ_ABORT_TYPE: case EMC_TRAJ_SET_SCALE_TYPE: case EMC_SPINDLE_INCREASE_TYPE: case EMC_SPINDLE_DECREASE_TYPE: case EMC_SPINDLE_CONSTANT_TYPE: case EMC_TASK_PLAN_EXECUTE_TYPE: case EMC_TASK_PLAN_PAUSE_TYPE: case EMC_TASK_PLAN_RESUME_TYPE: case EMC_TASK_SET_MODE_TYPE: case EMC_TASK_SET_STATE_TYPE: case EMC_TASK_ABORT_TYPE: case EMC_TRAJ_SET_PROBE_INDEX_TYPE: case EMC_TRAJ_SET_PROBE_POLARITY_TYPE: case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: case EMC_TRAJ_PROBE_TYPE: case EMC_SET_DEBUG_TYPE: retval = emcTaskIssueCommand(emcCommand); break; case EMC_TASK_PLAN_STEP_TYPE: stepping = 1; // set stepping mode in case it's not steppingWait = 0; // clear the wait break; // otherwise we can't handle it default: sprintf(errstring, _ ("can't do that (%s) in auto mode with the interpreter waiting"), emc_symbol_lookup(type)); emcOperatorError(0, errstring); retval = -1; break; } // switch (type) in ON, AUTO, WAITING // now handle call logic // check for subsystems done if (interp_list.len() == 0 && emcTaskCommand == 0 && emcStatus->motion.traj.queue == 0 && emcStatus->io.status == RCS_DONE) // finished { int was_open = taskplanopen; if (was_open) { emcTaskPlanClose(); if (EMC_DEBUG & EMC_DEBUG_INTERP && was_open) { rcs_print ("emcTaskPlanClose() called at %s:%d\n", __FILE__, __LINE__); } // then resynch interpreter emcTaskQueueCommand(&taskPlanSynchCmd); } else { emcStatus->task.interpState = EMC_TASK_INTERP_IDLE; } emcStatus->task.readLine = 0; interp_list.set_line_number(0); } else { // still executing } break; // end of case EMC_TASK_INTERP_WAITING default: // coding error rcs_print_error("invalid mode(%d)", emcStatus->task.mode); retval = -1; break; } // switch (mode) in ON, AUTO break; // case EMC_TASK_MODE_AUTO case EMC_TASK_MODE_MDI: // ON, MDI switch (type) { case 0: case EMC_NULL_TYPE: // no command break; // immediate commands case EMC_AXIS_SET_CYCLE_TIME_TYPE: case EMC_AXIS_SET_GAINS_TYPE: case EMC_AXIS_SET_BACKLASH_TYPE: case EMC_AXIS_SET_HOMING_PARAMS_TYPE: case EMC_AXIS_SET_OUTPUT_SCALE_TYPE: case EMC_AXIS_SET_FERROR_TYPE: case EMC_AXIS_SET_MIN_FERROR_TYPE: case EMC_AXIS_SET_OUTPUT_TYPE: case EMC_AXIS_ALTER_TYPE: case EMC_AXIS_SET_STEP_PARAMS_TYPE: case EMC_TRAJ_SET_SCALE_TYPE: case EMC_SPINDLE_ON_TYPE: case EMC_SPINDLE_OFF_TYPE: case EMC_SPINDLE_BRAKE_RELEASE_TYPE: case EMC_SPINDLE_BRAKE_ENGAGE_TYPE: case EMC_SPINDLE_INCREASE_TYPE: case EMC_SPINDLE_DECREASE_TYPE: case EMC_SPINDLE_CONSTANT_TYPE: case EMC_COOLANT_MIST_ON_TYPE: case EMC_COOLANT_MIST_OFF_TYPE: case EMC_COOLANT_FLOOD_ON_TYPE: case EMC_COOLANT_FLOOD_OFF_TYPE: case EMC_LUBE_ON_TYPE: case EMC_LUBE_OFF_TYPE: case EMC_TASK_SET_MODE_TYPE: case EMC_TASK_SET_STATE_TYPE: case EMC_TASK_PLAN_INIT_TYPE: case EMC_TASK_PLAN_OPEN_TYPE: case EMC_TASK_PLAN_EXECUTE_TYPE: case EMC_TASK_PLAN_PAUSE_TYPE: case EMC_TASK_PLAN_RESUME_TYPE: case EMC_TASK_ABORT_TYPE: case EMC_TRAJ_SET_PROBE_INDEX_TYPE: case EMC_TRAJ_SET_PROBE_POLARITY_TYPE: case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: case EMC_TRAJ_PROBE_TYPE: case EMC_SET_DEBUG_TYPE: retval = emcTaskIssueCommand(emcCommand); break; case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: case EMC_TOOL_SET_OFFSET_TYPE: // send to IO emcTaskQueueCommand(emcCommand); // signify no more reading emcTaskPlanSetWait(); if (EMC_DEBUG & EMC_DEBUG_INTERP) { rcs_print("emcTaskPlanSetWait() called\n"); } // then resynch interpreter emcTaskQueueCommand(&taskPlanSynchCmd); break; // otherwise we can't handle it default: sprintf(errstring, _("can't do that (%s) in MDI mode"), emc_symbol_lookup(type)); emcOperatorError(0, errstring); retval = -1; break; } // switch (type) in ON, MDI break; // case EMC_TASK_MODE_MDI default: break; } // switch (mode) break; // case EMC_TASK_STATE_ON default: break; } // switch (task.state) return retval;}/* emcTaskCheckPreconditions() is called for commands on the interp_list. Immediate commands, i.e., commands sent from calls to emcTaskIssueCommand() in emcTaskPlan() directly, are not handled here. The return value is a state for emcTaskExecute() to wait on, e.g., EMC_TASK_EXEC_WAITING_FOR_MOTION, before the command can be sent out. */static int emcTaskCheckPreconditions(NMLmsg * cmd){ if (0 == cmd) { return EMC_TASK_EXEC_DONE; } switch (cmd->type) { // operator messages, if queued, will go out when everything before // them is done case EMC_OPERATOR_ERROR_TYPE: case EMC_OPERATOR_TEXT_TYPE: case EMC_OPERATOR_DISPLAY_TYPE: case EMC_SYSTEM_CMD_TYPE: case EMC_TRAJ_PROBE_TYPE: // prevent blending of this case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: // and this return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO; break; case EMC_TRAJ_LINEAR_MOVE_TYPE: case EMC_TRAJ_CIRCULAR_MOVE_TYPE: case EMC_TRAJ_SET_VELOCITY_TYPE: case EMC_TRAJ_SET_ACCELERATION_TYPE: case EMC_TRAJ_SET_TERM_COND_TYPE: case EMC_TRAJ_SET_SPINDLESYNC_TYPE: return EMC_TASK_EXEC_WAITING_FOR_IO; break; case EMC_TRAJ_SET_OFFSET_TYPE: // this applies the tool length offset variable after previous // motions case EMC_TRAJ_SET_ORIGIN_TYPE: // this applies the program origin after previous motions return EMC_TASK_EXEC_WAITING_FOR_MOTION; break; case EMC_TOOL_LOAD_TYPE: case EMC_TOOL_UNLOAD_TYPE: case EMC_COOLANT_MIST_ON_TYPE: case EMC_COOLANT_MIST_OFF_TYPE: case EMC_COOLANT_FLOOD_ON_TYPE: case EMC_COOLANT_FLOOD_OFF_TYPE: case EMC_SPINDLE_ON_TYPE: case EMC_SPINDLE_OFF_TYPE: return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO; break; case EMC_TOOL_PREPARE_TYPE: case EMC_LUBE_ON_TYPE: case EMC_LUBE_OFF_TYPE: return EMC_TASK_EXEC_WAITING_FOR_IO; break; case EMC_TOOL_LOAD_TOOL_TABLE_TYPE: case EMC_TOOL_SET_OFFSET_TYPE: return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO; break; case EMC_TASK_PLAN_PAUSE_TYPE: /* pause on the interp list is queued, so wait until all are done */ return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO; break; case EMC_TASK_PLAN_END_TYPE: return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO; break; case EMC_TASK_PLAN_INIT_TYPE: case EMC_TASK_PLAN_RUN_TYPE: case EMC_TASK_PLAN_SYNCH_TYPE: case EMC_TASK_PLAN_EXECUTE_TYPE: return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO; break; case EMC_TRAJ_DELAY_TYPE: return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO; break; case EMC_MOTION_SET_AOUT_TYPE: if (((EMC_MOTION_SET_AOUT *) cmd)->now) { return EMC_TASK_EXEC_WAITING_FOR_MOTION; } return EMC_TASK_EXEC_DONE; break; case EMC_MOTION_SET_DOUT_TYPE: if (((EMC_MOTION_SET_DOUT *) cmd)->now) { return EMC_TASK_EXEC_WAITING_FOR_MOTION; } return EMC_TASK_EXEC_DONE; break; default: // unrecognized command if (EMC_DEBUG & EMC_DEBUG_TASK_ISSUE) { rcs_print_error("preconditions: unrecognized command %d:%s\n", cmd->type, emc_symbol_lookup(cmd->type)); } return EMC_TASK_EXEC_ERROR; break; } return EMC_TASK_EXEC_DONE;}// puts command on interp liststatic int emcTaskQueueCommand(NMLmsg * cmd){ if (0 == cmd) { return 0; } interp_list.append(cmd); return 0;}// issues command immediatelystatic int emcTaskIssueCommand(NMLmsg * cmd){ int retval = 0; int execRetval = 0;/*! \todo FIXME - debug */ if (EMC_DEBUG & EMC_DEBUG_TASK_ISSUE) { printf("emcTaskIssueCommand()\n"); } if (0 == cmd) { return 0; } if (EMC_DEBUG & EMC_DEBUG_TASK_ISSUE) { rcs_print("Issuing %s -- \t (%s)\n", emcSymbolLookup(cmd->type),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -