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

nml_mod.hh

Go to the documentation of this file.
00001 
00002 #ifndef NML_MODULE_H
00003 #define NML_MODULE_H
00004 
00005 /*
00006    nml_mod.h
00007 
00008    Declarations of NML class derived from RCS_MODULE_C, which include
00009    NML channels and an RCS_TIMER.
00010    */
00011 
00012 /*
00013    Modification history:
00014 
00015      9-Sep-1997 WPS eliminated LOAL_LOCAL_VARIABLES, UNLOAD_LOCAL_VARIABLES,
00016     READ_CHILD_BUFFERS, WRITE_CHILD_BUFFERS, and DETERMINE_CHILD_STATUS
00017    3-Apr-1997 WPS made NML_MODULE no longer the subordinate of RCS_MODULE_C
00018     and brought those functions, variables from RCS_MODULE_C we want in
00019     here directly.
00020     7-Mar-1997 WPS changed header files to 8.3 format.
00021    11-Feb-1997 WPS modified --  calc_avg_time, update_line_history, and
00022    stop_timing all use exec_history but fail to check to
00023    see if it is initialized.
00024    I override them here minimize changes to rcs_module.cc
00025    3-Dec-1996  FMP changed NML to RCS_CMD/STAT_CHANNEL for commandIn,
00026    statusOut, etc.
00027    112696  hui, changed the base class for commandInData, etc., from NMLmsg
00028    to RCS_CMD_MSG and RCS_STAT_MSG.
00029    29-Jul-1996  FMP moved NML_ERROR, NML_TEXT, NML_DISPLAY, and NML_STATUS
00030    into nml_emc.hh
00031    29-Jul-1996  FMP added NML_TEXT and NML_DISPLAY classes; added member
00032    functions for logText and requestDisplay
00033    10-Jun-1996  Fred Proctor added commandOutstanding, commandLastNum arrays;
00034    NML_STATUS struct
00035    5-Jun-1996  Fred Proctor added errorLog, logError()
00036    29-Apr-1996  Fred Proctor moved 'done' from RCS_MODULE_C to here.
00037    16-Apr-1996  Fred Proctor added NMLmsg *'s
00038    5-Apr-1996  Fred Proctor created
00039     */
00040 
00041 #include "nml.hh"               // NML, NMLmsg
00042 #include "stat_msg.hh"          // RCS_STAT_CHANNEL, RCS_STAT_MSG
00043 #include "cmd_msg.hh"           // RCS_CMD_CHANNEL, RCS_CMD_MSG
00044 #include "timer.hh"             // RCS_TIMER
00045 #include "inifile.h"            // class INIFILE
00046 
00047 
00048 
00049 
00050 #define STATE_MATCH (set_file_and_line(__FILE__,__LINE__)),stateMatch
00051 
00052 
00053 
00054 enum RCS_STATE
00055 {
00056   UNINITIALIZED_STATE = -1,
00057   NEW_COMMAND = -2,
00058   NOP_STATE = -3,
00059   SE0 = -10,
00060   SE1 = -11,
00061   SE2 = -12,
00062   SE3 = -13,
00063   SE4 = -14,
00064   SE5 = -15,
00065   SE6 = -16,
00066   SE7 = -17,
00067   SE8 = -18,
00068   SE9 = -19,
00069   S0 = 0,
00070   S1 = 1,
00071   S2 = 2,
00072   S3 = 3,
00073   S4 = 4,
00074   S5 = 5,
00075   S6 = 6,
00076   S7 = 7,
00077   S8 = 8,
00078   S9 = 9,
00079   S10 = 10,
00080   S11 = 11,
00081   S12 = 12,
00082   S13 = 13,
00083   S14 = 14,
00084   S15 = 15,
00085   S16 = 16,
00086   S17 = 17,
00087   S18 = 18,
00088   S19 = 19,
00089   S20 = 20,
00090   S21 = 21,
00091   S22 = 22,
00092   S23 = 23,
00093   S24 = 24,
00094   S25 = 25,
00095   S26 = 26,
00096   S27 = 27,
00097   S28 = 28,
00098   S29 = 29,
00099   S30 = 30,
00100   S31 = 31,
00101   S32 = 32,
00102   S33 = 33,
00103   S34 = 34,
00104   S35 = 35,
00105   S36 = 36,
00106   S37 = 37,
00107   S38 = 38,
00108   S39 = 39
00109 };
00110 
00111 
00112 enum RCS_STATUS
00113 {
00114   UNINITIALIZED_STATUS = -1,
00115   RCS_DONE = 1,
00116   RCS_EXEC = 2,
00117   RCS_ERROR = 3
00118 };
00119 
00120 struct NML_SUBORDINATE_STRUCT
00121 {
00122 public:
00123   RCS_CMD_CHANNEL * commandOut; // NML channels for commands to subordinates
00124   RCS_STAT_CHANNEL *statusIn;   // NML channels for status from subordinates
00125   RCS_CMD_MSG *commandOutData;  // ptrs to NML data to be put in channel
00126   RCS_STAT_MSG *statusInData;   // ptrs to NML data in channels
00127   int modification_number;
00128   char *name;
00129 };
00130 
00131 
00132 #if 0
00133 class RCS_EXPORT NML_MODULE_INI_INFO
00134 {
00135 public:
00136   NML_MODULE_INI_INFO (const char *inifile, const char *section);
00137     virtual ~ NML_MODULE_INI_INFO ();
00138   INIFILE *inif;
00139   char nml_file[256];
00140   char ini_file[256];
00141   char ini_section[80];
00142   char module_name[80];
00143   char cmd_buf_name[80];
00144   char stat_buf_name[80];
00145   char err_buf_name[80];
00146   INIFILE_ENTRY entries[32];
00147   int num_entries;
00148 
00149   long getLongInt (const char *, long def = -1);
00150   const char *getString (const char *, const char *def = NULL);
00151   double getDouble (const char *, double def = -1.0);
00152 };
00153 #endif
00154 
00155 class RCS_EXPORT NML_MODULE
00156 {
00157 public:
00158   // This section taken from RCS_MODULE_C
00159   void controller (void);
00160 
00161   virtual void DECISION_PROCESS (void);
00162 
00163   virtual void READ_COMM_BUFFERS (void);
00164   virtual void PRE_PROCESS ();
00165 
00166 
00167   virtual void WRITE_COMM_BUFFERS (void);
00168   virtual void POST_PROCESS ();
00169 
00170   // State table functions
00171   int stateMatch (char *_src_file, int source_line, int state, int conds = 1);
00172   int stateMatch (int state, int conds = 1);
00173   void stateNext (int state);
00174   void stateNext (RCS_STATE state);
00175 
00176   void read_command_in ();
00177   void read_subordinates_status ();
00178   void write_status_out ();
00179   void write_commands_to_subordinates ();
00180   void setCmdChannel (RCS_CMD_CHANNEL *);
00181 
00182   void setStatChannel (RCS_STAT_CHANNEL *, RCS_STAT_MSG *);
00183 
00184   void setErrorLogChannel (NML *);
00185   int addSubordinate (RCS_CMD_CHANNEL *, RCS_STAT_CHANNEL *);
00186   int sendCommand (RCS_CMD_MSG *, int sub_num);
00187   int modifyCommand (RCS_CMD_MSG *, int sub_num);
00188   void setSelfCommand (RCS_CMD_MSG *);
00189   int force_command;
00190 
00191   void check_if_new_command (void);
00192 
00193 #if 0
00194   RCS_EXEC_HISTORY_STRUCT exec_history; // Exec History
00195   RCS_EXEC_STATUS_STRUCT exec_status;
00196 
00197   RCS_RUN_COMMAND_STRUCT run_command;   // Run Command
00198   RCS_RUN_STATUS_STRUCT run_status;
00199 #endif
00200 
00201   long cycle_start;             // Data
00202   long cycle_stop;
00203 
00204   int command_time_averaged;
00205   int new_command_sequence;
00206   int new_line_num_sequence;
00207   int new_sup_request;
00208 
00209   long delta_clock;
00210   long command_current_time;
00211 
00212   int pause_status;
00213   int command;
00214   int last_line;
00215 
00216   int execute;
00217   int command_time;
00218   RCS_STATE state;
00219   int status;
00220 
00221   int sup_req_num;
00222   int sup_req_num_echo;
00223   int command_num;
00224   int command_num_echo;
00225 
00226 private:
00227   int matched;                  /* flag set when a state is matched, to
00228                                    prevent fall-through to another state */
00229   int stateBegin;               /* flag set by controller() signifying
00230                                    that stateMatch should init line number */
00231   char *source_file;
00232   int source_line;
00233 
00234 public:
00235 
00236     NML_MODULE (const char *inifile, const char *section);
00237     NML_MODULE ();
00238     virtual ~ NML_MODULE ();
00239 
00240   void zero_common_vars ();
00241 
00242 #if 0
00243   NML_MODULE_INI_INFO *ini;     // pointer to an area of data from which ini file info is gathered.
00244 #endif
00245 
00246   RCS_CMD_CHANNEL *commandIn;   // NML channel for command from supervisor
00247   RCS_STAT_CHANNEL *statusOut;  // NML channel for status to supervisor
00248   NML *errorLog;                // NML channel for logging errors
00249 
00250   RCS_CMD_MSG *commandInData;   // ptr to NML data in channel
00251   RCS_STAT_MSG *statusOutData;  // ptr to NML data to be put in channel
00252 
00253   int *commandLastNum;          // array of command nums saved before writes
00254   int *commandOutstanding;      // array of flags, 1 = command has been sent,
00255   // 0 = command has finished
00256 
00257   NML_SUBORDINATE_STRUCT **subs;        // pointer to array of pointers to subordinates
00258   RCS_STAT_MSG **statusInData;  // ptrs to NML data in channels
00259   RCS_CMD_MSG **commandOutData; // ptrs to NML data in channels
00260 
00261   RCS_TIMER *timer;             // synch timer
00262 
00263   int done;                     // non-zero means stop calling controller()
00264 
00265   int setSubordinates (int number);
00266   int setLogInfo (const char *src, int l);
00267   int logError (const char *fmt, ...);
00268   int logText (const char *fmt, ...);
00269   int requestDisplay (const char *display);
00270   void stop_timing (void);
00271   void set_file_and_line (char *file, int line);
00272 
00273   int commands_received;
00274   int commands_executed;
00275   int cycles;
00276   int cycles_executing;
00277   int cycles_executing_completed_commands;
00278   int cycles_executing_this_command;
00279   int last_command_completed_serial_number;
00280   double expected_cycle_time;
00281   double start_run_time;
00282   double last_start_run_time;
00283   double stop_run_time;
00284   double total_run_time;
00285   double min_run_time;
00286   double max_run_time;
00287   double start_cycle_time;
00288   double min_cycle_time;
00289   double max_cycle_time;
00290   double last_cycle_time;
00291 
00292   void check_cycle_time_start ();
00293   void check_cycle_time_end ();
00294   void print_statistics ();
00295 
00296   void loadDclock (double expiration);
00297   int checkDclock ();
00298 
00299 protected:
00300 
00301   char *proc_name;
00302   char *temp_file;
00303   int temp_line;
00304   int numSubordinates;          // number of subordinates for this module
00305   double Dclock_expiration;
00306   double Dclock_start_time;
00307   int log_line;
00308   const char *log_src;
00309 
00310 public:
00311 
00312   // 1 if realloc works and we should use, 0 if we need to avoid lame NT problem.
00313   int subs_allocated;
00314   static int use_realloc;
00315 
00316 
00317 };
00318 
00319 #define NML_MOD_LOG_ERROR setLogInfo(__FILE__,__LINE__); logError
00320 extern int logTextToNML (NML *, const char *fmt, ...);
00321 
00322 #endif

Generated on Sun Dec 2 15:56:50 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001