Skip to content
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
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 May 23, 2024
64e06ec
add basic setup of informationlayer containing basic dbrouter and rea…
chrizmc May 29, 2024
5ee12fd
add files
claireqiu May 31, 2024
75c0eb3
Fixed readme format of config.js
sschleemilch Jun 6, 2024
a77d8a3
Renamed knowledge-connector -> connector
sschleemilch Jun 6, 2024
327db86
Removed dead README link
sschleemilch Jun 6, 2024
69da82d
Fixed README formatting and fixed typos
sschleemilch Jun 6, 2024
9bb7dc4
Updated docs, added config.js
sschleemilch Jun 6, 2024
e0d7aa6
Added handlers layer
sschleemilch Jun 6, 2024
9722e2b
Hint for hard coded realmdb and js formatting
sschleemilch Jun 6, 2024
dbbed43
Fixed require path for new structure
sschleemilch Jun 6, 2024
f98ef6f
Added missing dot in readme
chrizmc Jun 18, 2024
0da163a
Fixed wrong readme link
chrizmc Jun 18, 2024
0c83de4
add basic router parts
chrizmc Jul 8, 2024
3e36432
Add environment variable functionallity and update README files.
chrizmc Jul 9, 2024
72ab98b
Update link URL and create a IoTDB connection using the IoTDB Handler
chrizmc Jul 24, 2024
c075e51
Update the authentification configuration for the IoTDB handler
chrizmc Jul 31, 2024
684f3f9
Add validator for message format and IoTDB message processing
chrizmc Aug 7, 2024
62e8402
Extend supported data points in RealmDB Handler
sschleemilch Aug 9, 2024
cd597d1
Support for UseCase endpoits in IoTDB Handler
sschleemilch Aug 9, 2024
5f142ab
Add write support to realmdb
sschleemilch Aug 13, 2024
56a1109
Extracted common methods
sschleemilch Aug 21, 2024
6d28e89
Support dots separation for endpoint naming in realm db
aw-muc Aug 22, 2024
deff29c
• Import supported endpoints for IoTDB and RealmDB from YAML/JSON fil…
aw-muc Aug 27, 2024
c8ef06d
Dockerize informations-layer
aw-muc Sep 6, 2024
7f1ae37
Fixed doc typos
sschleemilch Sep 6, 2024
838af3f
Remove unnecessary config files and add it as gitignore.
aw-muc Sep 13, 2024
dfb873f
Data transmission via websocket client in knowledge layer:
aw-muc Sep 16, 2024
28ec28b
Documentation for new data source within information layer
aw-muc Sep 16, 2024
b84a37e
Handle and send error message within information layer for websocket …
aw-muc Sep 16, 2024
8614c90
Vehicle data point knowledge layer configuration
sschleemilch Sep 26, 2024
e68d6bb
CMake windows support
sschleemilch Sep 27, 2024
bbe803f
Add --help CLI feature to display configured and default parameters
chrizmc Oct 9, 2024
9559d7f
Use configuration file to organize the use case model directory
chrizmc Oct 9, 2024
ffce704
Configure RDFox environment
chrizmc Oct 9, 2024
24b871e
Develop RDFox adapter for rest api integration
Oct 17, 2024
1bcadd7
Refactored information-layer Docs (#36)
sschleemilch Oct 21, 2024
7ae2fb4
- Migrate JS to TypeScript
aw-muc Oct 21, 2024
c936c4b
add hello world kl usecase readme
chrizmc Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 118 additions & 19 deletions cdsp/information-layer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'hier' should be 'here'?


# 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
Expand All @@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'If you the handler'?


```
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>",
}
```

54 changes: 27 additions & 27 deletions cdsp/information-layer/handlers/handler.js
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;
14 changes: 6 additions & 8 deletions cdsp/information-layer/handlers/iotdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ Create `config/config.js` with the following format, replacing the app id and th

```js
module.exports = {
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
};
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
};
```

Expand Down
11 changes: 11 additions & 0 deletions cdsp/information-layer/handlers/iotdb/config/Database.js
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;
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;
Loading
Loading