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

Add support for PlanPro 1.10 #13

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# planpro-importer
# PlanPro Importer

This is a small library (generated by [generateDS.py](http://www.davekuhlman.org/generateDS.html)) that can import PlanPro files into a [yaramo](https://github.com/simulate-digital-rail/yaramo) topology for further processing.

Expand All @@ -7,43 +7,46 @@ It supports:
- Parsing of ppxml files
- Finder for UUID of infrastructure elements

Current version:
- Schema version: 1.9.0.1202_2019-02-22
- Library version: 1.9.0.1202_2019-02-22-v2
Supported PlanPro versions:
- PlanPro 1.9.0.1202_2019-02-22 (with `PlanProVersion.PlanPro19`)
- PlanPro 1.10.0.2147_2022-05-31 (with `PlanProVersion.PlanPro110`)

## Installation

Just install it with pip:
```
pip3 install git+https://github.com/arneboockmeyer/planpro-python-model
```bash
pip3 install git+https://github.com/simulate-digital-rail/planpro-importer
```

You may need some authentication ([Hint 1](https://cloud.google.com/artifact-registry/docs/python/authentication), [Hint 2](https://pip.pypa.io/en/latest/topics/authentication/)).

## Usage

Parse a PlanPro file:
```
from planpro_importer.reader import PlanProReader
topology = PlanProReader("filename.ppxml").read_topology_from_plan_pro_file()
```python
from planpro_importer import PlanProVersion, import_planpro
# For PlanPro 1.9
topology = import_planpro("filename.ppxml", PlanProVersion.PlanPro19)
# For PlanPro 1.10
topology = import_planpro("filename.ppxml", PlanProVersion.PlanPro110)
```

Further examples can be found in the [demo repository](https://github.com/simulate-digital-rail/demo).

## Usage UUID finder

Import:
```
```python
import uuidfinder
```

Method:
```
```python
uuidfinder.find_infrastructure_element_by_uuid(<Infrastructure Container>, <UUID>)
```

Example:
```
```python
import planpromodel
import uuidfinder
root_object = planpromodel.parse('PlanProFile.ppxml')
Expand All @@ -57,7 +60,9 @@ Use [generateDS.py](http://www.davekuhlman.org/generateDS.html) to generate a mo
Therefore you need the schema files of the current PlanPro version.

CLI-Command:
```
```bash
generateDS -o model.py PlanPro.xsd
# or
python3 generateDS.py -o planpromodel.py -f --output-directory="." 1.9.0.1202_2019-02-22_Schema/PlanPro.xsd
```

Expand Down
17 changes: 17 additions & 0 deletions example/example.py
Copy link

Choose a reason for hiding this comment

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

putting the two examples/tests in two functions would remove the need for the comments and would avoid variable reuse, but this is just a nit pick

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from planpro_importer import PlanProVersion, import_planpro


if __name__ == "__main__":
# Test 1.9
topology = import_planpro("filename.ppxml", PlanProVersion.PlanPro19)
print(f"{len(topology.edges)}")
print(f"{len(topology.nodes)}")
print(f"{len(topology.signals)}")
print(f"{len(topology.routes)}")

# Test 1.10
topology = import_planpro("filename.ppxml", PlanProVersion.PlanPro110)
print(f"{len(topology.edges)}")
print(f"{len(topology.nodes)}")
print(f"{len(topology.signals)}")
print(f"{len(topology.routes)}")
2 changes: 2 additions & 0 deletions planpro_importer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .planproversion import PlanProVersion
from .planproimporter import import_planpro
1 change: 1 addition & 0 deletions planpro_importer/planpro110/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .reader110 import PlanProReader110
Loading