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

Added example for time series data plugin #67

Merged
merged 7 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added aas-gui/Docs/Figs/AAS_UI_TimeSeriesConfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added aas-gui/Docs/Figs/InfluxDB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
174 changes: 174 additions & 0 deletions aas-gui/examples/TimeSeriesData/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# Ignore the engine directory in influxdb/data
influxdb/data/engine

# Ignore environment-specific files
docker-compose.override.yml

# Ignore system files
.DS_Store
Thumbs.db

# Ignore directories for virtual environments
venv/
env/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
87 changes: 87 additions & 0 deletions aas-gui/examples/TimeSeriesData/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# AAS TimeSeries

This example includes a demo for the time series data plugin. It is designed to to be used with the time series data submodel template specified by the IDTA. The specification can be found [here](https://industrialdigitaltwin.org/wp-content/uploads/2023/03/IDTA-02008-1-1_Submodel_TimeSeriesData.pdf).

The plugin supports the following segment types:

- **InternalSegment**: This segment defines time series data within the AAS
- **ExternalSegment**: This segment defines time series data inside a file or blob SubmodelElement (the example includes a csv file as an example)
- **LinkedSegment**: This segment defines time series data inside a linked time series database (the example includes an InfluxDB together with telegraf for mqtt as an example)

## Getting Started

### Prerequisites

- Docker

### Installing

1. Clone the repository
2. Run `docker-compose up -d` in this directory

You can now access the AAS Web UI (http://localhost:3000) and InfluxDB UI (http://localhost:8086) in your browser.
The username and password for InfluxDB are `admin` and `testtest`.

## Usage

### Internal Segment

1. Open the AAS Web UI in your browser (http://localhost:3000)
2. Select the `TimeSeriesDemo` AAS and click on the `TimeSeriesTest` submodel in the treeview
3. In the `Visualization`-window select the `InternalSegment` in the Segment dropdown
4. Select `time` as time-value and `speed` as y-value
5. Click on `Fetch Data`
6. In the `Preview Chart`-window select a chart type
7. You should now see a chart with the time series data

### External Segment

1. Open the AAS Web UI in your browser (http://localhost:3000)
2. Select the `TimeSeriesDemo` AAS and click on the `TimeSeriesTest` submodel in the treeview
3. In the `Visualization`-window select the `ExternalSegment` in the Segment dropdown
4. Select `time` as time-value and `speed` and `temperature` as y-values
5. Click on `Fetch Data`
6. In the `Preview Chart`-window select a chart type
7. You should now see a chart with the time series data

### Linked Segment

Prerequisites:

Check if the query property of the `LinkedSegment` corrosponds to the data you want to fetch from the database. If not, change the query property to the desired query (see images below).

![InfluxDB Data Explorer](../../Docs/Figs/InfluxDB.png)
![AAS Web UI query property](../../Docs/Figs//AAS_UI_TimeSeriesConfig.png)

1. Open the AAS Web UI in your browser (http://localhost:3000)
2. Select the `TimeSeriesDemo` AAS and click on the `TimeSeriesTest` submodel in the treeview
3. In the `Visualization`-window select the `LinkedSegment` in the Segment dropdown
4. Select `time` as time-value and `speed` and `temperature` as y-values
5. Enter the following API-Token for the InfluxDB: `noyBokO69-nLzsjhnE4gx53TVkRc7QzFe6IUPkvkNIk9ynjl2zMcoO_wKkeMda8FBVaMElHBnIz7BcPLu5lL3g==`
6. Click on `Fetch Data`
7. In the `Preview Chart`-window select a chart type
8. You should now see a chart with the time series data

You can always press the `Fetch Data` button again to update the chart with the latest data from the database.

## Visualization Options

You can choose between the following chart types:

- Line Chart
- Area Chart
- Scatter Chart
- Histogram
- Gauge

For most of the chart types you can also alter some options. Those include:

- Time Range
- Interpolation Mode
- Number of Bins (for Histogram)
- If Bars should be stacked (for Histogram)

## Disclaimer

- The LinkedSegment was only tested with InfluxDB
- The ExternalSegment was only tested with csv files (RFC 4180 with header line) in a file SubmodelElement
Binary file not shown.
16 changes: 16 additions & 0 deletions aas-gui/examples/TimeSeriesData/basyx/aas-env.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server.port=8081

basyx.backend = InMemory

mqtt.clientId=AAS-Env-8081
mqtt.hostname = mosquitto
mqtt.port = 1883

basyx.environment=file:aas
basyx.aasrepository.feature.mqtt.enabled = true
basyx.cors.allowed-origins=*
basyx.cors.allowed-methods=GET,POST,PATCH,DELETE,PUT,OPTIONS,HEAD

basyx.aasrepository.feature.registryintegration = http://aas-registry:8080
basyx.submodelrepository.feature.registryintegration = http://sm-registry:8080
basyx.externalurl = http://localhost:8081
29 changes: 29 additions & 0 deletions aas-gui/examples/TimeSeriesData/basyx/aas-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
servlet:
headers:
- path: /**
values:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: POST,PUT,GET,DELETE,OPTIONS
Access-Control-Allow-Headers: Content-Type, Accept
Access-Control-Max-Age: 10000
- path: /shell-descriptors
values:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: POST,PUT,GET,DELETE,OPTIONS
Access-Control-Allow-Headers: Accept, Content-Type
methods:
- OPTIONS
- path: /registry/shell-descriptors/search
values:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: POST,GET,OPTIONS
Access-Control-Allow-Headers: Accept, Content-Type
methods:
- OPTIONS

management:
endpoints:
web:
exposure:
include: "health,metrics"
29 changes: 29 additions & 0 deletions aas-gui/examples/TimeSeriesData/basyx/sm-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
servlet:
headers:
- path: /**
values:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: POST,PUT,GET,DELETE,OPTIONS
Access-Control-Allow-Headers: Content-Type, Accept
Access-Control-Max-Age: 10000
- path: /submodel-descriptors
values:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: POST,PUT,GET,DELETE,OPTIONS
Access-Control-Allow-Headers: Accept, Content-Type
methods:
- OPTIONS
- path: /registry/submodel-descriptors/search
values:
Access-Control-Allow-Origin: "*"
Access-Control-Allow-Methods: POST,GET,OPTIONS
Access-Control-Allow-Headers: Accept, Content-Type
methods:
- OPTIONS

management:
endpoints:
web:
exposure:
include: "health,metrics"
Loading