=Sample Format= 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. At minimum requirement there must be two fields: "time" and "value". The data type can be anything numerical; but typically is a double or an integer type. 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. An example of a simple '''Sample Format''' {| border="1" cellpadding="3" cellspacing="0" align="center" |- style="background-color: #f9f9f9;" |'''Field Name''' ||'''Required'''|| '''Description''' |- |time || yes || Time, the time of the 1st sample included into the band. |- |value || yes || First value in the band. |- |quality || no || 0 = Good, -1 = No value (Byte) |} If collector is given interval or deadband settings, some input samples may need to be dropped. If the sample format is in ''banded'' mode, then some information about dropped steps are preserved as count, avg, min, max and median values. In a banded sample there are (start)time and endTime fields - henge the name value band. An example of a '''Banded Sample Format''': {| border="1" cellpadding="3" cellspacing="0" align="center" |- style="background-color: #f9f9f9;" |'''Field Name''' ||'''Required'''|| '''Description''' |- |time || yes || Region start time, the time of the 1st sample included into the band. |- |endTime || no || Region end time, the time of the last sample included into the band. |- | || |- |value || yes || First value in the band. |- |lastValue || no || Last value in the band. |- |avg || no || Average value from all the steps that were included. |- |median || no || Median value from all the steps that were included into the band. |- |min || no || Lowest value in the band. |- |max || no || Highest value in the band. |- | || |- |quality || no || 0 = Good, -1 = No value (Byte) |- |count || no || The number of included samples in the band (Integer) |} To create a sample format, instantiate RecordType and add fields.
// Create a sample format ( simple though ) RecordType sampleFormat = new RecordType(); sampleFormat.addComponent("time", Datatypes.DOUBLE ); sampleFormat.addComponent("value", Datatypes.DOUBLE ); sampleFormat.addComponent("quality", Datatypes.BYTE );Optionally, get sample format from a user defined class.
class Sample { public double time; public double value; } // Get sample binding from a class Binding sampleBinding = Bindings.getBinding( Sample.class ); // Get sample type from the binding Datatype sampleFormat = sampleBinding.type();