예제 #1
0
    def _domainListCheck(self):
        newList = self._getMessagesForDomainListing('add')
        adds, removes = splitDictLists(newList, self._domainListMessages,
                                       RH_Message().keys())

        # Removals
        ids = [r['rhid'] for r in removes]
        indices = []
        if (0 < len(ids)):
            for i, d in enumerate(self._domains):
                if (d.getID in ids):
                    d.cleanUp()
                    indices.append(i)
            self._domains = [
                d for i, d in enumerate(self._domains) if i not in indices
            ]

        # Additions
        for a in adds:
            self._domains.append(
                Domain(
                    redhawk.attach(
                        a['rhname']),  # Return redhawk domain instance
                    '',  # No parent ID
                    self.outbox))  # Using the global outbox

        self._domainListMessages = newList
        self.domainTask = gevent.spawn_later(self._domainTaskWaitSec,
                                             self._domainListCheck)
예제 #2
0
def get_domain(domain, devices=[]):
    """Get the domain

    .. warn:: Enforcing device list has not been implemented

    Parameters
    ----------
    domain : str or None
        The name of the domain.  If None, tries to connect to
        available domain

    devices : list
        List of devices to launch with the domain.
    """
    active_domains = redhawk.scan()
    if domain in active_domains:
        # domain exists, just attach
        dom = redhawk.attach(domain)
    else:
        if devices:
            dom = redhawk.kickDomain(domain,
                kick_domain_managers=True, device_managers=devices)
        else:
            dom = redhawk.kickDomain(domain, kick_device_managers=False)

    # TODO: check that devices is available, otherwise launch them now
    pass

    return dom
예제 #3
0
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager()
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.basedir = '/tmp'
     self.data_signal = threading.Event()
     self.delete_feedback_signal = threading.Event()
     self.read_feedback_signal = threading.Event()
예제 #4
0
    def checkRTL(self):
        numRTLnow = 0
        self.dom = redhawk.attach("REDHAWK_DEV")
        if((self.dom != None) and (self.dom.devices != None)):
            for myDev in self.dom.devices:
                if type(myDev) != None:
                    #print "name is : " + myDev.name
                    if myDev.name == "rtl_sdr_device":
                        numRTLnow += 1
                        #print myDev
                        
            #redhawk.core.ExecutableDevice._get_identifier(self)
            #for dev in self.dom.devices:
                #print type(mgr) 
                #print dev._get_identifier()

            if (numRTLnow > self.numRTL):
                print "\nadd to gui"
                self.addRTL()            
                self.numRTL += 1
            elif (numRTLnow < self.numRTL):
                print "\nsub from gui"
                self.subRTL()
                self.numRTL -= 1
                
        return True
예제 #5
0
    def getDomain(self, domainName):
        try:
            self.currentDomain = domainName
            self.disconnectFromODMChannel()
            self.domManager = redhawk.attach(domainName)
            self.connectToODMChannel()
            if self.domManager is None:
                raise StandardError('Could not narrow Domain Manager')

            # this is here just to make sure that the pointer is accessible
            if self.domManager._non_existent():
                raise StandardError(
                    "Unable to access the Domain Manager in naming context " +
                    domainName)
        except:
            raise StandardError(
                "Unable to access the Domain Manager in naming context " +
                domainName)

        try:
            self.fileMgr = self.domManager._get_fileMgr()
        except:
            raise StandardError(
                "Unable to access the File Manager in Domain Manager " +
                domainName)
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager(
         loggingURI='file://' + os.getcwd() + '/macro_config.cfg')
     self.devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml",
         loggingURI='file://' + os.getcwd() + '/macro_config.cfg')
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager()
     devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml")
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.app = self._rhDom.createApplication(
         "/waveforms/TestPythonProps/TestPythonProps.sad.xml")
예제 #8
0
def find_waveform_from_domain(domain, name):
    """Find a waveform by name on a given domain

    Scans through the list of waveforms to find one
    with the matching name.  The Waveforms will have
    a unique number attached, so this just finds the
    first instance that matches.

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

    name : str
        Name of the waveform

    Returns
    -------
    output : waveform (ossie.cf.CF._objref_Application) or None
        If no match, return None
        If match return the first instance in waveforms that
        matches
    """
    try:
        dom = redhawk.attach(domain)
        return find_waveform(dom.apps, name)
    except:
        return None
예제 #9
0
 def test_deploytime_sequenceDirect(self):
     dom = redhawk.attach(self._domMgr._get_name())
     sadpath = "/waveforms/testWave/testWave.sad.xml"
     props3 = [CF.DataType(id='a', value=any.to_any(['a']))]
     _app = dom.createApplication(sadpath, 'appname', props3)
     self.assertEqual(len(_app.prop), 1)
     self.assertEqual(_app.prop[0], 'a')
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager(
         debug=self.debuglevel)
     devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml",
         debug=self.debuglevel)
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.assertEquals(len(self._rhDom._get_applications()), 0)
예제 #11
0
    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
예제 #12
0
 def _connectToDomain(self):
     self.dom = redhawk.attach(redhawk.scan()[0])
     rx_pis, tx_pis = self._getPisList()
     for node in rx_pis:
         lat, lon, valid = self._getNodeLatLon(node)
         self.update_map(node.name, 'add', lat, lon)
     for node in tx_pis:
         lat, lon, valid = self._getNodeLatLon(node)
         self.update_map(node.name, 'addTx', lat, lon)
 def test_triggerTiming(self):
     self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
     self.assertNotEqual(self._devBooter, None)
     dom=redhawk.attach(self._domMgr._get_name())
     app = self._domMgr.createApplication("/waveforms/prop_trigger_timing_w/prop_trigger_timing_w.sad.xml", "prop_trigger_timing_w", [], [])
     self.assertEquals(dom.apps[0].comps[0].prop_1_trigger, False)
     self.assertEquals(dom.apps[0].comps[0].prop_2_trigger, False)
     self.assertEquals(dom.apps[0].comps[0].prop_3_trigger, False)
     self.assertEquals(dom.apps[0].comps[0].prop_4_trigger, False)
예제 #14
0
 def test_triggerTiming(self):
     self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
     self.assertNotEqual(self._devBooter, None)
     dom=redhawk.attach(self._domMgr._get_name())
     app = self._domMgr.createApplication("/waveforms/prop_trigger_timing_w/prop_trigger_timing_w.sad.xml", "prop_trigger_timing_w", [], [])
     self.assertEquals(dom.apps[0].comps[0].prop_1_trigger, False)
     self.assertEquals(dom.apps[0].comps[0].prop_2_trigger, False)
     self.assertEquals(dom.apps[0].comps[0].prop_3_trigger, False)
     self.assertEquals(dom.apps[0].comps[0].prop_4_trigger, False)
 def setUp(self):
     super(LoggingConfigPropTests, self).setUp()
     domBooter, self._domMgr = self.launchDomainManager(
         loggingURI="dom/mgr/logging.properties")
     devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/loggingconfig/DeviceManager.dcd.xml",
         loggingURI="dev/mgr/logging.properties")
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.assertEquals(len(self._rhDom._get_applications()), 0)
 def setUp(self):
     self.stderr_filename = 'stderr.out'
     self.output_file = open(self.stderr_filename, 'w')
     nb, self._domMgr = self.launchDomainManager(stderr=self.output_file)
     nb, self._devMgr = self.launchDeviceManager(
         '/nodes/test_PortTestDevice_node/DeviceManager.dcd.xml')
     self.dom = redhawk.attach(self._domMgr._get_name())
     fp = open('loggers/syncappender/log4j.appender', 'r')
     self.logconfig = fp.read()
     fp.close()
예제 #17
0
    def test_InvalidCapacity_node(self):
        domBooter, self._domMgr = self.launchDomainManager()
        devBooter, self._devMgr = self.launchDeviceManager("/nodes/invalid_capacity/DeviceManager.dcd.xml.java")

        from ossie.utils import redhawk
        dom=redhawk.attach(scatest.getTestDomainName())
        dev=dom.devices[0]
        self.assertNotEquals(dev,None)
        b=[ CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3))]
        self.assertRaises(CF.Device.InvalidCapacity, dev.allocateCapacity, b)
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager()
     devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml")
     self._domain=redhawk.attach(scatest.getTestDomainName())
     self._app = None
     if self._domMgr:
         try:
             self._app = self._domain.createApplication('/waveforms/TestJavaProps/TestJavaReadOnly.sad.xml')
         except:
             pass
    def test_NicDeploymentPolicySocketUnlocked(self):
        nodebooter, domMgr = self.launchDomainManager()
        devBooter, devMgr = self.launchDeviceManager("/nodes/test_affinity_node_unlocked/DeviceManager.dcd.xml")

        # Ensure the expected device is available
        self.assertNotEqual(devMgr, None)
        # wait for all devices to register
        count=0
        for count in range(10):
            if len( devMgr._get_registeredDevices() ) < 2 :
                time.sleep(1)
            else:
                break

        rhdom= redhawk.attach(scatest.getTestDomainName())
        
        try:
            app=rhdom.createApplication('affinity_test3')

            if app != None:
                self.check_affinity( 'C1',  get_match("sock0sans0"), False )
                self.check_affinity( 'C2',  get_match("sock0sans0"), False )
                app.releaseObject()
                if ( maxcpus < 2):  time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ( "busy" in e.msg ) == False:
              raise

        # run second application to make sure we are still working
        #rhdom= redhawk.attach(scatest.getTestDomainName())
        try:
            app=rhdom.createApplication('affinity_test1')

            if app: 
                self.check_affinity( 'C2', get_match("5") , False )
                app.releaseObject()
                if ( maxcpus < 2):  time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ( "busy" in e.msg ) == False:
              raise

        try:
            app=rhdom.createApplication('affinity_test2')

            if app != None:
                self.check_affinity( 'C2', get_match("sock1"), False )
                if app: app.releaseObject()
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ( "busy" in e.msg ) == False:
              raise

        
        devMgr.shutdown()

        self.assertEqual(len(domMgr._get_deviceManagers()), 0)
    def test_NicDeploymentPolicySocketUnlocked(self):
        nodebooter, domMgr = self.launchDomainManager()
        devBooter, devMgr = self.launchDeviceManager(
            "/nodes/test_affinity_node_unlocked/DeviceManager.dcd.xml")

        # Ensure the expected device is available
        self.assertNotEqual(devMgr, None)
        # wait for all devices to register
        count = 0
        for count in range(10):
            if len(devMgr._get_registeredDevices()) < 2:
                time.sleep(1)
            else:
                break

        rhdom = redhawk.attach(scatest.getTestDomainName())

        try:
            app = rhdom.createApplication('affinity_test3')

            if app != None:
                self.check_affinity('C1', get_match("sock0sans0"), False)
                self.check_affinity('C2', get_match("sock0sans0"), False)
                app.releaseObject()
                if (maxcpus < 2): time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ("busy" in e.msg) == False:
                raise

        # run second application to make sure we are still working
        #rhdom= redhawk.attach(scatest.getTestDomainName())
        try:
            app = rhdom.createApplication('affinity_test1')

            if app:
                self.check_affinity('C2', get_match("5"), False)
                app.releaseObject()
                if (maxcpus < 2): time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ("busy" in e.msg) == False:
                raise

        try:
            app = rhdom.createApplication('affinity_test2')

            if app != None:
                self.check_affinity('C2', get_match("sock1sans0"), False)
                if app: app.releaseObject()
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ("busy" in e.msg) == False:
                raise

        devMgr.shutdown()

        self.assertEqual(len(domMgr._get_deviceManagers()), 0)
예제 #21
0
 def redhawkSetup(self):
     self.dom = redhawk.attach("REDHAWK_DEV")
     self.numRTL = 0
     self.listOfRTL = []   
     self.rtl_list = []
     self.freq_list = []
     self.samp_list = []
     self.box_list = []
     self.demod_list = []
     #self.plot_list = []
     return
예제 #22
0
def find_event_channel_from_domain(domain, name):
    try:
        dom = redhawk.attach(domain)
        for evt in dom.eventChannels:
            if evt.name == name:
                return evt

        # no match
        return None
    except:
        return None
예제 #23
0
  def locate(domain):
    if isinstance(domain, types.StringTypes):
      domainptr = redhawk.attach(domain)
    else:
      domainptr = domain

    for dev in domainptr.devices:
      if SIM_ID == dev._get_identifier():
        return sim_FM_Device(dev)

    raise DeviceNotFoundError(SIM_NAME)
예제 #24
0
    def locate(domain):
        if isinstance(domain, types.StringTypes):
            domainptr = redhawk.attach(domain)
        else:
            domainptr = domain

        for dev in domainptr.devices:
            if SIM_ID == dev._get_identifier():
                return sim_FM_Device(dev)

        raise DeviceNotFoundError(SIM_NAME)
 def setUp(self):
     self._domBooter, self._domMgr = self.launchDomainManager()
     self.dom = redhawk.attach(scatest.getTestDomainName())
     # create listener interface
     self._app = None
     self.channel_name = "TestChan"
     self.chanMgr = self.dom._get_eventChannelMgr()
     try:
         self.channel1 = self.chanMgr.create(self.channel_name)
     except CF.EventChannelManager.ChannelAlreadyExists:
         self.channel1 = self.chanMgr.get(self.channel_name)
예제 #26
0
    def test_deallocate_overage_node_java(self):
        domBooter, self._domMgr = self.launchDomainManager()
        devBooter, self._devMgr = self.launchDeviceManager("/nodes/invalid_capacity/DeviceManager.dcd.xml.overage.java")

        from ossie.utils import redhawk
        dom=redhawk.attach(scatest.getTestDomainName())
        d=dom.devices[0]
        self.assertNotEquals(d,None)
        res=d.allocateCapacity({'myulong': 3 } )
        self.assertEquals(res,True)

        a=[ CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3)), CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3))]
        self.assertRaises(CF.Device.InvalidCapacity,d.deallocateCapacity, a)
예제 #27
0
def getLaptopLatLon():
    dom = redhawk.attach(redhawk.scan()[0])
    for node in dom.devMgrs:
        if node.name.lower() == 'LaptopNode':
            for dev in node.devs:
                if dev.name.lower() == 'gps_receiver':
                    gps_port = dev.getPort('GPS_idl')
                    pos = gps_port._get_gps_time_pos().position
                    return pos.lat, pos.lon, pos.valid
    lat = raw_input(
        "WARNING: Unable to find GPS device connected to server.\nPlease enter latitude in degrees: "
    )
    lon = raw_input("Please enter longitue in degrees: ")
    return lat, lon, True
예제 #28
0
def attach(dname='REDHAWK_DEV', debug=False):
    global dom
    try:
        olist, a = getopt.gnu_getopt(sys.argv, "d:")
        d = filter(lambda x: x[0] == '-d', olist)[0]
        dname = d[1]
        sys.argv = a
    except:
        pass

    print "Attach:" + str(dname)
    dom = redhawk.attach(dname)
    if debug:
        redhawk.setDebug(true)
def attach(dname='REDHAWK_DEV', debug=False):
    global dom
    try :
        olist, a= getopt.gnu_getopt(sys.argv,"d:")
        d=filter(lambda x:  x[0] == '-d', olist )[0]
        dname=d[1]
        sys.argv=a
    except:
        pass

    print "Attach:"+str(dname)
    dom=redhawk.attach(dname )
    if debug:
        redhawk.setDebug(true)
예제 #30
0
 def get(self):
     print("A client pulled map_template.html to show the map")
     pis = 0
     dom = redhawk.attach(redhawk.scan()[0])
     for node in dom.devMgrs:
         print("Node name: %s" % node.name)
         if 'raspberry' in node.name.lower():
             pis = pis + 1
     print("Number of pis: %s" % pis)
     self.render("map_template.html",
                 ipaddr=self._ipaddr,
                 port=self._port,
                 lat=self._lat,
                 lon=self._lon,
                 num_pis=0)
예제 #31
0
def setup_domains(domain_dict, delay=5):
    """Setup domains specified

    Attempts to attach or kick start a list of domains with the
    specified device managers.

    .. warning:: Currently does not support launching device managers
        when attaching to a domain

    Parameters
    ----------
    domain_dict : dict
        Dictionary of domain specs.  The key will be the domain name.
        The supported fields include:
            devices_managers : list
    """
    active_domains = redhawk.scan()

    for domain in domain_dict:
        # extract potential list of device managers
        dev_mgrs = domain_dict[domain].get("device_managers", [])

        # -----------------------  setup domain instance  -------------------
        if domain in active_domains:
            # attach to active domain
            dom = redhawk.attach(domain)

        else:
            # kick start domain
            if dev_mgrs:
                dom = redhawk.kickDomain(domain, device_managers=dev_mgrs)
            else:
                # no device managers.. just launch domain
                dom = redhawk.kickDomain(domain, kick_device_managers=False)

            # allow delay x number of device managers to load
            time.sleep(delay * len(dev_mgrs))

        # -----------------------  check device managers  -------------------
        if dev_mgrs:
            # check if device managers have been loaded
            for dev_mgr in dev_mgrs:
                if dev_mgr not in dom.devMgrs:
                    warnings.warn("Have not implemented setting up device"+\
                        " managers on an active domain")
    def test_Property_JAVA(self):
        self._devBooter, self._devMgr = self.launchDeviceManager(
            "/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml",
            self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication(
            "/waveforms/Property_T2/Property_T2.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        app.start()
        time.sleep(1)

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

        self.assertEquals(c.p1, "prop1")
        self.assertAlmostEquals(c.p2, 123.4)
        self.assertEquals(c.p3, 567)
        self.assertEquals(c.p4.p4sub1, "prop2")
        t1 = int(c.p4.p4sub2)
        self.assertEquals(t1, 890)

        c.p1 = "testing"
        c.p2 = 100.0
        c.p3 = 100
        c.p4.p4sub1 = "testing2"
        c.p4.p4sub2 = 200.0

        self.assertEquals(c.p1, "testing")
        self.assertAlmostEquals(c.p2, 100.0)
        self.assertEquals(c.p3, 100)
        self.assertEquals(c.p4.p4sub1, "testing2")
        t1 = int(c.p4.p4sub2)
        self.assertEquals(t1, 200)

        app.releaseObject()
예제 #33
0
    def getDomain(self, domainName):
        try:
            self.currentDomain = domainName
            self.disconnectFromODMChannel()
            self.domManager = redhawk.attach(domainName)
            self.connectToODMChannel()
            if self.domManager is None:
                raise StandardError('Could not narrow Domain Manager')

            # this is here just to make sure that the pointer is accessible
            if self.domManager._non_existent():
                raise StandardError("Unable to access the Domain Manager in naming context "+domainName)
        except:
            raise StandardError("Unable to access the Domain Manager in naming context "+domainName)

        try:
            self.fileMgr = self.domManager._get_fileMgr()
        except:
            raise StandardError("Unable to access the File Manager in Domain Manager "+domainName)
예제 #34
0
 def _getMessagesForDomainListing(self, change='add'):
     msgs = []
     
     try:
         names = redhawk.scan()
         for name in names:
             d = redhawk.attach(name)
             id = d._get_identifier()
             msgs.append(RH_Message(change = change, 
                                    rhtype = 'domain', 
                                    rhid   = id, 
                                    rhname = name))
     except Exception as e:
         print("Caught exception while scanning REDHAWK CORE...never good.")
         print("---> Forcing a reset of the RH_Gateway."); sys.stdout.flush()
         self.close()
         
     finally:
         return msgs
    def test_Property_CPP(self):
        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication("/waveforms/Property_T1/Property_T1.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        app.start()
        time.sleep(1)

        ps=None
        c=None
        d=redhawk.attach(scatest.getTestDomainName())
        a=d.apps[0]
        c=filter( lambda c : c.name == 'Property_CPP', a.comps )[0]
        self.assertNotEqual(c,None)
        ps = c.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps,None)
        
        self.assertEquals(c.p1,"prop1")
        self.assertAlmostEquals(c.p2,123.4)
        self.assertEquals(c.p3,567)
        self.assertEquals(c.p4.p4sub1,"prop2")
        t1=int(c.p4.p4sub2)
        self.assertEquals(t1,890)

        c.p1 = "testing"
        c.p2 = 100.0
        c.p3 = 100
        c.p4.p4sub1="testing2"
        c.p4.p4sub2=200.0

        self.assertEquals(c.p1,"testing")
        self.assertAlmostEquals(c.p2,100.0)
        self.assertEquals(c.p3,100)
        self.assertEquals(c.p4.p4sub1,"testing2")
        t1=int(c.p4.p4sub2)
        self.assertEquals(t1,200)


        app.releaseObject()
예제 #36
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):
        super(ConnectionManagerTestRedhawkUtils, self).setUp()
        nb, self._domMgr = self.launchDomainManager()
        nb, self._devMgr = self.launchDeviceManager(
            '/nodes/test_PortTestDevice_node/DeviceManager.dcd.xml')

        # Device IDs taken from the DCD
        self.devId1 = 'DCE:322fb9b2-de57-42a2-ad03-217bcb244262'
        self.devId2 = 'DCE:47dc45d8-19b5-4b7e-bcd4-b165babe5b84'

        self.dom = redhawk.attach(self._domMgr._get_name())
        for dev in self.dom.devices:
            if dev._get_identifier() == self.devId1:
                self.dev1 = dev
            if dev._get_identifier() == self.devId2:
                self.dev2 = dev
        self.assertNotEqual(self.dom, None)

        # The DCD has one connection, verify that it is listed
        self.cm = self.dom.getConnectionMgr()
        self.assertNotEqual(self.cm, None)
예제 #38
0
 def _domainListCheck(self):
     newList = self._getMessagesForDomainListing('add')
     adds, removes = splitDictLists(newList, self._domainListMessages, RH_Message().keys())
     
     # Removals
     ids = [r['rhid'] for r in removes]
     indices = []
     if (0 < len(ids)):
         for i, d in enumerate(self._domains):
             if (d.getID in ids):
                 d.cleanUp()
                 indices.append(i)
         self._domains = [d for i, d in enumerate(self._domains) if i not in indices]
     
     # Additions
     for a in adds:
         self._domains.append(Domain(redhawk.attach(a['rhname']), # Return redhawk domain instance
                                     '',                          # No parent ID
                                     self.outbox))                # Using the global outbox
     
     self._domainListMessages = newList;
     self.domainTask = gevent.spawn_later(self._domainTaskWaitSec, self._domainListCheck)
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager(debug=self.debuglevel)
     devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml", debug=self.debuglevel)
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.assertEquals(len(self._rhDom._get_applications()), 0)
    def connectAndTune(self):
        
        # Lets make sure we have everything we need before continuing.
        if not self.InputComponent.componentName:
            self._log.error("Stopping. Component name must be specified.")
            self.stop()
            return
        
        if not self.InputComponent.inputPortName:
            self._log.error("Stopping. Component input port name must be specified.")
            self.stop()
            return
        
        if not self.FEIDevice.deviceName:
            self._log.error("Stopping. Device name must be specified.")
            self.stop()
            return
        
        if not self.FEIDevice.outputPortName:
            self._log.error("Stopping. Device output port name must be specified.")
            self.stop()
            return
        
        if not self.FEIDevice.tunerPortName:
            self._log.error("Stopping. Device tuner port name must be specified.")
            self.stop()
            return
                
        # While the domain port does give us a direct connection to the domain, the
        # API exposed is cleaner from the domain instance returned via the redhawk.attach method.
        try:
            domainname = self.port_DomainManager_out._get_name()
            self.domain = redhawk.attach(domainname)
        except Exception as ex:
            self._log.error("Failed to connect to domain: " + str(ex))
            self.stop()
            return

        if self.domain is None:
            self._log.error("Stopping.  Could not connect to domain.")
            self.stop()
            return
        
        
        self._log.debug("Searching for the current waveform in the domain")
        waveform = self.findWaveformByComponentInstanceName(self._name)
        
        if waveform is None:
            self._log.error("Stopping. Could not find the running waveform.")
            self.stop();
            return
             
        self._log.debug("Searching for the component in the waveform: " + str(waveform.name))
        
        # Gets the component from the application.  The component name can be the name or instantition.  ex.  DataConverter or DataConveter_3
        # This allows you to use the same component multiple times in a waveform and know for certain which one you are connecting to.
        for comp in waveform.comps:
            if self.InputComponent.componentName in comp._instanceName:
                self.targetComponent = comp
                break
        
        if self.targetComponent is None:
            self._log.error("Stopping.  Could not find the component: " + self.InputComponent.componentName)
            self.stop();
            return
             
         
        self._log.debug("Searching device managers for device: " + self.FEIDevice.deviceName)
        
        self.targetDevice = self.findByDeviceName(self.FEIDevice.deviceName)
        
        if self.targetDevice is None:
            self._log.error("Stopping. Could not find the device: " + self.FEIDevice.deviceName)
            self.stop()
            return


        # Gets the references to the input and output ports
        self.targetComponentPort = self.targetComponent.getPort(self.InputComponent.inputPortName)
        self.targetDevicePort = self.targetDevice.getPort(self.FEIDevice.outputPortName)
        self.feiTunerPort = self.targetDevice.getPort(self.FEIDevice.tunerPortName)
         
        if self.targetComponentPort is None:
            self._log.error("Stopping.  Could not find the component input port: " + self.InputComponent.inputPortName)
            self.stop()
            return
             
        if self.targetDevicePort is None:
            self._log.error("Stopping.  Could not find the component output port: " + self.FEIDevice.outputPortName)
            self.stop()
            return
         
        if self.feiTunerPort is None:
            self._log.error("Stopping.  Could not find the tuner port: " + self.FEIDevice.tunerPortName)
            self.stop()
            return
         
        self.allocationRequest = frontend.createTunerAllocation(
                                                    tuner_type              =   self.tunerType, 
                                                    allocation_id           =   self.allocationId,
                                                    center_frequency        =   self.TuneRequest.frequency * 1e6, 
                                                    sample_rate             =   self.TuneRequest.sampleRate * 1e6,
                                                    sample_rate_tolerance   =   20.0
                                                    )
         
         
         
        self._log.debug("Performing allocation of FEI Device")
        self._log.debug("Allocation contains: " + str(self.allocationRequest))
        
        retVal = False
        
        try:
            retVal = self.targetDevice.allocateCapacity(self.allocationRequest)
        except CF.Device.InvalidCapacity as ex:
            self._log.error("Device has invalid capacity, allocation failed: " + str(ex))
        except CF.Device.InvalidState as ex:
            self._log.error("Device in invalid state, allocation failed: " + str(ex))
        except Exception as ex:
            self._log.error("Exception thrown while allocating: " + str(ex))
         
        if (retVal is False):
            self._log.error("Allocation failed.  Stopping.")
            self.stop()
            return
        
        
        self._log.debug("Allocation succeeded!")
        
        # Makes the actual connection
        self._log.debug("Connecting component and device ports")
        self.targetDevicePort.connectPort(self.targetComponentPort, self.allocationId)
        self.connected = True
 
        self._log.debug("Starting device and component")
        
        # Make sure device and component are started
        self.targetDevice.start()
        self.targetComponent.start()
    def test_PropertyChangeListener_CPP(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        if java_support:
            self._domMgr.installApplication("/waveforms/PropertyChangeListener/PropertyChangeListener.sad.xml")
        else:
            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)

        ps=None
        c=None
        d=redhawk.attach(scatest.getTestDomainName())
        a=d.apps[0]
        c=filter( lambda c : c.name == 'PropertyChange_C1', a.comps )[0]
        self.assertNotEqual(c,None)
        ps = c.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps,None)
        
        # create listener interface
        myl = PropertyChangeListener_Receiver()
        t=float(0.5)
        regid=ps.registerPropertyListener( myl._this(), ['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
        
        # now check results
        self.assertEquals(myl.count,4)

        # change unmonitored property
        c.prop2 = 100
        time.sleep(.6)   # wait for listener to receive notice

        # now check results
        self.assertEquals(myl.count,4)

        # unregister
        ps.unregisterPropertyListener( regid )

        c.prop1 = 100.0
        time.sleep(.6)   # wait for listener to receive notice
        
        # now check results, should be same... 
        self.assertEquals(myl.count,4)

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

        app.releaseObject()