PDA

View Full Version : sensor wrapper


jsnider
06-15-2010, 05:12 PM
Hi,
I want to wrap an interface around a sensor plugin. I've done it before with a CustomObject ( derive from viz.CustomChild and use viz.upgradeCustomNode ...), and that works great. It looks like the same thing should work for a VizSensor object, but on the following it won't let me call the functions in the derived class (testCall).


import viz

class SensorClass(viz.VizSensor):
def testCall(self):
self.command(1, '', 1)

viz.upgradeSensor('sensor.dls',SensorClass)
def addMySensor():
return viz.add('sensor.dls')

if __name__ == '__main__':
viz.go()

S1 = addMySensor()
ball = viz.add('ball.wrl')
viz.link(S1, ball)

S1.testCall()



sensor.dls is just the sample sensor from the SDK and it works fine (the ball moves around in a circle), but the call to testCall throws an error:
AttributeError: 'VizSensor' object has no attribute 'testCall'
Is there a way to get access to the functions I define in the derived class?
Thanks,
Joe

farshizzo
06-15-2010, 05:16 PM
Remove the extension when you call viz.upgradeSensor:viz.upgradeSensor('sensor',Senso rClass)

jsnider
06-15-2010, 05:32 PM
Works great.
Thanks,
Joe