file name: algfta.hpp, algfta.cpp
classification: simulation
contents: class CFta, derived from class ACClockSyncAlgorithm,
class CMidpoint, derived from class CFta
use: provides a convergence function that uses fault tolerant
average (FTA) to compute a new clock value; whereas CFta uses
the reference point of all time intervals, CMidpoint uses the
midpoints of the intervals
global items used by CFta:
member variables of CFta:
EBool
midpoint_: is True if function FTA() should use the midpoint
of the time intervals, False if it should use the reference point.
member functions of CFta:
CFta (CClockSync
*cs): Sets member midpoint to False. If cs is NULL,
an assert fails.
virtual
EBool ConvergenceFunction (): The function first gets the associated
network calling GetAssociatedNetwork(). If it exists, FTA()
is called with this network. If the function returns True, the new clock
value is set to the midpoint of the interval computed by the FTA and stored
in newClockValue, and timeValid is set to True. If there
is no associated network, or if FTA() returns False, timeValid
is set to False. The function returns True if a new timestamp could be
computed (in that case, inherited function ReportInterval() is
called with the resulting interval of the CV), False if no associated network
exists or if FTA() has failed.
Note: If no associated network exists, FTA() is not
called and the database remains unchanged. If FTA() is called
and fails, all time intervals stored for the associated network are discarded.
static ACClockSyncAlgorithm
*CreateFta(CClockSync *cs): Creates a new object of type CFta
(passes cs to the ctor) and returns a pointer to it.
EBool FTA
(STimeInterval& interval, SINT32 networkID): Computes the new
clock interval for the network, uses the time intervals that are stored
in database. All interval entries of the given network are then
deleted. The function returns True if the computation was successful, in
that case interval contains the computed timestamp. If the computation
has failed, False is returned and interval is not changed.
Note: the FTA does not work with the stored intervals, but with
single timestamps. If midpoint is True, the midpoints of the intervals
are used as input to the FTA. Otherwise, the reference points are used.
In any case, the timestamps are sorted, the first and last faulty
are discarded, and the rest is averaged to obtain the new clock value.
At last, interval::low, interval::high and interval::refpoint
are set to that result.
global items used by CMidpoint:
member functions of CMidpoint: CMidpoint
(CClockSync *cs): calls the ctor of CFta and sets inherited
member midpoint to True.
static ACClockSyncAlgorithm
*CreateMidpoint(CClockSync *cs): Creates a new object of type CMidpoint
(passes cs to the ctor) and returns a pointer to it.
local items of the implementation file:
const INT32
HighestAccuracyBit: the highest bit in the timestamp that is covered
by the accuracy (as seen from the lsb of the timestamp).
const INT32
HighestAccuracyValue: the highest value in the timestamp that is covered
by the accuracy.
const INT32
Infinity: infinite accuracy (that is, the limit of the accuracy value).
local (static) functions of the implementation file:
SExtendedTimestamp
Mean (const CNtpTime& low, const CNtpTime& high): returns
the arithmetic mean of the two time values, sets the accuracies to "high-mean"
and "mean-low".