Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

stripemcmoti.cc

Go to the documentation of this file.
00001 /*
00002 
00003  Modifications:
00004  19-Aug-2001 P.C. Some of the variables needed are found in EMCMOT_DEBUG
00005  and EMCMOT_CONFIG structs in emcmot.h
00006  */
00007 
00008 
00009 extern "C" {
00010 extern double gstrip_emcmot_get(void *);
00011 extern void * gstrip_emcmot_open(const char *);
00012 }
00013 
00014 #include <stdlib.h>
00015 #include <stdio.h>
00016 #include <string.h>
00017 #include <math.h>
00018 
00019 #include "emcmot.h"
00020 #include "mbuff.h"
00021 
00022 static int first_emcmot_variable = 1;
00023 static int no_emcmot_stat_channel=0;
00024 struct EMCMOT_STRUCT *emcmotStruct=NULL;
00025 
00026 struct emcmot_data
00027 {
00028   int variable_number;
00029   int first;
00030 };
00031 
00032 static double get_emcmot_variable_value(int varnum);
00033 static int get_emcmot_variable_id(const char *str);
00034 
00035 double gstrip_emcmot_get(void *p)
00036 {
00037   return get_emcmot_variable_value(((emcmot_data *)p)->variable_number);
00038 }
00039 
00040 
00041 void * gstrip_emcmot_open(const char *str)
00042 {
00043   struct emcmot_data *nd = NULL;
00044   int varnum=-1;
00045 
00046   if(no_emcmot_stat_channel)
00047     {
00048       return NULL;
00049     }
00050 
00051   emcmotStruct = (EMCMOT_STRUCT *) mbuff_alloc("emcmotStruct",sizeof(EMCMOT_STRUCT));
00052  if(emcmotStruct == NULL)
00053    {
00054      fprintf(stderr,"mbuff_alloc failed.\n");
00055      no_emcmot_stat_channel = 1;
00056      return(NULL);
00057    }
00058 
00059  varnum = get_emcmot_variable_id(str);
00060  if(varnum < 0)
00061    {
00062      fprintf(stderr,"Bad variable name: %s\n",str);
00063      return NULL;
00064    }
00065  else
00066    {
00067      nd = (struct emcmot_data *) malloc(sizeof(struct emcmot_data));
00068      nd->variable_number = varnum;
00069      nd->first = first_emcmot_variable;
00070       first_emcmot_variable = 0;
00071       return nd;
00072     }
00073   return NULL;
00074 }
00075 
00076 
00077 static int get_emcmot_variable_id(const char *str)
00078 {
00079   if(!strcmp("heartbeat",str))
00080     {
00081       return 1;
00082     }
00083   else if(!strcmp("computeTime",str))
00084     {
00085       return 2;
00086     }
00087   else if(!strcmp("pos.tran.x",str))
00088     {
00089       return 3;
00090     }
00091   else if(!strcmp("pos.tran.y",str))
00092     {
00093       return 4;
00094     }
00095   else if(!strcmp("pos.tran.z",str))
00096     {
00097       return 5;
00098     }
00099   else if(!strcmp("axisPos[0]",str))
00100     {
00101       return 6;
00102     }
00103   else if(!strcmp("axisPos[1]",str))
00104     {
00105       return 7;
00106     }
00107   else if(!strcmp("axisPos[2]",str))
00108     {
00109       return 8;
00110     }
00111   else if(!strcmp("ferrorCurrent[0]",str))
00112     {
00113       return 9;
00114     }
00115   else if(!strcmp("ferrorCurrent[1]",str))
00116     {
00117       return 10;
00118     }
00119   else if(!strcmp("ferrorCurrent[2]",str))
00120     {
00121       return 11;
00122     }
00123   else if(!strcmp("ferrorHighMark[0]",str))
00124     {
00125       return 12;
00126     }
00127   else if(!strcmp("ferrorHighMark[1]",str))
00128     {
00129       return 13;
00130     }
00131   else if(!strcmp("ferrorHighMark[2]",str))
00132     {
00133       return 14;
00134     }
00135   else if(!strcmp("output[0]",str))
00136     {
00137       return 15;
00138     }
00139   else if(!strcmp("output[1]",str))
00140     {
00141       return 16;
00142     }
00143   else if(!strcmp("output[2]",str))
00144     {
00145       return 17;
00146     }
00147   else if(!strcmp("input[0]",str))
00148     {
00149       return 18;
00150     }
00151   else if(!strcmp("input[1]",str))
00152     {
00153       return 19;
00154     }
00155   else if(!strcmp("input[2]",str))
00156     {
00157       return 20;
00158     }
00159   else if(!strcmp("actualPos.tran.x",str))
00160     {
00161       return 21;
00162     }
00163   else if(!strcmp("actualPos.tran.y",str))
00164     {
00165       return 22;
00166     }
00167   else if(!strcmp("actualPos.tran.z",str))
00168     {
00169       return 23;
00170     }
00171   else if(!strcmp("id",str))
00172     {
00173       return 24;
00174     }
00175   else if(!strcmp("depth",str))
00176     {
00177       return 25;
00178     }
00179   else if(!strcmp("activeDepth",str))
00180     {
00181       return 26;
00182     }
00183   else if(!strcmp("queueFull",str))
00184     {
00185       return 27;
00186     }
00187   else if(!strcmp("motionFlag",str))
00188     {
00189       return 28;
00190     }
00191   else if(!strcmp("axisFlag[0]",str))
00192     {
00193       return 29;
00194     }
00195   else if(!strcmp("axisFlag[1]",str))
00196     {
00197       return 30;
00198     }
00199   else if(!strcmp("axisFlag[2]",str))
00200     {
00201       return 31;
00202     }
00203   else if(!strcmp("axisPolarity[0]",str))
00204     {
00205       return 32;
00206     }
00207   else if(!strcmp("axisPolarity[1]",str))
00208     {
00209       return 33;
00210     }
00211   else if(!strcmp("axisPolarity[2]",str))
00212     {
00213       return 34;
00214     }
00215   else if(!strcmp("paused",str))
00216     {
00217       return 36;
00218     }
00219   else if(!strcmp("overrideLimits",str))
00220     {
00221       return 38;
00222     }
00223   else if(!strcmp("tMin",str))
00224     {
00225       return 39;
00226     }
00227   else if(!strcmp("tMax",str))
00228     {
00229       return 40;
00230     }
00231   else if(!strcmp("tAvg",str))
00232     {
00233       return 41;
00234     }
00235   else if(!strcmp("sMin",str))
00236     {
00237       return 42;
00238     }
00239   else if(!strcmp("sMax",str))
00240     {
00241       return 43;
00242     }
00243   else if(!strcmp("sAvg",str))
00244     {
00245       return 44;
00246     }
00247   else if(!strcmp("nMin",str))
00248     {
00249       return 45;
00250     }
00251   else if(!strcmp("nMax",str))
00252     {
00253       return 46;
00254     }
00255   else if(!strcmp("nAvg",str))
00256     {
00257       return 47;
00258     }
00259   return -1;
00260 }
00261 
00262 
00263 static double get_emcmot_variable_value(int varnum)
00264 {
00265   switch(varnum)
00266     {
00267     case 1:
00268       return emcmotStruct->status.heartbeat;
00269 
00270     case 2:
00271       return emcmotStruct->status.computeTime;
00272 
00273     case 3:
00274       return emcmotStruct->status.pos.tran.x;
00275 
00276     case 4:
00277       return emcmotStruct->status.pos.tran.y;
00278 
00279     case 5:
00280       return emcmotStruct->status.pos.tran.z;
00281 
00282     case 6:
00283       return emcmotStruct->status.axisPos[0];
00284 
00285     case 7:
00286       return emcmotStruct->status.axisPos[1];
00287 
00288     case 8:
00289       return emcmotStruct->status.axisPos[2];
00290 
00291     case 9:
00292       return emcmotStruct->debug.ferrorCurrent[0];
00293 
00294     case 10:
00295       return emcmotStruct->debug.ferrorCurrent[1];
00296 
00297     case 11:
00298       return emcmotStruct->debug.ferrorCurrent[2];
00299 
00300     case 12:
00301       return emcmotStruct->debug.ferrorHighMark[0];
00302 
00303     case 13:
00304       return emcmotStruct->debug.ferrorHighMark[1];
00305 
00306     case 14:
00307       return emcmotStruct->debug.ferrorHighMark[2];
00308 
00309     case 15:
00310       return emcmotStruct->status.output[0];
00311 
00312     case 16:
00313       return emcmotStruct->status.output[1];
00314 
00315     case 17:
00316       return emcmotStruct->status.output[2];
00317 
00318     case 18:
00319       return emcmotStruct->status.input[0];
00320 
00321     case 19:
00322       return emcmotStruct->status.input[1];
00323 
00324     case 20:
00325       return emcmotStruct->status.input[2];
00326 
00327     case 21:
00328       return emcmotStruct->status.actualPos.tran.x;
00329 
00330     case 22:
00331       return emcmotStruct->status.actualPos.tran.y;
00332 
00333     case 23:
00334       return emcmotStruct->status.actualPos.tran.z;
00335 
00336     case 24:
00337       return emcmotStruct->status.id;
00338 
00339     case 25:
00340       return emcmotStruct->status.depth;
00341 
00342     case 26:
00343       return emcmotStruct->status.activeDepth;
00344 
00345     case 27:
00346       return emcmotStruct->status.queueFull;
00347 
00348     case 28:
00349       return emcmotStruct->status.motionFlag;
00350 
00351     case 29:
00352       return emcmotStruct->status.axisFlag[0];
00353 
00354     case 30:
00355       return emcmotStruct->status.axisFlag[1];
00356 
00357     case 31:
00358       return emcmotStruct->status.axisFlag[2];
00359 
00360     case 32:
00361       return emcmotStruct->config.axisPolarity[0];
00362 
00363     case 33:
00364       return emcmotStruct->config.axisPolarity[1];
00365 
00366     case 34:
00367       return emcmotStruct->config.axisPolarity[2];
00368 
00369     case 36:
00370       return emcmotStruct->status.paused;
00371 
00372     case 37:
00373       return emcmotStruct->status.overrideLimits;
00374 
00375     case 39:
00376       return emcmotStruct->debug.tMin;
00377 
00378     case 40:
00379       return emcmotStruct->debug.tMax;
00380 
00381     case 41:
00382       return emcmotStruct->debug.tAvg;
00383 
00384     case 42:
00385       return emcmotStruct->debug.sMin;
00386 
00387     case 43:
00388       return emcmotStruct->debug.sMax;
00389 
00390     case 44:
00391       return emcmotStruct->debug.sAvg;
00392 
00393     case 45:
00394       return emcmotStruct->debug.nMin;
00395 
00396     case 46:
00397       return emcmotStruct->debug.nMax;
00398 
00399     case 47:
00400       return emcmotStruct->debug.nAvg;
00401 
00402     default:
00403       return 0.0;
00404     }
00405 }

Generated on Sun Dec 2 15:27:44 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001