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

emcdummy.cc File Reference

#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "rcs.hh"
#include "emc.hh"

Include dependency graph for emcdummy.cc:

Include dependency graph

Go to the source code of this file.

Functions

int startup ()
int shutdown ()
void quit (int sig)
int main (int argc, char *argv[])

Variables

RCS_CMD_CHANNEL * emcCommandBuffer = 0
RCS_STAT_CHANNEL * emcStatusBuffer = 0
NML * emcErrorBuffer = 0
RCS_CMD_MSGemcCommand = 0
EMC_STATemcStatus = 0
char nmlFile [256] = "emc.nml"
int done


Function Documentation

int main int    argc,
char *    argv[]
 

Definition at line 165 of file emcdummy.cc.

00166 {
00167   NMLTYPE type;
00168 
00169   // set print destination to stdout, for console apps
00170   set_rcs_print_destination(RCS_PRINT_TO_STDOUT);
00171 
00172   // blank out the annoying RCS version message
00173   rcs_version_printed = 1;
00174 
00175   if (argc > 1)
00176     {
00177       // first arg is NML file-- copy it to global used in startup()
00178       strcpy(nmlFile, argv[1]);
00179     }
00180 
00181   // set up NML
00182   if (0 != startup())
00183     {
00184       exit(1);
00185     }
00186 
00187   // fill in NML status with initial blank values
00188   emcStatus->command_type = 0;
00189   emcStatus->echo_serial_number = 0;
00190   emcStatus->status = RCS_DONE;
00191 
00192   // enter dummy loop
00193   done = 0;
00194   while (! done)
00195     {
00196       // read command
00197       type = emcCommandBuffer->read();
00198 
00199       if (0 != type &&
00200           -1 != type)
00201         {
00202           // new command-- show "executing" immediately
00203           emcStatus->command_type = emcCommand->type;
00204           emcStatus->echo_serial_number = emcCommand->serial_number;
00205           emcStatus->status = RCS_EXEC;
00206           emcStatusBuffer->write(emcStatus);
00207         }
00208 
00209       // wait a second
00210       esleep(1.0);
00211 
00212       // now show "done"
00213       emcStatus->status = RCS_DONE;
00214       emcStatusBuffer->write(emcStatus);
00215     }
00216 
00217   if (0 != shutdown())
00218     {
00219       exit(1);
00220     }
00221 
00222   exit(0);
00223 }

void quit int    sig [static]
 

Definition at line 145 of file emcdummy.cc.

00146 {
00147   // set main's done flag
00148   done = 1;
00149 
00150   // restore signal handler
00151   signal(SIGINT, quit);
00152 }

int shutdown   [static]
 

Definition at line 110 of file emcdummy.cc.

Referenced by main().

00111 {
00112   // delete the NML channels
00113 
00114   if (0 != emcErrorBuffer)
00115     {
00116       delete emcErrorBuffer;
00117       emcErrorBuffer = 0;
00118     }
00119 
00120   if (0 != emcStatusBuffer)
00121     {
00122       delete emcStatusBuffer;
00123       emcStatusBuffer = 0;
00124       emcStatus = 0;
00125     }
00126 
00127   if (0 != emcCommandBuffer)
00128     {
00129       delete emcCommandBuffer;
00130       emcCommandBuffer = 0;
00131       emcCommand = 0;
00132     }
00133 
00134   if( 0 != emcStatus)
00135     {
00136       delete emcStatus;
00137       emcStatus = 0;
00138     }
00139 
00140   return 0;
00141 }

int startup   [static]
 

Definition at line 74 of file emcdummy.cc.

Referenced by main().

00075 {
00076   // get the NML command buffer
00077   emcCommandBuffer = new RCS_CMD_CHANNEL(emcFormat, "emcCommand", "emc", nmlFile);
00078   if (! emcCommandBuffer->valid())
00079     {
00080       rcs_print_error("can't get emcCommand buffer\n");
00081       return -1;
00082     }
00083 
00084   // get our command data structure
00085   emcCommand = emcCommandBuffer->get_address();
00086 
00087   // get the NML status buffer
00088   emcStatusBuffer = new RCS_STAT_CHANNEL(emcFormat, "emcStatus", "emc", nmlFile);
00089   if (! emcStatusBuffer->valid())
00090     {
00091       rcs_print_error("can't get emcStatus buffer\n");
00092       return -1;
00093     }
00094 
00095   // get our status data structure
00096   emcStatus = new EMC_STAT;
00097 
00098   // get the error log buffer
00099   emcErrorBuffer = new NML(nmlErrorFormat, "emcError", "emc", nmlFile);
00100   if (! emcErrorBuffer->valid())
00101     {
00102       rcs_print_error("can't get emcError buffer\n");
00103       return -1;
00104     }
00105 
00106   return 0;
00107 }


Variable Documentation

int done [static]
 

Definition at line 144 of file emcdummy.cc.

RCS_CMD_MSG* emcCommand = 0 [static]
 

Definition at line 66 of file emcdummy.cc.

RCS_CMD_CHANNEL* emcCommandBuffer = 0 [static]
 

Definition at line 61 of file emcdummy.cc.

NML* emcErrorBuffer = 0 [static]
 

Definition at line 63 of file emcdummy.cc.

EMC_STAT* emcStatus = 0
 

Definition at line 69 of file emcdummy.cc.

RCS_STAT_CHANNEL* emcStatusBuffer = 0 [static]
 

Definition at line 62 of file emcdummy.cc.

char nmlFile[256] = "emc.nml" [static]
 

Definition at line 72 of file emcdummy.cc.


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