Skip to content

Data Processor URI Scheme

Eric Tsai edited this page Dec 3, 2015 · 6 revisions

An alternative to configuring data processors 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.

Processor Type Description Scheme
Accumulator transformer Computes a running sum of all data received accumulator
Average transformer Calculates a running average of the input data over a given sample size average
Comparison filter Only allow data through that satisfies the comparison comparison
Counter transformer Counts the number of data samples that pass through counter
Delta both Only allow data through that exceeds a relative offset from a reference value delta
Math transformer Performs a mathematical operation on the input math
Passthrough filter A gate that users can manually control passthrough
Pulse transformer Detects and quantifies a pulse over a set of data pulse
Rms transformer Combines multi-component data by computing root mean square rms
Rss transformer Combines multi-component data by computing root sum square rss
Sample filter Only allow every Nth data sample through sample
Threshold both Only allow data through that crosses a boundary threshold
Time both Periodically allow data through time

Accumulator

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: process(new Accumulator((byte) 4))
///< accumulate input and allocate 4 bytes for the output regardless of input
process("accumulator?output=4")

///< equivalent to: fromSwitch().process(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().process("accumulator")

Average

Field Description Required
sampleSize How many data samples to compute a running average of Yes
///< equivalent to: process(new Average((byte) 16))
///< Compute a running average over the past 16 samples
process("average?sampleSize=16")

Comparison

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: process(new Comparison(Comparison.Operation.EQ, 511))
///< Only allow data that is equal to 511 to pass, infer signed or unsigned based on input
process("comparison?operation=eq&reference=511")

///< equivalent to: process(new Comparison(Comparison.Operation.LTE, 511, true))
///< Only allow data less than or equal to 511 to pass, use a signed comparison
process("comparison?operation=lte&reference=511&signed=true")

Counter

Field Description Required
size Size of the counter, between [1, 4] bytes. If not specified, defaults to 1 byte (counts to 255) No
///< equivalent to: process(new Counter((byte) 2))
///< Count number of samples, up to 65535
process("counter?size=2")

///< equivalent to: process(new Counter())
///< Count number of samples, up to 255
process("counter")

Delta

Field Description Required
mode Sets the operation mode of the delta processor Yes
threshold The limit that the relative distance between the current and reference values must exceed Yes
Mode Description Value
Absolute Output the value as is abs
Differential Opposite the difference between the current and reference values diff
Binary 1 for positive difference, -1 for negative difference bin
///< Equivalent to: fromTemperature().process(new Delta(Delta.Mode.DIFFERENTIAL, 2.f))
///< Only allow data through that is 2 degrees or higher from a reference value 
///< and output the difference
fromTemperature().process("delta?mode=diff&threshold=2.0")

///< Equivalent to: fromTemperature().process(new Delta(Delta.Mode.BINARY, 4.f))
///< Only allow data through that is 4 degrees or higher from a reference value 
///< and output 1 or -1 to signify positive or negative difference, respectively
fromTemperature().process("delta?mode=bin&threshold=4.0")

Math

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: fromTemperature().process(new Math(Math.Operation.ADD, 273.15))
///< Add 273.15 to the input, infer signed operation based on input
fromTemperature().process("math?operation=add&rhs=273.15")

///< equivalent to: fromTemperature().process(new Math(Math.Operation.ADD, 273.15, true))
///< Add 273.15 to the input with signed addition
fromTemperature().process("math?operation=add&rhs=273.15&signed=true")

Passthrough

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: process(new Passthrough())
///< passthrough filter allowing all data through
process("passthrough?mode=all")

///< equivalent to: process(new Passthrough(Passthrough.Mode.CONDITIONAL, (short) 0))
///< do not allow data through for now
process("passthrough?mode=conditional&value=0")

///< equivalent to: process(new Passthrough(Passthrough.Mode.COUNT, (short) 4))
///< only allow 4 samples through
process("passthrough?mode=count&value=4")

Pulse

Field Description Required
mode Sets the output mode of the processor Yes
threshold Value the sensor data must exceed for a valid pulse Yes
width Number of samples that exceed the threshold No
Mode Description Value
area Output sum of all data samples in the pulse area
peak Output max value in the pulse peak
width Output number of samples in the pulse width
///< equivalent to: process(new Pulse(Pulse.OutputMode.AREA, 1.f, (short) 16))
///< pulse detector looking for a pulse above 1g consisting of min 16 samples
fromXAxis().process("pulse?mode=area&threshold=1.0&width=16")

Rms

No query string required for rms.

///< equivalent to: fromAccelAxis().process(new Rms())
///< Compute RMS value of the accelerometer XYZ axis data
fromAccelAxis().process("rms")

Rss

No query string required for rss.

///< equivalent to: fromAccelAxis().process(new Rss())
///< Compute RSS value of the accelerometer XYZ axis data i.e. vector magnitude
fromAccelAxis().process("rss")

Sample

Field Description Required
binSize Number of elements to Yes
///< Equivalent to: process(new Sample((byte) 4))
///< Only let data through once 4 samples have been collected
process("sample?binSize=4")

Threshold

Field Description Required
hysteresis Minimum distance between the limit and value to signal a successful crossing. Use with data that may frequently oscillate around the threshold limit. No
limit Boundary the data must cross Yes
mode Processor output mode Yes
Mode Description Value
Absolute Output the value as is abs
Binary 1 if data rose above the limit, -1 if data fell below the limit bin
///< Equivalent to: fromTemperature().process(new Threshold(30.f, Threshold.Mode.ABSOLUTE))
///< Only allow data through that crosses the 30 degree limit
fromTemperature().process("threshold?limit=30.0&mode=abs")

///< Equivalent to: fromTemperature().process(new Threshold(30.f, Threshold.Mode.BINARY))
///< Only allow data through that crosses the 30 degree limit, convert the data to 
///< a 1 if higher, or -1 if lower than the limit
fromTemperature().process("threshold?limit=30.0&mode=bin")

Time

Field Description Required
mode Processor output mode Yes
period How often to allow data through. Specify value in milliseconds Yes
Mode Description Value
Absolute Output the value as is abs
Differential Output the difference between the current and previous value diff
///< equivalent to: process(new Time(10000, Time.Mode.DIFFERENTIAL))
///< Allow the difference between the current and previous value through every 10 seconds
process("time?period=10000&mode=diff")

///< equivalent to: process(new Time(15000, Time.Mode.ABSOLUTE))
///< Allow data through every 15 seconds
process("time?period=15000&mode=abs")