-
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
48
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 18 commits
Commits
Show all changes
48 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 cd64ada
IMplementation of Thrift to access IoTDB without TypeScript; JavaScri…
aw-muc 7465d61
Switched README graph to mermaid
sschleemilch c078a05
Subscription functionality for IoTDB data layer
aw-muc 21236aa
Locate another transformation function in transformations.ts, too
chrizmc 9693e64
Add instruction how to build and run tests
chrizmc d9da312
change _ to . notation in readme
chrizmc c76f57a
Transform Json data into RDF triples using SHACL shapes and SPARQ…
21e519b
Add subscription status message after subscribe/unsubscribe when usin…
chrizmc 43a1758
Add session management to Information Layer
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 |
---|---|---|
@@ -0,0 +1,167 @@ | ||
This directory contains files related to the [Information Layer](https://en.wikipedia.org/wiki/DIKW_pyramid) of the Central Data Service Playground. | ||
|
||
# Information Layer Playground components | ||
- [Database-Handlers](./handlers) | ||
- [Database-Router](./router) | ||
|
||
# Setting up a CDSP Information Layer | ||
Setting up an information layer in the CDSP involves running a [Database-Router](./router), which is technically a configurable Websocket server that enables northbound connections for WebSocket clients, such as a [Knowledge Layer Connector](../knowledge-layer/README.md), to read, subscribe, and write data. The WebSocket server is connected to a database, which can be selected before starting the web server. Southbound feeders write data to the database in a predefined semantic format, such as [VSS](https://github.com/COVESA/vehicle_signal_specification). | ||
|
||
## Installation of Database-Handler | ||
|
||
Please follow installation instructions of the chosen [handler](./handlers/). | ||
|
||
## 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 `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 `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 | ||
- Ensure to start and run Docker containers defined in a [Docker Compose file](/docker/). | ||
- Ensure that in the IoTDB CLI there is a `root.Vehicles` *database* like this: | ||
|
||
``` | ||
IoTDB> show databases; | ||
+-------------+----+-----------------------+---------------------+---------------------+ | ||
| Database| TTL|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval| | ||
+-------------+----+-----------------------+---------------------+---------------------+ | ||
|root.Vehicles|null| 1| 1| 604800000| | ||
+-------------+----+-----------------------+---------------------+---------------------+ | ||
Total line number = 1 | ||
It costs 0.004s | ||
``` | ||
|
||
- 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.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 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 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 |
||
|
||
``` | ||
{ | ||
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 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Handlers | ||
|
||
- [IotDB](./iotdb) | ||
- [RealmDB](./realmdb) |
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,35 @@ | ||
class Handler { | ||
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" })); | ||
} | ||
} | ||
|
||
read(message, ws) { | ||
throw new Error("Read 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!"); | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Node.js | ||
node_modules/ | ||
package-lock.json | ||
|
||
# Credentials Config File | ||
config.js | ||
|
||
# MAC | ||
**/.DS_Store |
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,39 @@ | ||
This directory contains the IoTDB Handler as a Node.js application. As [Apache IoTDB](https://iotdb.apache.org/) is a time-series database, the IoTDB Handler connects to an existing IoTDB instance using the Thrift protocol. The handler utilizes the [IoTDB Thrift API](https://github.com/apache/thrift) to communicate with the database and perform operations. Configuration details, such as the IoTDB host, port, user credentials, and time zone, are specified in the handler's configuration file. The IoTDB Handler is designed to manage sessions, execute queries, and interact with the IoTDB instance efficiently during runtime. | ||
|
||
# Features | ||
|
||
- **Authentication**: Authenticates with IoTDB using the IoTDB host, port, user credentials, and time zone. | ||
- **Error Handling**: Logs and handles errors during database operations and synchronization. | ||
|
||
# Installation | ||
|
||
Execute within `iotdb` directory | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
# Configure IoTDB | ||
|
||
Before the Database-Router can start the IoTDB Handler without any errors you need to start and run Docker containers defined in a [Docker Compose file](/docker/). | ||
|
||
## Configure of a IoTDB Handler | ||
|
||
Create `config/config.js` with the following format, replacing the app id and the api key with yours. | ||
|
||
```js | ||
module.exports = { | ||
iotdbHost: "your-iotdb-host", // Default "localhost" | ||
iotdbPort: 6667, // Set this to the appropriate IotDB Port | ||
iotdbUser: "your-iotdb-user", // Default "root" | ||
iotdbPassword: "your-iotdb-password", // Default "root" | ||
timeZoneId: Intl.DateTimeFormat().resolvedOptions().timeZone, // Set this to the appropriate time zone | ||
fetchSize: 10000, // number of rows that will be fetched from the database at a time when executing a query | ||
}; | ||
``` | ||
|
||
> **_IMPORTANT:_** Do not commit this file to github! | ||
|
||
## Starting the IoTDB handler | ||
|
||
You do not need to start IotDB Handler manually. It is started by the DB-Router like described [here](../../router/README.md#Run). |
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; |
12 changes: 12 additions & 0 deletions
12
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const JSDataType = require("../utils/IoTDBConstants"); | ||
|
||
/* | ||
* Define the supported endpoints and the corresponding data types. | ||
*/ | ||
const MeasurementType = Object.freeze({ | ||
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'?