TPT Assessment-Language - PikeTec
TPT Assessment-Language - PikeTec
TPT Assessment-Language - PikeTec
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>TPT</strong> assessments analyse and generate signals over time. The<br />
computational model is based on the concept of intervals, assessment<br />
variables and step sizes (aka sample rates). This quick reference should<br />
not replace the “<strong>Assessment</strong> Manual” shipped with the <strong>TPT</strong> installation.<br />
It just gives users a brief overview over the most important assessment<br />
features.<br />
Standard Python<br />
The following section describes basic concepts of the standard Python<br />
syntax. Beside the <strong>TPT</strong> specific syntax elements for handling signals and<br />
signal analysis this syntax can be used to compute auxiliary values,<br />
whenever appropriate.<br />
Python Variables<br />
x = 3 / 2.4;<br />
y = 2 * x;<br />
# print infos to stdout<br />
print “x is ” + x + “ and y is ” + y;<br />
Using Sequences in Python<br />
s = [1, 4, 5];<br />
print s[2]; # -> "5"<br />
print s[1:2]; # -> "[4, 5]" to stdout<br />
Control Flow in Python<br />
For block-like structures Python uses indentation (no braces or<br />
begin/end pairs such as common in other language).<br />
if x == 3:<br />
print “x is 3”;<br />
else:<br />
print “x is not 3”;<br />
print “instead, x is ” + x;<br />
Iterations and loops can be expressed like this:<br />
# compute 5+6+7+8+9+10<br />
y = 0;<br />
for i in range(5, 10):<br />
y = y + i;<br />
Time, during, “this”, and context interval<br />
For time values the following time units are supported: usec, us,<br />
msec, ms, sec, s, min, h, d (1000ms = 1s = 1).<br />
<strong>TPT</strong>.setStepSize(10ms);<br />
myStepSize = <strong>TPT</strong>.getStepSize(); # “0.01”<br />
myStepSize = @; # the same: “0.01”<br />
<strong>Assessment</strong> Quick Reference.docx <strong>PikeTec</strong> GmbH, Berlin Copyright © 2009<br />
<strong>TPT</strong> <strong>Assessment</strong> Quick Reference<br />
Version 3.1.0<br />
Intervals can be defined explicitly:<br />
myInterval = <strong>TPT</strong>.Interval(100ms, n * 3s);<br />
With intervals the context interval can be determined. Within a<br />
during-block this represents the context interval itself (in local<br />
time):<br />
during <strong>TPT</strong>.Interval(2s, 5s):<br />
print this.getStartTime (); # -> 0.0<br />
print this.getEndTime (); # -> 3.0<br />
# local “t” betw. 0s..3s<br />
f(t) := sin(t); # f is defined betw. 2s..5s<br />
Within a during-block “t” represents local time (always starts with 0s).<br />
Global time can be accessed as follows:<br />
during <strong>TPT</strong>.Interval(2s, 5s):<br />
x = <strong>TPT</strong>.toGlobal(this.getEndTime()); # 5.0<br />
<strong>Assessment</strong> Variables (Signals)<br />
Creating <strong>Assessment</strong> Variables<br />
The assessment concept supports the data types uint8, int8, uint16,<br />
int16, uint32, int32, int64, double, float, boolean. Creating an<br />
assessment variable requires the specification of the data type:<br />
f = <strong>TPT</strong>.Double(); # creating a double var<br />
i = <strong>TPT</strong>.UInt16(); # creating a uint16 var<br />
Assigning Variables<br />
f = <strong>TPT</strong>.Double();<br />
f(t) := sin(t);<br />
g = <strong>TPT</strong>.Double();<br />
g := average / 2; # constant over time<br />
Using Variables<br />
A variable supports the following functions:<br />
f.getSize();<br />
f.getStartTime();<br />
f.getEndTime();<br />
f.getLength();<br />
f.isDefined(20ms);<br />
print “value at 2ms is ” + str(f(20ms));<br />
f.getLeftValue<br />
f.getRightValue();<br />
f.isConstant();<br />
Dejittering Variables<br />
Resamples a signal according to the step size<br />
f.dejitter();<br />
File I/O<br />
Reading Signals from Files<br />
<strong>TPT</strong> supports the file formats CSV, MDF, <strong>TPT</strong>BIN, MAT and some<br />
proprietary customer specific formats.<br />
file1 = <strong>TPT</strong>.readRecord(“mydata.csv”);<br />
file2 = <strong>TPT</strong>.readRecord(“mydata2.mdf”);<br />
f = file1.getVariable(“signal01”);<br />
g = file2.getVariable(“torque[Nm]”);<br />
Writing to Signal Files<br />
Signals can be exported to signal files. Default mechanism is to “export”<br />
the signals. Supported Formats: CSV, MAT, <strong>TPT</strong>BIN<br />
f = <strong>TPT</strong>.Double();<br />
g = <strong>TPT</strong>.Int32();<br />
...<br />
<strong>TPT</strong>.export(f);<br />
<strong>TPT</strong>.export(g);<br />
h = <strong>TPT</strong>.BooleanX(); # “X” means implicit “export”<br />
...<br />
<strong>TPT</strong>.writeExportRecord(“results.tptbin”);<br />
In addition, records can be used if necessary:<br />
myrecord = <strong>TPT</strong>.Record();<br />
myrecord.add(f);<br />
myrecord.add(g);<br />
myrecord.add(h);<br />
myrecord.writeRecord(“results.csv”);<br />
Regular expressions<br />
Regular expressions can be used to identify intervals with custom<br />
characteristics.<br />
# find all intervals with f above 7<br />
# within the first 12 sec<br />
iv = <strong>TPT</strong>.regexp([f(t) > 7 and t < 12sec]);<br />
In more complex cases additional features can be used:<br />
# f exceeds 7 for at least 2, at most 3 seconds<br />
iv = <strong>TPT</strong>.regexp([f(t) > 7]{2s, 3s});<br />
# a is 1 and afterwards immediately 2<br />
iv = <strong>TPT</strong>.regexp([a(t) == 1][a(t) == 2]);<br />
Seite 1
Signal analysis functions: value computations<br />
<strong>TPT</strong>.always()<br />
Checks if the condition is true in current context interval<br />
res = <strong>TPT</strong>.always(f(t) < 2);<br />
<strong>TPT</strong>.average()<br />
Computes average value of the given signal in current context interval<br />
res = <strong>TPT</strong>.average(2 * t);<br />
<strong>TPT</strong>.check()<br />
Behaves similar to a switch-case-operator<br />
<strong>TPT</strong>.check(mode == MODE1, 1, “mode 1”,<br />
mode == MODE2, 2, “mode 2”,<br />
-1, “unknown mode”);<br />
<strong>TPT</strong>.checkAlways()<br />
Average value of the given signal in current context interval<br />
res = <strong>TPT</strong>.checkAlwys(f(t) < 2,<br />
“f below 2”, “f partially above 2!”);<br />
<strong>TPT</strong>.exists()<br />
Checks if the condition is true at least once in current context<br />
res = <strong>TPT</strong>.exits(f(t) < 2);<br />
<strong>TPT</strong>.max()<br />
Maximum value of the given signal in current context interval<br />
res = <strong>TPT</strong>.max(2 * t);<br />
<strong>TPT</strong>.min()<br />
Minimum value of the given signal in current context interval<br />
res = <strong>TPT</strong>.min(2 * t);<br />
<strong>TPT</strong>.never()<br />
Checks if the condition is never fulfilled in current context interval<br />
res = <strong>TPT</strong>.never(f(2) < 2);<br />
Signal analysis functions: signal computations<br />
<strong>TPT</strong>.boundControl()<br />
Signed distance to the min/max-area for every t; 0 if in range min/max<br />
<strong>Assessment</strong> Quick Reference.docx <strong>PikeTec</strong> GmbH, Berlin Copyright © 2009<br />
<strong>TPT</strong> <strong>Assessment</strong> Quick Reference<br />
Version 3.1.0<br />
b(t) := <strong>TPT</strong>.boundControl(sin(t), -0.5, 0.5);<br />
<strong>TPT</strong>.deviation()<br />
Distance of two signals with time tolerance<br />
d(t) := <strong>TPT</strong>.deviation(f(t), 2*g(t), 30ms);<br />
<strong>TPT</strong>.dt()<br />
First derivative (more precisely: the difference quotient) over time<br />
d(t) := <strong>TPT</strong>.dt(2* f(t/2));<br />
<strong>TPT</strong>.dt2()<br />
Second derivative (difference quotient) over time<br />
d(t) := <strong>TPT</strong>.dt2(2* f(t/2));<br />
<strong>TPT</strong>.hose()<br />
Generates bounds around a reference signal (2nd argument) and checks<br />
if the signal (1st argument) is encapsulated within these bounds, taking<br />
x-tolerance (3rd argument) and y-tolerance (4th argument) into account.<br />
res(t) := <strong>TPT</strong>.hose(f(t), f_ref(t), 0.01, 5.0);<br />
<strong>TPT</strong>.integrate()<br />
Integrates a signal over time<br />
res(t) = <strong>TPT</strong>.integrate(f(t), <strong>TPT</strong>.TUSTIN);<br />
<strong>TPT</strong>.monotony()<br />
Analyses the monotony of a signal for every t; delivers true or false.<br />
m(t) := <strong>TPT</strong>.monotony(f(t)-x, <strong>TPT</strong>.INCREASING);<br />
<strong>TPT</strong>.filterFIR()<br />
Applies a FIR-filter to a signal (1st arg) with order (2nd arg), type<br />
(LOWPASS, HIGHPASS, BANDPASS; 3rd arg), window type<br />
(RECTANGULAR, HANNING, HAMMING, BACKMAN; 4th arg), lower pass<br />
band freq (5th arg); max pass band freq (6th arg)<br />
f2(t) := <strong>TPT</strong>.filterFIR(f(t), 100, <strong>TPT</strong>.LOWPASS,<br />
<strong>TPT</strong>.HANNING, 0.0, 5.0);<br />
<strong>TPT</strong>.filterIIR()<br />
Similar to filterFIR for an IIR-Filter; uses a prototype parameter<br />
(BUTTERWORTH, CHEBYSHEV; 4th arg) instead of a window type<br />
f2(t) := <strong>TPT</strong>.filterIIR(f(t), 100, <strong>TPT</strong>.LOWPASS,<br />
<strong>TPT</strong>. BUTTERWORTH, 0.0, 5.0);<br />
<strong>TPT</strong>.filterMA()<br />
Moving average filter with order (2 nd arg) and type (SIGNAL, SIGMA)<br />
f2(t) := <strong>TPT</strong>.filterMA(f(t), 100, <strong>TPT</strong>.SIGNAL);<br />
<strong>TPT</strong>.stepDetection()<br />
Analyses signals (1st arg) in order to find significant steps with order (2nd arg) and scale (3rd arg); works also for noisy signals<br />
f2(t) := <strong>TPT</strong>.stepDetection(f(t), 50, 1.7);<br />
Comments and Results<br />
When assigning assessment variables, a result (SUCCESS, FAILED,<br />
DONT_KNOW) and a comment can be attached to this definition.<br />
f = <strong>TPT</strong>.Double():<br />
f(t) := somedef(t);<br />
f.setResult(SUCCESS); # ... means “as expected”<br />
f.setComment(“feature behaves as expected”);<br />
##-comments can be used instead of setComment() if appropriate:<br />
f = <strong>TPT</strong>.Double():<br />
## feature behaves as expected<br />
f(t) := somedef(t);<br />
f.setResult(SUCCESS); # ... means “as expected”<br />
Debug features<br />
<strong>Assessment</strong> scripts can be interactively suspended using the<br />
<strong>TPT</strong>.debug() statement:<br />
f(t) := sin(t);<br />
<strong>TPT</strong>.debug(); # opens a console window<br />
In the console, a signal viewer can be opened with <strong>TPT</strong>.show():<br />
<strong>TPT</strong>.show();<br />
Seite 2