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

simctrlintf.h File Reference

#include <gtk/gtk.h>

Include dependency graph for simctrlintf.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

int initializeSimctrlInterface (int argc, char **argv)
int loadSimulationIniFile (const char *filename)
int saveSimulationIniFile (const char *filename)
gint read_status_and_update_display (GtkWidget *widget)
void read_status (void)
void update_display (void)
void store_control_values (int axis)
void send_values_to_controller (void)


Function Documentation

int initializeSimctrlInterface int    argc,
char **    argv
 

Referenced by main().

int loadSimulationIniFile const char *    filename
 

Definition at line 106 of file simctrlintf.cc.

Referenced by on_ok_button1_clicked().

00108 {
00109 #if 0
00110 /*
00111   Taken from dumpAxis in iniaxis.cc but modified to do Simulation stuff instead.
00112 
00113   dumpSimAxis(int axis, const char *filename, EMC_AXIS_STAT *stat)
00114 
00115   Takes the file name for the ini file, makes a backup copy, opens the
00116   backup copy, then overwrites the original with a line-by-line version
00117   of the original, parsing the lines for ones it understands and
00118   replacing the values with the current ones.
00119  */
00120   char ourAxisSection[256];
00121   int ourAxis = 0;
00122   FILE *infp = NULL;
00123   FILE *outfp = NULL;
00124   char line[256];
00125   char section[256];
00126   char var[256], val[256];
00127   char fmt[256];
00128   char *inistring;
00129 
00130   // rename with backup suffix
00131   strcpy(line, filename);
00132   strcat(line, ".bak");
00133   if (0 != rename(filename, line)) {
00134     fprintf(stderr, "can't make backup copy of INI file %s\n", filename);
00135     return -1;
00136   }
00137 
00138   // open backup for reading
00139   if (NULL == (infp = fopen(line, "r"))) {
00140     fprintf(stderr, "can't open backup copy of INI file %s\n", line);
00141     return -1;
00142   }
00143 
00144   // open original for writing
00145   if (NULL == (outfp = fopen(filename, "w"))) {
00146     fprintf(stderr, "can't open original copy of INI file %s\n", line);

void read_status void   
 

gint read_status_and_update_display GtkWidget *    widget
 

int saveSimulationIniFile const char *    filename
 

Definition at line 150 of file simctrlintf.cc.

Referenced by on_ok_button1_clicked().

00153                       {
00154     if (NULL == fgets(line, 256, infp)) {
00155       break;
00156     }
00157 
00158     if (iniIsSection(line, section)) {
00159       // if this is "AXIS_0,1,...", it's what we want
00160       if (!strncmp(section, "AXIS_",5)) {
00161         ourSection = 1;
00162         axis = section[5]-'0';
00163         if(axis > 8 || axis < 0)
00164           {
00165             axis = 0;
00166             ourSection = 0;
00167           }
00168         /* look up torque units */
00169         if (NULL != (inistring = iniFind(infp, "TORQUE_UNITS", section)))
00170           {
00171             /* found the entry in the ini file */
00172             if (!strcmp(inistring, "N_M"))
00173               {
00174                 torque_units = N_M;
00175               }
00176             else if (!strcmp(inistring, "LB_FT"))
00177               {
00178                 torque_units = LB_FT;
00179               }
00180             else if (!strcmp(inistring, "OZ_IN"))
00181               {
00182                 torque_units = OZ_IN;
00183               }
00184             else
00185               {
00186                 torque_units = TORQUE_UNITS_INVALID;
00187                 rcs_print_error( "bad torque units specified in ini file: %s\n",
00188                                  inistring);
00189                 retval = -1;
00190               }
00191           }
00192   }
00193   else
00194   {
00195     /* not in ini file-- use default */
00196     torque_units = N_M;
00197   }
00198       }
00199       else {
00200         ourSection = 0;
00201       }
00202     }
00203 
00204     if (ourSection) {
00205       if (iniIsEntry(line, var, val)) {
00206         if (!strcmp(var, "AMPLIFIER_GAIN")) {
00207           iniFormatFloat(fmt, var, val);
00208           fprintf(outfp, fmt, amplifier[axis].gain);
00209           continue;             // avoid fputs() below, since we wrote it
00210         }
00211         else if (!strcmp(var, "MAX_OUTPUT_CURRENT")) {
00212           iniFormatFloat(fmt, var, val);
00213           fprintf(outfp, fmt, amplifier[axis].maxOutputCurrent);
00214           continue;             // avoid fputs() below, since we wrote it
00215         }
00216         else if (!strcmp(var, "LOAD_RESISTANCE")) {
00217           iniFormatFloat(fmt, var, val);
00218           fprintf(outfp, fmt, amplifier[axis].loadResistance);
00219           continue;             // avoid fputs() below, since we wrote it
00220         }
00221         else if (!strcmp(var, "ARMATURE_RESISTANCE")) {
00222           iniFormatFloat(fmt, var, val);
00223           fprintf(outfp, fmt, dcmotor[axis].Ra);
00224           continue;             // avoid fputs() below, since we wrote it
00225         }
00226         else if (!strcmp(var, "ARMATURE_INDUCTANCE")) {
00227           iniFormatFloat(fmt, var, val);
00228           fprintf(outfp, fmt, dcmotor[axis].La);
00229           continue;             // avoid fputs() below, since we wrote it
00230         }
00231         else if (!strcmp(var, "BACK_EMF_CONSTANT")) {
00232           iniFormatFloat(fmt, var, val);
00233           fprintf(outfp, fmt, dcmotor[axis].Kb);
00234           continue;             // avoid fputs() below, since we wrote it
00235         }       
00236         else if (!strcmp(var, "ROTOR_INERTIA")) {
00237           iniFormatFloat(fmt, var, val);
00238           fprintf(outfp, fmt, dcmotor[axis].Jm);
00239           continue;             // avoid fputs() below, since we wrote it
00240         }
00241         else if (!strcmp(var, "DAMPING_FRICTION_COEFFICIENT")) {
00242           iniFormatFloat(fmt, var, val);
00243           fprintf(outfp, fmt, dcmotor[axis].Bm);
00244           continue;             // avoid fputs() below, since we wrote it
00245         }
00246       }
00247     }
00248 
00249     // write it out
00250     fputs(line, outfp);
00251   }
00252 
00253   fclose(infp);
00254   fclose(outfp);
00255 #endif  
00256   return 0;
00257 
00258 }
00259 
00260 
00261 
00262 
00263 

void send_values_to_controller void   
 

Referenced by on_SetButton_clicked().

void store_control_values int    axis
 

Referenced by on_AxisSpinbutton_changed().

void update_display void   
 

Referenced by on_AxisSpinbutton_changed().


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