Pylogix as a part of a simple Web Project
GitHubDragonFly opened this issue · 7 comments
This is only intended to show a possible way of using the pylogix library to read tags and show their values in a web page:
https://github.com/GitHubDragonFly/WebProject
Close this non-issue whenever you want.
@GitHubDragonFly That is very cool, I had built a very simple similar API a while back in flask though.
https://github.com/TheFern2/pylogix-api
@dmroeder I think it might be a good idea to add a doc with all these cool projects built with pylogix.
I like your API, since it's somewhat simpler.
If you would like some improvements here is the app.py file that allows the following:
Reading array of simple tags:
- localhost:5000/pylogix/v1.0/plc/192.168.0.10/0/tags/[someTag1, someTag2, someTag3, someTag4]
Reading elements of 1-dimensional array, has to be entered as a single tag (x = start index, y = number of elements):
- localhost:5000/pylogix/v1.0/plc/192.168.0.10/0/tags/someArrayTag[x]{y}
EDIT: Some improvements were made and array reading was changed in the pylogix-api project ( https://github.com/TheFern2/pylogix-api ) and can now be entered either on its own or as a part of the array of tags. Besides for 1-dimensional array it is also applicable for multi-dimensional arrays, for example:
- localhost:5000/pylogix/v1.0/plc/192.168.0.10/0/tags/[someTag1, someArrayTag[x]{a}, someArrayTag[x,y,z]{b}, someTag2]
If you like it then just include it in your repo and spare me from submitting a PR.
Your idea about creating a doc or a text file with all the cool project links sounds good to me and would poke people in the eye if it was a part of let's say "examples".
@GitHubDragonFly Thanks for your contribution, I've added you to that commit for proper credit.
If you ever go about creating a list of pylogix projects, here is another one that was done couple of years ago and does require some understanding:
https://github.com/tdw1004/PylogixGUI
If you might ever be interested in running this web project in Linux, I did bother converting the batch file to shell script.
It does need to be first made executable by running chmod +x on it.
Here are some pictures of how pylogix can also be used with Node-RED (this was done on Raspberry Pi 2).
It is a modified version of this example: https://flows.nodered.org/flow/778859ca2503db35ff0e12341508efef
Some benefits of Node-RED would be already available GUI elements and other packages (like pythonshell used in this example), minimal python code, cyclic reading and live dashboard updates.
There is a new repo for this Node-RED example project: https://github.com/GitHubDragonFly/Node-RED_PLC_Example
It is a hybrid project, using pylogix library for tag reading and using pycomm3 library for the device discovery, tag listing and MicroLogix.