Skip to content

Commit 33dec06

Browse files
c-morleySebKuzminsky
authored andcommitted
emc: add a system param :_metric_machine
we read the INI file to check [TRAJ]LINEAR_AXES for 'inch'. and then set th eparam accordingly. Useful for remaps to decide how some varibles should be interpreted. (cherry picked from commit fc01702)
1 parent 30f7380 commit 33dec06

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

src/emc/rs274ngc/interp_namedparams.cc

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,6 @@ int Interp::lookup_named_param(const char *nameBuf,
744744
*value = _task;
745745
break;
746746

747-
748747
default:
749748
ERS(_("BUG: lookup_named_param(%s): unhandled index=%fn"),
750749
nameBuf,index);
@@ -781,12 +780,16 @@ int Interp::init_named_parameters()
781780
const char *pkgversion = PACKAGE_VERSION; //examples: 2.4.6, 2.5.0~pre
782781
const char *version_major = "_vmajor";// named_parameter name (use lower case)
783782
const char *version_minor = "_vminor";// named_parameter name (use lower case)
784-
double vmajor=0.0, vminor=0.0;
783+
const char *metric_machine = "_metric_machine";// named_parameter name (use lower case)
784+
double vmajor=0.0, vminor=0.0, munits = 1.0;
785785
sscanf(pkgversion, "%lf%lf", &vmajor, &vminor);
786786

787787
init_readonly_param(version_major,vmajor,0);
788788
init_readonly_param(version_minor,vminor,0);
789789

790+
munits = inicheck();
791+
init_readonly_param(metric_machine,munits,0);
792+
790793
// params tagged with PA_USE_LOOKUP will call the lookup_named_param()
791794
// method. The value is used as a index for the switch() statement.
792795

@@ -906,3 +909,32 @@ int Interp::init_named_parameters()
906909

907910
return INTERP_OK;
908911
}
912+
913+
double Interp::inicheck()
914+
{
915+
IniFile inifile;
916+
const char *filename;
917+
const char *inistring;
918+
double result = -1.0;
919+
920+
if ((filename = getenv("INI_FILE_NAME")) == NULL) {
921+
return -1.0;
922+
}
923+
924+
// open it
925+
if (inifile.Open(filename) == false) {
926+
return -1.0;
927+
}
928+
929+
if (NULL != (inistring = inifile.Find("LINEAR_UNITS", "TRAJ"))) {
930+
if (!strcmp(inistring, "inch")) {
931+
result = 0.0;
932+
} else {
933+
result = 1.0;
934+
}
935+
}
936+
// close it
937+
inifile.Close();
938+
939+
return result;
940+
}

src/emc/rs274ngc/rs274ngc_interp.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public:
134134
int add_named_param(const char *nameBuf, int attr = 0);
135135
int fetch_ini_param( const char *nameBuf, int *status, double *value);
136136
int fetch_hal_param( const char *nameBuf, int *status, double *value);
137+
double inicheck();
137138

138139
// common combination of add_named_param and store_named_param
139140
// int assign_named_param(const char *nameBuf, int attr = 0, double value = 0.0);

0 commit comments

Comments
 (0)