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

Function block library located in sorces of dinasore #11

Open
ramo48859 opened this issue Dec 18, 2024 · 0 comments
Open

Function block library located in sorces of dinasore #11

ramo48859 opened this issue Dec 18, 2024 · 0 comments

Comments

@ramo48859
Copy link

Hello,
First of all thanks for your great work!

Whats the problem?

Currently the function block library is located within the resources folder, where the dinasore function blocks must be manually copied or cloned into. This makes the dinasore source code and the function block library heavily intertwined and it is harder to develop them independently from each other.

  • if you want to add your own library you have to mess around with the search path

  • However the hardest issues are naming conflics:
    Consider the following custom function block library located within resources/custom_lib:

├── core
│   ├── analysis
│   ├── APIs
│   └── scripts
├── FBs
│   ├── FB1.py
│   ├── FB1.fbt
│   ├── FB2.py
│   └── FB2.fbt
└── tests

In this case the core folder contains algorithms and helper functions used in FB1.py and FB2.py. The functionblocks import elements of the core library as follows:

from core.analysis.my_module import something

When the function blocks are tested from the tests folder everything works nicely using pytest. However, importing the functionblocks from dinasore fails because it tries to import the modules of the custom library from its core folder.

Workarounds I tried:
  • add my custom library to the search path -> now the modules of dinasore are not found because it searches in my library for them
  • renaming the library folder core to someting else -> works but is very ugly in my opinion

A possible solution:

Why not install function block libraries like regular python libraries. The standard library and custom function block libraries are then installed. A configuration file or command line arguments specify which function block libraries are loaded when starting dinasore. When a function block is instantiated the xml function block definition and classes are read from the installed package folder.

Benefits

  • function block library can be developed independent from dinasore installation
  • a simple uv add git+https://github.com/function_block_lib --branch main installs the function block library
  • simpler version control because the requirements of dinasore and the functionblock libraries are separated

Final words

This requires considerable rework of dinasores function block import mechanism. So before I invest a lot of time into this:
What do you think of my suggestion? Do you know of other user (uses dinasore with default library) and library developer (works on new functionblocks) friendly ways to tackle this problem?

BR,
David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant