-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(WIP) Enabling of Knowledge Layer #50
Open
chrizmc
wants to merge
39
commits into
COVESA:main
Choose a base branch
from
chrizmc:feature/enabling-of-knowledgelayer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
db8e01a
Add basis directory structure with readme files
chrizmc 64e06ec
add basic setup of informationlayer containing basic dbrouter and rea…
chrizmc 5ee12fd
add files
claireqiu 75c0eb3
Fixed readme format of config.js
sschleemilch a77d8a3
Renamed knowledge-connector -> connector
sschleemilch 327db86
Removed dead README link
sschleemilch 69da82d
Fixed README formatting and fixed typos
sschleemilch 9bb7dc4
Updated docs, added config.js
sschleemilch e0d7aa6
Added handlers layer
sschleemilch 9722e2b
Hint for hard coded realmdb and js formatting
sschleemilch dbbed43
Fixed require path for new structure
sschleemilch f98ef6f
Added missing dot in readme
chrizmc 0da163a
Fixed wrong readme link
chrizmc 0c83de4
add basic router parts
chrizmc 3e36432
Add environment variable functionallity and update README files.
chrizmc 72ab98b
Update link URL and create a IoTDB connection using the IoTDB Handler
chrizmc c075e51
Update the authentification configuration for the IoTDB handler
chrizmc 684f3f9
Add validator for message format and IoTDB message processing
chrizmc 62e8402
Extend supported data points in RealmDB Handler
sschleemilch cd597d1
Support for UseCase endpoits in IoTDB Handler
sschleemilch 5f142ab
Add write support to realmdb
sschleemilch 56a1109
Extracted common methods
sschleemilch 6d28e89
Support dots separation for endpoint naming in realm db
aw-muc deff29c
• Import supported endpoints for IoTDB and RealmDB from YAML/JSON fil…
aw-muc c8ef06d
Dockerize informations-layer
aw-muc 7f1ae37
Fixed doc typos
sschleemilch 838af3f
Remove unnecessary config files and add it as gitignore.
aw-muc dfb873f
Data transmission via websocket client in knowledge layer:
aw-muc 28ec28b
Documentation for new data source within information layer
aw-muc b84a37e
Handle and send error message within information layer for websocket …
aw-muc 8614c90
Vehicle data point knowledge layer configuration
sschleemilch e68d6bb
CMake windows support
sschleemilch bbe803f
Add --help CLI feature to display configured and default parameters
chrizmc 9559d7f
Use configuration file to organize the use case model directory
chrizmc ffce704
Configure RDFox environment
chrizmc 24b871e
Develop RDFox adapter for rest api integration
1bcadd7
Refactored information-layer Docs (#36)
sschleemilch 7ae2fb4
- Migrate JS to TypeScript
aw-muc c936c4b
add hello world kl usecase readme
chrizmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,21 +11,24 @@ Setting up an information layer in the CDSP involves running a [Database-Router] | |
|
||
Please follow installation instructions of the chosen [handler](./handlers/). | ||
|
||
## [Installation of Database-Router](./router/README.md#Install) | ||
## Installation of Database-Router | ||
See [hier](./router/README.md#Install) how to install the Database-Router. | ||
|
||
# Running "Hello World" example | ||
|
||
The Hello World example in our case is quite simple. We feed an updated value for the HVAC ambient air temperature into the database and we check afterwards in the logs if the DB-router creates a Websocket update message for it. | ||
The Hello World example in our case is quite simple. We feed an updated value for the `CurrentLocation_Longitude` into the database and we check afterwards in the logs if the DB-router creates a Websocket update message for it. | ||
|
||
## Choose and prepare your Database | ||
|
||
### Realm | ||
- Ensure that in your [ATLAS cloud](https://cloud.mongodb.com/) app there is a vehicle *document* with an `_id: 1234567` in a collection named *Vehicles*. | ||
- Ensure that this document as well contains VSS data. At the moment only 1 data point is supported, namely `Vehicle.Cabin.HVAC.AmbientAirTemperature`. Here you can see how the vehicle document within the *Vehicles* should look like in ATLAS: | ||
|
||
``` | ||
_id: 1234567 (Int64) | ||
Vehicle_Cabin_HVAC_AmbientAirTemperature: 6 (Double) | ||
- Ensure that in your [ATLAS cloud](https://cloud.mongodb.com/) app there is a vehicle *document* with an `VehicleIdentification_VIN: SMT905JN26J262542` in a collection named *`Vehicles`*. | ||
- Ensure that this document as well contains VSS data. Here you can see the supported data in a vehicle document within the *Vehicles* should look like in ATLAS: | ||
|
||
``` | ||
_id: "<SOME_ID>" (string) | ||
VehicleIdentification_VIN: "<SOME_VIN>" (string) | ||
CurrentLocation_Latitude: <SOME_LATITUDE_VALUE> (Int64) | ||
CurrentLocation_Longitude: <SOME_LONGITUDE_VALUE> (Int64) | ||
``` | ||
|
||
### IoTDB | ||
|
@@ -43,26 +46,122 @@ The Hello World example in our case is quite simple. We feed an updated value fo | |
It costs 0.004s | ||
``` | ||
|
||
- Create two *timeseries* with the `root.Vehicles.VIN` and some VSS data. At the moment only 1 data point is supported, namely `root.Vehicles.Vehicle_Cabin_HVAC_AmbientAirTemperature`. Here you can see how the vehicle document within the *Vehicles* should look like in IoTDB CLI: | ||
- Create two *timeseries* with the `root.Vehicles.VehicleIdentification_VIN` and some VSS data. Here you can see an example how the vehicle document within the *Vehicles* should look like in IoTDB CLI: | ||
|
||
``` | ||
IoTDB> show timeseries; | ||
+------------------------------------------------------+-----+-------------+--------+--------+-----------+----+----------+--------+------------------+--------+ | ||
| Timeseries|Alias| Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType| | ||
+------------------------------------------------------+-----+-------------+--------+--------+-----------+----+----------+--------+------------------+--------+ | ||
|root.Vehicles.Vehicle_Cabin_HVAC_AmbientAirTemperature| null|root.Vehicles| FLOAT| RLE| LZ4|null| null| null| null| BASE| | ||
| root.Vehicles.VIN| null|root.Vehicles| TEXT| PLAIN| LZ4|null| null| null| null| BASE| | ||
+------------------------------------------------------+-----+-------------+--------+--------+-----------+----+----------+--------+------------------+--------+ | ||
+---------------------------------------+-----+-------------+--------+--------+-----------+----+----------+--------+------------------+--------+ | ||
| Timeseries|Alias| Database|DataType|Encoding|Compression|Tags|Attributes|Deadband|DeadbandParameters|ViewType| | ||
+---------------------------------------+-----+-------------+--------+--------+-----------+----+----------+--------+------------------+--------+ | ||
|root.Vehicles.VehicleIdentification_VIN| null|root.Vehicles| TEXT| PLAIN| LZ4|null| null| null| null| BASE| | ||
| root.Vehicles.CurrentLocation_Latitude| null|root.Vehicles| DOUBLE| RLE| LZ4|null| null| null| null| BASE| | ||
|root.Vehicles.CurrentLocation_Longitude| null|root.Vehicles| DOUBLE| RLE| LZ4|null| null| null| null| BASE| | ||
+---------------------------------------+-----+-------------+--------+--------+-----------+----+----------+--------+------------------+--------+ | ||
``` | ||
|
||
## [Start](./router/README.md#Run) the Database Router | ||
## Start the Database Router | ||
|
||
See [here](./router/README.md#Run) how to start the database router. | ||
|
||
## Look out for the Websocket Server message in the console | ||
If you are running the RealmDB handler and you change the value of `Vehicle_Cabin_HVAC_AmbientAirTemperature` in ATLAS cloud (let's say `23`), you should immediately see this line in console: | ||
If you the handler is running and you are subscribed to that element, when you change the value of `CurrentLocation_Longitude` in ATLAS cloud (let's say `-157845.68200000003`), you should immediately see this line in console: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'If |
||
|
||
``` | ||
the value of "Vehicle_Cabin_HVAC_AmbientAirTemperature" changed to 23 | ||
{ | ||
type: 'update', | ||
tree: 'VSS', | ||
id: '<your_VIN>', | ||
dateTime: '<actual_data_time>', | ||
uuid: '<your_uuid>', | ||
node: { name: 'CurrentLocation_Longitude', value: `-157845.68200000003` } | ||
} | ||
``` | ||
|
||
## Connect your own Websocket Client | ||
# Connect your own Websocket Client | ||
Connect your own websocket client by connecting to `ws://localhost:8080` | ||
|
||
The examples use the VIN (Vehicle Identification Number) as object identifier. | ||
|
||
### Reading data | ||
|
||
To read data, send a message with the type of request and VIN as object ID: | ||
|
||
* Example for one Node: | ||
```json | ||
{ | ||
"type": "read", | ||
"tree": "VSS", | ||
"id": "<some_VIN>", | ||
"uuid": "<random_string>", | ||
"node": { | ||
"name": "<some_endpoint>" | ||
} | ||
} | ||
``` | ||
* Example for multiple Nodes: | ||
```json | ||
{ | ||
"type": "read", | ||
"tree": "VSS", | ||
"id": "<some_VIN>", | ||
"uuid": "<random-string>", | ||
"nodes": [ | ||
{ | ||
"name": "<some_endpoint>" | ||
}, | ||
{ | ||
"name": "<other_endpoint>" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Writing data | ||
|
||
To write data, send a message with the type of request and VIN as object ID (at this moment only with IoTDB available): | ||
|
||
* Example for one Node: | ||
```json | ||
{ | ||
"type": "write", | ||
"tree": "VSS", | ||
"id": "<some_VIN>", | ||
"uuid": "<random_string>", | ||
"node": { | ||
"name": "<some_endpoint>", | ||
"value": "<some_value>" | ||
} | ||
} | ||
``` | ||
* Example for multiple Nodes: | ||
```json | ||
{ | ||
"type": "write", | ||
"tree": "VSS", | ||
"id": "<some_VIN>", | ||
"uuid": "<random-string>", | ||
"nodes": [ | ||
{ | ||
"name": "<some_endpoint>", | ||
"value": "<some_value>" | ||
}, | ||
{ | ||
"name": "<other_endpoint>", | ||
"value": "<other_value>" | ||
} | ||
] | ||
} | ||
``` | ||
### Subscribing to changes | ||
|
||
To subscribe to changes in a specific object, send a message with the type of request and VIN as object ID (at this moment only with RealmDB available): | ||
|
||
```json | ||
{ | ||
"type": "subscribe", | ||
"tree": "VSS", | ||
"id": "<some_VIN>", | ||
"uuid": "<your_uuid>", | ||
} | ||
``` | ||
|
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,35 +1,35 @@ | ||
class Handler { | ||
authenticateAndConnect(sendMessageToClients) { | ||
throw new Error("Method 'authenticateAndConnect' must be implemented."); | ||
} | ||
authenticateAndConnect(sendMessageToClients) { | ||
throw new Error("Method 'authenticateAndConnect' must be implemented."); | ||
} | ||
|
||
handleMessage(message, ws) { | ||
switch (message.type) { | ||
case 'read': | ||
this.read(message, ws); | ||
break; | ||
case 'write': | ||
this.write(message, ws); | ||
break; | ||
case 'subscribe': | ||
this.subscribe(message, ws); | ||
break; | ||
default: | ||
ws.send(JSON.stringify({ error: 'Unknown message type'})) | ||
} | ||
handleMessage(message, ws) { | ||
switch (message.type) { | ||
case "read": | ||
this.read(message, ws); | ||
break; | ||
case "write": | ||
this.write(message, ws); | ||
break; | ||
case "subscribe": | ||
this.subscribe(message, ws); | ||
break; | ||
default: | ||
ws.send(JSON.stringify({ error: "Unknown message type" })); | ||
} | ||
} | ||
|
||
read(message, ws) { | ||
throw new Error('Read method not implemented, yet!') | ||
} | ||
read(message, ws) { | ||
throw new Error("Read method not implemented, yet!"); | ||
} | ||
|
||
write(message, ws) { | ||
throw new Error('Write method not implemented, yet!') | ||
} | ||
write(message, ws) { | ||
throw new Error("Write method not implemented, yet!"); | ||
} | ||
|
||
subscribe(message, ws) { | ||
throw new Error('Subscribe method not implemented, yet!') | ||
} | ||
subscribe(message, ws) { | ||
throw new Error("Subscribe method not implemented, yet!"); | ||
} | ||
} | ||
|
||
module.exports = Handler; | ||
module.exports = Handler; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Contains the definition of the database name and its identifier endpoint for each catalog. | ||
*/ | ||
const Database = Object.freeze({ | ||
VSS: { | ||
database_name: "root.Vehicles", // name of the configured IoTDB for the VSS Database | ||
endpoint_id: "VehicleIdentification_VIN", // endpoint used as element ID | ||
}, | ||
}); | ||
|
||
module.exports = Database; |
8 changes: 6 additions & 2 deletions
8
cdsp/information-layer/handlers/iotdb/config/MeasurementsType.js
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,8 +1,12 @@ | ||
const JSDataType = require("../utils/IoTDBConstants"); | ||
|
||
/* | ||
* Define the supported endpoints and the corresponding data types. | ||
*/ | ||
const MeasurementType = Object.freeze({ | ||
VIN: JSDataType.TEXT, | ||
Vehicle_Cabin_HVAC_AmbientAirTemperature: JSDataType.FLOAT, | ||
VehicleIdentification_VIN: JSDataType.TEXT, | ||
CurrentLocation_Latitude: JSDataType.DOUBLE, | ||
CurrentLocation_Longitude: JSDataType.DOUBLE, | ||
}); | ||
|
||
module.exports = MeasurementType; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'hier' should be 'here'?