#ifndef NML_MODULE_H
#define NML_MODULE_H
#include "rcs.hh"
#include "nml.hh"
#include "stat_msg.hh"
#include "cmd_msg.hh"
#include "timer.hh"
#include "inifile.hh"
#define STATE_MATCH (set_file_and_line(__FILE__,__LINE__)),stateMatch
struct NML_SUBORDINATE_STRUCT
{
public:
RCS_CMD_CHANNEL * commandOut; RCS_STAT_CHANNEL *statusIn; RCS_CMD_MSG *commandOutData; RCS_STAT_MSG *statusInData; int modification_number;
char *name;
};
#if 0#endif
class NML_MODULE
{
public:
void controller (void);
virtual void DECISION_PROCESS (void);
virtual void READ_COMM_BUFFERS (void);
virtual void PRE_PROCESS ();
virtual void WRITE_COMM_BUFFERS (void);
virtual void POST_PROCESS ();
int stateMatch (char *_src_file, int source_line, int state, int conds = 1);
int stateMatch (int state, int conds = 1);
void stateNext (int state);
void stateNext (RCS_STATE state);
void read_command_in ();
void read_subordinates_status ();
void write_status_out ();
void write_commands_to_subordinates ();
void setCmdChannel (RCS_CMD_CHANNEL *);
void setStatChannel (RCS_STAT_CHANNEL *, RCS_STAT_MSG *);
void setErrorLogChannel (NML *);
int addSubordinate (RCS_CMD_CHANNEL *, RCS_STAT_CHANNEL *);
int sendCommand (RCS_CMD_MSG *, int sub_num);
int modifyCommand (RCS_CMD_MSG *, int sub_num);
void setSelfCommand (RCS_CMD_MSG *);
int force_command;
void check_if_new_command (void);
#if 0#endif
long cycle_start; long cycle_stop;
int command_time_averaged;
int new_command_sequence;
int new_line_num_sequence;
int new_sup_request;
long delta_clock;
long command_current_time;
int pause_status;
int command;
int last_line;
int execute;
int command_time;
RCS_STATE state;
RCS_STATUS status;
int sup_req_num;
int sup_req_num_echo;
int command_num;
int command_num_echo;
private:
int matched;
int stateBegin;
char *source_file;
int source_line;
public:
NML_MODULE (const char *inifile, const char *section);
NML_MODULE ();
virtual ~ NML_MODULE ();
void zero_common_vars ();
#if 0#endif
RCS_CMD_CHANNEL *commandIn; RCS_STAT_CHANNEL *statusOut; NML *errorLog;
RCS_CMD_MSG *commandInData; RCS_STAT_MSG *statusOutData;
int *commandLastNum; int *commandOutstanding;
NML_SUBORDINATE_STRUCT **subs; RCS_STAT_MSG **statusInData; RCS_CMD_MSG **commandOutData;
RCS_TIMER *timer;
int done;
int setSubordinates (int number);
int setLogInfo (const char *src, int l);
int logError (const char *fmt, ...) __attribute__((format(printf,2,3)));
int logText (const char *fmt, ...) __attribute__((format(printf,2,3)));
int requestDisplay (const char *display);
void stop_timing (void);
void set_file_and_line (char *file, int line);
int commands_received;
int commands_executed;
int cycles;
int cycles_executing;
int cycles_executing_completed_commands;
int cycles_executing_this_command;
int last_command_completed_serial_number;
double expected_cycle_time;
double start_run_time;
double last_start_run_time;
double stop_run_time;
double total_run_time;
double min_run_time;
double max_run_time;
double start_cycle_time;
double min_cycle_time;
double max_cycle_time;
double last_cycle_time;
void check_cycle_time_start ();
void check_cycle_time_end ();
void print_statistics ();
void loadDclock (double expiration);
int checkDclock ();
protected:
char *proc_name;
char *temp_file;
int temp_line;
int numSubordinates; double Dclock_expiration;
double Dclock_start_time;
int log_line;
const char *log_src;
public:
int subs_allocated;
static int use_realloc;
};
#define NML_MOD_LOG_ERROR setLogInfo(__FILE__,__LINE__); logError
extern int logTextToNML (NML *, const char *fmt, ...) __attribute__((format(printf,2,3)));
#endif