def _setMotion(self, motion): """ Stops the current motion and starts this one """ eventPublisher = core.EventPublisher(self._eventHub) started = False if motion.type & Motion.IN_PLANE: if self._inPlaneMotion is not None: self._stopMotion(self._inPlaneMotion) self._inPlaneMotion = motion self._inPlaneMotion.start(self._controller, self._vehicle, self._qeventHub, eventPublisher) started = True if motion.type & Motion.DEPTH: if self._depthMotion is not None: self._stopMotion(self._depthMotion) self._depthMotion = motion if not started: self._depthMotion.start(self._controller, self._vehicle, self._qeventHub, eventPublisher) started = True if motion.type & Motion.ORIENTATION: if self._orientationMotion is not None: self._stopMotion(self._orientationMotion) self._orientationMotion = motion if not started: self._orientationMotion.start(self._controller, self._vehicle, self._qeventHub, eventPublisher)
def testLookupByName(self): self.called = False def recieve(event): self.called = True # Create a publisher with an event hub eventHub = core.EventHub() mypub = core.EventPublisher(eventHub = eventHub, name = TestEventPublisher.EVTP_NAME) # Look it up and make sure it works epub = core.EventPublisher.lookupByName(TestEventPublisher.EVTP_NAME) self.assertNotEquals(None, epub) self.assertEquals(TestEventPublisher.EVTP_NAME, epub.getPublisherName()) # Subscribe to the new one (which is wrapper of the same underlying # C++ object as self.epub) # BUG: This line below should work instead of the one two down # eventHub.subscribe("TestEvent", epub, recieve) eventHub.subscribe("TestEvent", mypub, recieve) # Send through our local mypub.publish("TestEvent", core.Event()) # Make sure we got it self.assert_(self.called)
def setUp(self): TimerTester.setUp(self) # Set up publisher and event handler self.epub = core.EventPublisher() self.epub.subscribe(TestTimer.TIMER_EVENT, self.handleTimer) self.event = None self.count = 0
def testMakeEventHub(self): cfg = {'name': 'Test', 'type': 'EventHub'} cfg = core.ConfigNode.fromString(str(cfg)) ehub = core.SubsystemMaker.newObject(cfg, core.SubsystemList()) recv = Reciever() epub = core.EventPublisher(ehub) ehub.subscribeToType("Type", recv) epub.publish("Type", core.Event()) self.assertEquals(1, recv.calls)
def testSend(self): self.epub = core.EventPublisher(name = TestEventPublisher.EVTP_NAME) # Handler for the function reciever = Reciever() # Register function to recieve the event self.epub.subscribe("TestEvent", reciever) # Test Basic event publishing self.epub.publish("TestEvent", core.Event()) self.assert_(reciever.called) self.assertEquals(1, reciever.calls) self.assertEquals("TestEvent", reciever.etype)
def test(self): epub = core.EventPublisher() recv = Reciever() # Create a queued event manager to listen queue up recieved events qepub = core.QueuedEventPublisher(epub) qepub.subscribe("TestEvent", recv) # Test Basic event publishing epub.publish("TestEvent", core.Event()) self.assertEquals(0, recv.calls) # Release all messages qepub.publishEvents() self.assertEquals(1, recv.calls) self.assertEquals("TestEvent", recv.etype)
def setUp(self): self.eventHub = core.EventHub() self.qeventHub = core.QueuedEventHub(self.eventHub) self.epub = core.EventPublisher()
def setUp(self): self.ehub = core.EventHub() self.epubA = core.EventPublisher(self.ehub) self.epubB = core.EventPublisher(self.ehub)
def setUp(self): self.epub = core.EventPublisher(name = TestEventPublisher.EVTP_NAME)