Comments (11)
I would say that it has been improved since the addition of returning the Response class. If you are actively reading something in a loop, then suddenly the PLC is no longer available, you will initially receive "Connection Lost" as the status. The problem then is that the next read, it will try to reconnect and will fail. If you use a try/catch around your read, it will reconnect once the PLC is available.
from pylogix.
There is definitely room for improvement on error handling on my part. For now, if you are only reading every few minutes, I'd do your reads, then close the connection by calling .Close(). Even though you are probably not currently closing the connection, the PLC will purge connections after a period of inactivity.
I'll see what improvements I can make.
from pylogix.
No problem. I just wanted to make sure that I wasn't overlooking something.
If I come up with a solution I'll let you know.
Thanks!
from pylogix.
Has anyone made progress on this issue? My python is pretty limited, but I'm thinking of jumping into this. My application is a 4-line text display replacement. So it's pretty simple. The issue is that the my users need some indication that the system is no longer communicating.
from pylogix.
Excellent. I just added try/except and it works perfectly. If I were a little more experienced with python I guess I would have known to try that.
For my simple application this is probably all I'll ever need in the way of comm loss detection.
Thank you!
from pylogix.
Excellent. I just added try/except and it works perfectly. If I were a little more experienced with python I guess I would have known to try that.
For my simple application this is probably all I'll ever need in the way of comm loss detection.
Thank you!
Can you please upload and commit? Or give an example?
Thanks in advance.
from pylogix.
Try/Catch is a concept in all programming languages. Have a look in my repo file below line 158 for an example of try catch. Basically what happens is that it tries to do the code inside the try, if it gets an exception then the code inside the exception gets executed. There's another one finally, for clean up too.
https://github.com/kodaman2/Data_Preserve/blob/master/data_preserve.py
Docs: https://docs.python.org/3/tutorial/errors.html
from pylogix.
This is what's working for me...
def UpdateValue():
try:
retL = comm.Read(tagList1)
myapp.commerror=FALSE
except:
myapp.commerror=TRUE
### ... continue processing valid results
from pylogix.
What will the value of tag be when it gets "Connection Lost" Status?
from pylogix.
What will the value of tag be when it gets "Connection Lost" Status?
Should be None
from pylogix.
In my application, the code that uses the tag values is notified that myapp.commerror=TRUE. At that point I can decide what's more appropriate - hold previous tag values, or zero the tag values.
from pylogix.
Related Issues (20)
- cannot import name 'Adapter' from 'pylogix' HOT 23
- Tag Write falsely reports Success HOT 7
- "Forward open failed" when trying to read tags from Berghof PLC HOT 8
- .GetDeviceProperties always returns DeviceType of "None" HOT 5
- Issues connecting to emulate HOT 7
- micro850 connection HOT 5
- Return data gets jumbled up on a multi write when the tags don't exist. HOT 13
- The return value is different when using a multi write compared to a single write for a string. HOT 4
- cannot get a tag list HOT 3
- Is it possible to inhibit a periodic task? HOT 2
- pylogix - returning a tag list as a row of values HOT 7
- PLC REAL values HOT 5
- Pylogix - compare a previously acquired tag list with the current one HOT 5
- Discover does not work while running pylogix in docker HOT 10
- Invalid Continuation Byte HOT 5
- Abnormal code termination. HOT 8
- Do I need to use routing? HOT 20
- PLC connection best practice HOT 8
- Forward Open Failed HOT 13
- Connection Issues HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylogix.