From d48a70a34f28b5a1dfc2a5db2f531c1c81d265af Mon Sep 17 00:00:00 2001 From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl> Date: Thu, 3 Dec 2020 06:15:00 +0100 Subject: [PATCH] Add requirements.txt dependencies Explain in README.md that dependencies are needed and how to install them in a virtual environment. Also add an explanation how to run the thing. --- .gitignore | 1 + README.md | 68 ++++++++++++++++++++++++++++++++++++++++++------ requirements.txt | 3 +++ 3 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index d9722a3..0cfd4cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +**/env **/__pycache__ diff --git a/README.md b/README.md index fa336c3..afb32b2 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,66 @@ Python OPC-UA server to control the I2C devices in the LTS. + opcuserv.py: OPC-UA server that expose (visible) variables and methods. -# LTS structure: +# Prerequisites + +## Requirements + +This Python3 code uses other Python3 modules: + +- opcua +- pyyaml +- numpy + +We recommend to install a virtual environment and then install the dependencies there. For convenience we have added the relevant modules to the file `requirements.txt` that can be used to install them with pip3: `python3 -m pip install -r requirements.txt` + +Below are step-by-step instructions that show how to install the dependencies neatly in a Python3 virtual environment. + +```bash +# Create a Python3 virtual environment with the name "env" +python3 -m venv env +# Activate the virtual environment +. env/bin/activate +# Update the already installed modules in the virtual environment since they are usually outdated +python3 -m pip install --upgrade pip wheel +# Deactivate the virtual environment and start it again +deactivate +. env/bin/activate +# And finally install the module dependencies +python3 -m pip install -r requirements.txt +``` + +# Execute it + +The software can be simply executed with Python3: `python3 opcuaserv.py` + +Optional parameters are explained when the `-h` or `--help` parameter is supplied: + +```bash +python3 opcuaserv.py --help +cryptography is not installed, use of crypto disabled +cryptography is not installed, use of crypto disabled +usage: opcuaserv.py [-h] [-s] [--no-lib-hack] [-p PORT] + +optional arguments: + -h, --help show this help message and exit + -s, --simulator Do not connect to I2c, but simulate behaviour. + --no-lib-hack Do not require a hacked opcua library. Breaks behaviour. + -p PORT, --port PORT Port number to listen on [4842]. +``` + +# LTS structure Raspberry pi (LTS_pypcc.yaml -> I2C controller on raspberry pi) + > Control PCB (LTS_switch.yaml -> I2C switch) ->> RCU2 PCB (LTS_RCUx.yaml -> I2C devices) ->>> RCU2 Dither source (LTS_RCU2_dither.yaml -> I2C bitbang) ->> ->>> ADC (LTS_RCU2_ADC.yaml -> SPI bitbang2) ->> ->> Clock PCB (LTS_clk.yaml -> I2C device) ->>> PLL (LTS_clkPLL.yaml -> SPI bitbang1) +> +> > RCU2 PCB (LTS_RCUx.yaml -> I2C devices) +> > +> > > RCU2 Dither source (LTS_RCU2_dither.yaml -> I2C bitbang) +> > +> > > ADC (LTS_RCU2_ADC.yaml -> SPI bitbang2) +> > +> > Clock PCB (LTS_clk.yaml -> I2C device) +> > +> > > PLL (LTS_clkPLL.yaml -> SPI bitbang1) + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a0a7409 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +opcua +pyyaml +numpy -- GitLab