-
Notifications
You must be signed in to change notification settings - Fork 52
Data Processor URI Scheme
Metawear edited this page Jul 6, 2015
·
6 revisions
An alternative to configuring data processors (filters and transformers) is to use a String URI. The configuration URI is a combination of a scheme and query string. The scheme and query string are separated by a question mark (?) and the query fields are separated by an ampersand (&).
"[scheme]?[field1=value1]&[field2=value2]...&[fieldN=valueN]"
The following tables provide a brief overview of the available transformers and filters and their scheme string. Further details about each scheme is given in the below sections.
Transformer | Description | Scheme |
---|---|---|
Accumulator | Computes a running sum of all data received | accumulator |
Average | Calculates a running average of the input data over a given sample size | average |
Math | Performs a mathematical operation on the input | math |
Rms | Combines multi-component data by computing root mean square | rms |
Rss | Combines multi-component data by computing root sum square | rss |
Time | Periodically output the difference between the current and previous input | time |
Filter | Description | Scheme |
---|---|---|
Comparison | Only allow data through that satisfies the comparison | comparison |
Passthrough | A gate that users can manually control | passthrough |
Time | Periodically allow data through | time |
Field | Description | Required |
---|---|---|
output | Output size of the running sum. If not specified, it will infer the output size based on the input | No |
///< equivalent to: transform(new Accumulator((byte) 4))
///< accumulate input and allocate 4 bytes for the output regardless of input
transform("accumulator?output=4")
///< equivalent to: fromSwitch().transform(new Accumulator())
///< accumulate input and infer the output size based in the input signal
///< will implicitly allocate 1 byte because switch data is only 1 byte
fromSwitch().transform("accumulator")
Field | Description | Required |
---|---|---|
sampleSize | How many data samples to compute a running average of | Yes |
///< equivalent to: transform(new Average((byte) 16))
///< Compute a running average over the past 16 samples
transform("average?sampleSize=16")
Field | Description | Required |
---|---|---|
operation | Sets the comparison used to filter data | Yes |
reference | Value on the right hand side of the operation the input data is compared to | Yes |
signed | Force a signed or unsigned comparison. If not specified, this field will be inferred from the input signal | No |
Operation | Description | Value |
---|---|---|
Equals | True if input and reference are equivalent | eq |
Not equals | Opposite result of equals to comparison | neq |
Less than | True if input is less than the reference | lt |
Less than or Equals | True if input is less than or equal to the reference | lte |
Greater Than | True if input is greater than the reference | gt |
Greater Than Or Equals | True if input is greater than or equal to the reference | gte |
///< equivalent to: filter(new Comparison(Comparison.Operation.EQ, 511))
///< Only allow data that is equal to 511 to pass, infer signed or unsigned based on input
filter("comparison?operation=eq&reference=511")
///< equivalent to: filter(new Comparison(Comparison.Operation.LTE, 511, true))
///< Only allow data less than or equal to 511 to pass, use a signed comparison
filter("comparison?operation=lte&reference=511&signed=true")
Field | Description | Required |
---|---|---|
operation | Sets the mathematical operation to perform on the data | Yes |
rhs | Value on the right hand side of the operation | Depends, yes if operation requires 2 inputs, no otherwise |
signed | Force a signed or unsigned operation, If not specified, this field will be inferred from the input signal | No |
Operation | Description | Value | # Operands |
---|---|---|---|
Addition | Adds the input data with an offset | add | 2 |
Multiplication | Multiplies the input data by a scale factor | mult | 2 |
Division | Divides the input data by a scale factor | div | 2 |
Modulus | Computes the remainder of the input data and a divisor | mod | 2 |
Exponent | Computes exponentiation using the input as the base, and the rhs value as the exponent | exp | 2 |
Square Root | Computes square root of the data | sqrt | 1 |
Left Shift | Performs a left shift of the data | lshift | 2 |
Right Shift | Performs a right shift of the data | rshift | 2 |
Subtraction | Subtracts the input data with an offset | sub | 2 |
Absolute Value | Computes the absolute value of the ipnut | abs | 1 |
///< equivalent to: transform(new Math(Math.Operation.ADD, 273.15))
///< Add 273.15 to the input, infer signed operation based on input
transform("math?operation=add&rhs=273.15")
///< equivalent to: transform(new Math(Math.Operation.ADD, 273.15, true))
///< Add 273.15 to the input with signed addition
transform("math?operation=add&rhs=273.15&signed=true")
Field | Description | Required |
---|---|---|
mode | Sets the operation mode | Yes |
value | Sets the value or condition corresponding to the passthrough mode | Depends, yes for conditional and count modes, no otherwise |
Mode | Description | Value |
---|---|---|
All | Allow all data to pass through | all |
Conditional | If value is 0, unconditionally block all data. If value is 1, allow all data through | conditional |
Count | Only allow a fixed number of data samples through | count |
///< equivalent to: filter(new Passthrough())
///< passthrough filter allowing all data through
filter("passthrough?mode=all")
///< equivalent to: filter(new Passthrough(Passthrough.Mode.CONDITIONAL, (short) 0))
///< do not allow data through for now
filter("passthrough?mode=conditional&value=0")
///< equivalent to: filter(new Passthrough(Passthrough.Mode.COUNT, (short) 4))
///< only allow 4 samples through
filter("passthrough?mode=count&value=4")
No query string required for rms.
///< equivalent to: transform(new Rms())
///< Compute RMS value of the accelerometer XYZ axis data
fromAccelAxis().transform("rms")
No query string required for rss.
///< equivalent to: transform(new Rss())
///< Compute RSS value of the accelerometer XYZ axis data i.e. vector magnitude
fromAccelAxis().transform("rms")
Field | Description | Required |
---|---|---|
period | How often to allow data through. Specify value in milliseconds | Yes |
///< equivalent to: transform(new Time(10000))
///< Allow the difference between the current and previous value through every 10 seconds
transform("time?period=10000")
///< equivalent to: filter(new Time(15000))
///< Allow data through every 15 seconds
filter("time?period=15000")