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

bridgeportlube.cc

Go to the documentation of this file.
00001 /*
00002   bridgeportlube.cc
00003 
00004   Controller for Bridgeport lube controller
00005 
00006   Modification history:
00007 
00008   19-May-2000  FMP added lubeOn,Off(), isLubeOn(); control code for these
00009   31-Aug-1999  FMP changed to bridgeportlube.cc
00010   10-Feb-1999  FMP just a test
00011   28-Apr-1998  FMP took out ::iniLoad(), put in iniLube()
00012   1-Apr-1998  FMP changed from emclube.cc to shvlube.cc
00013   24-Mar-1998  FMP changed ERROR() to REPORT_ERROR() due to conflict
00014   in VC++
00015   15-Dec-1997  FMP created from emcaux.cc
00016   */
00017 
00018 #include "rcs.hh"               // NML
00019 #include "emc.hh"               // EMC NML
00020 #include "emcio.hh"             // these decls
00021 #include "emcglb.h"
00022 #include "extintf.h"            // extDioSet(),Clear()
00023 #include "inilube.hh"           // iniLube()
00024 
00025 /* ident tag */
00026 #ifndef __GNUC__
00027 #ifndef __attribute__
00028 #define __attribute__(x)
00029 #endif
00030 #endif
00031 
00032 static char __attribute__((unused)) ident[] = "$Id: bridgeportlube.cc,v 1.3 2001/06/29 20:27:29 wshackle Exp $";
00033 
00034 // local functions
00035 
00036 static void lubeOn()
00037 {
00038   extDioWrite(LUBE_WRITE_INDEX, LUBE_WRITE_POLARITY);
00039 }
00040 
00041 static void lubeOff()
00042 {
00043   extDioWrite(LUBE_WRITE_INDEX, ! LUBE_WRITE_POLARITY);
00044 }
00045 
00046 static int isLubeOn()
00047 {
00048   int f;
00049 
00050   extDioCheck(LUBE_WRITE_INDEX, &f);
00051 
00052   return f == LUBE_WRITE_POLARITY;
00053 }
00054 
00055 // returns 0 if lube level is low, 1 if OK
00056 static int lubeLevel()
00057 {
00058   int lube;
00059 
00060   extDioRead(LUBE_SENSE_INDEX, &lube);
00061 
00062   return lube == LUBE_SENSE_POLARITY;
00063 }
00064 
00065 // constructor
00066 
00067 EMC_LUBE_MODULE::EMC_LUBE_MODULE()
00068 {
00069   setErrorLogChannel(new NML(nmlErrorFormat, "emcError", "lube", EMC_NMLFILE));
00070 
00071   setCmdChannel(new RCS_CMD_CHANNEL(emcFormat, "lubeCmd", "lube", EMC_NMLFILE));
00072 
00073   setStatChannel(new RCS_STAT_CHANNEL(emcFormat, "lubeSts", "lube", EMC_NMLFILE), &lubeStatus);
00074 }
00075 
00076 // destructor
00077 
00078 EMC_LUBE_MODULE::~EMC_LUBE_MODULE(void)
00079 {
00080 }
00081 
00082 void EMC_LUBE_MODULE::DECISION_PROCESS(void)
00083 {
00084   switch (commandInData->type)
00085     {
00086     case EMC_LUBE_INIT_TYPE:
00087       INIT((EMC_LUBE_INIT *) commandInData);
00088       break;
00089 
00090     case EMC_LUBE_HALT_TYPE:
00091       HALT((EMC_LUBE_HALT *) commandInData);
00092       break;
00093 
00094     case EMC_LUBE_ABORT_TYPE:
00095       ABORT((EMC_LUBE_ABORT *) commandInData);
00096       break;
00097 
00098     case EMC_LUBE_ON_TYPE:
00099       LUBE_ON((EMC_LUBE_ON *) commandInData);
00100       break;
00101 
00102     case EMC_LUBE_OFF_TYPE:
00103       LUBE_OFF((EMC_LUBE_OFF *) commandInData);
00104       break;
00105 
00106     default:
00107       REPORT_ERROR(commandInData);
00108       break;
00109     }
00110 }
00111 
00112 void EMC_LUBE_MODULE::PRE_PROCESS(void)
00113 {
00114 }
00115 
00116 void EMC_LUBE_MODULE::POST_PROCESS(void)
00117 {
00118   lubeStatus.on = isLubeOn();
00119   lubeStatus.level = lubeLevel();
00120 }
00121 
00122 void EMC_LUBE_MODULE::INIT(EMC_LUBE_INIT *cmdIn)
00123 {
00124   if (STATE_MATCH(NEW_COMMAND))
00125     {
00126       // load params from ini file
00127       iniLube(EMC_INIFILE);
00128 
00129       // turn lube off
00130       lubeOff();
00131 
00132       status = RCS_DONE;
00133       stateNext(S0);
00134     }
00135   else if (STATE_MATCH(S0))
00136     {
00137       // idle
00138     }
00139 }
00140 
00141 void EMC_LUBE_MODULE::HALT(EMC_LUBE_HALT *cmdIn)
00142 {
00143   if (STATE_MATCH(NEW_COMMAND))
00144     {
00145       // turn lube off
00146       lubeOff();
00147 
00148       status = RCS_DONE;
00149       stateNext(S0);
00150     }
00151   else if (STATE_MATCH(S0))
00152     {
00153       // idle
00154     }
00155 }
00156 
00157 void EMC_LUBE_MODULE::ABORT(EMC_LUBE_ABORT *cmdIn)
00158 {
00159   if (STATE_MATCH(NEW_COMMAND))
00160     {
00161       // turn lube off
00162       lubeOff();
00163 
00164       status = RCS_DONE;
00165       stateNext(S0);
00166     }
00167   else if (STATE_MATCH(S0))
00168     {
00169       // idle
00170     }
00171 }
00172 
00173 void EMC_LUBE_MODULE::REPORT_ERROR(RCS_CMD_MSG *cmdIn)
00174 {
00175   if (STATE_MATCH(NEW_COMMAND))
00176     {
00177       rcs_print_error("EMC_LUBE_MODULE: unknown command %d\n",
00178                       cmdIn->type);
00179       status = RCS_ERROR;
00180       stateNext(S0);
00181     }
00182   else if (STATE_MATCH(S0))
00183     {
00184       // idle
00185     }
00186 }
00187 
00188 void EMC_LUBE_MODULE::LUBE_ON(EMC_LUBE_ON *cmdIn)
00189 {
00190   if (STATE_MATCH(NEW_COMMAND))
00191     {
00192       // turn lube on
00193       lubeOn();
00194 
00195       status = RCS_DONE;
00196       stateNext(S0);
00197     }
00198   else if (STATE_MATCH(S0))
00199     {
00200       // idle
00201     }
00202 }
00203 
00204 void EMC_LUBE_MODULE::LUBE_OFF(EMC_LUBE_OFF *cmdIn)
00205 {
00206   if (STATE_MATCH(NEW_COMMAND))
00207     {
00208       // turn lube off
00209       lubeOff();
00210 
00211       status = RCS_DONE;
00212       stateNext(S0);
00213     }
00214   else if (STATE_MATCH(S0))
00215     {
00216       // idle
00217     }
00218 }

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