Code Monkey home page Code Monkey logo

Comments (7)

TheFern2 avatar TheFern2 commented on August 17, 2024 2

Fernando, my pylogix version is 0.8.14. i also have pylogix2 installed which is version 0.5.3. Assume I'm using pylogix and not pylogix2

if you are running your script and calling lower case value then you're running pylogix2 which we are not affiliated with nor support. I suggest you uninstall pylogix2 it was a rogue fork.

Also forgot to mention you might want to add a sleep in your while loop to prevent high cpu usage.

from pylogix.

TheFern2 avatar TheFern2 commented on August 17, 2024 1

In your example ret is a list of Response objects. So, you'll need to return ret, then iterate again outside the run_script function just like you did inside the function.

def run_script():
    with PLC() as comm:
        comm.IPAddress = 'xx.xx.xx.xx'
        ret = comm.Read(list)

    for r in ret:
        print(r.Value)

    return ret

while True:
    y = run_script()
    for r in y:
        print(r.Value)

Alternatively, you can create a new integer list:

def run_script():
    int_ret = [] 
    with PLC() as comm:
        comm.IPAddress = 'xx.xx.xx.xx'
        ret = comm.Read(list)

    for r in ret:
        print(r.Value)
        int_ret.append(r.Value)

    return int_ret

while True:
    y = run_script()
    print(y)

Also note that this library Response object is upper case Value, not value. You might be using the wrong package. What's your pylogix version?

from pylogix.

wksriaanc avatar wksriaanc commented on August 17, 2024

Fernando, my pylogix version is 0.8.14. i also have pylogix2 installed which is version 0.5.3. Assume I'm using pylogix and not pylogix2

from pylogix.

wksriaanc avatar wksriaanc commented on August 17, 2024

Hi, Fernando. Thank you :) I've uninstalled pylogix2 and added a 5 sec sleep. Just one last thing - r.value as mentioned by yourself is a list of response objects. How do I store this list as a row of integer values e.g. [50, 10, 25, 22].

from pylogix.

wksriaanc avatar wksriaanc commented on August 17, 2024

I might use the append method.

from pylogix.

wksriaanc avatar wksriaanc commented on August 17, 2024

Fernando, the append function seems to work. Thank you again for getting me on track with my issue :)

from pylogix.

TheFern2 avatar TheFern2 commented on August 17, 2024

Fernando, the append function seems to work. Thank you again for getting me on track with my issue :)

Glad to be able to help.

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.