def launch(self, execparams={}, ossiehome=None, configure={}, initialize=True): """ Launch the component. The component will be executed as a child process, then (optionally) initialized and configured. Arguments: execparams - Execparams to override on component execution. ossiehome - Base location of REDHAWK installation for finding IDL files. Default location is determined from $OSSIEHOME environment variable. configure - If a dictionary, a set of key/value pairs to override the initial configuration values of the component. If None, skip initial configuration. initialize - If true, call initialize() after launching the component. If false, skip initialization. """ if IDE_REF_ENV == None: if ossiehome: model._ossiehome = str(ossiehome) model._interface_list = importIDL.importStandardIdl(std_idl_path=str(ossiehome)+'/idl', std_idl_include_path=str(ossiehome)+'/idl') model._loadedInterfaceList = True component = sb.launch(self.spd_file, impl=self.impl, execparams=execparams, configure=configure, initialize=initialize) else: # spd file path passed in to unit test is relative to current component tests directory (i.e. "..") # IDE unit test requires spd file path relative to sca file system componentName = str(self.spd.get_name()) sca_file_system_spd_file = "components/" + componentName + "/" + self.spd_file[3:] component = sb.launch(sca_file_system_spd_file, impl=self.impl, execparams=execparams, configure=configure, initialize=initialize) self.comp_obj = component.ref self.comp = component
def __init__(self, profile, spd, scd, prf, instanceName, refid, impl, execparams, debugger, window): CorbaObject.__init__(self, None) self._profile = profile self._refid = refid self._spd = spd self._scd = scd self._impl = impl self._instanceName = instanceName # Load IDL list if it hasn't already been done global _loadedInterfaceList, _interface_list if not _loadedInterfaceList: _interface_list = _importIDL.importStandardIdl(std_idl_path=_std_idl_path, std_idl_include_path = _std_idl_include_path) _loadedInterfaceList = True # Add mapping of services operations and attributes found = False self._repid = self._scd.get_interfaces().interface[0].repid for interface in _interface_list: if self._repid == interface.repoId: self._operations = interface.operations self._attributes = interface.attributes self._namespace = interface.nameSpace self._interface = interface.name found = True if not found: log.error("Can't find IDL repo: " + str(self._repid) + " for service: " + str(self._instanceName)) self.populateMemberFunctions()
def _launchResource(self, execparams={}, ossiehome=None): if IDE_REF_ENV == None: if ossiehome: sb.domainless._ossiehome = str(ossiehome) sb.domainless._interface_list = importIDL.importStandardIdl( std_idl_path=str(ossiehome) + "/idl", std_idl_include_path=str(ossiehome) + "/idl" ) sb.domainless._loadedInterfaceList = True component = sb.Component(self.spd_file, impl=self.impl, execparams=execparams) else: # spd file path passed in to unit test is relative to current component tests directory (i.e. "..") # IDE unit test requires spd file path relative to sca file system componentName = str(self.spd.get_name()) sca_file_system_spd_file = "components/" + componentName + "/" + self.spd_file[3:] component = sb.Component(sca_file_system_spd_file, impl=self.impl, execparams=execparams) self.comp_obj = component.ref self.comp = component if IDE_REF_ENV == None: if component._sub_process != None: pid = component._sub_process.pid self._processes[pid] = component._sub_process logging.debug("Component is running (%d)...", pid) else: raise AssertionError, "Component instance has _sub_process equal to None"
def findInterface(repid): # Return immediately if the repository ID is already in the cache global idlRepo if repid in idlRepo: return idlRepo[repid] namespace = IDLInterface(repid).namespace() if namespace.startswith('omg.org'): includePaths = [] includePaths.append('/usr/local/share/idl/omniORB') includePaths.append('/usr/share/idl/omniORB') includePaths.append('/usr/local/share/idl/omniORB/COS') includePaths.append('/usr/share/idl/omniORB/COS') idlRepo.update((interface.repoId, interface) for interface in findInterfacesByPath(namespace, '/usr/share/idl/omniORB/COS', includePaths)) if idlRepo == {}: includePaths = [] includePaths.append('/usr/local/share/idl/omniORB') includePaths.append('/usr/share/idl/omniORB') idlRepo.update((interface.repoId, interface) for interface in findInterfacesByPath(namespace, '/usr/share/idl/omniORB/', includePaths, includeAll=True, includeCOS=False)) elif 'IDL:CF/Resource:1.0' not in idlRepo: idlRepo.update((interface.repoId, interface) for interface in importIDL.importStandardIdl()) # Try to find the interface again; if it is not in the cache by now, we # don't know anything about it. if repid in idlRepo: return idlRepo[repid] else: raise KeyError('Unsupported IDL interface ' + repid)
def launch(self, execparams={}, ossiehome=None, configure={}, initialize=True): """ Launch the component. The component will be executed as a child process, then (optionally) initialized and configured. Arguments: execparams - Execparams to override on component execution. ossiehome - Base location of REDHAWK installation for finding IDL files. Default location is determined from $OSSIEHOME environment variable. configure - If a dictionary, a set of key/value pairs to override the initial configuration values of the component. If None, skip initial configuration. initialize - If true, call initialize() after launching the component. If false, skip initialization. """ if IDE_REF_ENV == None: if ossiehome: model._ossiehome = str(ossiehome) model._interface_list = importIDL.importStandardIdl( std_idl_path=str(ossiehome) + '/idl', std_idl_include_path=str(ossiehome) + '/idl') model._loadedInterfaceList = True component = sb.launch(self.spd_file, impl=self.impl, execparams=execparams, configure=configure, initialize=initialize) else: # spd file path passed in to unit test is relative to current component tests directory (i.e. "..") # IDE unit test requires spd file path relative to sca file system componentName = str(self.spd.get_name()) sca_file_system_spd_file = "components/" + componentName + "/" + self.spd_file[ 3:] component = sb.launch(sca_file_system_spd_file, impl=self.impl, execparams=execparams, configure=configure, initialize=initialize) self.comp_obj = component.ref self.comp = component
def __init__(self, name="", AC=False, type="resource", generate=True, int_list=None): self.name = name # this refers to the instance name self.baseName = name # this refers to the component that the instance is based on self.connections = [] self.ports = [] self.Ports = {} self.mutable_params = [] self.device = None self.node = None self.uuid = uuidgen() self.file_uuid = uuidgen() #self.ace = False self.timing = False self.logging = False self.AssemblyController = AC self.type = type self.generate = generate self.xmlName = name #if imported from component library - this may change self.properties = [] self.reference = None self.ref = None self.profile = '' self.spd_path = '' self.prf_path = '' self.scd_path = '' if os.path.exists('/sdr/sca'): self.root = '/sdr/sca' elif os.path.exists('/sdr'): self.root = '/sdr' else: self.root = '' if int_list == None: #print "importing idl" self.interface_list = importIDL.importStandardIdl() else: self.interface_list = int_list self.API = {}
def __init__(self, name="",AC=False,type="resource",generate=True, int_list=None): self.name = name # this refers to the instance name self.baseName = name # this refers to the component that the instance is based on self.connections = [] self.ports = [] self.Ports = {} self.mutable_params = [] self.device = None self.node = None self.uuid = uuidgen() self.file_uuid = uuidgen() #self.ace = False self.timing = False self.logging = False self.AssemblyController = AC self.type = type self.generate = generate self.xmlName = name #if imported from component library - this may change self.properties = [] self.reference = None self.ref = None self.profile = '' self.spd_path = '' self.prf_path = '' self.scd_path = '' if os.path.exists('/sdr/sca'): self.root = '/sdr/sca' elif os.path.exists('/sdr'): self.root = '/sdr' else: self.root = '' if int_list == None: #print "importing idl" self.interface_list = importIDL.importStandardIdl() else: self.interface_list = int_list self.API = {}
def __init__(self, name="DomainName1", int_list=None, location=None): self.name = name self._sads = [] self.ref = None self.NodeAlive = True self._waveformsUpdated = False self.location = location # create orb reference input_arguments = _sys.argv if location != None: if len(_sys.argv) == 1: if _sys.argv[0] == '': input_arguments = [ '-ORBInitRef', 'NameService=corbaname::' + location ] else: input_arguments.extend( ['-ORBInitRef', 'NameService=corbaname::' + location]) else: input_arguments.extend( ['-ORBInitRef', 'NameService=corbaname::' + location]) self.orb = _CORBA.ORB_init(input_arguments, _CORBA.ORB_ID) obj = self.orb.resolve_initial_references("NameService") self.rootContext = obj._narrow(_CosNaming.NamingContext) # get DomainManager reference dm_name = [ _CosNaming.NameComponent(self.name, ""), _CosNaming.NameComponent(self.name, "") ] found_domain = False domain_find_attempts = 0 self.poa = self.orb.resolve_initial_references("RootPOA") self.poaManager = self.poa._get_the_POAManager() self.poaManager.activate() while not found_domain and domain_find_attempts < 30: try: obj = self.rootContext.resolve(dm_name) found_domain = True except: _time.sleep(0.1) domain_find_attempts += 1 if domain_find_attempts == 30: raise StandardError, "Did not find domain " + name self.ref = obj._narrow(_CF.DomainManager) self.fileManager = self.ref._get_fileMgr() if int_list == None: self._interface_list = _importIDL.importStandardIdl() else: self._interface_list = int_list for int_entry in self._interface_list: _interfaces[int_entry.repoId] = int_entry self.__deviceManagers = DomainObjectList( WeakBoundMethod(self._get_deviceManagers), WeakBoundMethod(self.__newDeviceManager), lambda x: x._get_identifier()) self.__applications = DomainObjectList( WeakBoundMethod(self._get_applications), WeakBoundMethod(self.__newApplication), lambda x: x._get_identifier()) # Connect notification points to domain object lists. self.__deviceManagers.itemAdded.addListener( WeakBoundMethod(self.deviceManagerAdded)) self.__deviceManagers.itemRemoved.addListener( WeakBoundMethod(self.deviceManagerRemoved)) self.__applications.itemAdded.addListener( WeakBoundMethod(self.applicationAdded)) self.__applications.itemRemoved.addListener( WeakBoundMethod(self.applicationRemoved)) # Connect the the IDM channel for updates to device states. try: idmListener = IDMListener() idmListener.connect(self.ref) except Exception, e: # No device events will be received log.warning('Unable to connect to IDM channel: %s', e) idmListener = None
def _populatePorts(self): """Add all port descriptions to the component instance""" interface_modules = ['BULKIO', 'BULKIO__POA'] int_list = {} global _loadedInterfaceList, _interface_list if not _loadedInterfaceList: _interface_list = _importIDL.importStandardIdl(std_idl_path=_std_idl_path, std_idl_include_path = _std_idl_include_path) _loadedInterfaceList = True scdPorts = self._scd.componentfeatures.ports ports = [] for int_entry in _interface_list: int_list[int_entry.repoId]=int_entry for uses in scdPorts.uses: idl_repid = str(uses.repid) if not int_list.has_key(idl_repid): if _DEBUG == True: print "Invalid port descriptor in scd for " + idl_repid continue int_entry = int_list[idl_repid] new_port = _Port(str(uses.usesname), interface=None, direction="Uses", using=int_entry) try: new_port.generic_ref = self.getPort(str(new_port._name)) new_port.ref = new_port.generic_ref._narrow(_ExtendedCF.QueryablePort) if new_port.ref == None: new_port.ref = new_port.generic_ref._narrow(_CF.Port) new_port.extendPort() idl_repid = new_port.ref._NP_RepositoryId if not int_list.has_key(idl_repid): if _DEBUG == True: print "Unable to find port description for " + idl_repid continue int_entry = int_list[idl_repid] new_port._interface = int_entry ports.append(new_port) except: if _DEBUG == True: print "getPort failed for port name: ", str(new_port._name) for provides in scdPorts.provides: idl_repid = str(provides.repid) if not int_list.has_key(idl_repid): if _DEBUG == True: print "Invalid port descriptor in scd for " + idl_repid continue int_entry = int_list[idl_repid] new_port = _Port(str(provides.providesname), interface=int_entry, direction="Provides") try: new_port.generic_ref = object.__getattribute__(self,'ref').getPort(str(new_port._name)) # See if interface python module has been loaded, if not then try to import it if str(int_entry.nameSpace) not in interface_modules: success = False try: pkg_name = (int_entry.nameSpace.lower())+'.'+(int_entry.nameSpace.lower())+'Interfaces' _to = str(int_entry.nameSpace) mod = __import__(pkg_name,globals(),locals(),[_to]) globals()[_to] = mod.__dict__[_to] success = True except ImportError, msg: pass if not success: std_idl_path = _os.path.join(_os.environ['OSSIEHOME'], 'lib/python') for dirpath, dirs, files in _os.walk(std_idl_path): if len(dirs) == 0: continue for directory in dirs: try: _from = directory+'.'+(int_entry.nameSpace.lower())+'Interfaces' _to = str(int_entry.nameSpace) mod = __import__(_from,globals(),locals(),[_to]) globals()[_to] = mod.__dict__[_to] success = True except: continue break if success: break if not success: continue interface_modules.append(str(int_entry.nameSpace)) exec_string = 'new_port.ref = new_port.generic_ref._narrow('+int_entry.nameSpace+'.'+int_entry.name+')' try: exec(exec_string) ports.append(new_port) except: continue except:
def __init__(self, name="DomainName1", int_list=None, location=None): self.name = name self.Devices = [] self.Waveforms = {} self.DomainManager = None self.NodeAlive = True self.Nodes = [] self.location = location # create orb reference input_arguments = sys.argv if location != None: if len(sys.argv) == 1: if sys.argv[0] == '': input_arguments = ['-ORBInitRef','NameService=corbaname::'+location] else: input_arguments.append('-ORBInitRef','NameService=corbaname::'+location) else: input_arguments.append('-ORBInitRef','NameService=corbaname::'+location) self.orb = CORBA.ORB_init(input_arguments, CORBA.ORB_ID) obj = self.orb.resolve_initial_references("NameService") self.rootContext = obj._narrow(CosNaming.NamingContext) # get DomainManager reference dm_name = [CosNaming.NameComponent(self.name,""),CosNaming.NameComponent(self.name,"")] found_domain = False domain_find_attempts = 0 self.poa = self.orb.resolve_initial_references("RootPOA") self.poaManager = self.poa._get_the_POAManager() self.poaManager.activate() while not found_domain and domain_find_attempts < 30: try: obj = self.rootContext.resolve(dm_name) found_domain = True except: time.sleep(0.1) domain_find_attempts += 1 if domain_find_attempts == 30: print "Did not find the domain" return #else: # print "found the domain" self.DomainManager = obj._narrow(CF.DomainManager) # get poa and poaManager reference # check to make sure that all the devices are installed devmgr_find_attempts = 0; found_devMgrs = False second_try = False while not found_devMgrs and devmgr_find_attempts < 30: try: if second_try: obj = self.rootContext.resolve(dm_name) self.DomainManager = obj._narrow(CF.DomainManager) devMgrs = self.DomainManager._get_deviceManagers() found_devMgrs = True except: devmgr_find_attempts += 1 time.sleep(0.1) second_try = True if devmgr_find_attempts == 30: return for devmgr in range(len(devMgrs)): devMgr = devMgrs[devmgr] curr_devSeq = devMgr._get_registeredDevices() for dev in range(len(curr_devSeq)): curr_dev = curr_devSeq[dev] dev_label = str(curr_dev._get_label()) dev_name = [CosNaming.NameComponent(self.name,""),CosNaming.NameComponent(dev_label,"")] found_device = False while not found_device: try: obj = self.rootContext.resolve(dev_name) found_device = True except: time.sleep(0.1) if int_list == None: self.interface_list = importIDL.importStandardIdl() else: self.interface_list = int_list # find and store the sdr root self.root = findSdrRoot() if not self.root: self.root = None # update information self.updateListAvailableWaveforms() self.updateInstalledWaveforms(shallow=True)
import os as _os import sys as _sys from omniORB import CORBA as _CORBA import CosNaming as _CosNaming from xml.dom import minidom as _minidom import core as _core from ossie.cf import CF as _CF import ossie.utils as _utils from ossie.utils.sca import importIDL as _importIDL _ossiehome = _os.getenv('OSSIEHOME') if _ossiehome == None: _ossiehome = '' _interface_list = [] else: _interface_list = _importIDL.importStandardIdl(std_idl_path=_ossiehome+'/share/idl/ossie') class _envContainer(object): def __init__(self, domain, stdout): self.domain = int(domain) self.stdout = stdout def __del__(self): _os.kill(self.domain,2) if self.stdout != None: self.stdout.close() def kickDomain(domain_name=None, kick_device_managers=True, device_managers=[], detached=False, sdrroot=None, stdout=None, logfile=None): """Kick-start a REDHAWK domain. domain_name: the name that should be used
import os as _os import sys as _sys from omniORB import CORBA as _CORBA import CosNaming as _CosNaming from xml.dom import minidom as _minidom import core as _core from ossie.cf import CF as _CF import ossie.utils as _utils from ossie.utils.sca import importIDL as _importIDL _ossiehome = _os.getenv('OSSIEHOME') if _ossiehome == None: _ossiehome = '' _interface_list = [] else: _interface_list = _importIDL.importStandardIdl(std_idl_path=_ossiehome + '/share/idl/ossie') class _envContainer(object): def __init__(self, domain, stdout): self.domain = int(domain) self.stdout = stdout def __del__(self): import os as _os _os.kill(self.domain, 2) if self.stdout != None: self.stdout.close() def kickDomain(domain_name=None,
def __init__(self, name="DomainName1", int_list=None, location=None): self.name = name self._sads = [] self.ref = None self.NodeAlive = True self._waveformsUpdated = False self.location = location # create orb reference input_arguments = _sys.argv if location != None: if len(_sys.argv) == 1: if _sys.argv[0] == '': input_arguments = ['-ORBInitRef','NameService=corbaname::'+location] else: input_arguments.extend(['-ORBInitRef','NameService=corbaname::'+location]) else: input_arguments.extend(['-ORBInitRef','NameService=corbaname::'+location]) self.orb = _CORBA.ORB_init(input_arguments, _CORBA.ORB_ID) obj = self.orb.resolve_initial_references("NameService") self.rootContext = obj._narrow(_CosNaming.NamingContext) # get DomainManager reference dm_name = [_CosNaming.NameComponent(self.name,""),_CosNaming.NameComponent(self.name,"")] found_domain = False domain_find_attempts = 0 self.poa = self.orb.resolve_initial_references("RootPOA") self.poaManager = self.poa._get_the_POAManager() self.poaManager.activate() while not found_domain and domain_find_attempts < 30: try: obj = self.rootContext.resolve(dm_name) found_domain = True except: _time.sleep(0.1) domain_find_attempts += 1 if domain_find_attempts == 30: raise StandardError, "Did not find domain "+name self.ref = obj._narrow(_CF.DomainManager) self.fileManager = self.ref._get_fileMgr() if int_list == None: self._interface_list = _importIDL.importStandardIdl() else: self._interface_list = int_list for int_entry in self._interface_list: _interfaces[int_entry.repoId]=int_entry self.__deviceManagers = DomainObjectList(WeakBoundMethod(self._get_deviceManagers), WeakBoundMethod(self.__newDeviceManager), lambda x: x._get_identifier()) self.__applications = DomainObjectList(WeakBoundMethod(self._get_applications), WeakBoundMethod(self.__newApplication), lambda x: x._get_identifier()) # Connect notification points to domain object lists. self.__deviceManagers.itemAdded.addListener(WeakBoundMethod(self.deviceManagerAdded)) self.__deviceManagers.itemRemoved.addListener(WeakBoundMethod(self.deviceManagerRemoved)) self.__applications.itemAdded.addListener(WeakBoundMethod(self.applicationAdded)) self.__applications.itemRemoved.addListener(WeakBoundMethod(self.applicationRemoved)) # Connect the the IDM channel for updates to device states. try: idmListener = IDMListener() idmListener.connect(self.ref) except Exception, e: # No device events will be received log.warning('Unable to connect to IDM channel: %s', e) idmListener = None
def __init__(self, name="DomainName1", int_list=None, location=None): self.name = name self.Devices = [] self.Waveforms = {} self.DomainManager = None self.NodeAlive = True self.Nodes = [] self.location = location # create orb reference input_arguments = sys.argv if location != None: if len(sys.argv) == 1: if sys.argv[0] == '': input_arguments = [ '-ORBInitRef', 'NameService=corbaname::' + location ] else: input_arguments.append( '-ORBInitRef', 'NameService=corbaname::' + location) else: input_arguments.append('-ORBInitRef', 'NameService=corbaname::' + location) self.orb = CORBA.ORB_init(input_arguments, CORBA.ORB_ID) obj = self.orb.resolve_initial_references("NameService") self.rootContext = obj._narrow(CosNaming.NamingContext) # get DomainManager reference dm_name = [ CosNaming.NameComponent(self.name, ""), CosNaming.NameComponent(self.name, "") ] found_domain = False domain_find_attempts = 0 self.poa = self.orb.resolve_initial_references("RootPOA") self.poaManager = self.poa._get_the_POAManager() self.poaManager.activate() while not found_domain and domain_find_attempts < 30: try: obj = self.rootContext.resolve(dm_name) found_domain = True except: time.sleep(0.1) domain_find_attempts += 1 if domain_find_attempts == 30: print "Did not find the domain" return #else: # print "found the domain" self.DomainManager = obj._narrow(CF.DomainManager) # get poa and poaManager reference # check to make sure that all the devices are installed devmgr_find_attempts = 0 found_devMgrs = False second_try = False while not found_devMgrs and devmgr_find_attempts < 30: try: if second_try: obj = self.rootContext.resolve(dm_name) self.DomainManager = obj._narrow(CF.DomainManager) devMgrs = self.DomainManager._get_deviceManagers() found_devMgrs = True except: devmgr_find_attempts += 1 time.sleep(0.1) second_try = True if devmgr_find_attempts == 30: return for devmgr in range(len(devMgrs)): devMgr = devMgrs[devmgr] curr_devSeq = devMgr._get_registeredDevices() for dev in range(len(curr_devSeq)): curr_dev = curr_devSeq[dev] dev_label = str(curr_dev._get_label()) dev_name = [ CosNaming.NameComponent(self.name, ""), CosNaming.NameComponent(dev_label, "") ] found_device = False while not found_device: try: obj = self.rootContext.resolve(dev_name) found_device = True except: time.sleep(0.1) if int_list == None: self.interface_list = importIDL.importStandardIdl() else: self.interface_list = int_list # find and store the sdr root self.root = findSdrRoot() if not self.root: self.root = None # update information self.updateListAvailableWaveforms() self.updateInstalledWaveforms(shallow=True)