示例#1
0
    def shutdown(self):
        ConnectionManager.instance().cleanup()
        self.stop()

        # Clean up all components
        for name, component in self.__components.items():
            log.debug("Releasing component '%s'", name)
            try:
                component.releaseObject()
            except:
                log.debug("Component '%s' raised an exception while exiting",
                          name)
        self.__components = {}

        # Terminate all services
        for name, service in self.__services.items():
            log.debug("Terminating service '%s'", name)
            try:
                service._terminate()
            except:
                log.debug("Service '%s' raised an exception while terminating",
                          name)
        self.__services = {}

        # Clean up the component host
        if self.__container:
            log.debug('Releasing component host')
            try:
                self.__container.releaseObject()
            except:
                log.debug(
                    'Component host raised an exception while terminating')
        self.__container = None

        super(LocalSandbox, self).shutdown()
示例#2
0
 def shutdown(self):
     ConnectionManager.instance().cleanup()
     self.stop()
     for name, component in self.__components.items():
         log.debug("Releasing component '%s'", name)
         try:
             component.releaseObject()
         except:
             log.debug("Component '%s' raised an exception while exiting", name)
     for pid in self.__services:
         os.kill(pid, 9)
     self.__components = {}
     self.__services = []
def reset():
    '''
    Set all components to their initial running condition
    '''
    # Save connection state.
    connectionList = []
    for connectionId, connection in ConnectionManager.instance().getConnections().iteritems():
        uses, provides = connection
        entry = { 'USES_REFID': uses.getRefid(),
                  'USES_PORT_NAME': uses.getPortName(),
                  'PROVIDES_REFID': provides.getRefid(),
                  'PROVIDES_PORT_NAME': provides.getPortName() }
        connectionList.append(entry)

    log.debug('Saved %d component connections', len(connectionList))

    # Reset all sandbox components.
    sandbox = _getSandbox()
    sandbox.reset()

    # Restore connections.
    for connection in connectionList:
        usesComp = sandbox.getComponentByRefid(connection['USES_REFID'])
        usesName = connection['USES_PORT_NAME']
        providesComp = sandbox.getComponentByRefid(connection['PROVIDES_REFID'])
        providesName = connection['PROVIDES_PORT_NAME']
        if usesComp and usesName and providesComp:
            usesComp.connect(providesComp, providesPortName=providesName, usesPortName=usesName)
示例#4
0
def reset():
    '''
    Set all components to their initial running condition
    '''
    # Save connection state.
    connectionList = []
    for connectionId, connection in ConnectionManager.instance(
    ).getConnections().iteritems():
        uses, provides = connection
        entry = {
            'USES_REFID': uses.getRefid(),
            'USES_PORT_NAME': uses.getPortName(),
            'PROVIDES_REFID': provides.getRefid(),
            'PROVIDES_PORT_NAME': provides.getPortName()
        }
        connectionList.append(entry)

    log.debug('Saved %d component connections', len(connectionList))

    # Reset all sandbox components.
    sandbox = _getSandbox()
    sandbox.reset()

    # Restore connections.
    for connection in connectionList:
        usesComp = sandbox.getComponentByRefid(connection['USES_REFID'])
        usesName = connection['USES_PORT_NAME']
        providesComp = sandbox.getComponentByRefid(
            connection['PROVIDES_REFID'])
        providesName = connection['PROVIDES_PORT_NAME']
        if usesComp and usesName and providesComp:
            usesComp.connect(providesComp,
                             providesPortName=providesName,
                             usesPortName=usesName)
示例#5
0
def show():
    '''
    Show current list of components running and component connections
    '''
    sandbox = _getSandbox()
    print "Components Running:"
    print "------------------"
    for component in sandbox.getComponents():
        print component._instanceName, component
    print "\n"

    print "Services Running:"
    print "----------------"
    for service in sandbox.getServices():
        print service._instanceName, service
    print "\n"

    print "Component Connections:"
    print "---------------------"
    for uses, provides in ConnectionManager.instance().getConnections().values():
        print "%s [%s] -> %s [%s]" % (uses.getName(), uses.getInterface(),
                                      provides.getName(), provides.getInterface())
    
    print "\n"
    print "Event Channels:"
    print "--------------"
    for channel in sandbox.getEventChannels():
        print '%s (%d supplier(s), %d consumer(s))' % (channel.name, channel.supplier_count,
                                                       channel.consumer_count)
    print "\n"

    print "SDRROOT:"
    print "-------"
    print sandbox.getSdrRoot().getLocation()
    print "\n"
示例#6
0
 def _breakConnections(self, target):
     # Break any connections involving this object.
     manager = ConnectionManager.instance()
     for _identifier, (identifier, uses,
                       provides) in manager.getConnections().items():
         if uses.hasComponent(target) or provides.hasComponent(target):
             manager.breakConnection(identifier, uses)
             manager.unregisterConnection(identifier, uses)
示例#7
0
 def shutdown(self):
     ConnectionManager.instance().cleanup()
     self.stop()
     for name, component in self.__components.items():
         log.debug("Releasing component '%s'", name)
         try:
             component.releaseObject()
         except:
             log.debug("Component '%s' raised an exception while exiting", name)
     for name, service in self.__services.items():
         log.debug("Terminating service '%s'", name)
         try:
             service._terminate()
         except:
             log.debug("Service '%s' raised an exception while terminating", name)
     self.__components = {}
     self.__services = {}
     super(LocalSandbox,self).shutdown()
示例#8
0
 def shutdown(self):
     ConnectionManager.instance().cleanup()
     self.stop()
     for name, component in self.__components.items():
         log.debug("Releasing component '%s'", name)
         try:
             component.releaseObject()
         except:
             log.debug("Component '%s' raised an exception while exiting", name)
     for name, service in self.__services.items():
         log.debug("Terminating service '%s'", name)
         try:
             service._terminate()
         except:
             log.debug("Service '%s' raised an exception while terminating", name)
     self.__components = {}
     self.__services = {}
     super(LocalSandbox,self).shutdown()
示例#9
0
 def destroy(self):
     # Break any connections involving this event channel.
     manager = ConnectionManager.instance()
     for identifier, (uses, provides) in manager.getConnections().items():
         if provides.hasComponent(self):
             manager.breakConnection(identifier)
             manager.unregisterConnection(identifier)
     self._sandbox._removeEventChannel(self._instanceName)
     EventChannel.destroy(self)
示例#10
0
 def releaseObject(self):
     # Break any connections involving this component.
     manager = ConnectionManager.instance()
     for identifier, (uses, provides) in manager.getConnections().items():
         if uses.hasComponent(self) or provides.hasComponent(self):
             manager.breakConnection(identifier)
             manager.unregisterConnection(identifier)
     self._sandbox._unregisterComponent(self)
     super(SandboxComponent,self).releaseObject()
示例#11
0
 def destroy(self):
     # Break any connections involving this event channel.
     manager = ConnectionManager.instance()
     for identifier, (uses, provides) in manager.getConnections().items():
         if provides.hasComponent(self):
             manager.breakConnection(identifier)
             manager.unregisterConnection(identifier)
     self._sandbox._removeEventChannel(self._instanceName)
     EventChannel.destroy(self)
示例#12
0
 def releaseObject(self):
     # Break any connections involving this component.
     manager = ConnectionManager.instance()
     for identifier, (uses, provides) in manager.getConnections().items():
         if uses.hasComponent(self) or provides.hasComponent(self):
             manager.breakConnection(identifier)
             manager.unregisterConnection(identifier)
     self._sandbox._unregisterComponent(self)
     super(SandboxComponent, self).releaseObject()
示例#13
0
 def releaseObject(self):
     # Break any connections involving this helper
     manager = ConnectionManager.instance()
     for identifier, uses, provides in manager.getConnections().itervalues(
     ):
         if uses.hasComponent(self) or provides.hasComponent(self):
             usesRef = uses.getReference()
             usesRef.disconnectPort(identifier)
             manager.unregisterConnection(identifier, uses)
     self._sandbox._unregisterComponent(self)
def show():
    '''
    Show current list of components running and component connections
    '''
    sandbox = _getSandbox()
    print "Components Running:"
    print "------------------"
    for component in sandbox.getComponents():
        print component._instanceName, component
    print "\n"
    print "Component Connections:"
    print "---------------------"
    for uses, provides in ConnectionManager.instance().getConnections().values():
        print "%s [%s] -> %s [%s]" % (uses.getName(), uses.getInterface(),
                                      provides.getName(), provides.getInterface())
    
    print "\n"
    print "SDRROOT:"
    print "-------"
    print sandbox.getSdrRoot().getLocation()
    print "\n"
示例#15
0
def show():
    '''
    Show current list of components running and component connections
    '''
    sandbox = _getSandbox()
    print "Components Running:"
    print "------------------"
    for component in sandbox.getComponents():
        print component._instanceName, component
    print "\n"
    print "Component Connections:"
    print "---------------------"
    for uses, provides in ConnectionManager.instance().getConnections().values(
    ):
        print "%s [%s] -> %s [%s]" % (uses.getName(), uses.getInterface(),
                                      provides.getName(),
                                      provides.getInterface())

    print "\n"
    print "SDRROOT:"
    print "-------"
    print sandbox.getSdrRoot().getLocation()
    print "\n"