def setUp(self): self._domBooter, self._domMgr = self.launchDomainManager() # create listener interface orb = CORBA.ORB_init() self.chanMgr = ChannelManager(orb) self._app=None # Force creation self.channel1 = self.chanMgr.createEventChannel("TestChan", force=True)
def test_ODMEvents_DeviceManager(self): # Test DeviceManager related events # launch DomainManager nodebooter, self._domMgr = self.launchDomainManager(debug=self.debuglevel) # connect to the channel domainName = scatest.getTestDomainName() channelManager = ChannelManager(self._orb) odmChannel = channelManager.getEventChannel('ODM_Channel', domainName) if odmChannel == None: self.fail("Could not connect to the ODM_Channel") # set up consumer consumer_admin = odmChannel.for_consumers() _proxy_supplier = consumer_admin.obtain_push_supplier() _consumer = ConsumerODM_i(self) _proxy_supplier.connect_push_consumer(_consumer._this()) # start the device manager devBooter, devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", debug=self.debuglevel) self.assertNotEqual(devMgr, None) timeout = 0.0 while ((_consumer.getAddedEventCount('DEVICE_MANAGER') < 1 or _consumer.getAddedEventCount('DEVICE') < 1) and timeout < 2): timeout += 0.2 time.sleep(0.2) try: devMgr.shutdown() except CORBA.Exception: pass timeout = 0.0 while ((_consumer.getRemovedEventCount('DEVICE_MANAGER') < 1 or _consumer.getRemovedEventCount('DEVICE') < 1) and timeout < 2): timeout += 0.2 time.sleep(0.2) # start the second device manager devBooter, devMgr = self.launchDeviceManager("/nodes/test_BasicService_node/DeviceManager.dcd.xml", debug=self.debuglevel) self.assertNotEqual(devMgr, None) timeout = 0.0 while ((_consumer.getAddedEventCount('DEVICE_MANAGER') < 2 or _consumer.getAddedEventCount('SERVICE') < 1) and timeout < 2): timeout += 0.2 time.sleep(0.2) try: devMgr.shutdown() except CORBA.Exception: pass timeout = 0.0 while ((_consumer.getRemovedEventCount('DEVICE_MANAGER') < 2 or _consumer.getRemovedEventCount('SERVICE') < 1) and timeout < 2): timeout += 0.2 time.sleep(0.2) self.assertEqual(_consumer.getAddedEventCount('DEVICE_MANAGER'), 2) self.assertEqual(_consumer.getAddedEventCount('DEVICE'), 1) self.assertEqual(_consumer.getAddedEventCount('SERVICE'), 1) self.assertEqual(_consumer.getRemovedEventCount('DEVICE_MANAGER'), 2) self.assertEqual(_consumer.getRemovedEventCount('DEVICE'), 1) self.assertEqual(_consumer.getRemovedEventCount('SERVICE'), 1) self.terminateChild(devBooter)