indexpreviousnext

file name: evalfunc.hpp, evalfunc.cpp
classification: evaluation
contents: many global functions
use: provides all functions of the evaluation that are necessary for communicating with SimUTC
 

global items used:


global items provided:

void ExecuteCommand (CStreamInterface *sock, SCommand *command): Sends the command over the socket.

void SetParameter (CStreamInterface *sock, SParameter *param): Sends the parameter over the socket.

EBool GetParameter (CStreamInterface *sock, SSingleParameter *param): Sends the parameter over the socket, waits for the reply and modifies param->value.

EBool ReceiveEvent (CStreamInterface *sock): Receives an event and prints it to cout. Returns True if the event was received successfully, else False.

EBool ReceiveReply (CStreamInterface *sock, SReply **reply): Receives a reply, allocates the appropriate reply structure and returns it in reply. Returns True if the reply was received successfully, else False. The function converts boolean/double replies if g_byteOrderReversed is True.

void CheckBooleanReply (CStreamInterface *sock, const char *command): Waits for a reply and prints an error message containing 'command' to cerr if (a) there was no reply, (b) it was no boolean reply, or (c) the reply contained the boolean value False.

int SelectSocket (): Waits for the supervisor sockets to become readable (using select()) and returns the index of the first socket that is readable (if more than one socket is readable, the smallest index is returned). If there is a timeout or some other failure, NoAccount is returned.
The function assumes that the arrays supsid[] (global) and supsock[] (local) correspond (i.e., the data of a particular socket has the same index in both arrays).

EBool SocketExists (const ACSocketAddress *addr, ESocketType type): Checks if the socket with the given address already exists and returns True if the check succeeds, False if the socket does not exist. The function performs its check by creating a socket with this address and type and by checking if the bind() call fails.

void PrintConfiguration (): Prints the system configuration.

void PrintPrecision (): Prints the precision data collected during evaluation.

void OpenPlotFiles(): Creates and opens all files needed for gnuplot output.

void ClosePlotFiles(): Closes all files needed for gnuplot output.
 

local items used:

#define PLOT_DIR: contains the name of the directory into which the gnuplot files are written. The macro is only defined if PLOT_DATA is defined. If you want to create the files in the working directory, then you should set the macro to the empty string. If a directory is specified, then the path must contain a trailing '/'.

#define Assert(expr): the macro is redefined if NDEBUG is not defined. The original macro from error.hpp is undefined and a new version is defined instead. This new macro evaluates to an if-statement checking whether expr is False and if it is, it deletes the serverSocket and then calls ReportError() like the original macro.

static double piMin: Contains the minimum precision of all snapshot rounds.
static double piMax: Contains the maximum precision of all snapshot rounds.
static double piSum: Contains the sum of all precisions (from all snapshot rounds).
static INT32 piRoundNumber: Stores the number of encountered snapshot rounds.

These variables are used to keep track of the best, worst, and average precision encountered during a simulation run.
Note: in fact, the piMin/Max/Sum values are not from all rounds, but their computation is started from a user-definable round on (the user sets the synchronization round in SEvalsysConfigData, and from this value the first valid snapshot round is computed).

static filebuf Frun: LaTeX wrapper file
static filebuf Fpik[numberOfNodes-1]: k-th precision file
static filebuf Fstate[numberOfNodes]: state file
static filebuf Fadj[numberOfNodes]: adjustments file
static filebuf Facc[numberOfNodes]: accuracy file
static filebuf Frate[numberOfNodes]: rates file
static filebuf Fgammak[numberOfNodes-1]: k-th consonance file
static filebuf Fdrift[numberOfNodes]: drifts file
static filebuf Fmult[numberOfNodes]

static ostream outRun: output stream for LaTeX wrapper file
static ostream outPik[numberOfNodes-1]: output stream for k-th precision
static ostream outState[numberOfNodes]: output stream for state
static ostream outAdj[numberOfNodes]: output stream for adjustments
static ostream outAcc[numberOfNodes]: output stream for accuracy
static ostream outRate[numberOfNodes]: output stream for rates
static ostream outGammak[numberOfNodes-1]: output stream for k-th consonance
static ostream outDrift[numberOfNodes]: output stream for drifts
static ostream outMult[numberOfNodes]

The file buffers and output streams are only available if PLOT_DATA is defined. In that case, they are used to plot various data ranging from clock accuracies to rate intervals into separate files.
 

static void AddConsonance (double rate, double simTime): Computes the consonance per round and stores it in global consonance data. The function is only available if PLOT_DATA is defined.

static void AddPrecision (double accuracy, double simTime): Computes the precision per round and stores it in the global precision data piMin, piMax, piSum and piRoundNumber.

static INT32 FirstSnapshotPrecisionRound: This is the first snapshot round that is taken into consideration when computing the precision. Do not confuse it with the synchronization round: the number of snapshot rounds depends on the SnapshotPeriod of the Supervisor triggering the snapshots, whereas the number of synchronization rounds depends on the RoundPeriod of the CSAs.

static void GenerateTexFile(): Prints the TeX-Output into a TeX-file named run.tex that is created in directory PLOT_DIR.

static const char *ModuleToString (EModule module): Converts a module number into a string constant (same function as in error.cpp).

static void Normalize (double input, double& output, char *unit): Converts input (which is given in seconds) to a double output >= 1 and stores the name of the unit of output in unit. String unit should be at least 8 characters wide.

static void OpenFile (filebuf *file, ostream* stream, int number,  const char *name): Generates the filename from name followed by number+1, with the extension ".dat" in the subdirectory PLOT_DIR, opens the filebuffer file[number] and associates the buffer with the ostream stream[number].
Example for file name generation: if PLOT_DIR is "test/", name is hello and number is 3, then the file that is opened has the name "test/hello4.dat".

static void OpenOrderFile (filebuf *file, ostream* stream, int number, const char *name): Same as OpenFile(), but the filename is generated from name followed by number (i.e., starting from 0), which is required by k-th order plots.

static void PlotInterval (ostream& out, double x, double y, double l, double u): Prints the line "x y l u" on stream out.

static void PlotPoint (ostream& out, double x, double y): Prints the line "x y" on stream out.

static double PrecisionKth (double* pi, INT32 upper, INT32 order): Computes the kth precision among pi[0], ..., pi[upper-1] which are supposed to be sorted ascendingly. If order=0, it returns the maximum distance, for order=1 the 2nd maximum distance, etc.

static void PrintCSAEvent (SEvent *event, _IO_ostream_withassign& out): Prints events from the CSAs.
Note: the function must convert the event even if it does not need its data. The calling function depends on it.

static void PrintEvent (SEvent *event): Prints the event data to cout.

static void PrintMsg (SINT32 msgID, SINT32 sender, int area, SINT32 receiver, _IO_ostream_withassign& out): Prints the data of one message. Format: "message <msgID> (<sender>,<area> => <receiver>) ".

static void PrintNetworkEvent (SEvent *event, _IO_ostream_withassign& out): Prints events from the network.
Note: the function must convert the event even if it does not need its data. The calling function depends on it.

static void PrintNormal (ostream& o, const char* param, double value): Prints the value to o in the form "<param> = <norm> <unit>", where norm and unit are obtained from Normalize().

static void PrintProbability (ostream& o, const char *prob, double value): Prints the string "probability of <prob> = <value>" to o.

static void SortArray (double* unsortedArray, double* sortedArray, INT32 size): Sorts an array of doubles.

static ostream& TexPrintPicture (ostream& out, const char *picture): Prints the TeX-text for displaying the postscript picture picture to out.

static ostream& TexPrintTime (ostream& out): Prints the time and date in TeX-format to out, followed by a newline.

const double TwoPowMinus23: Contains value of 2-23.
 


last modified: Fri Feb 5 18:56:16 1999