#include <string.h>#include <stdlib.h>#include <signal.h>#include "rcs.hh"#include "emcglb.h"#include "emcio.hh"#include "extintf.h"Include dependency graph for minimilliomain.cc:

Go to the source code of this file.
Defines | |
| #define | __attribute__(x) |
Functions | |
| char | __attribute__ ((unused)) ident[]="$Id |
| int | iniLoad (const char *filename) |
| int | main (int argc, char *argv[]) |
|
|
Definition at line 31 of file minimilliomain.cc. |
|
|
Definition at line 35 of file minimilliomain.cc. 00035 : minimilliomain.cc,v 1.5 2001/06/29 20:27:29 wshackle Exp $";
00036
00037 // command line args-- global so that other modules can access
00038 int Argc;
00039 char **Argv;
00040
00041 // flag signifying main loop is to terminate
00042 static int done;
00043
00044 // signal handler for ^C
00045 static void quit(int sig)
00046 {
00047 done = 1;
00048 }
|
|
|
Definition at line 50 of file minimilliomain.cc. 00051 {
00052 INIFILE inifile;
00053 const char *inistring;
00054 char version[INIFILE_MAX_LINELEN];
00055 double saveDouble;
00056
00057 // open it
00058 if (-1 == inifile.open(filename)) {
00059 return -1;
00060 }
00061
00062 if (NULL != (inistring = inifile.find("DEBUG", "EMC"))) {
00063 // copy to global
00064 if (1 != sscanf(inistring, "%i", &EMC_DEBUG)) {
00065 EMC_DEBUG = 0;
00066 }
00067 }
00068 else {
00069 // not found, use default
00070 EMC_DEBUG = 0;
00071 }
00072
00073 if (EMC_DEBUG & EMC_DEBUG_VERSIONS) {
00074 if (NULL != (inistring = inifile.find("VERSION", "EMC"))) {
00075 // print version
00076 sscanf(inistring, "$Revision: %s", version);
00077 rcs_print("Version: %s\n", version);
00078 }
00079 else {
00080 // not found, not fatal
00081 rcs_print("Version: (not found)\n");
00082 }
00083
00084 if (NULL != (inistring = inifile.find("MACHINE", "EMC"))) {
00085 // print machine
00086 rcs_print("Machine: %s\n", inistring);
00087 }
00088 else {
00089 // not found, not fatal
00090 rcs_print("Machine: (not found)\n");
00091 }
00092 }
00093
00094 if (NULL != (inistring = inifile.find("NML_FILE", "EMC"))) {
00095 // copy to global
00096 strcpy(EMC_NMLFILE, inistring);
00097 }
00098 else {
00099 // not found, use default
00100 }
00101
00102 saveDouble = EMC_IO_CYCLE_TIME;
00103 if (NULL != (inistring = inifile.find("CYCLE_TIME", "EMCIO"))) {
00104 if (1 == sscanf(inistring, "%lf", &EMC_IO_CYCLE_TIME)) {
00105 // found it
00106 }
00107 else {
00108 // found, but invalid
00109 EMC_IO_CYCLE_TIME = saveDouble;
00110 rcs_print("invalid [EMCIO] CYCLE_TIME in %s (%s); using default %f\n",
00111 filename, inistring, EMC_IO_CYCLE_TIME);
00112 }
00113 }
00114 else {
00115 // not found, using default
00116 rcs_print("[EMCIO] CYCLE_TIME not found in %s; using default %f\n",
00117 filename, EMC_IO_CYCLE_TIME);
00118 }
00119
00120 // close it
00121 inifile.close();
00122
00123 return 0;
00124 }
|
|
||||||||||||
|
Definition at line 129 of file minimilliomain.cc. 00130 {
00131 EMC_TOOL_MODULE *tool;
00132 EMC_AUX_MODULE *aux;
00133 RCS_TIMER *timer;
00134
00135 // copy command line args
00136 Argc = argc;
00137 Argv = argv;
00138
00139 // set print destination to stdout, for console apps
00140 set_rcs_print_destination(RCS_PRINT_TO_STDOUT);
00141
00142 // process command line args, indexing argv[] from [1]
00143 if (0 != emcGetArgs(argc, argv)) {
00144 rcs_print_error("error in argument list\n");
00145 exit(1);
00146 }
00147
00148 // get configuration information
00149 iniLoad(EMC_INIFILE);
00150
00151 // init external IO here, since everyone uses it
00152 if (0 != extDioInit(EMC_INIFILE)) {
00153 rcs_print_error("can't initialize IO-- privilege problems?\n");
00154 exit(1);
00155 }
00156
00157 // get controllers to run
00158 tool = new EMC_TOOL_MODULE();
00159 aux = new EMC_AUX_MODULE();
00160
00161 // get timer
00162 timer = new RCS_TIMER(EMC_IO_CYCLE_TIME);
00163
00164 // set the SIGINT handler
00165 signal(SIGINT, quit);
00166
00167 // enter main loop
00168 while (!done) {
00169 // run controller logic
00170 tool->controller();
00171 aux->controller();
00172
00173 // wait on timer
00174 if (EMC_IO_CYCLE_TIME > 0.0) {
00175 #if defined(LINUX_KERNEL_2_2)
00176 // work around bug in gettimeofday() by running off nominal time
00177 esleep(EMC_IO_CYCLE_TIME);
00178 #else
00179 timer->wait();
00180 #endif
00181 }
00182 }
00183
00184 // clean up timer
00185 delete timer;
00186
00187 // clean up controller
00188 delete aux;
00189 delete tool;
00190
00191 // quit external IO here, since everyone uses it
00192 extDioQuit();
00193
00194 exit(0);
00195 }
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001