def test_PropertyChangeListener_EC_APP(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(
            execDeviceNode, self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication(
            "/waveforms/PropertyChangeListenerNoJava/PropertyChangeListenerNoJava.sad.xml"
        )
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        self._app = app

        c = None
        a = self.dom.apps[0]
        # component with external property
        c = filter(lambda c: c.name == 'PropertyChange_C1', a.comps)[0]
        # assembly controller
        c2 = filter(lambda c: c.name == 'PropertyChange_P1', a.comps)[0]
        self.assertNotEqual(a, None)
        self.assertNotEqual(c, None)
        self.assertNotEqual(c2, None)

        # check if channel is valid
        self.assertNotEqual(self.channel1, None)
        self.assertNotEqual(
            self.channel1._narrow(CosEventChannelAdmin.EventChannel), None)

        sub = Subscriber(self.channel1)

        t = float(0.5)
        regid = a.registerPropertyListener(self.channel1,
                                           ['prop1', 'app_prop1'], t)
        app.start()
        time.sleep(1)

        # assign 3 changed values
        c.prop1 = 100.0
        time.sleep(.6)  # wait for listener to receive notice
        c.prop1 = 200.0
        time.sleep(.6)  # wait for listener to receive notice
        c.prop1 = 300.0
        time.sleep(.6)  # wait for listener to receive notice

        for n in range(4):
            xx = sub.getData()
            self.assertNotEqual(xx, None)

        # unregister
        a.unregisterPropertyListener(regid)

        self.assertRaises(CF.InvalidIdentifier, a.unregisterPropertyListener,
                          regid)

        app.releaseObject()
        self._app = None
    def test_PropertyChangeListener_EC_APP(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(execDeviceNode, self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication("/waveforms/PropertyChangeListener/PropertyChangeListener.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        self._app = app

        ps=None
        c=None
        d=redhawk.attach(scatest.getTestDomainName())
        a=d.apps[0]
        # component with external property
        c=filter( lambda c : c.name == 'PropertyChange_C1', a.comps )[0]
        # assembly controller
        c2=filter( lambda c : c.name == 'PropertyChange_P1', a.comps )[0]
        self.assertNotEqual(a,None)
        self.assertNotEqual(c,None)
        self.assertNotEqual(c2,None)
        ps = a.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps,None)

        # check if channel is valid
        self.assertNotEqual(self.channel1, None)
        self.assertNotEqual(self.channel1._narrow(CosEventChannelAdmin.EventChannel), None)

        sub = Subscriber( self.channel1 )

        t=float(0.5)
        regid=ps.registerPropertyListener( self.channel1, ['prop1', 'app_prop1'],t)
        app.start()
        time.sleep(1)

        # assign 3 changed values
        c.prop1 = 100.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 200.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 300.0
        time.sleep(.6)   # wait for listener to receive notice

        for n in range(4):
            xx=sub.getData()
            self.assertNotEqual(xx, None)

        # unregister
        ps.unregisterPropertyListener( regid )

        self.assertRaises( CF.InvalidIdentifier,
            ps.unregisterPropertyListener, regid )

        app.releaseObject()
        self._app=None
    def test_PropertyChangeListener_EC_PYTHON(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(
            execDeviceNode, self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication(
            "/waveforms/PropertyChangeListenerNoJava/PropertyChangeListenerNoJava.sad.xml"
        )
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        self._app = app

        ps = None
        c = None
        d = redhawk.attach(scatest.getTestDomainName())
        a = d.apps[0]
        c = filter(lambda c: c.name == 'PropertyChange_P1', a.comps)[0]
        self.assertNotEqual(c, None)
        ps = c.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps, None)

        # check if channel is valid
        self.assertNotEqual(self.channel1, None)
        self.assertNotEqual(
            self.channel1._narrow(CosEventChannelAdmin.EventChannel), None)

        sub = Subscriber(self.channel1)

        t = float(0.5)
        regid = ps.registerPropertyListener(self.channel1, ['prop1'], t)
        app.start()
        time.sleep(1)

        # assign 3 changed values
        c.prop1 = 100.0
        time.sleep(.6)  # wait for listener to receive notice
        c.prop1 = 200.0
        time.sleep(.6)  # wait for listener to receive notice
        c.prop1 = 300.0
        time.sleep(.6)  # wait for listener to receive notice

        for n in range(4):
            xx = sub.getData()
            self.assertNotEqual(xx, None)

        # unregister
        ps.unregisterPropertyListener(regid)

        self.assertRaises(CF.InvalidIdentifier, ps.unregisterPropertyListener,
                          regid)

        app.releaseObject()
        self._app = None
Beispiel #4
0
    def _test_PropertyChangeListener_EC_Comps(self, app_name, comp_name):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(execDeviceNode, self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication(app_name)
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        self._app = app

        c=None
        a=self.dom.apps[0]
        c=filter( lambda c : c.name == comp_name, a.comps )[0]
        self.assertNotEqual(c,None)

        # check if channel is valid
        self.assertNotEqual(self.channel1, None)
        self.assertNotEqual(self.channel1._narrow(CosEventChannelAdmin.EventChannel), None)

        sub = Subscriber( self.dom, self.channel_name )

        t=float(0.5)
        regid=c.registerPropertyListener( self.channel1, ['prop1'],t)
        app.start()
        time.sleep(1)

        # assign 3 changed values
        c.prop1 = 100.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 200.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 300.0
        time.sleep(.6)   # wait for listener to receive notice

        for n in range(4):
            xx=sub.getData()
            self.assertNotEqual(xx, None)

        # unregister
        c.unregisterPropertyListener( regid )

        self.assertRaises( CF.InvalidIdentifier,
            c.unregisterPropertyListener, regid )

        app.stop()
        app.releaseObject()
        self._app=None