-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IoT Agent was so far operating independent of datamodel. This had seveal disadvantages: - No detection of mismatch between namespaces - No systematic normalization/contextualization of input data with respect to data model - No trust building/plausiblity checks of incoming data - No use of knowledge graphs to pre-process data at gateway This PR provides a first draft of the future Dataservice which uses the ontology not only for data modelling but also to determine contextualization of incoming data. It only contains a test binding which is creating random data to demonstrate the concept. In future it will contain modules to retrieve data from other protocols, mainly proxied by MQTT and REST. As first step the JSON-LD "@context" is becoming a central structure. Every ontology must contain a context which determines the prefixes and namespace binding. For instance, it is assumed that every ontology must contain a "base:" prefix for the namespace which contains all the base terms of the used ontology (such as Binding and Connector classes) An example ontology is provided here: https://industryfusion.github.io/contexts/staging/example/v0.1 including context: https://industryfusion.github.io/contexts/staging/example/v0.1/context.jsonld Related Epic: #514 Related User Story: #515 Signed-off-by: marcel <[email protected]>
- Loading branch information
1 parent
58e845a
commit bfbbb6c
Showing
68 changed files
with
4,970 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
semantic-model/datamodel/examples/plasmacutter_and_filter_data2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
semantic-model/datamodel/examples/plasmacutter_data_normalized.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
semantic-model/datamodel/examples/plasmacutter_datatype_unit_data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
semantic-model/datamodel/examples/simple_plasmacutter2_data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"@context": "https://industryfusion.github.io/contexts/v0.1/context.jsonld", | ||
"@context": "https://industryfusion.github.io/contexts/tutorial/v0.1/context.jsonld", | ||
"id": "urn:iff:abc123", | ||
"type": "Plasmacutter" | ||
} |
2 changes: 1 addition & 1 deletion
2
semantic-model/datamodel/examples/simple_plasmacutter_data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"@context": "https://industryfusion.github.io/contexts/v0.1/context.jsonld", | ||
"@context": "https://industryfusion.github.io/contexts/tutorial/v0.1/context.jsonld", | ||
"id": "urn:iff:cutter1", | ||
"type": "eclass:0173-1#01-AKJ975#017" | ||
} |
2 changes: 1 addition & 1 deletion
2
semantic-model/datamodel/examples/simple_plasmacutter_data2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"@context": "https://industryfusion.github.io/contexts/v0.1/context.jsonld", | ||
"@context": "https://industryfusion.github.io/contexts/tutorial/v0.1/context.jsonld", | ||
"id": "urn:iff:cutter1", | ||
"type": "Plasmacutter" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
ignore = E722, W504 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
PYTHON := python3 | ||
LINTER := $(HOME)/.local/bin/flake8 | ||
PIP := pip | ||
HELM_DIR := ../../helm/charts/shacl | ||
NAMESPACE := iff | ||
|
||
|
||
lint: requirements-dev.txt | ||
$(LINTER) | ||
|
||
setup: requirements.txt setup-dev | ||
$(PIP) install -r requirements.txt | ||
|
||
setup-dev: requirements-dev.txt | ||
$(PIP) install -r requirements-dev.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Dataservice setup | ||
|
||
## Setup and Activate Device | ||
|
||
## Use Dataservice to send testdata | ||
Start dataservice with `startDataservice.py`: | ||
python3 ./startDataservice.py \<ontology-dir\> \<type\> \<binding-name\> | ||
|
||
*\<ontology\>* is supposed to be downloadable from a directory containing different *.ttl files, *\<type\>* is the (in the ontology context) namespaced class (e.g. `ex:MyClass` if `ex:` is defined in the ontologies context) and *\<binding-name\>* is the name of a *.ttl file in the *bindings* subdirectory of the ontoloy. | ||
|
||
Example: | ||
|
||
python3 ./startDataservice.py https://industryfusion.github.io/contexts/example/v0.1 iffBaseEntity:Cutter base_test.ttl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flake8==5.0.4 | ||
bandit==1.7.4 | ||
black==22.8.0 | ||
pytest==7.1.3 | ||
pytest-cov==4.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
rdflib==6.2.0 | ||
owlrl==6.0.2 | ||
ruamel.yaml==0.17.21 | ||
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Copyright (c) 2024 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import asyncio | ||
import random | ||
from random import randint | ||
from rdflib import Literal | ||
from rdflib.namespace import XSD | ||
|
||
|
||
########################################################################################## | ||
# This function will receive an array of dictionaries containing the needed parameters | ||
# to read out data from machines or databases. | ||
# It will update the values in regular intervals | ||
########################################################################################## | ||
async def subscribe(connector_attribute_dict, firmware): | ||
while True: | ||
logic_var_type = connector_attribute_dict['logicVarType'] | ||
if logic_var_type == XSD.boolean: | ||
connector_attribute_dict['value'] = Literal(random.choice([True, False])) | ||
elif logic_var_type == XSD.integer: | ||
connector_attribute_dict['value'] = Literal(randint(0, 1000)) | ||
elif logic_var_type == XSD.decimal or logic_var_type == XSD.float or logic_var_type == XSD.double: | ||
connector_attribute_dict['value'] = Literal(float(randint(0, 100000)) / 100.0) | ||
connector_attribute_dict['firmware'] = firmware | ||
|
||
await asyncio.sleep(1) |
Oops, something went wrong.