Libfaults is a project mainly written in ..., based on the BSD-3-Clause license.
A standalone library for modelling faults on ground-truth values.
A standalone library for modelling faults on ground-truth values.
Faulty values can be applied in-place, i.e. overwriting the ground truth, or returned as an extra variable.
Change into the build directory of libfaults and configure cmake
:
$ cd libfaults/build
$ cmake ..
Compile libfaults, run the unit tests and install if they all pass:
$ make && make test && make install
All properties for a fault model can be passed as parameters when constructed and changed using the appropriate Get/Set methods during usage. Two key methods are provided for getting faulty values:
GetFaulty(value) Applies the fault model to the given value and returns the faulty value, leaving the original value unmodified.
MakeFaulty(value) The same as GetFaulty, but modifies the true value in-place.
Fault models are templated classes supporting all signed/unsigned integers from 8 to 64 bits, along with floats, doubles and long doubles. The faulty values generated are of the same type as the original values. For example, a random fault model taking an integer value with always return integer values within a given range, never a floating point type.
Constant: Always replaces the true value with a constant value.
Cycle: Iterates through a value list, returning the next value in sequence each time GetFaulty/MakeFaulty is called. Wraps around when the last item is reached.
Noise: Either offsets or scales the true value by a random amount within a given range.
Offset: Offsets the true value by a constant amount.
Random: Replaces the true value with either a random number within a given range or, if given a value list, with a random item from it.
Scale: Scales the true value by a constant amount.
To offset a ground truth reading by +5.0:
OffsetFaultModel<double> fm = new OffsetFaultModel<double>(5.0);
double groundTruth = GetTrueValue();
fm.MakeFaulty(groundTruth);
Alternatively, using an extra variable:
OffsetFaultModel<double> fm = new OffsetFaultModel<double>(5.0);
double groundTruth = GetTrueValue();
double faultyValue = fm.GetFaulty(groundTruth);