Guide for Experimenters

5 Reasoning

5.2 Reasoning user interface



Rule Creation
An experimenter could create new rules in two ways: as a semantic expert or as a non-semantic expert. These actions could be performed on the FIESTA-IoT portal, where there is a menu called “Reasoning”, which has 3 submenus: Create Rule, Register Rule, and Execute Rule.



Create new Rule – Semantic Expert
The FIESTA-IoT Reasoning module provides a simple UI (in 1s Figure) for enabling experimenters to easily write the rule on a text-view. For assisting the experimenters in this process, the UI also provides sensor information base on the selected quantity kind, so that experimenters can easily see information for the sensors, so that they have a more detailed view when they create their own rule. Here, information like sensor ID, sensor quantity kind, sensor unit of measurement, sensor latitude, sensor longitude or current sensor data is presented as shown in the followings figures.

Experimenters can create a new simple rule with the “if then” logic within a query as shown in Table below. In this example, we apply rule “if power_consumption>0.56 Watt then notify experimenter for high consumption”:

@prefix iot-lite: <http://purl.oclc.org/NET/UNIS/fiware/iot-lite#> .

@prefix m3-lite: <http://purl.org/iot/vocab/m3-lite#> .

@prefix ssn: <http://purl.oclc.org/NET/ssnx/ssn#> .

@prefix geo:  <http://www.w3.org/2003/01/geo/wgs84_pos#> .

@prefix xsd:    <http://www.w3.org/2001/XMLSchema#> .

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

@prefix dul: <http://www.loa.istc.cnr.it/ontologies/DUL.owl#> .

@prefix time: <http://www.w3.org/2006/time#> .

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

@prefix reasoning: <https://fiesta-iot.eu/reasoning#> .

(?observation rdf:type ssn:Observation),

(?observation ssn:observedProperty ?observedProperty),

(?observedProperty rdf:type m3-lite:Power),

(?observation ssn:observationResult ?sensorOutput),

(?sensorOutput ssn:hasValue ?obsValue),

(?obsValue dul:hasDataValue ?dataValue),

(?obsValue iot-lite:hasUnit ?unit),

(?unit rdf:type m3-lite:Watt),

greaterThan(?dataValue, "0.56"^^xsd:double) -> (?observation reasoning:announce "high_notification"^^xsd:string).

After filling all the required information as in the UI, experimenters can click on the “save” button and store the rule in the FIESTA-IoT Reasoning database. Within FIESTA-IoT, by default all the created rules are public and available to all experimenters associated with FIESTA-IoT platform, hence all these rules can be re-used by other experimenters. When the rule is created successfully, the experimenter is redirected to the initial rule creation page, as shown in 1st Figure.



Create new Rule when Non-Semantic expert
The FIESTA-IoT Reasoning tool also provides a simple UI for experimenters who are not familiar with semantics. To create a new rule, such experimenters would click on the “Create new rule – Non-Semantic Expert” button. This option is much easier when an experimenter does not have Semantic knowledge and wants to create new rules with the IF THEN logic (see 4th Figure).

Create new Rule - Non-Semantic Expert

An experimenter can click on the add-new-rule button “+ New Rule” to add a new rule or click on the remove icon “X” to remove it. The FIESTA-IoT Reasoning tool will use the information added by the experimenter for the selected quantity kind, and the rule logic in order to generate a rule template by creating a SPARQL query as shown in Table below:

@prefix iot-lite: <http://purl.oclc.org/NET/UNIS/fiware/iot-lite#> .

@prefix m3-lite: <http://purl.org/iot/vocab/m3-lite#> .

@prefix ssn: <http://purl.oclc.org/NET/ssnx/ssn#> .

@prefix geo:  <http://www.w3.org/2003/01/geo/wgs84_pos#> .

@prefix xsd:    <http://www.w3.org/2001/XMLSchema#> .

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

@prefix dul: <http://www.loa.istc.cnr.it/ontologies/DUL.owl#> .

@prefix time: <http://www.w3.org/2006/time#> .

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

@prefix reasoning: <https://fiesta-iot.eu/reasoning#> .

(?observation rdf:type ssn:Observation),

(?observation ssn:observedProperty ?observedProperty),

(?observedProperty rdf:type m3-lite:Power),

(?observation ssn:observationResult ?sensorOutput),

(?sensorOutput ssn:hasValue ?obsValue),

(?obsValue dul:hasDataValue ?dataValue),

(?obsValue iot-lite:hasUnit ?unit),

(?unit rdf:type m3-lite:Watt),

greaterThan(?dataValue, "1"^^xsd:double) -> (?observation reasoning:announce "dangerous_notify"^^xsd:string).(?observation rdf:type ssn:Observation),

(?observation ssn:observedProperty ?observedProperty),

(?observedProperty rdf:type m3-lite:Power),

(?observation ssn:observationResult ?sensorOutput),

(?sensorOutput ssn:hasValue ?obsValue),

(?obsValue dul:hasDataValue ?dataValue),

(?obsValue iot-lite:hasUnit ?unit),

(?unit rdf:type m3-lite:Watt),

lessThan(?dataValue, "1"^^xsd:double) -> (?observation reasoning:announce "lowpower_notify"^^xsd:string).

 

When an Experimenter clicks on the “Save” button, this rule will be stored in the FIESTA-IoT platform and then it will be public and re-usable by other experimenters.



Details of Rules
On the list of rules (see 1st Figure) available on the FIESTA-IoT Reasoning, an experimenter can view (for example Rule 14 as shown in the 5th Figure) the details of any rule by clicking on the “View” icon.

Example of Rule details



Edit a Rule
The function for editing a rule is available only to those experimenters that have created the particular rule. This means, an experimenter is not allowed to change a rule created by other experimenters for security purposes.
On the screen showing the list of rules (see 1st Figure) or on the rule details screen (see 5th Figure), when an experimenter clicks on the “Edit” button, the screen for editing rules will be shown as in 6th and 7th figures. 

Edit Rule Information

Note that in the 7th figure an experimenter can edit the rule in the provided textbox).

Edit Rule content



Rule Registration
After creating the rule template, an experimenter needs to first register the rule on a selected sensor before executing it. This can be done through the “Reasoning” menu on the portal by selecting the “Register Rule: submenu.

Rule Registration home

For security/privacy reasons, each experimenter can only see his own registered rules and not those of other experimenters.



Register a rule
When an experimenter clicks on the “+ Create new Register Rule” button, the 9th Figure is shown, where the experimenter can add information, such as the description of the registered rule, the quantity kind and the sensor upon which the rule will be executed, and also select the rule template to be used for this registration:

Register Rule- Available Rules

As Figure shows, an experimenter can select the rule template from the dropdown menu that shows all the created rules on the platform. By selecting one rule, its detailed information is shown in the “Rule content” field, as shown in 10th Figure.

Register Rule - Detail Rule content

After selecting the rule template, the next step for the experimenter is to select the sensor ID to register (the quantity is pre-filled according to the rule information) as shown in 11th Figure.

Register Rule - Select Sensor

After filling the required information on the form and clicking the “Save” button, the rule registration functionality is finished and the new rule is registered and available for execution.



Detail Rule registration
Another functionality on the initial screen that lists the existing rule registrations (as shown in the 1st Figure) is to see the details of a registered rule, by clicking on the “detail” icon (as shown in 12th Figure).

Register Rule – detailed information



Edit a Rule registration
When experimenters want to edit a rule registration, they can click on the “Edit” button on the detail rule registration page or on the “edit” icon on the list of rule registrations screen. Then, the following is shown (see 13th Figure):

User Interface for editing a rule registration

The Experimenter can then edit the details of the registered rule, i.e. name, description, select new rule, select another sensor and then click “Save” to update all information on the FIESTA-IoT platform.



Rule Execution
The final step after creating and registering a rule is to execute it. The FIESTA-IoT platform provides three main functions for creating a “New execution”, performing a “Re-execution” and viewing the details of an execution.
A Rule execution is the function where the registered rule is executed upon the input sensor data, in order to create some inference data. The home screen of rule execution is shown in the 14th Figure

Rule Execution Home page



Create a New Execution
When an experimenter clicks on the “+ New Execution” button, the following form is shown (see 15th Figure):

User Interface for creating a new Rule execution

In this form, the Experimenter can create a new execution, by selecting a registered rule and setting the “Time for execution”, which can be either in the current measurement or in the measurements within a time range.



New execution with current time
This rule execution happens when the experimenter selects the “Current” option and clicks on the “Save” button. Then, the FIESTA-IoT Reasoning module will execute this registered rule (sensor, rule), giving the result of the execution, which can be either “true” (success) or “false”, together with other details, such as the start, end time, sensor id, rule content, original data, inference data, and full data.



New execution with period or range of time
When an experimenter selects the “Range” execute option, he will be able to select the starting and ending date of the measurements to be considered in this rule, as shown in Figure below.

Execute Rule on sensor base on specific time

The FIESTA-IoT Reasoning will execute a SPARQL query to retrieve sensor data as shown in Table below:

PREFIX iot-lite: <http://purl.oclc.org/NET/UNIS/fiware/iot-lite#>

PREFIX m3-lite: <http://purl.org/iot/vocab/m3-lite#>

PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#>

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX dul: <http://www.loa.istc.cnr.it/ontologies/DUL.owl#>

PREFIX time: <http://www.w3.org/2006/time#>

 

SELECT  ?sensingDevice ?dataValue ?dateTime ?observation ?sensorOutput ?obsValue ?instant

WHERE {

?observation ssn:observedBy ?sensingDevice .

VALUES ?sensingDevice {

<https://platform.fiesta-iot.eu/iot-registry/api/resources/Ur7Q-GLgxiLsfK4ZhXffEryue052DxDQzb8jxqKMPyLJZUiTr-ZpAj1ZK_hi302o5gp8V6Fe1a2jEzg_STnJkUCQHp8f7qAg1DiohqUnfcll3289LvfcuRmXiDPfZROl>} .

?observation ssn:observationResult ?sensorOutput .

?sensorOutput ssn:hasValue ?obsValue .

?obsValue dul:hasDataValue ?dataValue .

?observation ssn:observationSamplingTime ?instant .

?instant time:inXSDDateTime ?dateTime .

  FILTER (

       (xsd:dateTime(?dateTime) > xsd:dateTime("2017-09-16T23:00:00Z"))

    && (xsd:dateTime(?dateTime) < xsd:dateTime("2017-09-17T23:00:00Z"))

    ) .

}ORDER BY ?sensingDevice ASC(?dateTime)



Re-Execution
When an experimenter wants to repeat an execution of the rule, he can just click on the “Re-execute” button on the list of executions. Then, a similar form as with the rule execution will be shown (see 17th Figure) and the user will be allowed to select if he wants to re-execute the rule on the current measurement or on a range of measurements.

Re-Execute Rule