index previous next




file name: sim_gen.hpp, sim_gen.cpp
classification: pure simulation
contents: functions GetCurrentNodeID() and GetClockvalue(), struct SMsg
use: provides all globals needed only in pure simulation


global items used by the functions:


 EBool GetClockvalue (SINT32 nodeID, int area, STimestamp& time): Obtains the timestamp of the specified area on the given node. The function searches the listOfClocks for the clock with the <nodeID, area> key and calls CClock::GetTimestamp(). It returns True if the clock was found (in that case, time is set to the clock value), False if the clock was not found.

 SINT32 GetCurrentNodeID (): Returns the ID of the node that is currently active or NoAccount if no process is active.


 struct SMsg: The structure is used by the network to transmit a message from the sender to the receiver node. Apart from the message itself, a lot of internal information is used to specify what should be done with the message.


 int area: the DMA area of the sending node.

 EBool broadcast: True if the message should be broadcast, False if it is dedicated (in that case, receiver must be valid).

 bufx *buf: the data buffer that is transmitted.

 INT16 bufsize: the size of the buffer.

 int if_num: The ID of the transmitting network.

 INT32 msgID: the number of the message. The triple <sender, area, msgID> is unique.

 SINT32 receiver: the ID of the receiver node.

 INT32 rtime[MAXASICS]: Contains the send timestamps of the receiver(!) node. That is needed for the test of delay measurement.

 SINT32 sender: the ID of the sending node.

 EBool timestamped: True if the message should be timestamped.


 SMsg (): Sets bufsize to zero, buf to NULL. broadcast is set to True, and timestamped is set to False. The other members stay uninitialized.

 SMsg (bufx *b, INT16 size, int ifcNumber, int a): Copies the parameter values into the corresponding variables. Apart from that, broadcast is set to True and timestamped is set to False. If b is NULL, bufsize is set to 0, regardless of the value of size. Function ci_get_tbuf() is used to request a buffer of bufsize bytes. If this function returns an error, an assert fails. If b is not NULL and size is not zero, size bytes of b are copied into the internal buffer.

 SMsg (const SMsg& m): Copies the data of m into the own members. The internal buffer is allocated with ci_get_tbuf(), and if this function returns an error, an assert fails.

 ~SMsg(): If buf is not NULL, it is returned using ci_ret_tbuf(). The return value of this function is not checked.

 SMsg& operator= (const SMsg& m): Copies the data of m into the own members. If the buffer sizes of m::buf and the internal buf do not match, ci_ret_tbuf() is used to return buf (if it was not NULL), and ci_get_tbuf() is called to get a new buffer of the correct size. The return value of ci_ret_tbuf() is not checked, but if ci_get_tbuf() returns an error code, an assert fails.

 void SetTime (STimestamp time): If timestamped is True, the function puts the internal area and time (macrostamp, timestamp and accuracy) into buf. The position (and length) of the items are obtained by GetPosition(). All other data is shifted accordingly to make room for the new data. If the necessary space does not fit into the buffer, the buffer is returned with ci_ret_tbuf() and a new buffer is allocated using ci_get_tbuf(). Again, only the return value of ci_get_tbuf() is checked, and if it is not zero, an assert fails.
The function asserts that all items have sizes between zero and four byte. In addition, the accuracy may only have a size of zero, two or four bytes. And if the size of the macrostamp is greater than zero, the timestamp must have a size of four bytes.
If an item has a size less than four bytes, the following part of the original four byte value is used:


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