This is an automated email from the ASF dual-hosted git repository. jfeinauer pushed a commit to branch feature/PLC4X-111-interop-server in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
commit 87ddc847a0b31b1ac811c8c52e10c6ee610b790f Author: julian <[email protected]> AuthorDate: Sun Apr 21 13:52:42 2019 +0200 PLC4X-111 Added Readme and renamed the INIT Script. --- plc4py/README.md | 38 +++++++++++++++++++++++++++++++++++++ plc4py/copy_server.sh | 4 ---- plc4py/initialize_interop_server.sh | 7 +++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/plc4py/README.md b/plc4py/README.md new file mode 100644 index 0000000..e9e4eee --- /dev/null +++ b/plc4py/README.md @@ -0,0 +1,38 @@ +# Python binding for the interop server + +This module provides the (experimental) Python support for the interop server. +Or, simpler, a python 3 binding for PLC4X. + +The only thing which needs to be done as _installation_ is to run the `initialize_interop_server.sh` skript to build the interop server and copy it to `lib/` forder. + +Then, you are good to go. + +Here is some example code: + +```python +try: + manager = PlcDriverManager() + + connection = None + try: + connection = manager.get_connection("s7://192.168.167.210/0/1") + for _ in range(100): + result = connection.execute(Request(fields={"field1": "%M0:USINT"})) + print("Response Code is " + str(result.get_field("field1").get_response_code())) + # We now that we want to get an int... + print("Response Value is " + str(result.get_field("field1").get_int_value())) + + except PlcException as e: + raise Exception(str(e.url)) + finally: + if connection is not None: + connection.close() +finally: + manager.close() +``` + +the `PlcDriverManager` spawns an interop server in the background, thus it is important to close it afterwards. +Otherwise this process keeps alive and you have to kill by yourself. + +All generated files (from thrift) are in `org.apache.plc4x.interop`. +I built a very simple Python API in `org.apache.plc4x`. \ No newline at end of file diff --git a/plc4py/copy_server.sh b/plc4py/copy_server.sh deleted file mode 100755 index 57f7f27..0000000 --- a/plc4py/copy_server.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Moves the server from the target folder here -cp ../plc4j/utils/interop/target/apache-plc4x-incubating-* lib/ \ No newline at end of file diff --git a/plc4py/initialize_interop_server.sh b/plc4py/initialize_interop_server.sh new file mode 100755 index 0000000..80b0b2e --- /dev/null +++ b/plc4py/initialize_interop_server.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Builds the interop server module with maven +mvn clean package -f ../plc4j/utils/interop/pom.xml + +# Moves the server from the target folder here +cp ../plc4j/utils/interop/target/apache-plc4x-incubating-* lib/ \ No newline at end of file
