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

bridgeporttool.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 bridgeporttool.cc:

Include dependency graph

Go to the source code of this file.

Defines

#define __attribute__(x)
#define spindleStatus   ((EMC_SPINDLE_STAT *) statusInData[spindleSubNum])
#define coolantStatus   ((EMC_COOLANT_STAT *) statusInData[coolantSubNum])
#define auxStatus   ((EMC_AUX_STAT *) statusInData[auxSubNum])
#define lubeStatus   ((EMC_LUBE_STAT *) statusInData[lubeSubNum])

Functions

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


Define Documentation

#define __attribute__  
 

Definition at line 35 of file bridgeporttool.cc.

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

#define coolantStatus   ((EMC_COOLANT_STAT *) statusInData[coolantSubNum])
 

#define lubeStatus   ((EMC_LUBE_STAT *) statusInData[lubeSubNum])
 

#define spindleStatus   ((EMC_SPINDLE_STAT *) statusInData[spindleSubNum])
 


Function Documentation

char __attribute__ (unused)    [static]
 

Definition at line 39 of file bridgeporttool.cc.

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

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

Definition at line 152 of file bridgeporttool.cc.

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


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