Skip to content
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
22 changes: 22 additions & 0 deletions MachineDemoServer/Python/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
ARG VARIANT="3"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
52 changes: 52 additions & 0 deletions MachineDemoServer/Python/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/python-3
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
"VARIANT": "3.7",
// Options
"INSTALL_NODE": "false",
"NODE_VERSION": "lts/*"
}
},

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--max-line-length=200"
],
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [ 5000 ],
"appPort": 5000,

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install --user -r requirements.txt",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
5 changes: 4 additions & 1 deletion MachineDemoServer/Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Alarms and Conditions can only be subscribed on the "Messages" node. The Conditi
### Requirements
- Python >= Python 3.7
- Python opcua-asyncio library >= 0.9.14
- Python cffi >= 1.14.5

### Installation and Execution
With Python installed, the script file can be exuted with `python PythonMachineDemoServer.py`. As an alternative a fully self contained .exe can be created with PyInstaller.
Expand All @@ -31,8 +32,10 @@ With Python installed, the script file can be exuted with `python PythonMachineD
- [Download and install Python](https://www.python.org/downloads/) >= Python 3.7. On installation set checkbox for adding to system path.
- Install opcua-asnycio library >= 0.9.14 with
`pip3 install asyncua` or upgrade with `pip3 install --upgrade asyncua`
Behind a company proxy you may need to add the proxy server and trust servers. Search for proxy settings and look for the manual proxy server.

Behind a company proxy you may need to add the proxy server and trust servers. Search for proxy settings and look for the manual proxy server.
`pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org --proxy=http://username:password@proxyserver:port asyncua`
- Install cffi library with `pip3 install cffi`

- Download all files and copy them to a folder. Easiest way is to download all files of the github repository. [Download zip](https://github.com/TRUMPF-IoT/OpcUaMachineTools/archive/main.zip).
- Enter the folder containing PythonMachineDemoServer.py and execute the server with `python PythonMachineDemoServer.py`
Expand Down
2 changes: 1 addition & 1 deletion MachineDemoServer/Python/ReplayConfiguration.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<endpoint url="opc.tcp://localhost:50000"/>
<endpoint url="opc.tcp://0.0.0.0:50000"/>
<execution sourceFileName="recordTruLaserCenter.json" playSpeedFactor="20"/>
</configuration>
2 changes: 2 additions & 0 deletions MachineDemoServer/Python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
asyncua
cffi