📄 emcsh.cc
字号:
} } Tcl_SetResult(interp, "emc_wait: need 'received' or 'done'", TCL_VOLATILE); return TCL_ERROR;}static int emc_set_timeout(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ double timeout; Tcl_Obj *timeout_obj; if (objc == 1) { timeout_obj = Tcl_NewDoubleObj(emcTimeout); Tcl_SetObjResult(interp, timeout_obj); return TCL_OK; } if (objc == 2) { if (TCL_OK == Tcl_GetDoubleFromObj(0, objv[1], &timeout)) { emcTimeout = timeout; return TCL_OK; } } Tcl_SetResult(interp, "emc_set_timeout: need time as real number", TCL_VOLATILE); return TCL_ERROR;}static int emc_update(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status updateStatus(); return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "none")) { emcUpdateType = EMC_UPDATE_NONE; return TCL_OK; } if (!strcmp(objstr, "auto")) { emcUpdateType = EMC_UPDATE_AUTO; return TCL_OK; } } return TCL_OK;}static int emc_time(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc == 1) {#if defined(LINUX_KERNEL_2_2) /*! \todo FIXME-- Linux 2.2 has gettimeofday() bug, so return 0 */ Tcl_SetObjResult(interp, Tcl_NewDoubleObj(0.0));#else Tcl_SetObjResult(interp, Tcl_NewDoubleObj(etime()));#endif return TCL_OK; } Tcl_SetResult(interp, "emc_time: needs no arguments", TCL_VOLATILE); return TCL_ERROR;}static int emc_error(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc == 1) { // get any new error, it's saved in global error_string[] if (0 != updateError()) { Tcl_SetResult(interp, "emc_error: bad status from EMC", TCL_VOLATILE); return TCL_ERROR; } // put error on result list if (error_string[0] == 0) { Tcl_SetResult(interp, "ok", TCL_VOLATILE); } else { Tcl_SetResult(interp, error_string, TCL_VOLATILE); error_string[0] = 0; } return TCL_OK; } Tcl_SetResult(interp, "emc_error: need no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_operator_text(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc == 1) { // get any new string, it's saved in global operator_text_string[] if (0 != updateError()) { Tcl_SetResult(interp, "emc_operator_text: bad status from EMC", TCL_VOLATILE); return TCL_ERROR; } // put error on result list if (operator_text_string[0] == 0) { Tcl_SetResult(interp, "ok", TCL_VOLATILE); operator_text_string[0] = 0; } else { Tcl_SetResult(interp, operator_text_string, TCL_VOLATILE); } return TCL_OK; } Tcl_SetResult(interp, "emc_operator_text: need no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_operator_display(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc == 1) { // get any new string, it's saved in global operator_display_string[] if (0 != updateError()) { Tcl_SetResult(interp, "emc_operator_display: bad status from EMC", TCL_VOLATILE); return TCL_ERROR; } // put error on result list if (operator_display_string[0] == 0) { Tcl_SetResult(interp, "ok", TCL_VOLATILE); } else { Tcl_SetResult(interp, operator_display_string, TCL_VOLATILE); operator_display_string[0] = 0; } return TCL_OK; } Tcl_SetResult(interp, "emc_operator_display: need no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_estop(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->task.state == EMC_TASK_STATE_ESTOP) { Tcl_SetResult(interp, "on", TCL_VOLATILE); } else { Tcl_SetResult(interp, "off", TCL_VOLATILE); } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "on")) { sendEstop(); return TCL_OK; } if (!strcmp(objstr, "off")) { sendEstopReset(); return TCL_OK; } } Tcl_SetResult(interp, "emc_estop: need 'on', 'off', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_machine(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->task.state == EMC_TASK_STATE_ON) { Tcl_SetResult(interp, "on", TCL_VOLATILE); } else { Tcl_SetResult(interp, "off", TCL_VOLATILE); } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "on")) { sendMachineOn(); return TCL_OK; } if (!strcmp(objstr, "off")) { sendMachineOff(); return TCL_OK; } } Tcl_SetResult(interp, "emc_machine: need 'on', 'off', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_mode(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } switch (emcStatus->task.mode) { case EMC_TASK_MODE_MANUAL: Tcl_SetResult(interp, "manual", TCL_VOLATILE); break; case EMC_TASK_MODE_AUTO: Tcl_SetResult(interp, "auto", TCL_VOLATILE); break; case EMC_TASK_MODE_MDI: Tcl_SetResult(interp, "mdi", TCL_VOLATILE); break; default: Tcl_SetResult(interp, "?", TCL_VOLATILE); break; } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "manual")) { sendManual(); return TCL_OK; } if (!strcmp(objstr, "auto")) { sendAuto(); return TCL_OK; } if (!strcmp(objstr, "mdi")) { sendMdi(); return TCL_OK; } } Tcl_SetResult(interp, "emc_mode: need 'manual', 'auto', 'mdi', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_mist(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->io.coolant.mist == 1) { Tcl_SetResult(interp, "on", TCL_VOLATILE); } else { Tcl_SetResult(interp, "off", TCL_VOLATILE); } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "on")) { sendMistOn(); return TCL_OK; } if (!strcmp(objstr, "off")) { sendMistOff(); return TCL_OK; } } Tcl_SetResult(interp, "emc_mist: need 'on', 'off', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_flood(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->io.coolant.flood == 1) { Tcl_SetResult(interp, "on", TCL_VOLATILE); } else { Tcl_SetResult(interp, "off", TCL_VOLATILE); } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "on")) { sendFloodOn(); return TCL_OK; } if (!strcmp(objstr, "off")) { sendFloodOff(); return TCL_OK; } } Tcl_SetResult(interp, "emc_flood: need 'on', 'off', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_lube(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->io.lube.on == 0) { Tcl_SetResult(interp, "off", TCL_VOLATILE); } else { Tcl_SetResult(interp, "on", TCL_VOLATILE); } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "on")) { sendLubeOn(); return TCL_OK; } if (!strcmp(objstr, "off")) { sendLubeOff(); return TCL_OK; } } Tcl_SetResult(interp, "emc_lube: need 'on', 'off', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_lube_level(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->io.lube.level == 0) { Tcl_SetResult(interp, "low", TCL_VOLATILE); } else { Tcl_SetResult(interp, "ok", TCL_VOLATILE); } return TCL_OK; } Tcl_SetResult(interp, "emc_lube_level: need no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_spindle(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->motion.spindle.increasing > 0) { Tcl_SetResult(interp, "increase", TCL_VOLATILE); } else if (emcStatus->motion.spindle.increasing < 0) { Tcl_SetResult(interp, "decrease", TCL_VOLATILE); } else if (emcStatus->motion.spindle.direction > 0) { Tcl_SetResult(interp, "forward", TCL_VOLATILE); } else if (emcStatus->motion.spindle.direction < 0) { Tcl_SetResult(interp, "reverse", TCL_VOLATILE); } else { Tcl_SetResult(interp, "off", TCL_VOLATILE); } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "forward")) { sendSpindleForward(); return TCL_OK; } if (!strcmp(objstr, "reverse")) { sendSpindleReverse(); return TCL_OK; } if (!strcmp(objstr, "increase")) { sendSpindleIncrease(); return TCL_OK; } if (!strcmp(objstr, "decrease")) { sendSpindleDecrease(); return TCL_OK; } if (!strcmp(objstr, "constant")) { sendSpindleConstant(); return TCL_OK; } if (!strcmp(objstr, "off")) { sendSpindleOff(); return TCL_OK; } } Tcl_SetResult(interp, "emc_spindle: need 'on', 'off', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_brake(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ char *objstr; if (objc == 1) { // no arg-- return status if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } if (emcStatus->motion.spindle.brake == 1) { Tcl_SetResult(interp, "on", TCL_VOLATILE); } else { Tcl_SetResult(interp, "off", TCL_VOLATILE); } return TCL_OK; } if (objc == 2) { objstr = Tcl_GetStringFromObj(objv[1], 0); if (!strcmp(objstr, "on")) { sendBrakeEngage(); return TCL_OK; } if (!strcmp(objstr, "off")) { sendBrakeRelease(); return TCL_OK; } } Tcl_SetResult(interp, "emc_brake: need 'on', 'off', or no args", TCL_VOLATILE); return TCL_ERROR;}static int emc_tool(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ Tcl_Obj *toolobj; if (objc != 1) { Tcl_SetResult(interp, "emc_tool: need no args", TCL_VOLATILE); return TCL_ERROR; } if (emcUpdateType == EMC_UPDATE_AUTO) { updateStatus(); } toolobj = Tcl_NewIntObj(emcStatus->io.tool.toolInSpindle); Tcl_SetObjResult(interp, toolobj); return TCL_OK;}static int emc_tool_offset(ClientData clientdata, Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[]){ Tcl_Obj *tlobj;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -