file name: algfetz.hpp, algfetz.cpp
classification: simulation
contents: class CFtaWithFetzer, derived from class CFta
use: implements the Fetzer algorithm, which tries to incorporate
external synchronization into internal synchronization
global items used by CFtaWithFetzer:
local items of the implementation file:
const INT32
NumberOfPNodes: the maximum number of P-Node messages that can arrive
within one round.
member variables of CFtaWithFetzer:
STimeInterval
*gpsdata: array for storing the data of the P-Nodes.
INT32
gpsdataIndex: the first free entry in the gpsdata array.
default and reset value: 0
EBool
initCalled_: is set to True by Init(), to False by Dispose().
default and reset value: True
member functions of CFtaWithFetzer:
CFtaWithFetzer
(CClockSync *cs): Sets initCalled to False and calls
Init().
If cs is NULL, an assert fails.
~CFtaWithFetzer
(): Calls Dispose() to free all dynamic memory.
virtual
EBool ConvergenceFunction (): The function first calls the convergence
function of CFta to compute the resulting timestamp for the S-Nodes.
If it returns False, then the P-Node data is discarded at once and False
is returned by this function as well. If it returns True and there is no
data from P-Nodes, this function also returns True and the result of the
internal synchronization is used. Otherwise, the average of all time intervals
from P-Nodes is computed to form a result for the external synchronization,
and the final timestamp is computed according to the Fetzer algorithm (with
some adaptions to facilitate computation):
Let t_ext be the external result, t_int the internal
result, and M = P_round*rho_plus, where P_round is the
round period and rho_plus the worst case value of the positive
rate drift. Then the result t_res is set to
static ACClockSyncAlgorithm
*CreateFtaWithFetzer (CClockSync *cs): Creates a new object of type
CFtaWithFetzer
(passes cs to the ctor) and returns a pointer to it.
virtual
void Dispose(): If initCalled_ is False, the function returns
at once. Otherwise, it deletes the gpsdata array, calls CFta::Dispose()
and sets initCalled_ to False.
virtual
void Init(): If initCalled_ is True, the function returns
at once. Otherwise, it calls CFta::Init(), creates the array gpsdata,
sets gpsdataIndex to its default value and sets initCalled_
to True.
virtual
EBool StoreTime (const STimestamp& time, double resync, SINT32 networkID,
const CAddr& netAddress, int area, EBool gps): If gps
is False, then CFta::StoreTime() is called to handle S-Node data.
Otherwise, the accuracies of time are adjusted so that they are
valid at time resync. If the inherited database does not contain
transmission delay data or if the gpsdata array is already full,
then False is returned and the function has no effect. Otherwise, the resulting
interval is stored in gpsdata and the function returns True.
virtual
void Suspend(): Calls CFta::Suspend() to discard the data
from the S-Nodes, discards all data from the P-Nodes, and sets timeValid
to False.