Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var riot = require("riot");
- var simple_template = {
- "name" : "compute over time",
- "description": "What is the {{Device_group}} {{Function}}" +
- " {{Sensor}} every {{Window_Size}} with shift of {{Interval}} {{GroupBy}}",
- "aliases": {
- "Function": {
- "type": "aggregate-function",
- "hintText": "Select function"
- },
- "Device_group": {
- "type": "device_group_selector",
- "hintText": "Select group"
- },
- "Sensor": {
- "type": "selector",
- "valueType": "sensor_name",
- "hintText": "Select sensor",
- "dependsOn": "Device_group"
- },
- "Window_Size": {
- "type": "input",
- "inputType": "number",
- "multiplier": {
- "defaultValue": 1000,
- "hintText": "Select units",
- "values": {
- "sec": 1000,
- "min": 60000
- }
- }
- },
- "Interval": {
- "type": "input",
- "inputType": "number",
- "multiplier": {
- "defaultValue": 1000,
- "hintText": "Select units",
- "values": {
- "sec": 1000,
- "min": 60000
- }
- }
- },
- "GroupBy": {
- "type": "checkbox",
- "inputType": "boolean",
- "values": ["ALL", "device"],
- "hintText": "partition by device"
- }
- },
- "analyticsScriptTemplate":{
- "name": "compute",
- "metadata": {
- "deviceGroupId": "{{Device_group}}"
- },
- "query" : {
- "function" : {
- "type": "{{Function}}"
- },
- "groupBy": "{{GroupBy}}",
- "sensorName": "{{Sensor}}",
- "window" : {
- "type": "time",
- "args" : ["{{Window_Size}}", "{{Interval}}"]
- }
- }
- },
- "aliasesValues": {
- "Function": "avg",
- "Sensor": "Speed",
- "Window_Size": 10,
- "Interval": 1,
- "GroupBy": "device"
- }
- };
- var all_device = {
- "name": "Some_sensor_all_devices",
- "description": "Show me: {{sensor}} of all devices",
- "aliases": {
- "sensor": {
- "type": "selector",
- "valueType": "sensor_name",
- "hintText": "Select sensor"
- }
- },
- "analyticsScriptTemplate": {
- "name": "identity",
- "query": {
- "sensorName": "{{sensor}}"
- }
- },
- "aliasesValues":{
- }
- };
- var velocity_pattern_aggregator = {
- "name": "Velocity_with_pattern_aggregator",
- "description": "Show me when changing {{sensor}} by {{sensor_delta_value}}{{sensor_delta_unit}} " +
- "within {{duration}} " +
- "took {{time_delta_value}}{{time_delta_unit}} time to previous {{prev_dimension_count}}",
- "aliases": {
- "sensor": {
- "type": "selector",
- "valueType": "sensor_name",
- "hintText": "Select sensor"
- },
- "sensor_delta_value": {
- "type": "input",
- "inputType": "number",
- "hintText": ""
- },
- "sensor_delta_unit": {
- "type": "list",
- "values": {
- "%": "percent",
- "unit": "value"
- },
- "hintText": "Select units type"
- },
- "time_delta_value": {
- "type": "input",
- "inputType": "number",
- "hintText": "Input time delta"
- },
- "time_delta_unit": {
- "type": "list",
- "values": {
- "%": "percent",
- "unit": "value"
- },
- "hintText": "Select units type"
- },
- "prev_dimension_count": {
- "type": "input",
- "inputType": "number",
- "hintText": "Count of previous dimensions"
- },
- "duration": {
- "type": "input",
- "inputType": "number",
- "hintText": "hint",
- "multiplier": {
- "defaultValue": 1000,
- "hintText": "Select units",
- "values": {
- "sec": 1000,
- "min": 60000
- }
- }
- }
- },
- "analyticsScriptTemplate": {
- "name": "velocity",
- "query": {
- "type": "{{time_delta_unit}}",
- "differenceValue": "{{time_delta_value}}",
- "valuesToCompare": "{{prev_dimension_count}}",
- "dimension": "time"
- },
- "streams": {
- "base": {
- "type": "query",
- "value": {
- "name": "patternAggregator",
- "query": {
- "type": "length"
- },
- "streams": {
- "base": {
- "type": "query",
- "value": {
- "name": "pattern",
- "query": {
- "durations": ["{{duration}}"],
- "patterns": {
- "{{sensor}}" : [
- {
- "type": "change",
- "args": ["{{sensor_delta_value}}", "{{sensor_delta_unit}}"]
- }
- ]
- },
- "matchPolicy": "oncePerMatch"
- }
- }
- }
- }
- }
- }
- }
- },
- "aliasesValues": {
- "sensor": "Speed",
- "sensor_delta_value": 10,
- "sensor_delta_unit": "value",
- "time_delta_value": 10,
- "time_delta_unit": "percent",
- "prev_dimension_count": 1,
- "duration": 4
- }
- };
- var velocity_compute = {
- "name": "Velocity_with_compute",
- "description": "Show me when device have {{sensor}} changed by " +
- "{{sensor_delta_value}}{{sensor_delta_unit}} comparing to {{function}} " +
- "on {{prev_dimension_count}} previous {{dimension}}",
- "aliases": {
- "sensor": {
- "type": "selector",
- "valueType": "sensor_name",
- "hintText": "Select sensor"
- },
- "sensor_delta_value": {
- "type": "input",
- "inputType": "number",
- "hintText": ""
- },
- "sensor_delta_unit": {
- "type": "list",
- "values": {
- "%": "percent",
- "unit": "value"
- },
- "hintText": "Select units type"
- },
- "function": {
- "type": "aggregate-function",
- "hintText": "Select function"
- },
- "prev_dimension_count": {
- "type": "input",
- "inputType": "number",
- "hintText": "Count of previous dimensions"
- },
- "device_group": {
- "type": "device_group_selector",
- "hintText": "Select group"
- },
- "dimension": {
- "type": "input",
- "inputType": "text",
- "hintText": "Input dimension"
- }
- },
- "analyticsScriptTemplate": {
- "name": "velocity",
- "query": {
- "type": "{{sensor_delta_unit}}",
- "differenceValue": "{{sensor_delta_value}}",
- "valuesToCompare": "{{prev_dimension_count}}",
- "dimension": "{{dimension}}"
- },
- "streams": {
- "base": {
- "type": "query",
- "value": {
- "name": "compute",
- "query": {
- "function": {
- "type": "{{function}}"
- },
- "groupBy": "device",
- "sensorName": "{{sensor}}",
- "window": {
- "type": "dimension",
- "args": [ "{{dimension}}" ]
- }
- }
- }
- }
- }
- },
- "aliasesValues": {
- "sensor": "Speed",
- "sensor_delta_value": 10,
- "sensor_delta_unit": "value",
- "function": "avg",
- "prev_dimension_count": 1,
- "dimension": ""
- }
- };
- riot.registerTemplate(simple_template);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement