You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/fiware/readme.md
+58-24Lines changed: 58 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,15 @@ This is a demonstration of how to use **semantic-iot** framework to build up a K
3
3
4
4
It is assumed that data in IoT platform conforms with specific **data models**, no matter in which format.
5
5
In this demonstration, we provide data models of hotel energy systems in Python using [Pydantic](https://pydantic-docs.helpmanual.io/).
6
-
These data models can be found in `./datamodels/pydantic_models.py`.
6
+
These data models can be found in [`./datamodels/pydantic_models.py`](./datamodels/pydantic_models.py).
7
7
8
8
Important is that **an example data set** can be created, which fully represents the data models being used.
9
-
In this demonstration, we provide this example data set in JSON format as `./kgcp/rml/example_hotel.json`, which can also be created using the data model script.
9
+
In this demonstration, we provide this example data set in JSON format as [`./kgcp/rml/example_hotel.json`](./kgcp/rml/example_hotel.json), which can also be created using the data model script.
10
10
11
-
Additional data sets, representing different IoT systems of the same specialized IoT platform can be provisioned to a running FIWARE platform via the script `datamodels/hotel_provision.py`. For quick start, we provide a pre-provisioned data under `./hotel_dataset`. If you do like to provision the data by yourself, please deploy the FIWARE platform locally. You can use the docker configuration in `./deployment`.
11
+
Additional data sets, representing different IoT systems of the same specialized IoT platform can be provisioned to a running FIWARE platform via the script [`datamodels/hotel_provision.py`](datamodels/hotel_provision.py). For quick start, we provide a pre-provisioned data under `./hotel_dataset`. If you do like to provision the data by yourself, please deploy the FIWARE platform locally. You can use the docker configuration in `./deployment`.
@@ -23,11 +23,11 @@ Install extra dependencies needed for this demonstration.
23
23
```bash
24
24
pip install -r examples/fiware/requirements.txt
25
25
```
26
-
> **Note**: This demonstration currently has dependency issues with the `semantic-iot` framework. Therefore, you may see some warnings when installing the requirements. However, **you can ignore them**. We are working on fixing this issue.
26
+
> **Note**: This demonstration currently has dependency issues with the **semantic-iot** framework. Therefore, you may see some warnings when installing the requirements. However, **you can ignore them**. We are working on fixing this issue.
27
27
28
28
### Step 1 data model identification & vocabulary mapping
29
29
Set up the FIWARE platform specific configuration is the first step.
30
-
In this demonstration, we provide a configuration file `./kgcp/rml/fiware_config.json` for the specialized FIWARE platform:
30
+
In this demonstration, we provide a configuration file [`./kgcp/rml/fiware_config.json`](./kgcp/rml/fiware_config.json) for the specialized FIWARE platform:
31
31
```json
32
32
{
33
33
"ID_KEY": "id",
@@ -41,20 +41,20 @@ In this demonstration, we provide a configuration file `./kgcp/rml/fiware_config
41
41
]
42
42
}
43
43
```
44
-
For more details about each key of this configuration, please refer to the ``JSONPreprocessor`` class.
44
+
The ``JSONPATH_EXTRA_NODES`` is used to append extra resource types, which are not directly modeled as entities in the JSON dataset. For example `fanSpeed` is modeled as a property of `CoolingCoil`, but it should be mapped to a separate resource type in the knowledge graph.
45
45
46
-
After that, we can start the data model identification and vocabulary mapping with the script ``./kgcp/rml_preprocess.py``, in which the domain ontologies and the example JSON data set are given as input.
46
+
After understanding this, you can start the data model identification and vocabulary mapping by running the script [`./kgcp/rml/rml_preprocess.py`](./kgcp/rml/rml_preprocess.py). In this case, the above configuration file and the domain ontology for building energy system, brick, are given as input.
47
47
48
48
### Step 2 validation and completion
49
-
The last step generate a pre-filled **"resource node relationship"** document, which can be found as `./kgcp/rml/rdf_node_relationship.json`.
50
-
In this document, the data models are identified as different **resource types** and specific term from the ontologies are suggested based on the text similarity.
49
+
The last step generate a pre-filled **"resource node relationship"** document, which can be found as [`./kgcp/rml/rdf_node_relationship.json`](./kgcp/rml/rdf_node_relationship.json).
50
+
In this document, the data models are identified as different **resource types** and the terminology-mappings to specific term of the ontology are suggested based on the string similarity.
51
51
52
-
Manual validation and completion are now required:
53
-
1. Verify the term suggestions
54
-
2. Complete the interrelationship information between resource types
55
-
3. Complete the "link" for accessing the data
52
+
Manual validation and completion are now required for:
53
+
1. Verify the terminology-mappings. For example, the correct mapping for `PresenceSensor` should be `brick:Occupancy_Count_Sensor`.
54
+
2. Complete the interrelationship information between resource types. For example, `TemperatureSensor` is related to `HotelRoom` via the predicate `brick:isPointOf`.
55
+
3. Complete the "link" for accessing the data. For example, the link for `TemperatureSensor` should be `https://<host>/v2/entities/{id}/attrs/temperature/value`.
56
56
57
-
For example this is the resource type `TemperatureSensor` from the generated **"resource node relationship"** document:
57
+
For the resource type `TemperatureSensor`, this is the generated **"resource node relationship"** document:
58
58
````json
59
59
{
60
60
"identifier": "id",
@@ -93,17 +93,51 @@ And after validation and completion, it should look like this:
93
93
}
94
94
````
95
95
96
+
A validated and completed **"resource node relationship"** document for this example is provided in [`./kgcp/rml/rdf_node_relationship_validated.json`](./kgcp/rml/rdf_node_relationship_validated.json).
97
+
96
98
### Step 3 generate mapping file to build KGCP
97
99
Based on the completed **"resource node relationship"** document, we can generate the RML mapping file for the KGCP.
98
-
In this demonstration, this step is conducted in the script `./kgcp/rml_generate.py`.
100
+
In this demonstration, this step can be conducted by running the script [`./kgcp/rml_generate.py`](./kgcp/rml_generate.py).
101
+
The generated RML mapping file can be found in [`./kgcp/rml/fiware_hotel_rml.ttl`](./kgcp/rml/fiware_hotel_rml.ttl).
99
102
100
103
### Step 4 apply KGCP
101
-
So far, we have collected all required information to build the KGCP, i.e., 1) the platform configuration, and 2) the RML mapping file.
102
-
``./kgcp/fiware_kgcp.py`` showcases how to apply the KGCP and generate knowledge graphs for a large amount of data sets in ``./hotel_dataset``
103
-
104
-
### Step 5 (optional) knowledge inference
105
-
To improve the query performance, we can apply knowledge inference to the generated knowledge graph.
106
-
``./reasoning_owl_rl.py`` uses the [OWL-RL](https://owl-rl.readthedocs.io/en/latest/owlrl.html) to infer new knowledge based on the existing KGs.
104
+
So far, we have collected all required information to build the KGCP.
105
+
[``./kgcp/fiware_kgcp.py``](./kgcp/fiware_kgcp.py) showcases how to apply the KGCP and generate knowledge graphs for different volumes of data sets (range from 2 to 1000 rooms) in [``./hotel_dataset``](./hotel_dataset).
106
+
107
+
### Step 5 automated service deployment
108
+
The generated knowledge graph of a hotel IoT system can be used to deploy services, for example a building automation program, automatically.
109
+
110
+
To enable generic information extraction, we can apply logical inference, i.e., reasoning, to the generated knowledge graph. The script
111
+
[``./application_deployment/reasoning_owl_rl.py``](./application_deployment/reasoning_owl_rl.py) uses the [OWL-RL](https://owl-rl.readthedocs.io/en/latest/owlrl.html) to infer new knowledge based on the used brick ontology and the existing knowledge graphs. The inferred knowledge graph for the hotel with 10 rooms is provided as an example in [`./application_deployment/fiware_entities_10rooms_inferred.ttl`](./application_deployment/fiware_entities_10rooms_inferred.ttl). After the inference, the number of triples increases from 263 to 1597.
112
+
113
+
Since a lot of class subsumption relationships are inferred, generic information extraction can be applied to the inferred knowledge graph. For example, the class ``Ventilation_Air_System`` is inferred to be a subclass of ``Air_System`` and ``HVAC_System``. Therefor, all existing actuation for the air system in hotel rooms can be retrieved by the following SPARQL query:
By applying this approach to extract information about the presence of sensors and actuators, and data interactions via the platform API, building automation programs can be configured automatically:
133
+
```yaml
134
+
- controller_function: Ventilation # Control function Ventilation/Heating/Cooling
135
+
controller_mode: <...> # co2/presence/timetable
136
+
inputs:
137
+
sensor_access: <...> # URL to access the sensor data
138
+
outputs:
139
+
actuation_access: <...> # URL to access the actuation function
140
+
```
107
141
108
-
To give an impression, there are 103 triples in the generated KG for 10 rooms.
109
-
After inference, the number of triples increase to 934.
142
+
An example of such automated configuration is provided in [`./application_deployment/controller_configuration.py`](./application_deployment/controller_configuration.py).
143
+
The result is a configuration file for the distributed air systems in hotel, e.g., [`./application_deployment/controller_configs/fiware_entities_10rooms_inferred.yml`](./application_deployment/controller_configs/fiware_entities_10rooms_inferred.yml).
0 commit comments