2 The sample format is a record that contains fields that describe what and how data is stored from source. Its fields are defined by the user, their datatype, and possibly unit type too.
\r
3 At minimum requirement there must be two fields: "time" and "value".
\r
4 The data type can be anything numerical; but typically is a double or an integer type.
\r
6 If there is the optional field "quality", then it is used for expressing discontinuation regions (value -1). Discontinuation can be passed to the collector with a NaN or null value.
\r
8 An example of a simple '''Sample Format'''
\r
9 {| border="1" cellpadding="3" cellspacing="0" align="center"
\r
10 |- style="background-color: #f9f9f9;"
\r
11 |'''Field Name''' ||'''Required'''|| '''Description'''
\r
13 |time || yes || Time, the time of the 1st sample included into the band.
\r
15 |value || yes || First value in the band.
\r
17 |quality || no || 0 = Good, -1 = No value (Byte)
\r
20 If collector is given interval or deadband settings, some input samples may need to be dropped.
\r
21 If the sample format is in ''banded'' mode, then some information about dropped steps are
\r
22 preserved as count, avg, min, max and median values.
\r
23 In a banded sample there are (start)time and endTime fields - henge the name value band.
\r
25 An example of a '''Banded Sample Format''':
\r
26 {| border="1" cellpadding="3" cellspacing="0" align="center"
\r
27 |- style="background-color: #f9f9f9;"
\r
28 |'''Field Name''' ||'''Required'''|| '''Description'''
\r
30 |time || yes || Region start time, the time of the 1st sample included into the band.
\r
32 |endTime || no || Region end time, the time of the last sample included into the band.
\r
36 |value || yes || First value in the band.
\r
38 |lastValue || no || Last value in the band.
\r
40 |avg || no || Average value from all the steps that were included.
\r
42 |median || no || Median value from all the steps that were included into the band.
\r
44 |min || no || Lowest value in the band.
\r
46 |max || no || Highest value in the band.
\r
50 |quality || no || 0 = Good, -1 = No value (Byte)
\r
52 |count || no || The number of included samples in the band (Integer)
\r
55 To create a sample format, instantiate RecordType and add fields.
\r
57 // Create a sample format ( simple though )
\r
58 RecordType sampleFormat = new RecordType();
\r
59 sampleFormat.addComponent("time", Datatypes.DOUBLE );
\r
60 sampleFormat.addComponent("value", Datatypes.DOUBLE );
\r
61 sampleFormat.addComponent("quality", Datatypes.BYTE );
\r
64 Optionally, get sample format from a user defined class.
\r
68 public double value;
\r
71 // Get sample binding from a class
\r
72 Binding sampleBinding = Bindings.getBinding( Sample.class );
\r
73 // Get sample type from the binding
\r
74 Datatype sampleFormat = sampleBinding.type();
\r