Code Monkey home page Code Monkey logo

Comments (11)

dmroeder avatar dmroeder commented on July 18, 2024 1

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.

dmroeder avatar dmroeder commented on July 18, 2024

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.

mhuckaby21 avatar mhuckaby21 commented on July 18, 2024

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.

tblount70 avatar tblount70 commented on July 18, 2024

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.

tblount70 avatar tblount70 commented on July 18, 2024

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.

marne44 avatar marne44 commented on July 18, 2024

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.

TheFern2 avatar TheFern2 commented on July 18, 2024

@marne44

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.

tblount70 avatar tblount70 commented on July 18, 2024

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.

discoverchethan avatar discoverchethan commented on July 18, 2024

What will the value of tag be when it gets "Connection Lost" Status?

from pylogix.

dmroeder avatar dmroeder commented on July 18, 2024

What will the value of tag be when it gets "Connection Lost" Status?

Should be None

from pylogix.

tblount70 avatar tblount70 commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.