⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emcsh.cc

📁 Source code for an Numeric Cmputer
💻 CC
📖 第 1 页 / 共 5 页
字号:
			  "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->io.spindle.increasing > 0) {	    Tcl_SetResult(interp, "increase", TCL_VOLATILE);	} else if (emcStatus->io.spindle.increasing < 0) {	    Tcl_SetResult(interp, "decrease", TCL_VOLATILE);	} else if (emcStatus->io.spindle.direction > 0) {	    Tcl_SetResult(interp, "forward", TCL_VOLATILE);	} else if (emcStatus->io.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->io.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;    if (objc != 1) {	Tcl_SetResult(interp, "emc_tool_offset: need no args",		      TCL_VOLATILE);	return TCL_ERROR;    }    if (emcUpdateType == EMC_UPDATE_AUTO) {	updateStatus();    }    tlobj =	Tcl_NewDoubleObj(convertLinearUnits			 (emcStatus->task.toolOffset.tran.z));    Tcl_SetObjResult(interp, tlobj);    return TCL_OK;}static int emc_load_tool_table(ClientData clientdata,			       Tcl_Interp * interp, int objc,			       Tcl_Obj * CONST objv[]){    if (objc != 2) {	Tcl_SetResult(interp, "emc_load_tool_table: need file",		      TCL_VOLATILE);	return TCL_ERROR;    }    if (0 != sendLoadToolTable(Tcl_GetStringFromObj(objv[1], 0))) {	Tcl_SetResult(interp, "emc_load_tool_table: can't open file",		      TCL_VOLATILE);	return TCL_OK;    }    return TCL_OK;}static int emc_set_tool_offset(ClientData clientdata,			       Tcl_Interp * interp, int objc,			       Tcl_Obj * CONST objv[]){    int tool;    double length;    double diameter;    if (objc != 4) {	Tcl_SetResult(interp,		      "emc_set_tool_offset: need <tool> <length> <diameter>",		      TCL_VOLATILE);	return TCL_ERROR;    }    if (0 != Tcl_GetIntFromObj(0, objv[1], &tool)) {	Tcl_SetResult(interp,		      "emc_set_tool_offset: need tool as integer, 0..",		      TCL_VOLATILE);	return TCL_ERROR;    }    if (0 != Tcl_GetDoubleFromObj(0, objv[2], &length)) {	Tcl_SetResult(interp,		      "emc_set_tool_offset: need length as real number",		      TCL_VOLATILE);	return TCL_ERROR;    }    if (0 != Tcl_GetDoubleFromObj(0, objv[3], &diameter)) {	Tcl_SetResult(interp,		      "emc_set_tool_offset: need diameter as real number",		      TCL_VOLATILE);	return TCL_ERROR;    }    if (0 != sendToolSetOffset(tool, length, diameter)) {	Tcl_SetResult(interp, "emc_set_tool_offset: can't set it",		      TCL_VOLATILE);	return TCL_OK;    }    return TCL_OK;}static int emc_abs_cmd_pos(ClientData clientdata,			   Tcl_Interp * interp, int objc,			   Tcl_Obj * CONST objv[]){    int axis;    Tcl_Obj *posobj;    if (objc != 2) {	Tcl_SetResult(interp,		      "emc_abs_cmd_pos: 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], &axis)) {	if (axis == 0) {	    posobj =		Tcl_NewDoubleObj(convertLinearUnits(emcStatus->motion.traj.						    position.tran.x));	} else if (axis == 1) {	    posobj =		Tcl_NewDoubleObj(convertLinearUnits(emcStatus->motion.traj.						    position.tran.y));	} else if (axis == 2) {	    posobj =		Tcl_NewD

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -