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_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
Exemplo n.º 3
0
 def test_eventChannelForceDelete(self):
     sub = Subscriber(self._domMgr, self.channelName)
     pub = Publisher(self._domMgr, self.channelName)
     payload = 'hello'
     data = _any.to_any(payload)
     pub.push(data)
     rec_data = self._waitData(sub, 1.0)
     self.assertEquals(rec_data, payload)
     self.ecm.forceRelease(self.channelName)
     self.assertRaises(CF.EventChannelManager.ChannelDoesNotExist, self.ecm.release, self.channelName)
Exemplo n.º 4
0
 def test_eventChannelPull(self):
     sub = Subscriber(self._domMgr, self.channelName)
     pub = Publisher(self._domMgr, self.channelName)
     payload = 'hello'
     data = _any.to_any(payload)
     pub.push(data)
     rec_data = self._waitData(sub, 1.0)
     self.assertEquals(rec_data, payload)
     pub.terminate()
     sub.terminate()
Exemplo n.º 5
0
 def test_eventChannelCB(self):
     queue = Queue.Queue()
     sub = Subscriber(self._domMgr, self.channelName, dataArrivedCB=queue.put)
     pub = Publisher(self._domMgr, self.channelName)
     payload = 'hello'
     data = _any.to_any(payload)
     pub.push(data)
     rec_data = queue.get(timeout=1.0)
     self.assertEquals(rec_data._v, payload)
     pub.terminate()
     sub.terminate()
Exemplo n.º 6
0
    def setUp(self):
        domBooter, domMgr = self.launchDomainManager()

        # Create an event channel to receive the device and service start/stop
        # messages (the name must match the findbys in the DCD), and connect a
        # subscriber
        eventMgr = domMgr._get_eventChannelMgr()
        channel = eventMgr.createForRegistrations('test_events')
        self._started = Queue.Queue()
        self._stopped = Queue.Queue()
        self._subscriber = Subscriber(channel, dataArrivedCB=self._messageReceived)
    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()
        self._checkSubGotData(sub)

        # 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(3):
            self._checkSubGotData(sub)

        # unregister
        c.unregisterPropertyListener(regid)

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

        app.stop()
        app.releaseObject()
        self._app = None
Exemplo n.º 8
0
def forward_event_to_waveform(domain, evt_chan, wave, port, msg_id):
    """Forwards message on an event channel to specified waveform input port

    Parameters
    ----------
    domain : str
        The name of the active domain.

    evt_chan : str
        The name of the event channel (on the specified domain)

    wave : str
        The name of the waveform on the domain

    port : str
        The name of the port on the waveform to forward messages.
    """
    # access the event channel and waveform port
    dom = redhawk.attach(domain)
    e_chan = DT.find_event_channel_from_domain(domain, evt_chan)
    wfm = DT.find_waveform_from_domain(domain, wave)
    port_inst = wfm.getPort(port)

    # setup message source and connect to waveform port
    # FIXME: there can be multiple messages on an event channnel.
    #       1) should this filter messages based on this msg id?
    #       2) Do I need a separate message source per msg_id?
    msg_src = sb.MessageSource(msg_id)
    msg_port = msg_src.getPort("msgOut")
    msg_port.connectPort(port_inst, "conn_" + str(uuid.uuid1()))
    msg_src.start()

    # ----------------------  setup to forward messages ---------------------
    # setup the forwarder
    f = Forwarder(msg_src)

    # subscribe to channel with the callback in forwarder
    sub = Subscriber(dom, channel_name=evt_chan, dataArrivedCB=f.forward)

    # -----------  run forwarding until user hits enter  --------------------
    raw_input("Hit enter to exit")
    msg_src.releaseObject()
    def setUp(self):
        self.launchDomainManager()
        self.launchDeviceManager("/nodes/test_GPP_node/DeviceManager.dcd.xml")

        self._event = threading.Event()
        self._subscriber = Subscriber(self._domainManager, 'IDM_Channel', self._idmMessageReceived)