This is a template that facilitates the implementation of the Platform Provider Interface (PPI).
More information about PPI can be found here.
[ | |
{ | |
"id": "494c1dda.d45744", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/metadata", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 117, | |
"y": 91, | |
"wires": [ | |
[ | |
"ebc4ef45.5d498" | |
] | |
] | |
}, | |
{ | |
"id": "ebc4ef45.5d498", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "// CHANGEME: The ID of the system.\nvar system_id = \"http://example.com\";\n\n// CHANGEME: The name of the system.\nvar system_name = \"Sample IoT system\";\n\n// CHANGEME: The description of the system.\nvar system_description = \"This is a VITAL compliant IoT system.\";\n\n// CHANGEME: The person that operates the system.\nvar system_operator = \"http://example.com/people#john_doe\";\n\n// CHANGEME: The area that the system serves.\nvar system_service_area = \"http://dbpedia.org/page/Camden_Town\";\n\n// CHANGEME: The sensors that the system manages.\n// SEE ALSO: Get sensor metadata.\nvar sensors = [\n \"http://example.com/sensor/monitoring\",\n \"http://example.com/sensor/some\"\n];\n\n// CHANGEME: The IoT services that the system provides.\n// SEE ALSO: Get IoT service metadata.\nvar services = [\n \"http://example.com/service/configuration\",\n \"http://example.com/service/monitoring\",\n \"http://example.com/service/observation\"\n];\n\n// CHANGEME: The current status of the system.\n// VALUES: vital:Operational, vital:StartingUp, vital:Running,\n// vital:ShuttingDown, vital:Unavailable\nvar system_status = \"vital:Running\";\n\nmsg.payload = {\n \"@context\": \"http://vital-iot.eu/contexts/system.jsonld\",\n \"id\": system_id,\n \"type\": \"vital:VitalSystem\",\n \"name\": system_name,\n \"description\": system_description,\n \"operator\": system_operator,\n \"serviceArea\": system_service_area,\n \"sensors\": sensors,\n \"services\": services,\n \"status\": system_status\n};\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 295, | |
"y": 92, | |
"wires": [ | |
[ | |
"119827bd.877a08" | |
] | |
] | |
}, | |
{ | |
"id": "119827bd.877a08", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 448, | |
"y": 89, | |
"wires": [] | |
}, | |
{ | |
"id": "16147667.71814a", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get system metadata", | |
"info": "", | |
"x": 105, | |
"y": 47, | |
"wires": [] | |
}, | |
{ | |
"id": "54a92da2.064a44", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get system status", | |
"info": "", | |
"x": 96, | |
"y": 134, | |
"wires": [] | |
}, | |
{ | |
"id": "e04b60bb.b9998", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get sensor metadata", | |
"info": "", | |
"x": 879.8571319580078, | |
"y": 63.857139587402344, | |
"wires": [] | |
}, | |
{ | |
"id": "b5d3c42b.7e8998", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get sensor status", | |
"info": "", | |
"x": 859.8571319580078, | |
"y": 152.85713958740234, | |
"wires": [] | |
}, | |
{ | |
"id": "8679daa.c532f28", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get service metadata", | |
"info": "", | |
"x": 258, | |
"y": 271.42858123779297, | |
"wires": [] | |
}, | |
{ | |
"id": "cdb4d701.4807a8", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get sensor data", | |
"info": "", | |
"x": 858.8571319580078, | |
"y": 239.85713958740234, | |
"wires": [] | |
}, | |
{ | |
"id": "e98f4ce3.322d5", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 661, | |
"y": 315.42858123779297, | |
"wires": [] | |
}, | |
{ | |
"id": "f377a8c8.d0f1f8", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/service/metadata", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 298, | |
"y": 314.42858123779297, | |
"wires": [ | |
[ | |
"492f3981.daca58" | |
] | |
] | |
}, | |
{ | |
"id": "492f3981.daca58", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var data = msg.req.body;\n\n// The ID's of the IoT services to return metadata for.\nvar ids = data.id;\n\n// The types of the IoT services to return metadata for.\nvar types = data.type;\n\n// The configuration service.\nvar configuration_service = {\n \"@context\": \"http://vital-iot.eu/contexts/service.jsonld\",\n // CHANGEME: The ID of the configuration service.\n \"id\": \"http://example.com/service/configuration\",\n \"type\": \"vital:ConfigurationService\",\n \"msm:hasOperation\": [\n {\n \"type\": \"vital:GetConfiguration\",\n // CHANGEME: The URL for the get configuration operation.\n \"hrest:hasAddress\": \"http://example.com/configuration\",\n \"hrest:hasMethod\": \"hrest:GET\"\n },\n {\n \"type\": \"vital:SetConfiguration\",\n // CHANGEME: The URL for the set configuration operation.\n \"hrest:hasAddress\": \"http://example.com/configuration\",\n \"hrest:hasMethod\": \"hrest:POST\"\n }\n ]\n};\n\n// The monitoring service.\nvar monitoring_service = {\n \"@context\": \"http://vital-iot.eu/contexts/service.jsonld\",\n // CHANGEME: The ID of the monitoring service.\n \"id\": \"http://example.com/service/monitoring\",\n \"type\": \"vital:MonitoringService\",\n \"msm:hasOperation\": [\n {\n \"type\": \"vital:GetSystemStatus\",\n // CHANGEME: The URL for the get system status operation.\n \"hrest:hasAddress\": \"http://example.com/status\",\n \"hrest:hasMethod\": \"hrest:POST\"\n },\n {\n \"type\": \"vital:GetSensorStatus\",\n // CHANGEME: The URL for the get sensor status operation.\n \"hrest:hasAddress\": \"http://example.com/sensor/status\",\n \"hrest:hasMethod\": \"hrest:POST\"\n },\n {\n \"type\": \"vital:GetSupportedPerformanceMetrics\",\n // CHANGEME: The URL for the get supported performance metrics operation.\n \"hrest:hasAddress\": \"http://example.com/performance\",\n \"hrest:hasMethod\": \"hrest:GET\"\n },\n {\n \"type\": \"vital:GetPerformanceMetrics\",\n // CHANGEME: The URL for the get performance metrics operation.\n \"hrest:hasAddress\": \"http://example.com/performance\",\n \"hrest:hasMethod\": \"hrest:POST\"\n },\n {\n \"type\": \"vital:GetSupportedSLAParameters\",\n // CHANGEME: The URL for the get supported SLA parameters operation.\n \"hrest:hasAddress\": \"http://example.com/sla\",\n \"hrest:hasMethod\": \"hrest:GET\"\n },\n {\n \"type\": \"vital:GetSLAParameters\",\n // CHANGEME: The URL for the get SLA parameters operation.\n \"hrest:hasAddress\": \"http://example.com/sla\",\n \"hrest:hasMethod\": \"hrest:POST\"\n }\n ]\n};\n\n// The observation service.\nvar observation_service = {\n \"@context\": \"http://vital-iot.eu/contexts/service.jsonld\",\n // CHANGEME: The ID of the observation service.\n \"id\": \"http://example.com/service/observation\",\n \"type\": \"vital:ObservationService\",\n \"msm:hasOperation\": [\n {\n \"type\": \"vital:GetObservations\",\n // CHANGEME: The URL for the get observations operation.\n \"hrest:hasAddress\": \"http://example.com/sensor/data\",\n \"hrest:hasMethod\": \"hrest:POST\"\n }\n ]\n};\n\nvar services = [\n // CHANGEME: The services that the IoT system provides.\n monitoring_service,\n observation_service\n].filter(function(service) {\n return ids === undefined || ids.indexOf(service.id) >= 0;\n}).filter(function(service) {\n return types === undefined || types.indexOf(service.type) >= 0 || types.indexOf(service.type.replace('vital:', 'http://vital-iot.eu/ontology/ns/')) >= 0;\n});\n\nmsg.payload = services;\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 510, | |
"y": 314.42858123779297, | |
"wires": [ | |
[ | |
"e98f4ce3.322d5" | |
] | |
] | |
}, | |
{ | |
"id": "6fa4304a.b7412", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/status", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 107, | |
"y": 177, | |
"wires": [ | |
[ | |
"22bfb19.b3b494e" | |
] | |
] | |
}, | |
{ | |
"id": "552ce50.968cd1c", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 489, | |
"y": 176, | |
"wires": [] | |
}, | |
{ | |
"id": "22bfb19.b3b494e", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "// CHANGEME: The ID of the observation.\nvar observation_id = \"http://example.com/sensor/monitoring/observation/1\";\n\n// CHANGEME: The date and time when the status was observed.\nvar date_time = \"2014-08-20T16:47:32+01:00\";\n\n// CHANGEME: The ID of the system.\n// SEE ALSO: Get system metadata.\nvar system_id = \"http://example.com\";\n\n// CHANGEME: The status of the system.\n// VALUES: vital:Operational, vital:StartingUp, vital:Running,\n// vital:ShuttingDown, vital:Unavailable\nvar system_status = \"vital:Running\";\n\n// CHANGEME: The ID of the monitoring sensor.\n// SEE ALSO: Get sensor metadata.\nvar system_id = \"http://example.com/sensor/monitoring\";\n\nmsg.payload = {\n \"@context\": \"http://vital-iot.eu/contexts/measurement.jsonld\",\n \"id\": observation_id,\n \"type\": \"ssn:Observation\", \n \"ssn:observedBy\": monitoring_sensor,\n \"ssn:observationProperty\": { \n \"type\": \"vital:OperationalState\" \n }, \n \"ssn:observationResultTime\": { \n \"time:inXSDDateTime\": date_time \n }, \n \"ssn:featureOfInterest\": system_id, \n \"ssn:observationResult\": { \n \"type\": \"ssn:SensorOutput\", \n \"ssn:hasValue\": { \n \"type\": \"ssn:ObservationValue\", \n \"value\": system_status \n } \n } \n};\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 342, | |
"y": 177, | |
"wires": [ | |
[ | |
"552ce50.968cd1c" | |
] | |
] | |
}, | |
{ | |
"id": "c4f82a72.4d06e8", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/sensor/metadata", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 910.8571319580078, | |
"y": 107.85713958740234, | |
"wires": [ | |
[ | |
"e0036876.90f768" | |
] | |
] | |
}, | |
{ | |
"id": "6ae104b0.dde71c", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 1285.8571319580078, | |
"y": 106.85713958740234, | |
"wires": [] | |
}, | |
{ | |
"id": "e0036876.90f768", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var data = msg.req.body;\n\n// The ID's of the sensors to return metadata for.\nvar ids = data.id;\n\n// The types of the sensors to return metadata for.\nvar types = data.type;\n\n// The monitoring sensor.\nvar monitoring_sensor = {\n \"@context\": \"http://vital-iot.eu/contexts/sensor.jsonld\",\n // CHANGEME: The ID of the monitoring sensor.\n \"id\": \"http://example.com/sensor/monitoring\",\n \"type\": \"vital:MonitoringSensor\",\n // CHANGEME: The name of the monitoring sensor.\n \"name\": \"System Monitoring Sensor\",\n // CHANGEME: The description of the monitoring sensor.\n \"description\": \"A virtual sensor that monitors the operational state of the system, as well as its services and sensors.\",\n // CHANGEME: The status of the monitoring sensor.\n // VALUES: vital:Operational, vital:StartingUp, vital:Running,\n // vital:ShuttingDown, vital:Unavailable\n \"status\": \"vital:Running\",\n // CHANGEME: The properties that the monitoring sensor observes.\n \"ssn:observes\": [\n {\n // CHANGEME: The type of the observed property.\n \"type\": \"vital:OperationalState\",\n // CHANGEME: The ID of the observed property.\n \"id\": \"http://example.com/sensor/monitoring/operationalState\"\n }\n ]\n};\n\n// Some sensor.\nvar some_sensor = {\n \"@context\": \"http://vital-iot.eu/contexts/sensor.jsonld\",\n // CHANGEME: The ID of some sensor.\n \"id\": \"http://example.com/sensor/some\",\n // CHANGEME: The name of some sensor.\n \"name\": \"A sensor.\",\n // CHANGEME: The type of some sensor.\n \"type\": \"vital:VitalSensor\",\n // CHANGEME: The description of some sensor.\n \"description\": \"A sensor.\",\n // CHANGEME: The last known location of some sensor.\n \"hasLastKnownLocation\": {\n \"type\": \"geo:Point\",\n \"geo:lat\": 53.2719,\n \"geo:long\": -9.0849\n },\n // CHANGEME: The status of some sensor.\n \"status\": \"vital:Running\",\n // CHANGEME: The properties that some sensor observes.\n \"ssn:observes\": [\n {\n // CHANGEME: The type of the observed property.\n \"type\": \"vital:Speed\",\n // CHANGEME: The ID of the observed property.\n \"id\": \"http://example.com/sensor/some/speed\"\n }\n ]\n};\n\nvar sensors = [\n // CHANGEME: The sensors that the system manages.\n monitoring_sensor,\n some_sensor\n].filter(function(sensor) {\n return ids === undefined || ids.indexOf(sensor.id) >= 0;\n}).filter(function(sensor) {\n return types === undefined || types.indexOf(sensor.type) >= 0 || types.indexOf(sensor.type.replace('vital:', 'http://vital-iot.eu/ontology/ns/')) >= 0;\n});\n\nmsg.payload = sensors;\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1123.8571319580078, | |
"y": 104.85713958740234, | |
"wires": [ | |
[ | |
"6ae104b0.dde71c" | |
] | |
] | |
}, | |
{ | |
"id": "8bc98be3.b2c4c8", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/sensor/status", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 898.8571319580078, | |
"y": 195.85713958740234, | |
"wires": [ | |
[ | |
"2dab5301.5714bc" | |
] | |
] | |
}, | |
{ | |
"id": "2dab5301.5714bc", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var data = msg.req.body;\n\n// The ID's of the sensors to return their status.\nvar ids = data.id;\n\n// The types of the sensors to return their status.\nvar types = data.type;\n\n// CHANGEME: The ID of the monitoring sensor.\n// SEE ALSO: Get sensor metadata.\nvar monitoring_sensor = \"http://example.com/sensor/monitoring\";\n\nvar statuses = [\n // CHANGEME: The sensors that the system manages.\n // SEE ALSO: Get IoT sensor metadata.\n].filter(function(sensor) {\n return ids === undefined || ids.indexOf(sensor.id) >= 0;\n}).filter(function(sensor) {\n return types === undefined || types.indexOf(sensor.type) >= 0 || types.indexOf(sensor.type.replace('vital:', 'http://vital-iot.eu/ontology/ns/')) >= 0;\n}).map(function(sensor) {\n return {\n \"@context\": \"http://vital-iot.eu/contexts/measurement.jsonld\",\n // CHANGEME: The ID of the observation.\n \"id\": \"http://example.com/sensor/monitoring/observation/1\",\n \"type\": \"ssn:Observation\",\n \"ssn:observationProperty\": {\n \"type\": \"vital:OperationalState\"\n },\n \"ssn:observationResultTime\": {\n // CHANGEME: The date and time when the status was observed.\n \"time:inXSDDateTime\": \"2014-08-20T16:47:32+01:00\"\n },\n \"ssn:featureOfInterest\": sensor.id,\n \"ssn:observationResult\": {\n \"type\": \"ssn:SensorOutput\",\n \"ssn:hasValue\": {\n \"type\": \"ssn:ObservationValue\",\n // CHANGEME: The status of the sensor.\n // VALUES: vital:Operational, vital:StartingUp,\n // vital:Running, vital:ShuttingDown,\n // vital:Unavailable\n \"value\": \"vital:Running\"\n }\n }\n };\n});\n\nmsg.statuses = sensors;\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1082.8571319580078, | |
"y": 196.85713958740234, | |
"wires": [ | |
[ | |
"cea3ce69.27a97" | |
] | |
] | |
}, | |
{ | |
"id": "cea3ce69.27a97", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 1227.8571319580078, | |
"y": 194.85713958740234, | |
"wires": [] | |
}, | |
{ | |
"id": "9abc781b.438198", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 1279.8571319580078, | |
"y": 282.85713958740234, | |
"wires": [] | |
}, | |
{ | |
"id": "ec1a9f45.9b703", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/sensor/data", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 899.8571319580078, | |
"y": 281.85713958740234, | |
"wires": [ | |
[ | |
"bef13b5a.f095e8" | |
] | |
] | |
}, | |
{ | |
"id": "bef13b5a.f095e8", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var data = msg.req.body;\n\n// The ID's of the sensors to return observations for.\nvar sensors = data.id;\n\n// The property to return observations for.\nvar property = data.property;\n\n// The beginning of the time interval to return observations for.\nvar from = data.from;\n\n// The end of the time interval to return observations for.\nvar to = data.to;\n\nvar observations = [\n // CHANGEME: The observations to return.\n // NOTE: Return only the last if both from and to are undefined.\n {\n // CHANGEME: The ID of the observation.\n \"id\": \"http://example.com/sensor/some/observation/1\",\n // CHANGEME: The ID of the sensor that made the observation.\n \"sensor\": \"http://example.com/sensor/some\",\n // CHANGEME: The property that the observation was made for.\n \"property\": \"vital:Speed\",\n // CHANGEME: The date and time when the observation was made.\n \"date_time\": \"2014-08-20T16:47:32+01:00\",\n // CHANGEME: The latitude where the observation was made.\n \"latitude\": 55.701,\n // CHANGEME: The longitude where the observation was made.\n \"longitude\": 12.552,\n // CHANGEME: The observed value.\n \"value\": 100,\n // CHANGEME: The unit of the observed value.\n \"unit\": \"qudt:KilometerPerHour\"\n }\n].filter(function(observation) {\n return sensors === undefined || sensors.indexOf(observation.sensor) >= 0;\n}).filter(function(observation) {\n return property === observation.property || property === observation.property.replace('vital:', 'http://vital-iot.eu/ontology/ns/');\n}).filter(function(observation) {\n return from === undefined || new Date(from).toLocaleString() >= new Date(observation.date_time).toLocaleString();\n}).filter(function(observation) {\n return to === undefined || new Date(to).toLocaleString() <= new Date(observation.date_time).toLocaleString();\n}).map(function(observation) {\n return {\n \"@context\": \"http://vital-iot.eu/contexts/measurement.jsonld\", \n \"id\": observation.id,\n \"type\": \"ssn:Observation\", \n \"ssn:observedBy\": observation.sensor,\n \"ssn:observationProperty\": {\n \"type\": observation.property\n }, \n \"ssn:observationResultTime\": {\n \"time:inXSDDateTime\": observation.date_time\n }, \n \"dul:hasLocation\": { \n \"type\": \"geo:Point\", \n \"geo:lat\": observation.latitude,\n \"geo:lng\": observation.longitude\n }, \n \"ssn:observationResult\": { \n \"type\": \"ssn:SensorOutput\", \n \"ssn:hasValue\": { \n \"type\": \"ssn:ObservationValue\", \n \"value\": observation.value,\n \"qudt:unit\": observation.unit \n } \n } \n };\n});\n\nmsg.payload = observations;\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1131.8571319580078, | |
"y": 282.85713958740234, | |
"wires": [ | |
[ | |
"9abc781b.438198" | |
] | |
] | |
}, | |
{ | |
"id": "b742f828.b6a6f8", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get configuration", | |
"info": "", | |
"x": 891.5714263916016, | |
"y": 428.42856884002686, | |
"wires": [] | |
}, | |
{ | |
"id": "afab7fb1.b97d4", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Set configuration", | |
"info": "", | |
"x": 892.5714263916016, | |
"y": 510.42856884002686, | |
"wires": [] | |
}, | |
{ | |
"id": "7c39acfd.f26744", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get supported performance metrics", | |
"info": "", | |
"x": 184.14285278320312, | |
"y": 426.42857837677, | |
"wires": [] | |
}, | |
{ | |
"id": "985e8815.e76208", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get performance metrics", | |
"info": "", | |
"x": 157.14285278320312, | |
"y": 517.42857837677, | |
"wires": [] | |
}, | |
{ | |
"id": "62e43e85.69231", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get supported SLA parameters", | |
"info": "", | |
"x": 637.0000305175781, | |
"y": 687.8571529388428, | |
"wires": [] | |
}, | |
{ | |
"id": "422a3d25.51e254", | |
"type": "comment", | |
"z": "4e97a16a.36ab9", | |
"name": "Get SLA parameters", | |
"info": "", | |
"x": 598.5714950561523, | |
"y": 785.0000305175781, | |
"wires": [] | |
}, | |
{ | |
"id": "fbf4c0b9.6e47e", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/configuration", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 932.5714263916016, | |
"y": 467.42856884002686, | |
"wires": [ | |
[ | |
"deb51fa6.d019c" | |
] | |
] | |
}, | |
{ | |
"id": "deb51fa6.d019c", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var parameters = [\n // CHANGEME: The configuration parameters.\n {\n // CHANGEME: The name of the parameter.\n \"name\": \"x\",\n // CHANGEME: The current value of the parameter.\n \"value\": \"42\",\n // CHANGEME: The type of the parameter.\n \"type\": \" http://www.w3.org/2001/XMLSchema#int\",\n // CHANGEME: The permissions associated with the parameter.\n // VALUES: r, rw\n permissions: \"rw\"\n }\n];\n \nmsg.payload = {\"parameters\": parameters};\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1145.5714263916016, | |
"y": 464.42856884002686, | |
"wires": [ | |
[ | |
"db2ed20a.0eb32" | |
] | |
] | |
}, | |
{ | |
"id": "db2ed20a.0eb32", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 1301.5714263916016, | |
"y": 467.42856884002686, | |
"wires": [] | |
}, | |
{ | |
"id": "2addd15a.2d452e", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/configuration", | |
"method": "post", | |
"swaggerDoc": "", | |
"x": 932.5714263916016, | |
"y": 552.4285688400269, | |
"wires": [ | |
[ | |
"2fdcbbad.63d4d4" | |
] | |
] | |
}, | |
{ | |
"id": "6dc9ee39.634ab", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 1325.5714263916016, | |
"y": 550.4285688400269, | |
"wires": [] | |
}, | |
{ | |
"id": "2fdcbbad.63d4d4", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var data = msg.req.body;\n\n// The new configuration parameter values.\nvar new_parameters = data.parameters;\n\n// CHANGEME: The existing configuration.\nvar configuration = [\n // CHANGEME: The configuration parameters.\n];\n\nvar existing = new_parameters.filter(function(parameter) {\n return configuration.filter(function(p) {\n return p.name === parameter.name;\n }).length > 0;\n});\nif (existing.length !== new_parameters.length) {\n msg.statusCode = 404;\n return msg;\n}\n\nvar writable = new_parameters.filter(function(parameter) {\n return configuration.filter(function(p) {\n return p.name === parameter.name && p.permissions === \"rw\";\n }).length > 0;\n});\nif (writable.length !== new_parameters.length) {\n msg.statusCode = 403;\n return msg;\n}\n\n// The new configuration.\nconfiguration = configuration.map(function(parameter) {\n var new_value = new_parameters.filter(function(p) {\n return p.name === parameter.name;\n }).map(function(p) {\n return p.value;\n });\n if (new_value !== undefined) {\n parameter.value = new_value;\n }\n return parameter;\n});\n\n// CHANGEME: Save the new configuration.\n\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 1146.5714263916016, | |
"y": 552.4285688400269, | |
"wires": [ | |
[ | |
"6dc9ee39.634ab" | |
] | |
] | |
}, | |
{ | |
"id": "f31a3e92.b17d9", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 588.6428527832031, | |
"y": 468.42857837677, | |
"wires": [] | |
}, | |
{ | |
"id": "6fac8863.9e6328", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/performance/supported", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 193.64285278320312, | |
"y": 468.42857837677, | |
"wires": [ | |
[ | |
"a7e2fde0.f8108" | |
] | |
] | |
}, | |
{ | |
"id": "a7e2fde0.f8108", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var metrics = [\n // CHANGEME: The performance metrics.\n {\n // CHANGEME: The type of the corresponding observed property.\n \"type\": \"http://vital-iot.eu/ontology/ns/SysLoad\",\n // CHANGEME: The ID of the corresponding observed property.\n \"id\": \"http://example.com/sensor/monitoring/sysLoad\"\n }\n];\n \nmsg.payload = {\"metrics\": metrics};\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 426.6428527832031, | |
"y": 467.42857837677, | |
"wires": [ | |
[ | |
"f31a3e92.b17d9" | |
] | |
] | |
}, | |
{ | |
"id": "98d92ac4.e4d0e8", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/performance", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 162.64285278320312, | |
"y": 562.42857837677, | |
"wires": [ | |
[ | |
"b852cc1c.1eede" | |
] | |
] | |
}, | |
{ | |
"id": "9e5e9660.95c678", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 490.6428527832031, | |
"y": 559.42857837677, | |
"wires": [] | |
}, | |
{ | |
"id": "b852cc1c.1eede", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var data = msg.req.body;\n\n// The performance metrics to return values for.\n// SEE ALSO: Get supported performance metrics.\nvar metrics = data.metric;\n\n// CHANGEME: The ID of the system.\n// SEE ALSO: Get system metadata.\nvar system_id = \"http://example.com\";\n\n// CHANGEME: The ID of the monitoring sensor.\n// SEE ALSO: Get sensor metadata.\nvar monitoring_sensor = \"http://example.com/sensor/monitoring\";\n\nvar metric_values = [\n // CHANGEME: The metric values to return.\n {\n // CHANGEME: The ID of the value.\n \"id\": \"http://example.com/sensor/monitoring/observation/1\", \n // CHANGEME: The property that corresponds to the metric.\n \"metric\": \"vital:SysLoad\",\n // CHANGEME: The date and time when the value was collected.\n \"date_time\": \"2014-08-20T16:47:32+01:00\",\n // CHANGEME: The value.\n \"value\": 80,\n // CHANGEME: The unit of the value.\n \"unit\": \"qudt:Percent\"\n }\n].filter(function(metric_value) {\n return metrics === undefined || metrics.indexOf(metric_value.metric) >= 0;\n}).map(function(metric_value) {\n return {\n \"@context\": \"http://vital-iot.eu/contexts/measurement.jsonld\", \n \"id\": metric_value.id,\n \"type\": \"ssn:Observation\", \n \"ssn:observedBy\": monitoring_sensor,\n \"ssn:observationProperty\": {\n \"type\": metric_value.metric\n }, \n \"ssn:observationResultTime\": {\n \"time:inXSDDateTime\": metric_value.date_time\n }, \n \"ssn:featureOfInterest\": system_id, \n \"ssn:observationResult\": { \n \"type\": \"ssn:SensorOutput\", \n \"ssn:hasValue\": { \n \"type\": \"ssn:ObservationValue\", \n \"value\": metric_value.value,\n \"qudt:unit\": metric_value.unit \n } \n } \n };\n});\n\nmsg.payload = {\"metrics\": metrics};\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 348.6428527832031, | |
"y": 560.42857837677, | |
"wires": [ | |
[ | |
"9e5e9660.95c678" | |
] | |
] | |
}, | |
{ | |
"id": "773b5670.1ba968", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/sla/supported", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 630.7142868041992, | |
"y": 734.2857370376587, | |
"wires": [ | |
[ | |
"b1c6b0c5.77b19" | |
] | |
] | |
}, | |
{ | |
"id": "8882229e.6d999", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 1030.714340209961, | |
"y": 732.8571910858154, | |
"wires": [] | |
}, | |
{ | |
"id": "b1c6b0c5.77b19", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var parameters = [\n // CHANGEME: The performance metrics.\n {\n // CHANGEME: The type of the corresponding observed property.\n \"type\": \"http://vital-iot.eu/ontology/ns/ResponseTime\",\n // CHANGEME: The ID of the corresponding observed property.\n \"id\": \"http://example.com/sensor/monitoring/responseTime\"\n }\n];\n \nmsg.payload = {\"parameters\": parameters};\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 842.1428337097168, | |
"y": 729.9999442100525, | |
"wires": [ | |
[ | |
"8882229e.6d999" | |
] | |
] | |
}, | |
{ | |
"id": "72c31298.1dea5c", | |
"type": "http response", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"x": 1023.571403503418, | |
"y": 831.4285478591919, | |
"wires": [] | |
}, | |
{ | |
"id": "37a6d92.a681526", | |
"type": "http in", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"url": "/sla", | |
"method": "get", | |
"swaggerDoc": "", | |
"x": 597.8571166992188, | |
"y": 832.8571376800537, | |
"wires": [ | |
[ | |
"1ca070e2.4ba08f" | |
] | |
] | |
}, | |
{ | |
"id": "1ca070e2.4ba08f", | |
"type": "function", | |
"z": "4e97a16a.36ab9", | |
"name": "", | |
"func": "var data = msg.req.body;\n\n// The SLA parameters to return values for.\n// SEE ALSO: Get supported SLA parameters.\nvar parameters = data.parameter;\n\n// CHANGEME: The ID of the system.\n// SEE ALSO: Get system metadata.\nvar system_id = \"http://example.com\";\n\n// CHANGEME: The ID of the monitoring sensor.\n// SEE ALSO: Get sensor metadata.\nvar monitoring_sensor = \"http://example.com/sensor/monitoring\";\n\nvar parameter_values = [\n // CHANGEME: The SLA parameter values to return.\n {\n // CHANGEME: The ID of the value.\n \"id\": \"http://example.com/sensor/monitoring/observation/1\", \n // CHANGEME: The property that corresponds to the SLA parameter.\n \"parameter\": \"vital:ResponseTime\",\n // CHANGEME: The date and time when the value was collected.\n \"date_time\": \"2014-08-20T16:47:32+01:00\",\n // CHANGEME: The value.\n \"value\": 3000,\n // CHANGEME: The unit of the value.\n \"unit\": \"qudt:MilliSecond\"\n }\n].filter(function(parameter_value) {\n return parameters === undefined || parameters.indexOf(parameter_value.parameter) >= 0;\n}).map(function(parameter_value) {\n return {\n \"@context\": \"http://vital-iot.eu/contexts/measurement.jsonld\", \n \"id\": parameter_value.id,\n \"type\": \"ssn:Observation\", \n \"ssn:observedBy\": monitoring_sensor,\n \"ssn:observationProperty\": {\n \"type\": parameter_value.parameter\n }, \n \"ssn:observationResultTime\": {\n \"time:inXSDDateTime\": parameter_value.date_time\n }, \n \"ssn:featureOfInterest\": system_id, \n \"ssn:observationResult\": { \n \"type\": \"ssn:SensorOutput\", \n \"ssn:hasValue\": { \n \"type\": \"ssn:ObservationValue\", \n \"value\": parameter_value.value,\n \"qudt:unit\": parameter_value.unit \n } \n } \n };\n});\n\nmsg.payload = {\"metrics\": metrics};\nmsg.headers = {\"Content-Type\": \"application/json\"};\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 814.9999771118164, | |
"y": 831.4285745620728, | |
"wires": [ | |
[ | |
"72c31298.1dea5c" | |
] | |
] | |
} | |
] |