API that communicates with KEP server for XMPro demo machine
Project description
opc_app
This is a simple API that exposes a few routes to request information from the KEP
This app will make the following routes available at:
http://<ip_address>:5000
Depending on the router configuration you will be able to access this gateway from outside the local network as well, i.e. if it is NAT'd out.
Routes
GET / OR /api
Test if the API is alive
{
"message": "opc http endpoint is alive"
}
GET /api/sensor/<name>
Fetch the list of available servers to connect to
{
"quality": "Good",
"time": "02/01/19 07:08:28",
"value": 10614
}
GET /api/servers
Fetch the list of available servers to connect to
{
"servers": ["Kepware.KEPServerEX.V6"]
}
GET /api/nodes/<node>
Fetch the list of nodes
{
"nodes": [
"_AdvancedTags",
"_ConnectionSharing",
"_CustomAlarms",
"_DataLogger",
"_EFMExporter",
"_IDF_for_Splunk",
"_IoT_Gateway",
"_LocalHistorian",
"_Redundancy",
"_Scheduler",
"_SecurityPolicies",
"_SNMP Agent",
"_System",
"Channel1",
"Data Type Examples",
"Simulation Examples",
"XMPro"
]
}
Pre-requisites
Make sure everything installed is 32-bit (even on a 64-bit os)
Git BASH
Install git BASH. We will use this terminal emulator to run our program that will communicate with the PLC server.
There is no need to change any of the default settings during the installation process except the below caveats.
When installing git BASH the installer will ask you how you would like to use it from the command line. Select the option the same as the image below.
The installer will also ask you which terminal emulator you would like to use, we will use Winows' default console.
Python 2.7
Install Python 2.7 32-bit (if it is not already).
Ensure that python gets added to Path. Make sure the small symbol next to Add python..exe to Path
does not have a cross through.
Check the installation is working by opening git BASH and executing the following.
python
Expected output.
Pywin32
Install the 32-bit version of pywin32 for python 2.7.
OpenOPC
Install the OpenOPC library.
During the installation you'll be asked to choose the components you want to install. Uncheck the OPC Gateway service.
Quick Start
After all pre-requisites the following steps should get the API up and running
Install the app
Open git BASH and run the following command to install the app.
pip install opc-app
Run it!
xmpro-demo-app
On the first time you run this program you may be prompted by Windows about allowing python to communicate through the firewall. We want to allow incoming connections so we need to make sure both boxes are checked like in the image below.
Test it!
Open the browser and browse to any of the routes. Try browsing to http://localhost:5000/api
and you should see the following.
If you are using edge you will need to make sure you type the http://
in front of the web adress or it will probably not work.
Close it!
You will need to close git BASH by clicking the red cross. Ctrl-c does not appear to be working at this point.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file opc_app-1.0.0.0.tar.gz
.
File metadata
- Download URL: opc_app-1.0.0.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae593dfd0540f8cb79b6f82a92c5b72143b1a038eddfd758105e46592aed756a |
|
MD5 | bd5afcd3329ca5d85ea3ea22db36abad |
|
BLAKE2b-256 | 01461f76de7bc4315b87e2107479b45e61a94f7e3feef3722e89aca39bddac80 |