View Single Post
  #4  
Old 06-10-2008, 10:20 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can create your own custom task conditions. For example, here are two conditions that wait for an IS900 button to be pressed or released:
Code:
class waitIS900Down( viztask.Condition ):
    def __init__( self, sensor, button ):
        self._sensor = sensor
        self._button = button
   
    def update( self ):
        return int(self._sensor.getData()[7]) & self._button

class waitIS900Up( viztask.Condition ):
    def __init__( self, sensor, button ):
        self._sensor = sensor
        self._button = button
   
    def update( self ):
        return (int(self._sensor.getData()[7]) & self._button) == 0
Here is code that shows how to use it:
Code:
.
.
.
yield waitIS900Down(isense,1)
print 'Button 1 pressed'
yield waitIS900Up(isense,1)
print 'Button 1 released'
.
.
.
Reply With Quote