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

📄 emccanon.cc

📁 Source code for an Numeric Cmputer
💻 CC
📖 第 1 页 / 共 4 页
字号:
    CANON_POSITION position;    EmcPose pos;    pos = emcStatus->motion.traj.position;    // first update internal record of last position    canonEndPoint.x = FROM_EXT_LEN(pos.tran.x);    canonEndPoint.y = FROM_EXT_LEN(pos.tran.y);    canonEndPoint.z = FROM_EXT_LEN(pos.tran.z);    canonEndPoint.a = FROM_EXT_ANG(pos.a);    canonEndPoint.b = FROM_EXT_ANG(pos.b);    canonEndPoint.c = FROM_EXT_ANG(pos.c);    // now calculate position in program units, for interpreter    position.x = TO_PROG_LEN(canonEndPoint.x - programOrigin.x);    position.y = TO_PROG_LEN(canonEndPoint.y - programOrigin.y);    position.z =	TO_PROG_LEN(canonEndPoint.z - programOrigin.z -		    currentToolLengthOffset);    position.a = TO_PROG_ANG(canonEndPoint.a - programOrigin.a);    position.b = TO_PROG_ANG(canonEndPoint.b - programOrigin.b);    position.c = TO_PROG_ANG(canonEndPoint.c - programOrigin.c);    return position;}CANON_POSITION GET_EXTERNAL_PROBE_POSITION(){    CANON_POSITION position;    EmcPose pos;    static CANON_POSITION last_probed_position;    pos = emcStatus->motion.traj.probedPosition;    // first update internal record of last position    canonEndPoint.x = FROM_EXT_LEN(pos.tran.x) - programOrigin.x;    canonEndPoint.y = FROM_EXT_LEN(pos.tran.y) - programOrigin.y;    canonEndPoint.z = FROM_EXT_LEN(pos.tran.z) - programOrigin.z;    canonEndPoint.z -= currentToolLengthOffset;    canonEndPoint.a = FROM_EXT_ANG(pos.a) - programOrigin.a;    canonEndPoint.b = FROM_EXT_ANG(pos.b) - programOrigin.b;    canonEndPoint.c = FROM_EXT_ANG(pos.c) - programOrigin.c;    // now calculate position in program units, for interpreter    position.x = TO_PROG_LEN(canonEndPoint.x);    position.y = TO_PROG_LEN(canonEndPoint.y);    position.z = TO_PROG_LEN(canonEndPoint.z);    position.z -= TO_PROG_LEN(currentToolLengthOffset);    position.a = TO_PROG_ANG(canonEndPoint.a);    position.b = TO_PROG_ANG(canonEndPoint.b);    position.c = TO_PROG_ANG(canonEndPoint.c);    /*! \todo FIXME-- back end of hot comment */    if (probefile != NULL) {	if (last_probed_position.x != position.x ||	    last_probed_position.y != position.y ||	    last_probed_position.z != position.z) {	    fprintf(probefile, "%f %f %f\n", position.x, position.y,		    position.z);	    last_probed_position = position;	}    }    return position;}double GET_EXTERNAL_PROBE_VALUE(){    // only for analog non-contact probe, so force a 0    return 0.0;}int IS_EXTERNAL_QUEUE_EMPTY(){    return emcStatus->motion.traj.queue == 0 ? 1 : 0;}// feed rate wanted is in program units per minutedouble GET_EXTERNAL_FEED_RATE(){    double feed;    // convert from internal to program units    // it is wrong to use emcStatus->motion.traj.velocity here, as that is the traj speed regardless of G0 / G1    feed = TO_PROG_LEN(currentLinearFeedRate);    // now convert from per-sec to per-minute    feed *= 60.0;    return feed;}// traverse rate wanted is in program units per minutedouble GET_EXTERNAL_TRAVERSE_RATE(){    double traverse;    // convert from external to program units    traverse =	TO_PROG_LEN(FROM_EXT_LEN(emcStatus->motion.traj.maxVelocity));    // now convert from per-sec to per-minute    traverse *= 60.0;    return traverse;}double GET_EXTERNAL_LENGTH_UNITS(void){    double u;    u = emcStatus->motion.traj.linearUnits;    if (u == 0) {	CANON_ERROR("external length units are zero");	return 1.0;    } else {	return u;    }}double GET_EXTERNAL_ANGLE_UNITS(void){    double u;    u = emcStatus->motion.traj.angularUnits;    if (u == 0) {	CANON_ERROR("external angle units are zero");	return 1.0;    } else {	return u;    }}int GET_EXTERNAL_TOOL(){    return emcStatus->io.tool.toolInSpindle;}int GET_EXTERNAL_MIST(){    return emcStatus->io.coolant.mist;}int GET_EXTERNAL_FLOOD(){    return emcStatus->io.coolant.flood;}int GET_EXTERNAL_POCKET(){    return emcStatus->io.tool.toolPrepped;}double GET_EXTERNAL_SPEED(){    // speed is in RPMs everywhere    return emcStatus->io.spindle.speed;}CANON_DIRECTION GET_EXTERNAL_SPINDLE(){    if (emcStatus->io.spindle.speed == 0) {	return CANON_STOPPED;    }    if (emcStatus->io.spindle.speed >= 0.0) {	return CANON_CLOCKWISE;    }    return CANON_COUNTERCLOCKWISE;}int GET_EXTERNAL_TOOL_MAX(){    return CANON_TOOL_MAX;}char _parameter_file_name[LINELEN];	/* Not static.Driver					   writes */void GET_EXTERNAL_PARAMETER_FILE_NAME(char *file_name,	/* string: to copy							   file name into */				      int max_size){				/* maximum number of characters to copy */    // Paranoid checks    if (0 == file_name)	return;    if (max_size < 0)	return;    if (strlen(_parameter_file_name) < ((size_t) max_size))	strcpy(file_name, _parameter_file_name);    else	file_name[0] = 0;}double GET_EXTERNAL_POSITION_X(void){    CANON_POSITION position;    position = GET_EXTERNAL_POSITION();    return position.x;}double GET_EXTERNAL_POSITION_Y(void){    CANON_POSITION position;    position = GET_EXTERNAL_POSITION();    return position.y;}double GET_EXTERNAL_POSITION_Z(void){    CANON_POSITION position;    position = GET_EXTERNAL_POSITION();    return position.z;}double GET_EXTERNAL_POSITION_A(void){    CANON_POSITION position;    position = GET_EXTERNAL_POSITION();    return position.a;}double GET_EXTERNAL_POSITION_B(void){    CANON_POSITION position;    position = GET_EXTERNAL_POSITION();    return position.b;}double GET_EXTERNAL_POSITION_C(void){    CANON_POSITION position;    position = GET_EXTERNAL_POSITION();    return position.c;}double GET_EXTERNAL_PROBE_POSITION_X(void){    CANON_POSITION position;    position = GET_EXTERNAL_PROBE_POSITION();    return position.x;}double GET_EXTERNAL_PROBE_POSITION_Y(void){    CANON_POSITION position;    position = GET_EXTERNAL_PROBE_POSITION();    return position.y;}double GET_EXTERNAL_PROBE_POSITION_Z(void){    CANON_POSITION position;    position = GET_EXTERNAL_PROBE_POSITION();    return position.z;}double GET_EXTERNAL_PROBE_POSITION_A(void){    CANON_POSITION position;    position = GET_EXTERNAL_PROBE_POSITION();    return position.a;}double GET_EXTERNAL_PROBE_POSITION_B(void){    CANON_POSITION position;    position = GET_EXTERNAL_PROBE_POSITION();    return position.b;}double GET_EXTERNAL_PROBE_POSITION_C(void){    CANON_POSITION position;    position = GET_EXTERNAL_PROBE_POSITION();    return position.c;}CANON_MOTION_MODE GET_EXTERNAL_MOTION_CONTROL_MODE(){    return canonMotionMode;}double GET_EXTERNAL_MOTION_CONTROL_TOLERANCE(){    return canonMotionTolerance;}CANON_UNITS GET_EXTERNAL_LENGTH_UNIT_TYPE(){    return lengthUnits;}int GET_EXTERNAL_QUEUE_EMPTY(void){    return emcStatus->motion.traj.queue == 0 ? 1 : 0;}int GET_EXTERNAL_TOOL_SLOT(){    return emcStatus->io.tool.toolInSpindle;}int GET_EXTERNAL_SELECTED_TOOL_SLOT(){    return emcStatus->io.tool.toolPrepped;}CANON_PLANE GET_EXTERNAL_PLANE(){    return activePlane;}USER_DEFINED_FUNCTION_TYPE USER_DEFINED_FUNCTION[USER_DEFINED_FUNCTION_NUM]    = { 0 };int USER_DEFINED_FUNCTION_ADD(USER_DEFINED_FUNCTION_TYPE func, int num){    if (num < 0 || num >= USER_DEFINED_FUNCTION_NUM) {	return -1;    }    USER_DEFINED_FUNCTION[num] = func;    return 0;}/*! \function SET_MOTION_OUTPUT_BIT  sets a DIO pin  this message goes to task, then to motion which sets the DIO   when the first motion starts.  The pin gets set with value 1 at the begin of motion, and stays 1 at the end of motion  (this behaviour can be changed if needed)    warning: setting more then one for a motion segment will clear out the previous ones   (the TP doesn't implement a queue of these),   use SET_AUX_OUTPUT_BIT instead, that allows to set the value right away*/void SET_MOTION_OUTPUT_BIT(int index){  EMC_MOTION_SET_DOUT dout_msg;  dout_msg.index = index;  dout_msg.start = 1;		// startvalue = 1  dout_msg.end = 1;		// endvalue = 1, means it doesn't get reset after current motion  dout_msg.now = 0;		// not immediate, but synched with motion (goes to the TP)  interp_list.append(dout_msg);  return;}/*! \function CLEAR_MOTION_OUTPUT_BIT  clears a DIO pin  this message goes to task, then to motion which clears the DIO   when the first motion starts.  The pin gets set with value 0 at the begin of motion, and stays 0 at the end of motion  (this behaviour can be changed if needed)    warning: setting more then one for a motion segment will clear out the previous ones   (the TP doesn't implement a queue of these),   use CLEAR_AUX_OUTPUT_BIT instead, that allows to set the value right away*/void CLEAR_MOTION_OUTPUT_BIT(int index){  EMC_MOTION_SET_DOUT dout_msg;  dout_msg.index = index;  dout_msg.start = 0;           // startvalue = 1  dout_msg.end = 0;		// endvalue = 0, means it stays 0 after current motion  dout_msg.now = 0;		// not immediate, but synched with motion (goes to the TP)  interp_list.append(dout_msg);  return;}/*! \function SET_AUX_OUTPUT_BIT  sets a DIO pin  this message goes to task, then to motion which sets the DIO   right away.  The pin gets set with value 1 at the begin of motion, and stays 1 at the end of motion  (this behaviour can be changed if needed)  you can use any number of these, as the effect is imediate  */void SET_AUX_OUTPUT_BIT(int index){/* we're gonna use the EMC_MOTION_SET_DOUT for now  EMC_AUX_DIO_WRITE dio_msg;  dio_msg.index = index;  dio_msg.value = 1;  interp_list.append(dio_msg); */  EMC_MOTION_SET_DOUT dout_msg;  dout_msg.index = index;  dout_msg.start = 1;		// startvalue = 1  dout_msg.end = 1;		// endvalue = 1, means it doesn't get reset after current motion  dout_msg.now = 1;		// immediate, we don't care about synching for AUX  interp_list.append(dout_msg);  return;}/*! \function CLEAR_AUX_OUTPUT_BIT  clears a DIO pin  this message goes to task, then to motion which clears the DIO   right away.  The pin gets set with value 0 at the begin of motion, and stays 0 at the end of motion  (this behaviour can be changed if needed)  you can use any number of these, as the effect is imediate  */void CLEAR_AUX_OUTPUT_BIT(int index){/* we're gonna use the EMC_MOTION_SET_DOUT for now  EMC_AUX_DIO_WRITE dio_msg;  dio_msg.index = index;  dio_msg.value = 0;  interp_list.append(dio_msg);*/  EMC_MOTION_SET_DOUT dout_msg;  dout_msg.index = index;  dout_msg.start = 0;           // startvalue = 1  dout_msg.end = 0;		// endvalue = 0, means it stays 0 after current motion  dout_msg.now = 1;		// immediate, we don't care about synching for AUX  interp_list.append(dout_msg);  return;}/*! \function SET_MOTION_OUTPUT_VALUE  sets a AIO value, not used by the RS274 Interp,  not fully implemented in the motion controller either*/void SET_MOTION_OUTPUT_VALUE(int index, double value){  EMC_MOTION_SET_AOUT aout_msg;  aout_msg.index = index;	// which output  aout_msg.start = value;	// start value  aout_msg.end = value;		// end value  aout_msg.now = 0;		// immediate=1, or synched when motion start=0  interp_list.append(aout_msg);  return;}/*! \function SET_AUX_OUTPUT_VALUE  sets a AIO value, not used by the RS274 Interp,  not fully implemented in the motion controller either*/void SET_AUX_OUTPUT_VALUE(int index, double value){  EMC_AUX_AIO_WRITE aio_msg;  aio_msg.index = index;  aio_msg.value = value;  interp_list.append(aio_msg);  return;}

⌨️ 快捷键说明

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