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

initool.cc

Go to the documentation of this file.
00001 /*
00002   initool.cc
00003 
00004   INI file initialization for tool controller
00005 
00006   Modification history:
00007 
00008   21-Sep-1999  WPS eliminate sscanf and printf calls not supported under CE.
00009   23-Apr-1998  FMP created from inispin.cc
00010   */
00011 
00012 extern "C" {
00013 #ifndef UNDER_CE
00014 #include <stdio.h>              // NULL
00015 #endif
00016 #include <stdlib.h>             // atol()
00017 #include <string.h>             // strcpy()
00018 }
00019 
00020 #include "emc.hh"
00021 #include "inifile.h"
00022 #include "initool.hh"           // these decls
00023 #include "emcglb.h"             // TOOL_TABLE_FILE
00024 
00025 // inifile ref'ed by iniTool(), loadTool()
00026 static INIFILE *toolInifile = 0;
00027 
00028 /*
00029   loadTool()
00030 
00031   Loads ini file params for spindle from [EMCIO] section
00032 
00033   TOOL_TABLE <file name>  name of tool table file
00034 
00035   calls:
00036 
00037   emcToolSetToolTableFile(const char filename);
00038   */
00039 
00040 static int loadTool()
00041 {
00042   int retval = 0;
00043   const char *inistring;
00044 
00045   if (NULL != (inistring = toolInifile->find("TOOL_TABLE", "EMCIO")))
00046     {
00047       if (0 != emcToolSetToolTableFile(inistring))
00048         {
00049           rcs_print("bad return value from emcToolSetToolTableFile\n");
00050           retval = -1;
00051         }
00052     }
00053   // else ignore omission
00054 
00055   return retval;
00056 }
00057 
00058 /*
00059   iniTool(const char *filename)
00060 
00061   Loads ini file parameters for tool controller, from [EMCIO] section
00062  */
00063 int iniTool(const char *filename)
00064 {
00065   int retval = 0;
00066 
00067   toolInifile = new INIFILE;
00068 
00069   if (-1 == toolInifile->open(filename))
00070     {
00071       return -1;
00072     }
00073 
00074   // load tool values
00075   if (0 != loadTool())
00076     {
00077       retval = -1;
00078     }
00079 
00080   // close the inifile
00081   toolInifile->close();
00082   delete toolInifile;
00083 
00084   return retval;
00085 }
00086 
00087 // functions to set global variables
00088 
00089 int emcToolSetToolTableFile(const char *filename)
00090 {
00091   strcpy(TOOL_TABLE_FILE, filename);
00092 
00093   return 0;
00094 }

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