📄 emcsh.cc
字号:
Tcl_SetResult(interp, "emc_program: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (0 != emcStatus->task.file[0]) { Tcl_SetResult(interp, emcStatus->task.file, TCL_VOLATILE); return TCL_OK; } Tcl_SetResult(interp, "none", TCL_VOLATILE); return TCL_OK;}static int emc_program_status(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc != 1) { Tcl_SetResult(interp, "emc_program_status: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } switch (emcStatus->task.interpState) { case EMC_TASK_INTERP_READING: case EMC_TASK_INTERP_WAITING: Tcl_SetResult(interp, "running", TCL_VOLATILE); return TCL_OK; break; case EMC_TASK_INTERP_PAUSED: Tcl_SetResult(interp, "paused", TCL_VOLATILE); return TCL_OK; break; default: Tcl_SetResult(interp, "idle", TCL_VOLATILE); return TCL_OK; } Tcl_SetResult(interp, "idle", TCL_VOLATILE); return TCL_OK;}static int emc_program_line(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ Tcl_Obj *lineobj; int programActiveLine = 0; if (objc != 1) { Tcl_SetResult(interp, "emc_program_line: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (programStartLine < 0 || emcStatus->task.readLine < programStartLine) { // controller is skipping lines programActiveLine = emcStatus->task.readLine; } else { // controller is not skipping lines if (emcStatus->task.currentLine > 0) { if (emcStatus->task.motionLine > 0 && emcStatus->task.motionLine < emcStatus->task.currentLine) { // active line is the motion line, which lags programActiveLine = emcStatus->task.motionLine; } else { // active line is the current line-- no motion lag programActiveLine = emcStatus->task.currentLine; } } else { // no active line at all programActiveLine = 0; } } // end of else controller is not skipping // lines lineobj = Tcl_NewIntObj(programActiveLine); Tcl_SetObjResult(interp, lineobj); return TCL_OK;}static int emc_program_codes(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char codes_string[256]; char string[256]; int t; int code; if (objc != 1) { Tcl_SetResult(interp, "emc_program_codes: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } // fill in the active G codes codes_string[0] = 0; for (t = 1; t < ACTIVE_G_CODES; t++) { code = emcStatus->task.activeGCodes[t]; if (code == -1) { continue; } if (code % 10) { sprintf(string, "G%.1f ", (double) code / 10.0); } else { sprintf(string, "G%d ", code / 10); } strcat(codes_string, string); } // fill in the active M codes, settings too for (t = 1; t < ACTIVE_M_CODES; t++) { code = emcStatus->task.activeMCodes[t]; if (code == -1) { continue; } sprintf(string, "M%d ", code); strcat(codes_string, string); } // fill in F and S codes also sprintf(string, "F%.0f ", emcStatus->task.activeSettings[1]); strcat(codes_string, string); sprintf(string, "S%.0f", fabs(emcStatus->task.activeSettings[2])); strcat(codes_string, string); Tcl_SetResult(interp, codes_string, TCL_VOLATILE); return TCL_OK;}static int emc_joint_type(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ int joint; if (objc != 2) { Tcl_SetResult(interp, "emc_joint_type: need exactly 1 non-negative integer", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (TCL_OK == Tcl_GetIntFromObj(0, objv[1], &joint)) { if (joint < 0 || joint >= EMC_AXIS_MAX) { Tcl_SetResult(interp, "emc_joint_type: joint out of bounds", TCL_VOLATILE); return TCL_ERROR; } switch (emcStatus->motion.axis[joint].axisType) { case EMC_AXIS_LINEAR: Tcl_SetResult(interp, "linear", TCL_VOLATILE); break; case EMC_AXIS_ANGULAR: Tcl_SetResult(interp, "angular", TCL_VOLATILE); break; default: Tcl_SetResult(interp, "custom", TCL_VOLATILE); break; } return TCL_OK; } Tcl_SetResult(interp, "emc_joint_type: invalid joint number", TCL_VOLATILE); return TCL_ERROR;}static int emc_joint_units(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ int joint; if (objc != 2) { Tcl_SetResult(interp, "emc_joint_units: need exactly 1 non-negative integer", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (TCL_OK == Tcl_GetIntFromObj(0, objv[1], &joint)) { if (joint < 0 || joint >= EMC_AXIS_MAX) { Tcl_SetResult(interp, "emc_joint_type: joint out of bounds", TCL_VOLATILE); return TCL_ERROR; } switch (emcStatus->motion.axis[joint].axisType) { case EMC_AXIS_LINEAR: /* try mm */ if (CLOSE(emcStatus->motion.axis[joint].units, 1.0, LINEAR_CLOSENESS)) { Tcl_SetResult(interp, "mm", TCL_VOLATILE); return TCL_OK; } /* now try inch */ else if (CLOSE (emcStatus->motion.axis[joint].units, INCH_PER_MM, LINEAR_CLOSENESS)) { Tcl_SetResult(interp, "inch", TCL_VOLATILE); return TCL_OK; } /* now try cm */ else if (CLOSE(emcStatus->motion.axis[joint].units, CM_PER_MM, LINEAR_CLOSENESS)) { Tcl_SetResult(interp, "cm", TCL_VOLATILE); return TCL_OK; } /* else it's custom */ Tcl_SetResult(interp, "custom", TCL_VOLATILE); return TCL_OK; break; case EMC_AXIS_ANGULAR: /* try degrees */ if (CLOSE(emcStatus->motion.axis[joint].units, 1.0, ANGULAR_CLOSENESS)) { Tcl_SetResult(interp, "deg", TCL_VOLATILE); return TCL_OK; } /* now try radians */ else if (CLOSE (emcStatus->motion.axis[joint].units, RAD_PER_DEG, ANGULAR_CLOSENESS)) { Tcl_SetResult(interp, "rad", TCL_VOLATILE); return TCL_OK; } /* now try grads */ else if (CLOSE (emcStatus->motion.axis[joint].units, GRAD_PER_DEG, ANGULAR_CLOSENESS)) { Tcl_SetResult(interp, "grad", TCL_VOLATILE); return TCL_OK; } /* else it's custom */ Tcl_SetResult(interp, "custom", TCL_VOLATILE); return TCL_OK; break; default: Tcl_SetResult(interp, "custom", TCL_VOLATILE); return TCL_OK; break; } } Tcl_SetResult(interp, "emc_joint_units: invalid joint number", TCL_VOLATILE); return TCL_ERROR;}static int emc_program_linear_units(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc != 1) { Tcl_SetResult(interp, "emc_program_linear_units: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } switch (emcStatus->task.programUnits) { case CANON_UNITS_INCHES: Tcl_SetResult(interp, "inch", TCL_VOLATILE); return TCL_OK; break; case CANON_UNITS_MM: Tcl_SetResult(interp, "mm", TCL_VOLATILE); return TCL_OK; break; case CANON_UNITS_CM: Tcl_SetResult(interp, "cm", TCL_VOLATILE); return TCL_OK; break; default: Tcl_SetResult(interp, "custom", TCL_VOLATILE); return TCL_OK; break; } Tcl_SetResult(interp, "custom", TCL_VOLATILE); return TCL_OK;}static int emc_program_angular_units(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc != 1) { Tcl_SetResult(interp, "emc_program_angular_units: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } // currently the EMC doesn't have separate program angular units, so // these are simply "deg" Tcl_SetResult(interp, "deg", TCL_VOLATILE); return TCL_OK;}static int emc_user_linear_units(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc != 1) { Tcl_SetResult(interp, "emc_user_linear_units: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } /* try mm */ if (CLOSE(emcStatus->motion.traj.linearUnits, 1.0, LINEAR_CLOSENESS)) { Tcl_SetResult(interp, "mm", TCL_VOLATILE); return TCL_OK; } /* now try inch */ else if (CLOSE(emcStatus->motion.traj.linearUnits, INCH_PER_MM, LINEAR_CLOSENESS)) { Tcl_SetResult(interp, "inch", TCL_VOLATILE); return TCL_OK; } /* now try cm */ else if (CLOSE(emcStatus->motion.traj.linearUnits, CM_PER_MM, LINEAR_CLOSENESS)) { Tcl_SetResult(interp, "cm", TCL_VOLATILE); return TCL_OK; } /* else it's custom */ Tcl_SetResult(interp, "custom", TCL_VOLATILE); return TCL_OK;}static int emc_user_angular_units(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc != 1) { Tcl_SetResult(interp, "emc_user_angular_units: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } /* try degrees */ if (CLOSE(emcStatus->motion.traj.angularUnits, 1.0, ANGULAR_CLOSENESS)) { Tcl_SetResult(interp, "deg", TCL_VOLATILE); return TCL_OK; } /* now try radians */ else if (CLOSE(emcStatus->motion.traj.angularUnits, RAD_PER_DEG, ANGULAR_CLOSENESS)) { Tcl_SetResult(interp, "rad", TCL_VOLATILE); return TCL_OK; } /* now try grads */ else if (CLOSE(emcStatus->motion.traj.angularUnits, GRAD_PER_DEG, ANGULAR_CLOSENESS)) { Tcl_SetResult(interp, "grad", TCL_VOLATILE); return TCL_OK; } /* else it's an abitrary number, so just return it */ Tcl_SetResult(interp, "custom", TCL_VOLATILE); return TCL_OK;}static int emc_display_linear_units(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc != 1) { Tcl_SetResult(interp, "emc_display_linear_units: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } switch (linearUnitConversion) { case LINEAR_UNITS_INCH: Tcl_SetResult(interp, "inch", TCL_VOLATILE); break; case LINEAR_UNITS_MM: Tcl_SetResult(interp, "mm", TCL_VOLATILE); break; case LINEAR_UNITS_CM: Tcl_SetResult(interp, "cm", TCL_VOLATILE); break; case LINEAR_UNITS_AUTO: switch (emcStatus->task.programUnits) { case CANON_UNITS_MM: Tcl_SetResult(interp, "(mm)", TCL_VOLATILE); break; case CANON_UNITS_INCHES: Tcl_SetResult(interp, "(inch)", TCL_VOLATILE); break; case CANON_UNITS_CM: Tcl_SetResult(interp, "(cm)", TCL_VOLATILE); break; } break; default: Tcl_SetResult(interp, "custom", TCL_VOLATILE); break; } return TCL_OK;}static int emc_display_angular_units(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc != 1) { Tcl_SetResult(interp, "emc_display_angular_units: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } switch (angularUnitConversion) { case ANGULAR_UNITS_DEG: Tcl_SetResult(interp, "deg", TCL_VOLATILE); break; case ANGULAR_UNITS_RAD: Tcl_SetResult(interp, "rad", TCL_VOLATILE); break; case ANGULAR_UNITS_GRAD: Tcl_SetResult(interp, "grad", TCL_VOLATILE); break; case ANGULAR_UNITS_AUTO: Tcl_SetResult(interp, "(deg)", TCL_VOLATILE); /*! \todo FIXME-- always deg? */ break; default: Tcl_SetResult(interp, "custom", TCL_VOLATILE); break; } return TCL_OK;}static int emc_linear_unit_conversion(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return unit setting switch (linearUnitConversion) { case LINEAR_UNITS_INCH: Tcl_SetResult(interp, "inch", TCL_VOLATILE); break; case LINEAR_UNITS_MM: Tcl_SetResult(interp, "mm", TCL_VOLATILE); break; case LINEAR_UNITS_CM: Tcl_SetResult(interp, "cm", TCL_VOLATILE); break; case LINEAR_UNITS_AUTO: Tcl_SetResult(interp, "auto", TCL_VOLATILE); break; default: Tcl_SetResult(inte
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -