Skip to content

Commit 2d11ea5

Browse files
committed
docs: complete readme for fiware example
1 parent 3a27e66 commit 2d11ea5

File tree

2 files changed

+59
-25
lines changed

2 files changed

+59
-25
lines changed

examples/fiware/application_deployment/controller_configs/example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- controller_function: Ventilation
1+
- controller_function: Ventilation # Control function Ventilation/Heating/Cooling
22
controller_mode: <...> # co2/presence/timetable
33
inputs:
44
sensor_access: <...> # URL to access the sensor data

examples/fiware/readme.md

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ This is a demonstration of how to use **semantic-iot** framework to build up a K
33

44
It is assumed that data in IoT platform conforms with specific **data models**, no matter in which format.
55
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).
77

88
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.
1010

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`.
1212

1313
### Prerequisites
14-
Install the semantic-iot framework:
14+
Install the **semantic-iot** framework:
1515
```bash
1616
git clone https://github.com/N5GEH/semantic-iot.git
1717
cd semantic-iot
@@ -23,11 +23,11 @@ Install extra dependencies needed for this demonstration.
2323
```bash
2424
pip install -r examples/fiware/requirements.txt
2525
```
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.
2727
2828
### Step 1 data model identification & vocabulary mapping
2929
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:
3131
```json
3232
{
3333
"ID_KEY": "id",
@@ -41,20 +41,20 @@ In this demonstration, we provide a configuration file `./kgcp/rml/fiware_config
4141
]
4242
}
4343
```
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.
4545

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.
4747

4848
### 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.
5151

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`.
5656

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:
5858
````json
5959
{
6060
"identifier": "id",
@@ -93,17 +93,51 @@ And after validation and completion, it should look like this:
9393
}
9494
````
9595

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+
9698
### Step 3 generate mapping file to build KGCP
9799
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).
99102

100103
### 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:
114+
```sparql
115+
PREFIX brick: <https://brickschema.org/schema/Brick#>
116+
PREFIX rec: <https://w3id.org/rec#>
117+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
118+
119+
SELECT ?room ?airSystem ?actuation ?actuation_type ?actuation_access
120+
WHERE {
121+
?room a rec:Room .
122+
?airSystem a brick:Air_System ;
123+
brick:hasLocation ?room .
124+
OPTIONAL {
125+
?actuation a ?actuation_type ;
126+
brick:isPointOf ?airSystem ;
127+
rdf:value ?actuation_access .
128+
VALUES ?actuation_type { brick:Setpoint brick:Command }
129+
}
130+
}
131+
```
132+
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+
```
107141
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

Comments
 (0)