Processors#
Processors are compiled pre-defined routines.
They provide functionality that would be hard or slow to implement in FDL.
Trigonometric#
Calculated in radians:
acos(x)asin(x)atan(x)atan2(x,y)(arc tan ofy/x)cos(x)cosh(x)sin(x)sinh(x)tan(x)tanh(x)
Mathematical#
Simple scalar calculations:
abs(x)ceil(x)exp(x)floor(x)ln(x)(natural logarithm)log(x)(base 10 logarithm)sqrt(x)
Calulated against parameters with respect to time (even in distance-mode):
derivative(param)integral(param)
Logical#
not(x)or!x- Returns
TRUEifxis 0, otherwiseFALSE. IsInRange(a, b, epsilon)- Returns
1ifais in range ofb. IsGT(a, b)- Returns
1ifais greater thanb, otherwise returns0. IsGE(a, b)- Returns
1ifais greater than or equal tob, otherwise returns0. IsLT(a, b)- Returns
1ifaif less thanb, otherwise returns0. IsLE(a, b)- Returns
1isais less than or equal tob, otherwise returns0.
Interpolation#
BiLinearInterpolate(file, x, y)-
Returns a bi-linearly interpolated result corresponding to
x,yfromfile.xandyare parameter names (e.g.$vCar) or expressionsfileis the path to a.3dfile in the format specified below.
Data file format
The filename must have the extension
.3dThe content is ASCII text, representing the values of data points in a grid. Comment lines are prefixed with
#.Grid rules:
- The grid must be fully populated and rectilinear but need not be regular
i.e. there may be irregular intervals between ordinates but each intersection of an ordinate must have a data value; - There must be at least 4 data points in the grid;
- Entries must be ordered within a row such that column range values increase to the right
and within a column such that row range values increase to the bottom; - Entries on the same line must be separated with tabs or commas;
- Both input values must lie within the grid.
If any of these rules are broken,
BiLinearInterpolate(...)returns a result of0and a warning is displayed when ATLAS first attempts to use the processor.Line Entry Description 1 blank , X1, X2, …, Xi Xi = value of column i ordinate 2 Y1, Z1,1, Z2,1, … , Zi,1 1st row of table (i columns × j rows),
Yi = value of row j ordinate
Zi,j = data value at intersection of column i and row j3 Y2, Z1,2, Z2,2, … , Zi,2 2nd row of table … … 3rd and successive rows of table n Yj, Z1,j, Z2,j,... , Zi,j last row of table Example
This file…
# Example 3d grid ,5,7.5,10 0,1,2,3 10,4,5,6 25,7,8,9 30,10,11,12… creates this table:
Input X Range 5 7.5 10 Input Y Range 0 1 2 3 10 4 5 6 25 7 8 9 30 10 11 12 Formulae
If Xi <=
x<= Xi+1 and Yj <=y<= Yj+1 thenZa = Zi,j + ( (
x- Xj) * (Zi+1,j - Zi,j) / (Xi+1 - Xi) )
Zb = Zi,j+1 + ( (x- Xj) * (Zi+1,j+1 - Zi,j+1) / (Xi+1 - Xi) )
result = Za + ( (y- Yj) * (Zb - Za) / (Yj+1 - Yj) ) LinearInterpolate(file, x)-
Returns a linearly-interpolated result corresponding to
xfromfile.xis a parameter name (e.g.$vCar) or expressionfileis the path to a.3dfile in the format specified below.
If
xunder or over the limits of the data set then a result extrapolated from the lowest or highest two data points is returned.Data file format
The filename must have the extension
.2dThe content is ASCII text, representing the values of data points in a grid. Comment lines are prefixed with
#.Grid rules:
- There must be at least two pairs of data but there can be as many as required;
- Entries must be ordered with lowest input, first;
- Entries on the same line must be separated with tabs or commas;
- No consecutive pair of inputs may be the same (to prevent divide by zero errors when calculating m).
If any of these rules are broken,
LinearInterpolate(...)returns a result of0and a warning is displayed when ATLAS first attempts to use the processor.Line Entry Description 1 Y1, Z1 1st pair (Y = input value, Z = resulting data value); required 2 Y2, Z2 2nd pair; required … … 3rd and successive pairs; optional n Yn, Zn last pair Example
This file…
# Example 2d grid 0,1 10,4 25,7 30,10… creates this table:
Input range Data values 0 1 10 4 25 7 30 10 Formulae
- If
xis between Yi and Yi+1 then result = mi*(x– Yi) + Zi - If
xis below Y1 then result = m1*(x- Yi) + Z1 - If
xis above Yn then result = mn-1*(x- Yn) + Zn
Where mi = (Zi+1 - Zi)/(Yi+1 - Yi)
Filtering#
Note
param must be a parameter from a data channel or another function, not the result of a calculation:
Filter(param,freq)- Calculates the smoothed value of the parameter.
This is a low-pass filter with a cut-off frequency offreq. HighPassFilter(param,freq)- Calculates the smoothed value of the parameter.
This is a high-pass Filter with a cut-off frequency offreq. DigitalFilter1(param, B1, B2, A1, A2)- Implements a 1st order digital filter using the difference equation
A1y(n) =B1x(n) +B2x(n-1) -A2y(n-1) DigitalFilter2(param, B1, B2, B3, A1, A2, A3)- Implements a 2nd order digital filter using the difference equation
A1y(n) =B1x(n) +B2x(n-1) +B3x(n-2) –A2y(n-1) -A3y(n-2) DigitalFilter3(param, B1, B2, B3, B4, A1, A2, A3, A4)- Implements a 3rd order digital filter using the difference equation
A1y(n) =B1x(n) +B2x(n-1) +B3x(n-2) +B4x(n-3) -A2y(n-1) -A3y(n-2) -A4y(n-3)
Caution
For all 3 types of digital filter, it is your responsibility to ensure the function is evaluated at the appropriate frequency for the filter coefficients.
The Fixed Frequency calculation mode is recommended to ensure that changes to the parameters sampling rates do not affect filter results.
MedianFilter(param,n)- Calculates the median filter value in a data window of n/2 samples either side of the current data point.
MedianFilter9(param)- Calculates the median filter value of a data window 4 points either side of the current data point.
The effect is to remove spikes from the data, where their width is less than 4 data-points. MedianFilter17(param)- As above, but the data window is 17 points wide, enabling spikes to be filtered out up to 8 data-points wide.
MedianFilter25(param)- As above, but the data window is 25 points wide, enabling spikes to be filtered out up to 12 data-points wide.
PhaseCompFilter(param, freq)-
Calculates a phase-compensated filter which does not lag behind its input parameter.
The filter has a cut-off frequency offreq.The phase-compensated filter does not respond well at very low cut-off frequencies, especially for pre-calculated functions.
In this case, the data is filtered at a higher cut-off frequency.
Special#
These perform special operations on data — such as returning information about a recorded parameter — or special actions — such as writing log output.
Note
param must be a parameter from a data channel (i.e. not the result of a calculation).
BitOfWord(param, bit)- Returns
1if bit number bit in the parameterparamis1, otherwise returns0.
Bits count from0and from least significant to most significant. ClearLog(logname)- Clears the contents of the file path
logname. CurrentLapNumber()- Returns the current Lap number.
IsFirstPass()- Returns
TRUEthe first time that the function is used to evaluate a term and returnsFALSEfor successive passes.
Reset when the function is completed. IsInError(param)- Returns
TRUEif the parameter value is in error for that parameter (iIndicates that the sensor may be out of range). IndexBySample(param, n)- Returns the value of parameter
param,nsamples forward or backward (n–ve). IndexByTime(param, t)- Returns the value of parameter
param,tseconds forward or backward (t–ve). LapBestFit(x, y, Or, Os)- Returns the best fit line of parameters
xandywith nth order ofOrand coefficient index ofOs(i.e.0= offset,1= slope etc.)
Returns coefficients during current lap. LapMax(param)- Returns the maximum value of parameter
paramduring the current lap. LapMean(param)- Returns the mean value of parameter
paramduring the current lap. LapMin(param)- Returns the minimum value of parameter
paramduring the current lap. LapStdDev(param)- Returns the standard deviation of parameter
paramduring the current lap. LapTime(lap)- Returns the lap time in seconds of the given lap
lap. LinearRegressionOffset(x, y)- Returns Linear Regression Offset for parameters
xandyduring current lap. LinearRegressionR2(x, y)- Returns Linear Regression R2 for parameters
xandyduring current lap. LinearRegressionSlope(x, y)- Returns Linear Regression Slope for parameters
xandyduring current lap. SamplesMax(param, n)- Returns the rolling maximum value of parameter
paramover the previous n samples. SamplesMin(param, n)- Returns the rolling minimum value of parameter
paramover the previous n samples. SessionMax(param)- Returns the maximum value of parameter
paramduring the whole session. SessionMean(param)- Returns the mean value of parameter
paramduring the whole session. SessionMin(param)- Returns the minimum value of parameter
paramduring the whole session. SessionStdDev(param)- Returns the standard deviation of parameter
paramduring the whole session. SetEvent(n, d, g, p, v)-
Sets an Event at a given time.
n— Named— Descriptiong— Groupp— Priority (0 -2)v— Volatility (0,1)
SamplesPerSec(param)- Returns the sample rate in Hz being used to sample the parameter.
TimeIntoLap()- Returns the time in seconds from the start of the current lap in the Active Layer.
TimeIntoSession()- Returns the time in seconds from the start of the current session in the Active Layer.
TimeOfDay()- Returns the time in seconds from midnight for the Active Layer Time Position.
UwLapMean(param)- Returns the unweighted Mean value of parameter
paramduring the current Lap. UwLapStdDev(param)- Returns the unweighted Standard Deviation value of parameter
paramduring the current Lap. UwSessionMean(param)- Returns the unweighted Mean value of parameter
paramduring the Session. UwSessionStdDev(param)- Returns the unweighted Standard Deviation value of parameter
paramduring the Session. WriteToLog (‘logname’, entry)-
Appends a line to the file
lognamewith the text:FunctionName& Tab &entryFunctionName= the name of the function in which the processor was executed.entry= a string enclosed in quotes or an expression which can be evaluated to a numeric value which is converted to a string representing the value to 8 or more digits.
Operator Order of Precedence#
||boolean operator (left associative)&&boolean operator (left associative)!boolean operator (non-associative)<,<=,>,>=,==,!=relational operators (left associative)=assignment operator (right associative)+and-operators (left associative)*,/and%operators (left associative)^operator (right associative)- unary
-operator (non-associative) ++and--operators (non-associative)
Mathematical Operators#
-expr- The result is the negation of the expression.
- expr
+expr - The result of the expression is the sum of the two expressions.
- expr
–expr - The result of the expression is the difference between the two expressions.
- expr
*expr - The result of the expression is the product of the two expressions.
- expr
/expr - The result of the expression is the quotient of the two expressions.
- expr
%expr - The result of the expression is the remainder of the division.
^expr- The result of the expression is the value of the first expression raised to the second expression.
The second expression must be an integer. (expr)- Alters the standard precedence to force the evaluation of the expression, e.g. a + b / c is not the same as (a + b) / c.
Variable Operators#
var refers to either a simple or an array variable.
A simple variable is just a name; an array variable is specified as name[expr] (array subscript may be an expression).
++var- The variable is incremented by one and the new value is the result of the expression.
--var- The variable is decremented by one and the new value is the result of the expression.
- var
++ - The result of the expression is the value of the variable and the variable is then incremented by one.
- var
-- - The result of the expression is the value of the variable and the variable is then decremented by one.
- var
=expr - The variable is assigned the value of the expression.
- var op
=expr - This is equivalent to var
=var op expr with the exception that the var part is evaluated only once.
This can make a difference if var is an array.
op is one of the mathematical operators+,-,*,/,%or^.
Relational Operators#
Relational expressions evaluate to either 0 (if the relation is false) or 1 (if the relation is true).
These may appear in any legal expression.
- expr1
<expr2 - The result is
1if expr1 is strictly less than expr2. - expr1
<=expr2 - The result is
1if expr1 is less than or equal to expr2. - expr1
>expr2 - The result is
1if expr1 is strictly greater than expr2. - expr1
>=expr2 - The result is
1if expr1 is greater than or equal to expr2. - expr1
==expr2 - The result is
1if expr1 is equal to expr2. - expr1
!=expr2 - The result is
1if expr1 is not equal to expr2.
Boolean Operators#
The result of all boolean operators is either 0 or 1 (for false and true), as in Relational expressions.
Any non-zero value is treated as 1.
!expr- The result is
1if expr is0, otherwise0. (NOT) - expr
&&expr - The result is
1if both expressions are non⌀zero, otherwise0. (AND) - expr
||expr - The result is
1if either expression is non⌀zero otherwise0. (OR)
Bitwise Operators#
~expr- Bitwise
NOT - expr
&expr - Bitwise
AND - expr
|expr - Bitwise
OR - expr
>>expr - Shift right
- expr
<<expr - Shift left