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

minimilltool.cc File Reference

#include "rcs.hh"
#include "emc.hh"
#include "canon.hh"
#include "emcio.hh"
#include "emcglb.h"
#include "initool.hh"

Include dependency graph for minimilltool.cc:

Include dependency graph

Go to the source code of this file.

Defines

#define __attribute__(x)
#define auxStatus   ((EMC_AUX_STAT *) statusInData[auxSubNum])

Functions

char __attribute__ ((unused)) ident[]="$Id
int saveToolTable (const char *filename, CANON_TOOL_TABLE toolTable[])


Define Documentation

#define __attribute__  
 

Definition at line 27 of file minimilltool.cc.

#define auxStatus   ((EMC_AUX_STAT *) statusInData[auxSubNum])
 


Function Documentation

char __attribute__ (unused)    [static]
 

Definition at line 31 of file minimilltool.cc.

00031                                                   : minimilltool.cc,v 1.4 2001/06/29 20:27:29 wshackle Exp $";
00032 
00033 // shortcuts to NML module subordinate statuses
00034 #define auxStatus ((EMC_AUX_STAT *) statusInData[auxSubNum])
00035 
00036 /*
00037   load the tool table from file filename into toolTable[] array.
00038   Array is CANON_TOOL_MAX + 1 entries, since 0 is included.
00039 
00040   If filename is "", use global established from ini file
00041   */
00042 static int loadToolTable(const char *filename, CANON_TOOL_TABLE toolTable[])
00043 {
00044   int t;
00045   FILE *fp;
00046   char buffer[CANON_TOOL_ENTRY_LEN];
00047   const char *name;
00048 
00049   // check filename
00050   if (filename[0] == 0)
00051     {
00052       name = TOOL_TABLE_FILE;
00053     }
00054   else
00055     {
00056       // point to name provided
00057       name = filename;
00058     }
00059 
00060   // open tool table file
00061   if (NULL == (fp = fopen(name, "r")))
00062     {
00063       // can't open file
00064       return -1;
00065     }
00066 
00067   // clear out tool table
00068   for (t = 0; t <= CANON_TOOL_MAX; t++)
00069     {
00070       // unused tools are 0, 0.0, 0.0
00071       toolTable[t].id = 0;
00072       toolTable[t].length = 0.0;
00073       toolTable[t].diameter = 0.0;
00074     }
00075 
00076   /*
00077      Override 0's with codes from tool file
00078 
00079      File format is:
00080 
00081      <header>
00082      <pocket # 0..CANON_TOOL_MAX> <FMS id> <length> <diameter>
00083      ...
00084 
00085      */
00086 
00087   // read and discard header
00088   if (NULL == fgets(buffer, 256, fp))
00089     {
00090       // nothing in file at all
00091       fclose(fp);
00092       return -1;
00093     }
00094 
00095   while (!feof(fp))
00096     {
00097       int pocket;
00098       int id;
00099       double length;
00100       double diameter;
00101 
00102       // just read pocket, ID, and length offset
00103       if (NULL == fgets(buffer, CANON_TOOL_ENTRY_LEN, fp))
00104         {
00105           break;
00106         }
00107 
00108       if (4 != sscanf(buffer, "%d %d %lf %lf",
00109                       &pocket, &id, &length, &diameter))
00110         {
00111           // bad entry-- skip
00112           continue;
00113         }
00114       else
00115         {
00116           if (pocket < 0 || pocket > CANON_TOOL_MAX)
00117             {
00118               continue;
00119             }
00120           else
00121             {
00122               toolTable[pocket].id = id;
00123               toolTable[pocket].length = length;
00124               toolTable[pocket].diameter = diameter;
00125             }
00126         }
00127     }
00128 
00129   // close the file
00130   fclose(fp);
00131 
00132   return 0;
00133 }

int saveToolTable const char *    filename,
CANON_TOOL_TABLE    toolTable[]
[static]
 

Definition at line 141 of file minimilltool.cc.

Referenced by EMC_TOOL_MODULE::TOOL_SET_OFFSET().

00142 {
00143   int pocket;
00144   FILE *fp;
00145   const char *name;
00146 
00147   // check filename
00148   if (filename[0] == 0)
00149     {
00150       name = TOOL_TABLE_FILE;
00151     }
00152   else
00153     {
00154       // point to name provided
00155       name = filename;
00156     }
00157 
00158   // open tool table file
00159   if (NULL == (fp = fopen(name, "w")))
00160     {
00161       // can't open file
00162       return -1;
00163     }
00164 
00165   // write header
00166   fprintf(fp, "POC\tFMS\tLEN\t\tDIAM\n");
00167 
00168   for (pocket = 1; pocket <= CANON_TOOL_MAX; pocket++)
00169     {
00170       fprintf(fp, "%d\t%d\t%f\t%f\n",
00171               pocket,
00172               toolTable[pocket].id,
00173               toolTable[pocket].length,
00174               toolTable[pocket].diameter);
00175     }
00176 
00177   // close the file
00178   fclose(fp);
00179 
00180   return 0;
00181 }


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