Code Monkey home page Code Monkey logo

Comments (3)

tdesroches avatar tdesroches commented on July 2, 2024

I've also posted my code, maybe I'm just not programming effectively. It's pretty much the example slightly modified

import cpppo
import threading
from cpppo.server.enip import poll
from cpppo.server.enip.get_attribute import proxy as device # ControlLogix
import time
params = ["AI_XAxis[0].Status.rActualPosition","AI_YAxis[0].Status.rActualPosition","AI_ZAxis[0].Status.rActualPosition",
                    "AI_XAxis[1].Status.rActualPosition","AI_YAxis[1].Status.rActualPosition","AI_ZAxis[1].Status.rActualPosition"]

def failure( exc ):
    failure.string.append( str(exc) )
failure.string		= [] # [ <exc>, ... ]

def process( par, val ):
    process.values[par]	= val
process.done		= False
process.values		= {} # { <parameter>: <value>, ... }

poller			= threading.Thread(
    target=poll.poll, kwargs={
        'proxy_class':  device,
        'address':      ("192.168.60.30", 44818),
        'cycle':        0.1,
        'timeout':      0.5,
        'process':      process,
        'failure':      failure,
        'params':       params,
        'pass_thru':    True
    })
poller.start()
try:
    while True:
        while process.values:
            print("X: ", process.values.pop("AI_XAxis[0].Status.rActualPosition", "???"))
            print("Y: ", process.values.pop("AI_YAxis[0].Status.rActualPosition", "???"))
            print("Z: ", process.values.pop("AI_ZAxis[0].Status.rActualPosition", "???"))
            print("X2: ", process.values.pop("AI_XAxis[1].Status.rActualPosition", "???"))
            print("Y2: ", process.values.pop("AI_YAxis[1].Status.rActualPosition", "???"))
            print("Z2: ", process.values.pop("AI_ZAxis[1].Status.rActualPosition", "???"))
            #par,val		= process.values.popitem()
            #print( "%s: %16s == %r" % ( time.ctime(), par, val ))
        while failure.string:
            exc		= failure.string.pop( 0 )
            print( "%s: %s" %( time.ctime(), exc ))
        time.sleep( 0.1 )
finally:
    process.done		= True
    poller.join()

from cpppo.

pjkundert avatar pjkundert commented on July 2, 2024

That’s about the CPU usage you can expect for that poll rate. You can perhaps double that using pypy, but the parser is running in pure python, so it’s peaking out at about 20-30 polls/sec per i7 core...

I’m working on a Connected session support thread that will allow us to establish a spontaneous update stream, so we’ll only need to parse incoming data. That should help a lot, I think.

However, you are right - you’ll need to go to a more efficient parser for higher poll rates. The right solution is always spontaneous report of changes though.

from cpppo.

tdesroches avatar tdesroches commented on July 2, 2024

Ok thanks, I'll try pypy and see what I can squeeze out of it.

What is the timeline looking like for the connected session?

from cpppo.

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.