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

📄 iniaxis.cc

📁 Source code for an Numeric Cmputer
💻 CC
📖 第 1 页 / 共 2 页
字号:
	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] HOME: %s\n",		     axisString, inistring);	    }	    home = 0.0;		// default	}    } else {	// not found at all	home = 0.0;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error("can't find [%s] HOME, using default\n",			    axisString);	}    }    if (NULL != (inistring = axisInifile->find("HOME_OFFSET", axisString))) {	if (1 == sscanf(inistring, "%lf", &offset)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] HOME_OFFSET: %s\n",		     axisString, inistring);	    }	    offset = 0.0;	// default	}    } else {	// not found at all	offset = 0.0;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error("can't find [%s] HOME_OFFSET, using default\n",			    axisString);	}    }    if (NULL !=	(inistring = axisInifile->find("HOME_SEARCH_VEL", axisString))) {	if (1 == sscanf(inistring, "%lf", &search_vel)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] HOME_SEARCH_VEL: %s\n",		     axisString, inistring);	    }	    search_vel = 0.0;	// default - skips entire homing process	}    } else {	// not found at all	search_vel = 0.0;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error		("can't find [%s] HOME_SEARCH_VEL, using default\n",		 axisString);	}    }    if (NULL !=	(inistring = axisInifile->find("HOME_LATCH_VEL", axisString))) {	if (1 == sscanf(inistring, "%lf", &latch_vel)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] HOME_LATCH_VEL: %s\n",		     axisString, inistring);	    }	    latch_vel = 0.0;	// default	}    } else {	// not found at all	latch_vel = 0.0;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error		("can't find [%s] HOME_LATCH_VEL, using default\n",		 axisString);	}    }    if (NULL !=	(inistring = axisInifile->find("HOME_USE_INDEX", axisString))) {	if (1 == strbool(inistring, &use_index)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] HOME_USE_INDEX: %s\n",		     axisString, inistring);	    }	    use_index = 0;	// default	}    } else {	// not found at all	use_index = 0;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error		("can't find [%s] HOME_USE_INDEX, using default\n",		 axisString);	}    }    if (NULL !=	(inistring =	 axisInifile->find("HOME_IGNORE_LIMITS", axisString))) {	if (1 == strbool(inistring, &ignore_limits)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] HOME_IGNORE_LIMITS: %s\n",		     axisString, inistring);	    }	    ignore_limits = 0;	// default	}    } else {	// not found at all	ignore_limits = 0;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error		("can't find [%s] HOME_IGNORE_LIMITS, using default\n",		 axisString);	}    }    // issue NML message to set all params    if (0 != emcAxisSetHomingParams(axis, home, offset, search_vel,				    latch_vel, use_index, ignore_limits)) {	if (EMC_DEBUG & EMC_DEBUG_CONFIG) {	    rcs_print_error("bad return from emcAxisSetHomingParams\n");	}	return -1;    }    // set maximum velocity    if (NULL !=	(inistring = axisInifile->find("MAX_VELOCITY", axisString))) {	if (1 == sscanf(inistring, "%lf", &maxVelocity)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] MAX_VELOCITY: %s\n",		     axisString, inistring);	    }	    maxVelocity = DEFAULT_AXIS_MAX_VELOCITY;	// default	}    } else {	// not found at all	maxVelocity = DEFAULT_AXIS_MAX_VELOCITY;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error		("can't find [%s] MAX_VELOCITY, using default\n",		 axisString);	}    }    if (0 != emcAxisSetMaxVelocity(axis, maxVelocity)) {	if (EMC_DEBUG & EMC_DEBUG_CONFIG) {	    rcs_print_error("bad return from emcAxisSetMaxVelocity\n");	}	return -1;    }    if (NULL !=	(inistring = axisInifile->find("MAX_ACCELERATION", axisString))) {	if (1 == sscanf(inistring, "%lf", &maxAcceleration)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [%s] MAX_ACCELERATION: %s\n",		     axisString, inistring);	    }	    maxAcceleration = DEFAULT_AXIS_MAX_ACCELERATION;	// default	}    } else {	// not found at all	maxAcceleration = DEFAULT_AXIS_MAX_ACCELERATION;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error		("can't find [%s] MAX_ACCELERATION, using default\n",		 axisString);	}    }    if (0 != emcAxisSetMaxAcceleration(axis, maxAcceleration)) {	if (EMC_DEBUG & EMC_DEBUG_CONFIG) {	    rcs_print_error("bad return from emcAxisSetMaxAcceleration\n");	}	return -1;    }    if (NULL != (inistring = axisInifile->find("COMP_FILE", axisString))) {	if (0 != emcAxisLoadComp(axis, inistring)) {	    if (EMC_DEBUG & EMC_DEBUG_CONFIG) {		rcs_print_error("bad return from emcAxisLoadComp\n");	    }	    return -1;	}    }    // else not found, so ignore    // lastly, activate axis. Do this last so that the motion controller    // won't flag errors midway during configuration    emcAxisActivate(axis);    return 0;}/*  iniAxis(int axis, const char *filename)  Loads ini file parameters for specified axis, [0 .. AXES - 1]  Looks for AXES in TRAJ section for how many to do, up to  EMC_AXIS_MAX. */int iniAxis(int axis, const char *filename){    int retval = 0;    const char *inistring;    int axes;    axisInifile = new Inifile;    if (axisInifile->open(filename) == false) {	return -1;    }    if (NULL != (inistring = axisInifile->find("AXES", "TRAJ"))) {	if (1 == sscanf(inistring, "%d", &axes)) {	    // found, and valid	} else {	    // found, but invalid	    if (EMC_DEBUG & EMC_DEBUG_INVALID) {		rcs_print_error		    ("invalid inifile value for [TRAJ] AXES: %s\n",		     inistring);	    }	    axes = 0;	}    } else {	// not found at all	axes = 1;	if (EMC_DEBUG & EMC_DEBUG_DEFAULTS) {	    rcs_print_error("can't find [TRAJ] AXES, using default %d\n",			    axes);	}    }    if (axis < 0 || axis >= axes) {	// requested axis exceeds machine axes	axisInifile->close();	delete axisInifile;	return -1;    }    // load its values    if (0 != loadAxis(axis)) {	retval = -1;    }    // close the inifile    axisInifile->close();    delete axisInifile;    return retval;}/*! \todo FIXME-- begin temporary insert of ini file stuff */#define INIFILE_MIN_FLOAT_PRECISION 3#define INIFILE_BACKUP_SUFFIX ".bak"int iniGetFloatPrec(const char *str){    const char *ptr = str;    int prec = 0;    // find '.', return min precision if no decimal point    while (1) {	if (*ptr == 0) {	    return INIFILE_MIN_FLOAT_PRECISION;	}	if (*ptr == '.') {	    break;	}	ptr++;    }    // ptr is on '.', so step over    ptr++;    // count number of digits until whitespace or end or non-digit    while (1) {	if (*ptr == 0) {	    break;	}	if (!isdigit(*ptr)) {	    break;	}	// else it's a digit	prec++;	ptr++;    }    return prec >	INIFILE_MIN_FLOAT_PRECISION ? prec : INIFILE_MIN_FLOAT_PRECISION;}int iniFormatFloat(char *fmt, const char *var, const char *val){    sprintf(fmt, "%s = %%.%df\n", var, iniGetFloatPrec(val));    return 0;}// 'val' in this case is a string with a pair of floats, the first// which sets the precisionint iniFormatFloat2(char *fmt, const char *var, const char *val){    int prec;    /*! \todo FIXME-- should capture each one's float precision; right       now we're using the first as the precision for both */    prec = iniGetFloatPrec(val);    sprintf(fmt, "%s = %%.%df %%.%df\n", var, prec, prec);    return 0;}// end temporary insert of ini file stuff/*  dumpAxis(int axis, const char *filename, EMC_AXIS_STAT *status)  This used to rewrite an AXIS_n section of the ini file.  Everyone  now seems to think this is a bad idea.  It's certainly incompatible  with template/sample configurations that should not be changed by  the user OR the program. */int dumpAxis(int axis, const char *filename, EMC_AXIS_STAT * status){    return 0;}

⌨️ 快捷键说明

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