📄 emctaskmain.cc
字号:
emcStatus->task.interpState = EMC_TASK_INTERP_WAITING; } else { // got a good line // record the line number and command emcStatus->task.readLine = emcTaskPlanLine(); if (EMC_DEBUG & EMC_DEBUG_INTERP) { rcs_print ("emcTaskPlanLine() returned %d\n", emcStatus->task.readLine); } interp_list.set_line_number(emcStatus->task. readLine); emcTaskPlanCommand((char *) &emcStatus->task. command); if (EMC_DEBUG & EMC_DEBUG_INTERP) { rcs_print ("emcTaskPlanCommand(%s) called. (line_number=%d)\n", ((char *) &emcStatus->task.command), emcStatus->task.readLine); } // and execute it execRetval = emcTaskPlanExecute(0); if (EMC_DEBUG & EMC_DEBUG_INTERP) { rcs_print ("emcTaskPlanExecute(0) return %d\n", execRetval); } if (execRetval == -1 /* INTERP_ERROR */ || execRetval > INTERP_MIN_ERROR || execRetval == 1 /* INTERP_EXIT */ ) { // 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(); } if (emcStatus->task.readLine < programStartLine) { //update the position with our current position, as the other positions are only skipped through CANON_UPDATE_END_POINT(emcStatus->motion.traj.actualPosition.tran.x, emcStatus->motion.traj.actualPosition.tran.y, emcStatus->motion.traj.actualPosition.tran.z, emcStatus->motion.traj.actualPosition.a, emcStatus->motion.traj.actualPosition.b, emcStatus->motion.traj.actualPosition.c, emcStatus->motion.traj.actualPosition.u, emcStatus->motion.traj.actualPosition.v, emcStatus->motion.traj.actualPosition.w); } if (count++ < 1000 && emcStatus->task.interpState == EMC_TASK_INTERP_READING && interp_list.len() <= EMC_TASK_INTERP_MAX_LEN * 2/3) { goto interpret_again; } } // 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_BACKLASH_TYPE: case EMC_AXIS_SET_HOMING_PARAMS_TYPE: case EMC_AXIS_SET_FERROR_TYPE: case EMC_AXIS_SET_MIN_FERROR_TYPE: case EMC_AXIS_SET_OUTPUT_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_TRAJ_SET_SPINDLE_SCALE_TYPE: case EMC_TRAJ_SET_FO_ENABLE_TYPE: case EMC_TRAJ_SET_FH_ENABLE_TYPE: case EMC_TRAJ_SET_SO_ENABLE_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_TASK_PLAN_SET_OPTIONAL_STOP_TYPE: case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: case EMC_TRAJ_PROBE_TYPE: case EMC_AUX_INPUT_WAIT_TYPE: case EMC_TRAJ_RIGID_TAP_TYPE: case EMC_SET_DEBUG_TYPE: retval = emcTaskIssueCommand(emcCommand); break; case EMC_TASK_PLAN_STEP_TYPE: stepping = 1; steppingWait = 0; if (emcStatus->motion.traj.paused && emcStatus->motion.traj.queue > 0) { // there are pending motions paused; step them emcTrajStep(); } else { 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_BACKLASH_TYPE: case EMC_AXIS_SET_HOMING_PARAMS_TYPE: case EMC_AXIS_SET_FERROR_TYPE: case EMC_AXIS_SET_MIN_FERROR_TYPE: case EMC_AXIS_SET_OUTPUT_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_TRAJ_SET_SPINDLE_SCALE_TYPE: case EMC_TRAJ_SET_FO_ENABLE_TYPE: case EMC_TRAJ_SET_FH_ENABLE_TYPE: case EMC_TRAJ_SET_SO_ENABLE_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_PLAN_SET_OPTIONAL_STOP_TYPE: case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: case EMC_TASK_SET_MODE_TYPE: case EMC_TASK_SET_STATE_TYPE: case EMC_TASK_ABORT_TYPE: case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: case EMC_TRAJ_PROBE_TYPE: case EMC_AUX_INPUT_WAIT_TYPE: case EMC_TRAJ_RIGID_TAP_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_BACKLASH_TYPE: case EMC_AXIS_SET_HOMING_PARAMS_TYPE: case EMC_AXIS_SET_FERROR_TYPE: case EMC_AXIS_SET_MIN_FERROR_TYPE: case EMC_AXIS_SET_OUTPUT_TYPE: case EMC_AXIS_SET_STEP_PARAMS_TYPE: case EMC_TRAJ_SET_SCALE_TYPE: case EMC_TRAJ_SET_SPINDLE_SCALE_TYPE: case EMC_TRAJ_SET_FO_ENABLE_TYPE: case EMC_TRAJ_SET_FH_ENABLE_TYPE: case EMC_TRAJ_SET_SO_ENABLE_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_SET_OPTIONAL_STOP_TYPE: case EMC_TASK_PLAN_SET_BLOCK_DELETE_TYPE: case EMC_TASK_PLAN_RESUME_TYPE: case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE: case EMC_TASK_ABORT_TYPE: case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: case EMC_TRAJ_PROBE_TYPE: case EMC_AUX_INPUT_WAIT_TYPE: case EMC_TRAJ_RIGID_TAP_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_RIGID_TAP_TYPE: //and this case EMC_TRAJ_CLEAR_PROBE_TRIPPED_FLAG_TYPE: // and this case EMC_AUX_INPUT_WAIT_TYPE: 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: case EMC_TRAJ_SET_FO_ENABLE_TYPE: case EMC_TRAJ_SET_FH_ENABLE_TYPE: case EMC_TRAJ_SET_SO_ENABLE_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: case EMC_TASK_PLAN_OPTIONAL_STOP_TYPE:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -