Package: sila2lib-implementations
Creation date: 20.10.2020, 12:50Last modification: 11.11.2021, 12:52Authors: Lukas Bromig, Nikolas von den Eichen, Felix MoorhoffContributors: Valeryia Sidarava, Jose Jesus de Pina TorresSila2lib_implementationsThis repository containsSiLA2drivers for a variety of devices that are being used at theInstitute of Biochemical Engineeringat TUM.The following devices are supported:2mag, BioREACTOR48 (48x Parallel Bioreactor System)BlueSens, BlueVary (Offgas-analytics)Eppendorf, DASGIP (4x Parallel Bioeactor System)LAUDA, LOOP 250LAUDA, LOOP 500PreSens sensor barsReglo, RegloICC (Peristaltic Pump)Reglo, RegloDC (Peristaltic Pump)Bronkhorst, El-Flow Prestige (Flowmeter)Mettler-Toledo, MT Viper SW (Laboratory Balance)SiLA version of drivers may vary. In case of incompatibilities, please reach out to:lukas.bromig@tum.deContentDeviceDescriptionSiLA Python branch(*)StateLast update (main)BioREACTOR48mL-Bioreactor systemmaster (v.1.0)in use20.08.2021BlueVaryoff-gas analyticcodegenerator-0.3in use23.07.2021DASGIPL-Bioreactor systemmaster (v.1.0)in use26.04.2021ELFLOW Prestigeflowmetercodegenerator-0.3testing30.08.2021Lauda Loop250thermostatmaster (v.1.0)not used25.10.2020Lauda Loop500thermostatmaster (v.1.0)not used25.10.2020MT Viper SWlaboratory balancecodegenerator-0.3in use14.04.2021PresenspH/DO-sensor barscodegenerator-0.3in use20.08.2021RegloDCperistaltic pumpcodegenerator-0.3in use14.04.2021RegloICCperistaltic pumpmaster (v.1.0)in use12.03.2021(*) SiLA Python branches:
As of 11.11.2021, SiLA 2 Python versions "master (v.1.0)" and "codegenerator-0.3" are deprecated. Backwards
compatibility is intended. If you encounter any issues, please reach out! All forthcoming development and driver updates
will use the latest SiLA 2 Python reference implementation.Project structure - generically└── sila2lib_implementations
    ├── sila2lib_implementations
    │   ├── Device
    │   │   └── Device_project
    │   │   │   └── DeviceServicer.sila.xml
    │   │   │   └── service_description.json
    │   │   │   └── SiLAFramework.proto
    │   │   └── DeviceService
    │   │   │   └── DeviceServicer
    │   │   │   │   └── DeviceServicer_servicer.py
    │   │   │   │   └── DeviceServicer_real.py
    │   │   │   │   └── DeviceServicer_simulation.py
    │   │   │   │   └── DeviceServicer_default_arguments.py
    │   │   │   │   └── __init__.py
    │   │   │   └── DeviceService_client.py
    │   │   │   └── DeviceService_server.py    
    │   │   │   └── __init__.py    
    │   │   └── __init__.py
    │   └── __init__.py
    ├── tests
    │   ├── Device
    │   │   └── test_device.py  
    ├── README.md
    ├── LICENSE
    ├── pyproject.toml
    └── setup.pysila2lib_implementations: Projects rootsila2lib_implementations: All Device implementationsDevice: A device that is implementedDevice_project: Source code directory of the device implementationDeviceServicer.sila.xml: Feature implementation for the Device deviceservice_description.json: Keine Ahnung?SiLAFramework.proto: Keine Ahnung?DeviceService: Code generated directory for the deviceDeviceServicer: Contains the Device implementations for different modi (like simulation or real mode)
as well as a servicer that starts either the simulation- or real mode.DeviceServicer_default_argumentscontains
the default responses for the simulation mode.DeviceService_client.py: Sila server implementation specific for the deviceDeviceService_client.py: Sila client implementation specific for the devicetests: Unit tests for the devicesThe foldersila2lib_implementationscontains the listed devices. Each device itself consists of aDevice_projectfolder
where the devices were defined originally (in the file format.xml). These .xml-files are written according to the
SiLA2 schema available atsila_baseand are called FDL-files (FeatureDefinitionLanguage).
Based on these files, the sila2lib-codegenerator (Deprecated, In archived branch ofsila_python)
generated all services in the separate directoryDeviceService. Within theDeviceServicedirectory, server and clients have been
generated. Depending on the device's function there can be additional features, named Service, Provider, or Controller.
To learn more about the nomenclature of SiLA2 read thedocumentationwhich
contains links to the specification parts A and B. These features account for the main functionality
of the device (e.g. providing of sensor data, control of actors). Each feature contains an implementation for a simulation- or real mode, as well as some
default return arguments to enable a meaningful simulation run. The gRPC folders within theDeviceServicefolder can be ignored, usually.Unit tests for (almost) all devices can be found in thetestfolder (for details see 'Developer note')Installation requirementsRequires Python3, (pip, git and poetry)Further requirements include:InfluxDB, csv, persistent, opcua, pyserial, cryptographyThese packages can be installed via PyPIInstallationThe repository is setup in a way that it can be installed conveniently as python package.
In case of any failures make sure to accomplish theInstallation requirementsand read the
troubleshooting section. There are two possible ways for an installation:Python Package Index (PyPI) (recommended)Stable releases are available at thePython Package Index (PyPI).
Use the package installer for python (pip) for installation:$ pip install sila2lib_implementationsGitlab (for developers):Theprojects Gitlab repositoryfurther offers accessibility
to a specific branch that might be unstable, however.Navigate into a directory where you would like to build the sila2lib-implementations. Clone the repository (or desired branches)
and change (cd sila2lib_implementations) into it. Install the package management tool poetry (pip install poetry)
to be able to install the sila2lib-implementations repository (poetry install). Withpoetry shellyou can start the
venv where poetry installed your software in. Usedeactivateto exit the venv again. Alternatively, pip
or different methods listedherecan be used for
installation. They are not recommended, however.Finally, have a look atQuickstart - first stepsto verify if installation was entirely successful and to get comfortable with sila2lib-implementations :)$ git clone -b pipenv_to_poetry https://gitlab.com/lukas.bromig/sila2lib_implementations
$ cd sila2lib_implementations
# with poetry (recommended)
$ pip install poetry
$ poetry install
# with pip
$ pip install --editable .[dev]  # [dev] installs the development packages, defined in setup.pyQuickstart - first stepsSee if installation was successful: Try to start your first sila server and run some unit test. In simulation mode, of course ;)It is assumed that you are located in thesila2lib_implementationsroot directory. Refer to sectionProject structure - genericallyto get comfortable with the projects structure. Additionally you need to be within in your virtual environment in case you
installed all the packages there (source bin/activate).$ # start your first server (use str c to shut it down again to be able to issue new commands):
$ python -m sila2lib_implementations/LAUDA/LAUDA_ThermostatService/LAUDA_ThermostatService_server.py 
$ verify if a device is reacting properly to some simulation tests
$ poetry run python -m pytest testsFor further usage like editing existing devices or implementing new ones please continue reading the Developer sections.Developer noteAny contribution is highly appreciated, not only on a coding base. If you are having issues of any kind please do not
hesitate toopen an issue.
After installation have a look at the Quickstart paragraph for some first steps to get comfortable within the project.
Projects structure technically: gRPC, Protobuffer, .xml codegenerator, (encryption) -> i don't have the knowledge to write all thisDevelopment environmentblack: Code formatterisort: Import sortingflake8: Checks various code problemspytest: Testing suitepytest-cov: Measures pytests code coverageBefore commiting please make sure to run the checks to push nice code. You can run the scriptrun-formattingto apply some auto formatting (that you can define by yourself in the file, too btw.).
To verify that your code is executable without issues run some tests to see where conflicts or bugs might arise. Run therun-checksto execute all tests or only execute specific ones you are working on.Do we want to use tox instead?
Do we want to run checks in the pipeline or has the user to make it?Testing environmentThe default execution of the pytest command is regulated in thetests/pytest.inifile, where some markers
are defined for default executions or safe executions i.a..How do I run simulation tests?Tests in simulation mode are executed by default. See theQuickstart - first stepssection to get comfortable.How do I run "real" tests?Real tests itself are divided into tests that can be executed safely or not. Tests that can be executed safely are those that
do not require a special device set up like cooling- or moving units. By this it is tried to assure no device breakdown in case
crucial steps have been forgotten to use a device safely.
-> set tags etc....Which tests are run in the GitLAb CI/CD pipeline and when?Whenever we want...The pipeline routines are defined in the.gitlab-ci.ymlfile and can be changed there.Implementation of new devicesPlease refer to theSila_pythonproject for implementation
of new devices. In case of extension or changes of existing devices keep in mind to also include the changes in the respective
.xml files.DocumentationThe documentation of sila_python can be found here:DocumentationThe official SiLA-Standard specifications can be found athttps://sila-standard.org.
If you still can't find an answer, pleaseopen an issue.WIP: The documentation of this repository is also hosted on readthedocs.ioLicenseThis code is licensed under theGNU General Public License.Troubleshooting for Debian based installations (e.g. on Raspberry Pis)Distro might be shipped using very old and outdated software. Problems might disappear already by updating your system. Also
check theInstallation requirementsonce again.
On top, this troubleshooting section works best if the latest software is used anyways. It is assumed that all commands listed
here are executed in a linux terminal. Update your software:sudo apt update && sudo apt upgradeInstall issues:pip failure to findpoetryversion1.2.0a2pip might be outdated. Update it via:pip install --upgrade pippython2 pip might be used preferably by your (old, outdated) OS. Use and update pip3 for installationpip3 install -U pip && pip install poetry==1.2.0a2poetry command not foundlogout and login again (source ~/.bashrcnot sufficient unfortunately)commandbdist_wheelnot found. Probablywheelis not installed. Install it via:pip install --upgrade wheel setuptools(Sub-)Dependency issues:Build issues: Make sure to fulfill the dependencies. To ensure this type:pip install --upgrade pip setuptools==59.1.0 wheel==0.36.0install issues for the packagecryptographycryptography requires a (not too old) rust compiler (rustc). Make sure to have the rustc installed and additional dependencies by typing:sudo apt-get install libssl-dev libffi-dev build-essential python3-dev cargoinstall issues for the packagepsycopg2-binaryNote: Only applies for the LHS_scheduler: psycopg2-binary requires:libpq-devon Debian (Ubuntu, Mint) orlibpq-develon Centos/Fedora/Cygwin/Babun. Install them for Debians by typing:sudo apt-get install libpq-devinstall issues for the packagelxmllxml requires 2 additional development packages. Install them by typing:sudo apt-get install libxml2-dev libxslt1-devOn a Raspberry Pi OS Bullseye (python 3.9.2) you can issue this one line command to fulfill all dependencies in case the installation
fails:sudo apt-get install libssl-dev libffi-dev libxml2-dev libxslt1-dev libpq-devOn a Raspberry Pi OS Buster (python 3.7.3) you can issue this one line command to fulfill all dependencies in case the installation
fails:sudo apt-get install libssl-dev libffi-dev libxml2-dev libxslt1-dev libpq-devTroubleshooting during usage (points to installation issues finally)GLIBC_2.33 not found (BTW. this fix did not work for me :/)This issue is serious since GLIBC can not be changed easily. 'Upgrading very core libraries like libc can be challenging.
It's better to find a newer distribution if you can.'. Try to reinstall an older version of grpcio (1.23.0) without binary (--no-binary)pip install -U --force-reinstall grpcio==1.23.0 --no-binary=grpcio=1.23.0pip install -U --force-reinstall grpcio-tools --no-binary=grpcio-toolsImportError: undefined symbol: __atomic_exchange_8Please report the troubleshootingProblems that might arise with newer python versionOn a Raspbian OS it was not possible for us to change the python version to enable all installs (the version was changed
however that did not enable the install, unfortunately)