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

NML_MODULE Class Reference

#include <nml_mod.hh>

Collaboration diagram for NML_MODULE:

Collaboration graph
[legend]

Public Methods

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 *)
void check_if_new_command (void)
 NML_MODULE (const char *inifile, const char *section)
 NML_MODULE ()
virtual ~NML_MODULE ()
void zero_common_vars ()
int setSubordinates (int number)
int setLogInfo (const char *src, int l)
int logError (const char *fmt,...)
int logText (const char *fmt,...)
int requestDisplay (const char *display)
void stop_timing (void)
void set_file_and_line (char *file, int line)
void check_cycle_time_start ()
void check_cycle_time_end ()
void print_statistics ()
void loadDclock (double expiration)
int checkDclock ()

Data Fields

int force_command
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
int status
int sup_req_num
int sup_req_num_echo
int command_num
int command_num_echo
RCS_CMD_CHANNELcommandIn
RCS_STAT_CHANNELstatusOut
NMLerrorLog
RCS_CMD_MSGcommandInData
RCS_STAT_MSGstatusOutData
int * commandLastNum
int * commandOutstanding
NML_SUBORDINATE_STRUCT ** subs
RCS_STAT_MSG ** statusInData
RCS_CMD_MSG ** commandOutData
RCS_TIMERtimer
int done
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
int subs_allocated

Static Public Attributes

int use_realloc = 1

Protected Attributes

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

Private Attributes

int matched
int stateBegin
char * source_file
int source_line

Constructor & Destructor Documentation

NML_MODULE::NML_MODULE const char *    inifile,
const char *    section
 

Definition at line 197 of file node/nml_mod.cc.

00198 {
00199   zero_common_vars ();
00200 #if 0
00201   ini = new NML_MODULE_INI_INFO (inifile, section);
00202 #endif
00203 }

NML_MODULE::NML_MODULE  
 

Definition at line 41 of file cms/nml_mod.cc.

00042 {
00043   commandIn = 0;
00044   commandInData = 0;
00045   statusOut = 0;
00046   statusOutData = 0;
00047   commandOut = 0;
00048   commandOutData = 0;
00049   statusIn = 0;
00050   statusInData = 0;
00051   commandLastNum = 0;
00052   commandOutstanding = 0;
00053   timer = 0;
00054   numSubordinates = 0;
00055   errorLog = 0;
00056   done = 0;
00057 }

NML_MODULE::~NML_MODULE   [virtual]
 

Definition at line 59 of file cms/nml_mod.cc.

00060 {
00061   int t;
00062 
00063   if (commandIn != 0)
00064     delete commandIn;
00065   commandIn = 0;
00066 
00067   if (statusOut != 0)
00068     delete statusOut;
00069   statusOut = 0;
00070 
00071   if (errorLog != 0)
00072     delete (errorLog);
00073   errorLog = 0;
00074 
00075   if (commandOut != 0)
00076     {
00077       for (t = 0; t < numSubordinates; t++)
00078         {
00079           if (commandOut[t] != 0)
00080             delete commandOut[t];
00081         }
00082 
00083       free (commandOut);
00084       commandOut = 0;
00085     }
00086 
00087   if (commandInData != 0)
00088     {
00089       free (commandOutData);
00090       commandOutData = 0;
00091     }
00092 
00093   if (statusIn != 0)
00094     {
00095       for (t = 0; t < numSubordinates; t++)
00096         {
00097           if (statusIn[t] != 0)
00098             delete statusIn[t];
00099         }
00100 
00101       free (statusIn);
00102       statusIn = 0;
00103     }
00104 
00105   if (statusInData != 0)
00106     {
00107       free (statusInData);
00108       statusInData = 0;
00109     }
00110 
00111   if (commandOutstanding != 0)
00112     {
00113       free (commandOutstanding);
00114       commandOutstanding = 0;
00115     }
00116 
00117   if (commandLastNum != 0)
00118     {
00119       free (commandLastNum);
00120       commandLastNum = 0;
00121     }
00122 
00123   if (timer != 0)
00124     delete timer;
00125   timer = 0;
00126 }


Member Function Documentation

void NML_MODULE::controller void   
 

Definition at line 1011 of file node/nml_mod.cc.

01012 {
01013 
01014   check_cycle_time_start ();
01015   READ_COMM_BUFFERS ();
01016   PRE_PROCESS ();
01017 
01018   /* reset state table flags */
01019   stateBegin = 1;
01020   matched = 0;
01021 
01022   if (commandInData != NULL)
01023     {
01024       if (statusOutData != NULL)
01025         {
01026           if (statusOutData->command_type > 0)
01027             {
01028               DECISION_PROCESS ();
01029             }
01030         }
01031     }
01032 
01033   POST_PROCESS ();
01034   WRITE_COMM_BUFFERS ();
01035   check_cycle_time_end ();
01036 
01037 }

void NML_MODULE::DECISION_PROCESS void    [virtual]
 

Definition at line 789 of file node/nml_mod.cc.

Referenced by controller().

00790 {
00791 
00792 }

void NML_MODULE::READ_COMM_BUFFERS void    [virtual]
 

Definition at line 904 of file node/nml_mod.cc.

Referenced by controller().

00905 {
00906   read_command_in ();
00907   read_subordinates_status ();
00908   check_if_new_command ();
00909 }

void NML_MODULE::PRE_PROCESS void    [virtual]
 

Definition at line 912 of file node/nml_mod.cc.

Referenced by controller().

00913 {
00914 
00915 }

void NML_MODULE::WRITE_COMM_BUFFERS void    [virtual]
 

Definition at line 999 of file node/nml_mod.cc.

Referenced by controller().

01000 {
01001   write_status_out ();
01002   write_commands_to_subordinates ();
01003 }

void NML_MODULE::POST_PROCESS void    [virtual]
 

Definition at line 918 of file node/nml_mod.cc.

Referenced by controller().

00919 {
00920 
00921 }

int NML_MODULE::stateMatch char *    _source_file,
int    _source_line,
int    st,
int    conds = 1
 

Definition at line 1158 of file node/nml_mod.cc.

01160 {
01161   set_file_and_line (_source_file, _source_line);
01162   return stateMatch (st, conds);
01163 }

int NML_MODULE::stateMatch int    st,
int    conds = 1
 

Definition at line 1166 of file node/nml_mod.cc.

01167 {
01168   if (matched)
01169     {
01170       return 0;
01171     }
01172 
01173   // check if this is the first line in the state table
01174   if (stateBegin)
01175     {
01176       if (NULL != statusOutData)
01177         {
01178           statusOutData->line = 0;
01179         }
01180       source_line = -1;
01181       source_file = NULL;
01182       stateBegin = 0;
01183       if (state != st || !conds)
01184         {
01185           temp_line = -1;
01186           temp_file = NULL;
01187         }
01188     }
01189   else
01190     {
01191       // lines have gone before-- just increment
01192       if (NULL != statusOutData)
01193         {
01194           statusOutData->line++;
01195         }
01196     }
01197 
01198   // see if we match state and conditions
01199   if (state == st && conds)
01200     {
01201       matched = 1;
01202       source_file = temp_file;
01203       source_line = temp_line;
01204       return 1;
01205     }
01206   else
01207     {
01208       // no match
01209       return 0;
01210     }
01211 }

void NML_MODULE::stateNext int    st
 

Definition at line 1214 of file node/nml_mod.cc.

01215 {
01216   state = (RCS_STATE) st;
01217 }

void NML_MODULE::stateNext RCS_STATE    st
 

Definition at line 1220 of file node/nml_mod.cc.

01221 {
01222   state = (RCS_STATE) st;
01223 }

void NML_MODULE::read_command_in  
 

Definition at line 822 of file node/nml_mod.cc.

Referenced by READ_COMM_BUFFERS().

00823 {
00824   NMLTYPE type;
00825 
00826   if (force_command)
00827     {
00828       force_command = 0;
00829       return;
00830     }
00831 
00832   switch (type = commandIn->read ())
00833     {
00834     case -1:
00835       logError ("Can not read input command. (%d)", commandIn->error_type);
00836       if (NULL != statusOutData)
00837         {
00838           statusOutData->command_type = type;
00839         }
00840       break;
00841 
00842     case 0:
00843       // no new command
00844       break;
00845 
00846     default:
00847       commandInData = commandIn->get_address ();
00848       if (NULL != statusOutData)
00849         {
00850           statusOutData->command_type = type;
00851         }
00852       break;
00853     }
00854 }

void NML_MODULE::read_subordinates_status  
 

Definition at line 857 of file node/nml_mod.cc.

Referenced by READ_COMM_BUFFERS().

00858 {
00859   int t;
00860   NMLTYPE type;
00861 
00862   // read NML STATUS buffer from subordinates
00863   for (t = 0; t < numSubordinates; t++)
00864     {
00865       if (NULL == subs[t])
00866         {
00867           continue;
00868         }
00869       if (NULL == subs[t]->statusIn)
00870         {
00871           continue;
00872         }
00873       switch (type = subs[t]->statusIn->peek ())
00874         {
00875         case -1:
00876           // error on NML channel
00877           logError ("Can not read status from subodinate %s (%d).\n",
00878                     subs[t]->statusIn->cms->BufferName,
00879                     subs[t]->statusIn->error_type);
00880           break;
00881 
00882         case 0:
00883           // no new data
00884           break;
00885 
00886         default:
00887           subs[t]->statusInData = subs[t]->statusIn->get_address ();
00888           if (NULL != subs[t]->statusInData
00889               && NULL != subs[t]->commandOutData)
00890             {
00891               if (subs[t]->statusInData->echo_serial_number !=
00892                   subs[t]->commandOutData->serial_number)
00893                 {
00894                   subs[t]->statusInData->status = RCS_EXEC;
00895                 }
00896             }
00897           // something new in STATUS
00898           break;
00899         }
00900     }
00901 }

void NML_MODULE::write_status_out  
 

Definition at line 924 of file node/nml_mod.cc.

Referenced by WRITE_COMM_BUFFERS().

00925 {
00926   if (NULL == statusOutData)
00927     {
00928       return;
00929     }
00930   // update NML STATUS
00931   statusOutData->command_type = commandInData->type;
00932   statusOutData->state = state;
00933   statusOutData->status = status;
00934   if (status == RCS_DONE &&
00935       last_command_completed_serial_number != commandInData->serial_number)
00936     {
00937       last_command_completed_serial_number = commandInData->serial_number;
00938       commands_executed++;
00939     }
00940 
00941   statusOutData->source_line = source_line;
00942   if (NULL != source_file)
00943     {
00944       strncpy (statusOutData->source_file, source_file, 64);
00945     }
00946 
00947   // write STATUS
00948   if (-1 == statusOut->write (statusOutData))
00949     {
00950       logError ("bad write to status (%d)\n", statusOut->error_type);
00951     }
00952 }

void NML_MODULE::write_commands_to_subordinates  
 

Definition at line 955 of file node/nml_mod.cc.

Referenced by WRITE_COMM_BUFFERS().

00956 {
00957   int t;
00958   // write subordinates
00959   for (t = 0; t < numSubordinates; t++)
00960     {
00961       if (subs[t]->commandOutData == NULL)
00962         {
00963           continue;
00964         }
00965       if (subs[t]->commandOutData->type == 0)
00966         {
00967           continue;
00968         }
00969       if (subs[t]->statusInData != NULL)
00970         {
00971           if (subs[t]->statusInData->echo_serial_number ==
00972               subs[t]->commandOutData->serial_number
00973               && subs[t]->statusInData->echo_serial_number > 0
00974               && subs[t]->modification_number <= 0)
00975             {
00976               subs[t]->commandOutData->type = 0;
00977               continue;
00978             }
00979         }
00980       if (-1 == subs[t]->commandOut->write (subs[t]->commandOutData))
00981         {
00982           logError ("Error writing to %s (%d).\n",
00983                     subs[t]->commandOut->cms->BufferName,
00984                     subs[t]->commandOut->error_type);
00985         }
00986       else
00987         {
00988           //if the subordinates  command buffer is queued then
00989           // mark the command so it isn't sent out again.
00990           if (subs[t]->commandOut->cms->queuing_enabled)
00991             {
00992               subs[t]->commandOutData->type = 0;
00993             }
00994         }
00995     }
00996 }

void NML_MODULE::setCmdChannel RCS_CMD_CHANNEL   cmd_channel
 

Definition at line 381 of file node/nml_mod.cc.

00382 {
00383   if (NULL == cmd_channel)
00384     {
00385       rcs_print_error ("Command channel is NULL.\n");
00386       rcs_exit (-1);
00387     }
00388 
00389   commandIn = cmd_channel;
00390   if (!commandIn->valid ())
00391     {
00392       rcs_print_error ("Command channel is invalid.\n");
00393       rcs_exit (-1);
00394     }
00395   else
00396     {
00397       commandInData = commandIn->get_address ();
00398     }
00399   if (NULL != commandIn->cms)
00400     {
00401       if (NULL != commandIn->cms->ProcessName)
00402         {
00403           proc_name =
00404             (char *) malloc (strlen (commandIn->cms->ProcessName) + 1);
00405           strcpy (proc_name, commandIn->cms->ProcessName);
00406         }
00407     }
00408 }

void NML_MODULE::setStatChannel RCS_STAT_CHANNEL   stat_channel,
RCS_STAT_MSG   stat_msg
 

Definition at line 411 of file node/nml_mod.cc.

00413 {
00414   if (NULL == stat_channel)
00415     {
00416       rcs_print_error ("Status channel is NULL.\n");
00417       rcs_exit (-1);
00418     }
00419 
00420   statusOut = stat_channel;
00421   if (!statusOut->valid ())
00422     {
00423       rcs_print_error ("Status channel is invalid.\n");
00424       rcs_exit (-1);
00425     }
00426   if (NULL == stat_msg)
00427     {
00428       rcs_print_error ("Status out message is NULL.\n");
00429       rcs_exit (-1);
00430     }
00431   if (stat_msg->type <= 0)
00432     {
00433       rcs_print_error
00434         ("Status out message must have positive type. (type = %d)\n",
00435          stat_msg->type);
00436       rcs_exit (-1);
00437     }
00438   if (stat_msg->size < ((long) sizeof (RCS_STAT_MSG)))
00439     {
00440       rcs_print_error
00441         ("Status out message must have a size of atleast sizeof(RCS_STAT_MSG) or %d bytes,",
00442          sizeof (RCS_STAT_MSG));
00443       rcs_print_error ("but the status out message size was only %d.\n",
00444                        stat_msg->size);
00445       rcs_exit (-1);
00446     }
00447   statusOutData = stat_msg;
00448 }

void NML_MODULE::setErrorLogChannel NML   errorLog_channel
 

Definition at line 451 of file node/nml_mod.cc.

00452 {
00453   if (NULL == errorLog_channel)
00454     {
00455       rcs_print_error ("Error Log channel is NULL.\n");
00456       rcs_exit (-1);
00457     }
00458 
00459   errorLog = errorLog_channel;
00460   if (!errorLog->valid ())
00461     {
00462       rcs_print_error ("Error Log channel is invalid.\n");
00463       rcs_exit (-1);
00464     }
00465 
00466 }

int NML_MODULE::addSubordinate RCS_CMD_CHANNEL   cmd_channel,
RCS_STAT_CHANNEL   stat_channel
 

Definition at line 469 of file node/nml_mod.cc.

00471 {
00472   int sub_num = numSubordinates;
00473   setSubordinates (numSubordinates + 1);
00474   if (NULL == cmd_channel)
00475     {
00476       logError ("Command Channel for subordinate %d is NULL.\n", sub_num);
00477       rcs_exit (-1);
00478     }
00479   if (NULL == stat_channel)
00480     {
00481       logError ("Status Channel for subordinate %d is NULL.\n", sub_num);
00482       rcs_exit (-1);
00483     }
00484   subs[sub_num]->commandOut = cmd_channel;
00485   if (!subs[sub_num]->commandOut->valid ())
00486     {
00487       logError ("Command Channel for subordinate %d is invalid.\n", sub_num);
00488       rcs_exit (-1);
00489     }
00490   else
00491     {
00492       subs[sub_num]->commandOutData =
00493         subs[sub_num]->commandOut->get_address ();
00494     }
00495   commandOutData[sub_num] = subs[sub_num]->commandOutData;
00496 
00497   subs[sub_num]->statusIn = stat_channel;
00498   if (!subs[sub_num]->statusIn->valid ())
00499     {
00500       logError ("Command Channel for subordinate %d is invalid.\n", sub_num);
00501       rcs_exit (-1);
00502     }
00503   else
00504     {
00505       subs[sub_num]->statusInData = subs[sub_num]->statusIn->get_address ();
00506     }
00507   statusInData[sub_num] = subs[sub_num]->statusInData;
00508   return sub_num;
00509 }

int NML_MODULE::sendCommand RCS_CMD_MSG   cmd_msg,
int    sub_num
 

Definition at line 1226 of file node/nml_mod.cc.

01227 {
01228   if (sub_num >= numSubordinates || sub_num < 0)
01229     {
01230       return -1;
01231     }
01232   if (cmd_msg == NULL)
01233     {
01234       return -1;
01235     }
01236   if (cmd_msg->size <= 0 || cmd_msg->type <= 0)
01237     {
01238       return -1;
01239     }
01240   if (NULL == subs[sub_num])
01241     {
01242       return -1;
01243     }
01244   if (NULL == subs[sub_num]->statusInData)
01245     {
01246       return -1;
01247     }
01248   if (NULL == subs[sub_num]->commandOutData)
01249     {
01250       return -1;
01251     }
01252   if (NULL == subs[sub_num]->commandOut)
01253     {
01254       return -1;
01255     }
01256   if (NULL == subs[sub_num]->commandOut->cms)
01257     {
01258       return -1;
01259     }
01260 
01261   if (cmd_msg->size >= subs[sub_num]->commandOut->cms->size)
01262     {
01263       return -1;
01264     }
01265   memcpy (subs[sub_num]->commandOutData, cmd_msg, cmd_msg->size);
01266   subs[sub_num]->modification_number = 0;
01267   subs[sub_num]->commandOutData->serial_number =
01268     subs[sub_num]->statusInData->echo_serial_number + 1;
01269   return (0);
01270 }

int NML_MODULE::modifyCommand RCS_CMD_MSG   cmd_msg,
int    sub_num
 

Definition at line 1273 of file node/nml_mod.cc.

01274 {
01275   if (sub_num >= numSubordinates || sub_num < 0)
01276     {
01277       return -1;
01278     }
01279   if (cmd_msg == NULL)
01280     {
01281       return -1;
01282     }
01283   if (NULL == subs[sub_num])
01284     {
01285       return -1;
01286     }
01287   if (NULL == subs[sub_num]->commandOutData)
01288     {
01289       return -1;
01290     }
01291   cmd_msg->serial_number = subs[sub_num]->commandOutData->serial_number;
01292   memcpy (subs[sub_num]->commandOutData, cmd_msg, cmd_msg->size);
01293   subs[sub_num]->modification_number++;
01294   return (0);
01295 }

void NML_MODULE::setSelfCommand RCS_CMD_MSG   cmd
 

Definition at line 796 of file node/nml_mod.cc.

00797 {
00798   if (NULL == cmd || NULL == statusOutData || NULL == commandInData
00799       || NULL == commandIn)
00800     {
00801       return;
00802     }
00803   if (NULL == commandIn->cms)
00804     {
00805       return;
00806     }
00807   if (cmd->size > commandIn->cms->size)
00808     {
00809       rcs_print_error
00810         ("NML_MODULE::setSelfCommand, Command too big! %d(0x%X) > %d(0x%X)\n",
00811          cmd->size, cmd->size, commandIn->cms->size, commandIn->cms->size);
00812     }
00813   statusOutData->echo_serial_number++;
00814   cmd->serial_number = statusOutData->echo_serial_number + 1;
00815   commandIn->write (cmd);
00816   memcpy (commandInData, cmd, cmd->size);
00817   statusOutData->command_type = cmd->type;
00818   force_command = 1;
00819 }

void NML_MODULE::check_if_new_command void   
 

Definition at line 1065 of file node/nml_mod.cc.

Referenced by READ_COMM_BUFFERS().

01066 {
01067   if (NULL == commandInData)
01068     {
01069       return;
01070     }
01071   if (NULL == statusOutData)
01072     {
01073       return;
01074     }
01075   if (statusOutData->echo_serial_number != commandInData->serial_number)
01076     {
01077       state = NEW_COMMAND;
01078       status = RCS_EXEC;
01079       commands_received++;
01080       statusOutData->echo_serial_number = commandInData->serial_number;
01081       statusOutData->command_type = commandInData->type;
01082       command_time_averaged = 0;
01083       new_command_sequence = 1;
01084       new_line_num_sequence = 1;
01085 //    exec_status.line_num = 0;
01086     }
01087 }

void NML_MODULE::zero_common_vars  
 

Definition at line 213 of file node/nml_mod.cc.

Referenced by NML_MODULE().

00214 {
00215   commandIn = 0;
00216   force_command = 0;
00217   commandInData = 0;
00218   statusOut = 0;
00219   statusOutData = 0;
00220   subs = 0;
00221   commandLastNum = 0;
00222   commandOutstanding = 0;
00223   timer = 0;
00224   numSubordinates = 0;
00225   errorLog = 0;
00226   done = 0;
00227   statusInData = 0;
00228   commandOutData = 0;
00229 
00230 
00231   cycle_start = 0;
00232   cycle_stop = 0;
00233   command_time_averaged = 0;
00234   new_command_sequence = 0;
00235   new_line_num_sequence = 0;
00236   new_sup_request = 0;
00237 
00238   delta_clock = 0;
00239   command_current_time = 0;
00240 
00241   pause_status = 0;
00242   command = 0;
00243   last_line = 0;
00244 
00245   execute = 0;
00246   command_time = 0;
00247   state = UNINITIALIZED_STATE;
00248   status = UNINITIALIZED_STATUS;
00249 
00250   sup_req_num = 0;
00251   sup_req_num_echo = 0;
00252   command_num = 0;
00253   command_num_echo = 0;
00254 
00255   // state table vars
00256   matched = 0;
00257   stateBegin = 0;
00258 
00259 #if 0
00260 //below 010997-hui
00261   exec_status.command_num = 0;
00262   exec_status.command = 0;
00263   exec_status.status = 0;
00264   exec_status.state = 0;
00265   exec_status.line_num = 0;
00266   exec_status.command_time = 0;
00267 
00268   run_command.run_state = 0;
00269   run_command.step_num = 0;
00270 
00271   run_status.step_num_echo = 0;
00272   run_status.dummy1 = 0;
00273 #endif
00274 
00275   source_line = -1;
00276   source_file = NULL;
00277 
00278   commands_received = 0;
00279   commands_executed = 0;
00280   last_command_completed_serial_number = -1;
00281   total_run_time = 0;
00282   cycles = 0;
00283   max_cycle_time = 0;
00284   min_cycle_time = 1e6;
00285   last_cycle_time = 0;
00286   start_run_time = 0;
00287   stop_run_time = 0;
00288   last_start_run_time = 0;
00289   subs_allocated = 0;
00290   expected_cycle_time = 0;
00291   min_run_time = 1e6;
00292   max_run_time = 0;
00293   start_cycle_time = 0;
00294   temp_file = 0;
00295   temp_line = 0;
00296   Dclock_expiration = 0;
00297   Dclock_start_time = 0;
00298   log_line = 0;
00299   log_src = 0;
00300 }

int NML_MODULE::setSubordinates int    number
 

Definition at line 129 of file cms/nml_mod.cc.

Referenced by addSubordinate().

00130 {
00131   int t;
00132 
00133   if (number < 0)
00134     return -1;
00135 
00136   // record number of subordinates
00137   numSubordinates = number;
00138 
00139   // get out now if nothing else to do
00140   if (number == 0)
00141     return 0;
00142 
00143   // allocate subordinate NML channels
00144   commandOut =
00145     (RCS_CMD_CHANNEL **) malloc (number * sizeof (RCS_CMD_CHANNEL *));
00146   commandOutData = (RCS_CMD_MSG **) malloc (number * sizeof (RCS_CMD_MSG *));
00147   statusIn =
00148     (RCS_STAT_CHANNEL **) malloc (number * sizeof (RCS_STAT_CHANNEL *));
00149   statusInData = (RCS_STAT_MSG **) malloc (number * sizeof (RCS_STAT_MSG *));
00150 
00151   // allocate commandOutstanding array
00152   commandLastNum = (int *) malloc (number * sizeof (int));
00153   commandOutstanding = (int *) malloc (number * sizeof (int));
00154 
00155   // initialize each NML channel in the new arrays to 0
00156   for (t = 0; t < number; t++)
00157     {
00158       commandOut[t] = 0;
00159       commandOutData[t] = 0;
00160       statusIn[t] = 0;
00161       statusInData[t] = 0;
00162 
00163       commandOutstanding[t] = 0;
00164     }
00165 
00166   return 0;
00167 }

int NML_MODULE::setLogInfo const char *    src,
int    l
 

Definition at line 642 of file node/nml_mod.cc.

00643 {
00644   log_line = l;
00645   log_src = src;
00646   return (0);
00647 };

int NML_MODULE::logError const char *    fmt,
...   
 

Definition at line 175 of file cms/nml_mod.cc.

Referenced by addSubordinate(), read_command_in(), read_subordinates_status(), write_commands_to_subordinates(), and write_status_out().

00176 {
00177   NML_ERROR error_msg;
00178   va_list ap;
00179 
00180   // check channel for validity
00181   if (errorLog == NULL)
00182     return -1;
00183   if (!errorLog->valid ())
00184     return -1;
00185 
00186   // write args to NML message
00187   va_start (ap, fmt);
00188   vsprintf (error_msg.error, fmt, ap);
00189   va_end (ap);
00190 
00191   // force a NULL at the end for safety
00192   error_msg.error[NML_ERROR_LEN - 1] = 0;
00193 
00194   // write it
00195   errorLog->write (error_msg);
00196 
00197   return 0;
00198 }

int NML_MODULE::logText const char *    fmt,
...   
 

Definition at line 201 of file cms/nml_mod.cc.

00202 {
00203   NML_TEXT text_msg;
00204   va_list ap;
00205 
00206   // check channel for validity
00207   if (errorLog == NULL)
00208     return -1;
00209   if (!errorLog->valid ())
00210     return -1;
00211 
00212   // write args to NML message
00213   va_start (ap, fmt);
00214   vsprintf (text_msg.text, fmt, ap);
00215   va_end (ap);
00216 
00217   // force a NULL at the end for safety
00218   text_msg.text[NML_TEXT_LEN - 1] = 0;
00219 
00220   // write it
00221   errorLog->write (text_msg);
00222 
00223   return 0;
00224 }

int NML_MODULE::requestDisplay const char *    display
 

Definition at line 227 of file cms/nml_mod.cc.

00228 {
00229   NML_DISPLAY display_msg;
00230 
00231   // check channel for validity
00232   if (errorLog == NULL)
00233     return -1;
00234   if (!errorLog->valid ())
00235     return -1;
00236 
00237   // write args to NML message
00238   strcpy (display_msg.display, display);
00239 
00240   // force a NULL at the end for safety
00241   display_msg.display[NML_DISPLAY_LEN - 1] = 0;
00242 
00243   // write it
00244   errorLog->write (display_msg);
00245 
00246   return 0;
00247 }

void NML_MODULE::stop_timing void   
 

Definition at line 277 of file cms/nml_mod.cc.

00278 {
00279   if (NULL == exec_history)
00280     {
00281       return;
00282     }
00283   RCS_MODULE_C::update_line_num_history ();
00284 }

void NML_MODULE::set_file_and_line char *    _source_file,
int    _source_line
 

Definition at line 1145 of file node/nml_mod.cc.

Referenced by stateMatch().

01146 {
01147   temp_file = _source_file;
01148   temp_line = _source_line;
01149 }

void NML_MODULE::check_cycle_time_start  
 

Definition at line 1040 of file node/nml_mod.cc.

Referenced by controller().

01041 {
01042   start_run_time = etime ();
01043   cycles++;
01044   if (cycles < 2)
01045     {
01046       start_cycle_time = start_run_time;
01047     }
01048   else
01049     {
01050       last_cycle_time = start_run_time - last_start_run_time;
01051       if (last_cycle_time > max_cycle_time)
01052         {
01053           max_cycle_time = last_cycle_time;
01054         }
01055       if (last_cycle_time < min_cycle_time)
01056         {
01057           min_cycle_time = last_cycle_time;
01058         }
01059     }
01060   last_start_run_time = start_run_time;
01061 }

void NML_MODULE::check_cycle_time_end  
 

Definition at line 1135 of file node/nml_mod.cc.

Referenced by controller().

01136 {
01137   stop_run_time = etime ();
01138   total_run_time += stop_run_time - start_run_time;
01139 }

void NML_MODULE::print_statistics  
 

Definition at line 1090 of file node/nml_mod.cc.

01091 {
01092   double total_time = stop_run_time - start_cycle_time;
01093   rcs_print ("\n*************************************************\n");
01094   if (NULL != proc_name)
01095     {
01096       rcs_print ("Module Name: %s\n", proc_name);
01097     }
01098   rcs_print ("Total cycles: %d\n", cycles);
01099   rcs_print ("Total time: %f\n", total_time);
01100   if (cycles > 0)
01101     {
01102       rcs_print ("Average Cycle Time: %f\n", total_time / cycles);
01103     }
01104   else
01105     {
01106       rcs_print ("Average Cycle Time: CAN NOT BE DETERMINED\n");
01107     }
01108 
01109   rcs_print ("Minimum Cycle Time: %f\n", min_cycle_time);
01110   rcs_print ("Max Cycle Time: %f\n", max_cycle_time);
01111   rcs_print ("Commands Received: %d\n", commands_received);
01112   if (total_time > 0)
01113     {
01114       rcs_print ("Commands Received per second: %f\n",
01115                  commands_received / total_time);
01116     }
01117   else
01118     {
01119       rcs_print ("Commands Received per second: CAN NOT BE DETERMINED\n");
01120     }
01121 
01122   if (total_time > 0)
01123     {
01124       rcs_print ("Load: %f%%\n", total_run_time * 100 / total_time);
01125     }
01126   else
01127     {
01128       rcs_print ("Load: CAN NOT BE DETERMINED\n");
01129     }
01130 
01131   rcs_print ("*************************************************\n");
01132 }

void NML_MODULE::loadDclock double    expiration
 

Definition at line 1298 of file node/nml_mod.cc.

01299 {
01300   Dclock_expiration = expiration;
01301   Dclock_start_time = etime ();
01302 }

int NML_MODULE::checkDclock  
 

Definition at line 1305 of file node/nml_mod.cc.

01306 {
01307   return (fabs (etime () - Dclock_start_time) < Dclock_expiration);
01308 }


Field Documentation

int NML_MODULE::force_command
 

Definition at line 189 of file nml_mod.hh.

long NML_MODULE::cycle_start
 

Definition at line 201 of file nml_mod.hh.

long NML_MODULE::cycle_stop
 

Definition at line 202 of file nml_mod.hh.

int NML_MODULE::command_time_averaged
 

Definition at line 204 of file nml_mod.hh.

int NML_MODULE::new_command_sequence
 

Definition at line 205 of file nml_mod.hh.

int NML_MODULE::new_line_num_sequence
 

Definition at line 206 of file nml_mod.hh.

int NML_MODULE::new_sup_request
 

Definition at line 207 of file nml_mod.hh.

long NML_MODULE::delta_clock
 

Definition at line 209 of file nml_mod.hh.

long NML_MODULE::command_current_time
 

Definition at line 210 of file nml_mod.hh.

int NML_MODULE::pause_status
 

Definition at line 212 of file nml_mod.hh.

int NML_MODULE::command
 

Definition at line 213 of file nml_mod.hh.

int NML_MODULE::last_line
 

Definition at line 214 of file nml_mod.hh.

int NML_MODULE::execute
 

Definition at line 216 of file nml_mod.hh.

int NML_MODULE::command_time
 

Definition at line 217 of file nml_mod.hh.

RCS_STATE NML_MODULE::state
 

Definition at line 218 of file nml_mod.hh.

int NML_MODULE::status
 

Definition at line 219 of file nml_mod.hh.

int NML_MODULE::sup_req_num
 

Definition at line 221 of file nml_mod.hh.

int NML_MODULE::sup_req_num_echo
 

Definition at line 222 of file nml_mod.hh.

int NML_MODULE::command_num
 

Definition at line 223 of file nml_mod.hh.

int NML_MODULE::command_num_echo
 

Definition at line 224 of file nml_mod.hh.

int NML_MODULE::matched [private]
 

Definition at line 227 of file nml_mod.hh.

int NML_MODULE::stateBegin [private]
 

Definition at line 229 of file nml_mod.hh.

char* NML_MODULE::source_file [private]
 

Definition at line 231 of file nml_mod.hh.

int NML_MODULE::source_line [private]
 

Definition at line 232 of file nml_mod.hh.

RCS_CMD_CHANNEL* NML_MODULE::commandIn
 

Definition at line 246 of file nml_mod.hh.

RCS_STAT_CHANNEL* NML_MODULE::statusOut
 

Definition at line 247 of file nml_mod.hh.

NML* NML_MODULE::errorLog
 

Definition at line 248 of file nml_mod.hh.

RCS_CMD_MSG* NML_MODULE::commandInData
 

Definition at line 250 of file nml_mod.hh.

RCS_STAT_MSG* NML_MODULE::statusOutData
 

Definition at line 251 of file nml_mod.hh.

int* NML_MODULE::commandLastNum
 

Definition at line 253 of file nml_mod.hh.

int* NML_MODULE::commandOutstanding
 

Definition at line 254 of file nml_mod.hh.

NML_SUBORDINATE_STRUCT** NML_MODULE::subs
 

Definition at line 257 of file nml_mod.hh.

RCS_STAT_MSG** NML_MODULE::statusInData
 

Definition at line 258 of file nml_mod.hh.

RCS_CMD_MSG** NML_MODULE::commandOutData
 

Definition at line 259 of file nml_mod.hh.

RCS_TIMER* NML_MODULE::timer
 

Definition at line 261 of file nml_mod.hh.

int NML_MODULE::done
 

Definition at line 263 of file nml_mod.hh.

int NML_MODULE::commands_received
 

Definition at line 273 of file nml_mod.hh.

int NML_MODULE::commands_executed
 

Definition at line 274 of file nml_mod.hh.

int NML_MODULE::cycles
 

Definition at line 275 of file nml_mod.hh.

int NML_MODULE::cycles_executing
 

Definition at line 276 of file nml_mod.hh.

int NML_MODULE::cycles_executing_completed_commands
 

Definition at line 277 of file nml_mod.hh.

int NML_MODULE::cycles_executing_this_command
 

Definition at line 278 of file nml_mod.hh.

int NML_MODULE::last_command_completed_serial_number
 

Definition at line 279 of file nml_mod.hh.

double NML_MODULE::expected_cycle_time
 

Definition at line 280 of file nml_mod.hh.

double NML_MODULE::start_run_time
 

Definition at line 281 of file nml_mod.hh.

double NML_MODULE::last_start_run_time
 

Definition at line 282 of file nml_mod.hh.

double NML_MODULE::stop_run_time
 

Definition at line 283 of file nml_mod.hh.

double NML_MODULE::total_run_time
 

Definition at line 284 of file nml_mod.hh.

double NML_MODULE::min_run_time
 

Definition at line 285 of file nml_mod.hh.

double NML_MODULE::max_run_time
 

Definition at line 286 of file nml_mod.hh.

double NML_MODULE::start_cycle_time
 

Definition at line 287 of file nml_mod.hh.

double NML_MODULE::min_cycle_time
 

Definition at line 288 of file nml_mod.hh.

double NML_MODULE::max_cycle_time
 

Definition at line 289 of file nml_mod.hh.

double NML_MODULE::last_cycle_time
 

Definition at line 290 of file nml_mod.hh.

char* NML_MODULE::proc_name [protected]
 

Definition at line 301 of file nml_mod.hh.

char* NML_MODULE::temp_file [protected]
 

Definition at line 302 of file nml_mod.hh.

int NML_MODULE::temp_line [protected]
 

Definition at line 303 of file nml_mod.hh.

int NML_MODULE::numSubordinates [protected]
 

Definition at line 304 of file nml_mod.hh.

double NML_MODULE::Dclock_expiration [protected]
 

Definition at line 305 of file nml_mod.hh.

double NML_MODULE::Dclock_start_time [protected]
 

Definition at line 306 of file nml_mod.hh.

int NML_MODULE::log_line [protected]
 

Definition at line 307 of file nml_mod.hh.

const char* NML_MODULE::log_src [protected]
 

Definition at line 308 of file nml_mod.hh.

int NML_MODULE::subs_allocated
 

Definition at line 313 of file nml_mod.hh.

int NML_MODULE::use_realloc = 1 [static]
 

Definition at line 512 of file node/nml_mod.cc.


The documentation for this class was generated from the following files:
Generated on Sun Dec 2 15:58:49 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001