#include <string.h>#include <stdlib.h>#include <signal.h>#include "rcs.hh"#include "emcglb.h"#include "emcio.hh"#include "extintf.h"#include "parport.h"Include dependency graph for bridgeportiomain.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 bridgeportiomain.cc. |
|
|
Definition at line 35 of file bridgeportiomain.cc. 00035 : bridgeportiomain.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 bridgeportiomain.cc. 00051 {
00052 INIFILE inifile;
00053 const char *inistring;
00054 char version[INIFILE_MAX_LINELEN];
00055 int saveInt;
00056 double saveDouble;
00057
00058 // open it
00059 if (-1 == inifile.open(filename)) {
00060 return -1;
00061 }
00062
00063 if (NULL != (inistring = inifile.find("DEBUG", "EMC"))) {
00064 // copy to global
00065 if (1 != sscanf(inistring, "%i", &EMC_DEBUG)) {
00066 EMC_DEBUG = 0;
00067 }
00068 }
00069 else {
00070 // not found, use default
00071 EMC_DEBUG = 0;
00072 }
00073
00074 if (EMC_DEBUG & EMC_DEBUG_VERSIONS) {
00075 if (NULL != (inistring = inifile.find("VERSION", "EMC"))){
00076 // print version
00077 sscanf(inistring, "$Revision: %s", version);
00078 rcs_print("Version: %s\n", version);
00079 }
00080 else {
00081 // not found, not fatal
00082 rcs_print("Version: (not found)\n");
00083 }
00084
00085 if (NULL != (inistring = inifile.find("MACHINE", "EMC"))) {
00086 // print machine
00087 rcs_print("Machine: %s\n", inistring);
00088 }
00089 else {
00090 // not found, not fatal
00091 rcs_print("Machine: (not found)\n");
00092 }
00093 }
00094
00095 if (NULL != (inistring = inifile.find("NML_FILE", "EMC"))) {
00096 // copy to global
00097 strcpy(EMC_NMLFILE, inistring);
00098 }
00099 else {
00100 // not found, use default
00101 }
00102
00103 saveDouble = EMC_IO_CYCLE_TIME;
00104 if (NULL != (inistring = inifile.find("CYCLE_TIME", "EMCIO"))) {
00105 if (1 == sscanf(inistring, "%lf", &EMC_IO_CYCLE_TIME)) {
00106 // found it
00107 }
00108 else {
00109 // found, but invalid
00110 EMC_IO_CYCLE_TIME = saveDouble;
00111 rcs_print("invalid [EMCIO] CYCLE_TIME in %s (%s); using default %f\n",
00112 filename, inistring, EMC_IO_CYCLE_TIME);
00113 }
00114 }
00115 else {
00116 // not found, using default
00117 rcs_print("[EMCIO] CYCLE_TIME not found in %s; using default %f\n",
00118 filename, EMC_IO_CYCLE_TIME);
00119 }
00120
00121 // do miscellaneous ones
00122
00123 saveInt = PARPORT_IO_ADDRESS;
00124 // look for it as [EMCIO] section first
00125 if (NULL != (inistring = inifile.find("PARPORT_IO_ADDRESS", "EMCIO"))) {
00126 if (1 == sscanf(inistring, "%li", &PARPORT_IO_ADDRESS)) {
00127 // found it
00128 }
00129 else {
00130 // found, but invalid
00131 PARPORT_IO_ADDRESS = saveInt;
00132 rcs_print("invalid [EMCIO] PARPORT_IO_ADDRESS in %s (%s); using default %X\n",
00133 filename, inistring, PARPORT_IO_ADDRESS);
00134 }
00135 }
00136 else if (NULL != (inistring = inifile.find("PARPORT_IO_ADDRESS", "EMC"))) {
00137 if (1 == sscanf(inistring, "%li", &PARPORT_IO_ADDRESS)) {
00138 // found it
00139 }
00140 else {
00141 // found, but invalid
00142 PARPORT_IO_ADDRESS = saveInt;
00143 rcs_print("invalid [EMC] PARPORT_IO_ADDRESS in %s (%s); using default %X\n",
00144 filename, inistring, PARPORT_IO_ADDRESS);
00145 }
00146 }
00147 else {
00148 // not found, using default
00149 rcs_print("[EMC] PARPORT_IO_ADDRESS not found in %s; using default %X\n",
00150 filename, PARPORT_IO_ADDRESS);
00151 }
00152
00153 // close it
00154 inifile.close();
00155
00156 return 0;
00157 }
|
|
||||||||||||
|
Definition at line 162 of file bridgeportiomain.cc. 00163 {
00164 EMC_TOOL_MODULE *tool;
00165 EMC_SPINDLE_MODULE *spindle;
00166 EMC_COOLANT_MODULE *coolant;
00167 EMC_AUX_MODULE *aux;
00168 EMC_LUBE_MODULE *lube;
00169 RCS_TIMER *timer;
00170
00171 // copy command line args
00172 Argc = argc;
00173 Argv = argv;
00174
00175 // set print destination to stdout, for console apps
00176 set_rcs_print_destination(RCS_PRINT_TO_STDOUT);
00177
00178 // process command line args, indexing argv[] from [1]
00179 if (0 != emcGetArgs(argc, argv)) {
00180 rcs_print_error("error in argument list\n");
00181 exit(1);
00182 }
00183
00184 // get configuration information
00185 iniLoad(EMC_INIFILE);
00186
00187 // init external IO here, since everyone uses it
00188 if (0 != extDioInit(EMC_INIFILE)) {
00189 rcs_print_error("can't initialize IO-- privilege problems?\n");
00190 exit(1);
00191 }
00192
00193 // get controllers to run
00194 tool = new EMC_TOOL_MODULE();
00195 spindle = new EMC_SPINDLE_MODULE();
00196 coolant = new EMC_COOLANT_MODULE();
00197 aux = new EMC_AUX_MODULE();
00198 lube = new EMC_LUBE_MODULE();
00199
00200 // get timer
00201 timer = new RCS_TIMER(EMC_IO_CYCLE_TIME);
00202
00203 // set the SIGINT handler
00204 signal(SIGINT, quit);
00205
00206 // enter main loop
00207 while (!done) {
00208 // run controller logic
00209 tool->controller();
00210 spindle->controller();
00211 coolant->controller();
00212 aux->controller();
00213 lube->controller();
00214
00215 // wait on timer
00216 if (EMC_IO_CYCLE_TIME > 0.0) {
00217 #if defined(LINUX_KERNEL_2_2)
00218 // work around bug in gettimeofday() by running off nominal time
00219 esleep(EMC_IO_CYCLE_TIME);
00220 #else
00221 timer->wait();
00222 #endif
00223 }
00224 }
00225
00226 // clean up timer
00227 delete timer;
00228
00229 // clean up controller
00230 delete lube;
00231 delete aux;
00232 delete coolant;
00233 delete spindle;
00234 delete tool;
00235
00236 // quit external IO here, since everyone uses it
00237 extDioQuit();
00238
00239 exit(0);
00240 }
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001