Skip to content

Commit d680043

Browse files
author
a.krantz
committed
initial commit
0 parents  commit d680043

25 files changed

+3509
-0
lines changed

.devcontainer/devcontainer.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "Jupyter Dev Container",
3+
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.12",
4+
"features": {
5+
"docker-in-docker": "latest"
6+
},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"github.vscode-pull-request-github",
11+
"github.vscode-github-actions",
12+
"ms-toolsai.python-ds-extension-pack",
13+
"ms-python.vscode-pylance",
14+
"ms-python.flake8",
15+
"ms-python.black-formatter",
16+
"ms-python.isort",
17+
"streetsidesoftware.code-spell-checker",
18+
"ms-vscode.live-server",
19+
"GitHub.copilot"
20+
],
21+
"settings": {
22+
"python.defaultInterpreterPath": "/usr/local/bin/python",
23+
"black-formatter.path": [
24+
"/usr/local/py-utils/bin/black"
25+
],
26+
"pylint.path": [
27+
"/usr/local/py-utils/bin/pylint"
28+
],
29+
"flake8.path": [
30+
"/usr/local/py-utils/bin/flake8"
31+
],
32+
"isort.path": [
33+
"/usr/local/py-utils/bin/isort"
34+
],
35+
"terminal.integrated.shell.linux": "/bin/bash"
36+
}
37+
}
38+
},
39+
"postCreateCommand": "python -m pip install --upgrade pip && pip install jupyterlab odsbox[exd-data] matplotlib grpcio grpcio-tools pandas openpyxl xlrd",
40+
"forwardPorts": [
41+
8888
42+
],
43+
"remoteUser": "vscode"
44+
}

.gitattribute

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/workflows/python-package.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.12"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install flake8
31+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32+
- name: Lint with flake8
33+
run: |
34+
flake8 . --count --max-complexity=22 --max-line-length=200 --statistics --exclude=*pb2*,test*.py
35+
- name: Test with unittest
36+
run: |
37+
python -m unittest

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.proto
2+
.venv/
3+
.vscode/
4+
__pycache__/
5+
/data/examples/internal_test_files/

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# docker build --tag docker.peak-solution.de/exd_api/np_mdf4 .
2+
FROM python:3.12-slim
3+
WORKDIR /app
4+
# Install required packages
5+
COPY requirements.txt requirements.txt
6+
RUN pip3 install -r requirements.txt
7+
# Copy ASAM ODS Interface files into container
8+
## Download from ASAM ODS github repository
9+
ADD https://raw.githubusercontent.com/asam-ev/ASAM-ODS-Interfaces/main/ods.proto /app/
10+
ADD https://raw.githubusercontent.com/asam-ev/ASAM-ODS-Interfaces/main/ods_external_data.proto /app/
11+
## Use local copy
12+
# COPY proto_src/ods.proto ods.proto
13+
# COPY proto_src/ods_external_data.proto ods_external_data.proto
14+
# Use protoc to compile stubs in container
15+
RUN python3 -m grpc_tools.protoc -I. --python_out=. ods.proto
16+
RUN python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ods_external_data.proto
17+
# Copy Plugin Implementation
18+
COPY exd_api_server.py exd_api_server.py
19+
COPY external_data_reader.py external_data_reader.py
20+
# Start server
21+
CMD [ "python3", "exd_api_server.py"]

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Andreas K
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ASAM ODS EXD-API MDF4 plugin
2+
3+
This repository contains a [ASAM ODS EXD-API](https://www.asam.net/standards/detail/ods/) plugin that uses [asammdf](https://pypi.org/project/asammdf/) to read the [ASAM MDF4](https://www.asam.net/standards/detail/mdf/wiki/) files.
4+
5+
> This is only a prototype to check if it works with [asammdf](https://pypi.org/project/asammdf/).
6+
7+
8+
## GRPC stub
9+
10+
Because the repository does not contain the ASAM ODS protobuf files the generated stubs are added.
11+
The files that match `*_pb2*` are generated using the following command. To renew them you must put the
12+
[proto files from the ODS standard](https://github.com/asam-ev/ASAM-ODS-Interfaces) into `proto_src` and rerun the command.
13+
14+
```
15+
python -m grpc_tools.protoc --proto_path=proto_src --pyi_out=. --python_out=. --grpc_python_out=. ods.proto ods_external_data.proto
16+
```
17+
18+
## Content
19+
20+
### Implementation
21+
* [exd_api_server.py](exd_api_server.py)<br>
22+
Runs the GRPC service to be accessed using http-2.
23+
* [external_data_reader.py](external_data_reader.py)<br>
24+
Implements the EXD-API interface to access MDF4 files using [asammdf](https://pypi.org/project/asammdf/).
25+
26+
### Tests
27+
* [test_exd_api.py](test/test_exd_api.py)<br>
28+
Some basic tests on example files in `data` folder.
29+
* [example_access_exd_api_mdf4.ipynb](example_access_exd_api_mdf4.ipynb)<br>
30+
jupyter notebook the shows communication done by ASAM ODS server or Importer using the EXD-API plugin.
31+
32+
## Usage in ODS Server
33+
34+
```mermaid
35+
sequenceDiagram
36+
37+
actor CLIENT as Client
38+
participant PDTT as 🛠️Importer
39+
participant PODS as 🗃️ASAM ODS server
40+
participant PLUGIN as 📊EXD-API plugin
41+
participant FILE as 🗂️File Storage
42+
43+
autonumber
44+
45+
opt Import phase
46+
FILE ->>+ PDTT: New file shows up
47+
PDTT ->>+ PLUGIN : Get Structure
48+
PLUGIN -> FILE: Extract content information
49+
PLUGIN ->> PLUGIN: Create Structure
50+
PLUGIN ->>- PDTT: Return Structure
51+
PDTT ->> PODS: Import ODS structure
52+
Note right of PDTT: Create hierarchy<br/>AoTest,AoMeasurement,...
53+
PDTT ->>- PODS: Add External Data info
54+
Note right of PDTT: Attach AoFile ... for external data<br/>AoFile,AoSubmatrix,AoLocalColumn,...
55+
end
56+
57+
Note over CLIENT, FILE: Now we can work with the imported files
58+
59+
loop Runtime phase
60+
CLIENT ->> PODS: Establish ODS session
61+
CLIENT ->> PODS: Work with meta data imported from structure
62+
CLIENT ->> PODS: Access external channel in preview
63+
PODS ->> PLUGIN: GetValues
64+
PLUGIN ->> FILE: Get Channel values
65+
PLUGIN ->> PODS: Return values of channels
66+
PODS ->> CLIENT: Return values needed for plot
67+
end
68+
```

data/example_data.xlsx

4.9 KB
Binary file not shown.

data/example_data_two_sheets.xlsx

5.56 KB
Binary file not shown.

data/example_data_with_unit.xlsx

4.92 KB
Binary file not shown.

0 commit comments

Comments
 (0)