Trellis: tasks and discrete sensors

"Sergey Schetinin" <[email protected]>
Newsgroups gmane.comp.python.peak
Message-ID <[email protected]>
This test shows that @task rules never get to see discrete values. It
prints 'waiting' twice, so they are triggered, but sensor value is
None both times.

from peak.events.trellis import *
from peak.events.activity import *

class C(Component):
    sensor = None
    @task
    def wait(self):
        while not self.sensor.value:
            print 'waiting'
            yield Pause
        print 'got it!'

cell = Sensor(AbstractConnector(), discrete=True)
c = C(sensor=cell)
EventLoop.call(cell.receive, True)
EventLoop.run()



-- 
Best Regards,
Sergey Schetinin

http://s3bk.com/ -- S3 Backup
http://word-to-html.com/ -- Word to HTML Converter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.