示例#1
0
class comp_base(CF__POA.Resource, Component, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Component.__init__(self, identifier, execparams, loggerName=loggerName)
        ThreadedComponent.__init__(self)

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this component
        self.port_in = bulkio.InFloatPort("in",
                                          maxsize=self.DEFAULT_QUEUE_SIZE)
        self.port_out = bulkio.OutFloatPort("out")

    def start(self):
        Component.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        Component.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        Component.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_in = providesport(name="in",
                           repid="IDL:BULKIO/dataFloat:1.0",
                           type_="data")

    port_out = usesport(name="out",
                        repid="IDL:BULKIO/dataFloat:1.0",
                        type_="data")
示例#2
0
class PortTest(CF__POA.Resource, Resource):
    """Simple Python component for basic port testing"""

    toTest = usesport("resource_out", "IDL:CF/Resource:1.0", type_="test")
    fromOther = providesport("resource_in",
                             "IDL:CF/Resource:1.0",
                             type_="test")
    toPropSet = usesport("propset_out", "IDL:CF/PropertySet:1.0", type_="test")
    eventSupplier = usesport("event_supplier",
                             "IDL:CosEventChannelAdmin/EventChannel:1.0",
                             type_="test")
    eventConsumer = usesport("event_consumer",
                             "IDL:CosEventChannelAdmin/EventChannel:1.0",
                             type_="test")
    toDomainManager = usesport("domain_manager",
                               "IDL:CF/DomainManager:1.0",
                               type_="test")
    toDeviceManager = usesport("device_manager",
                               "IDL:CF/DeviceManager:1.0",
                               type_="test")

    def __init__(self, identifier, execparams):
        Resource.__init__(self, identifier, execparams)

    def initialize(self):
        Resource.initialize(self)
        self.toTest = TestUsesPort()
        self.fromOther = TestProvidesPort(self._get_identifier() +
                                          "/resource_in")
        self.toPropSet = PropSetUsesPort()
        self.eventSupplier = EventSupplierPort()
        self.eventConsumer = EventConsumerPort(self._onPush)
        self.toDomainManager = DomainManagerUsesPort()
        self.toDeviceManager = DeviceManagerUsesPort()

    def runTest(self, testid, properties):
        if testid == 0:
            return self.toTest.getIdentifiers()
        elif testid == 1:
            return self.toPropSet.query([])
        elif testid == 2:
            return self.toDomainManager.getIdentifiers()
        elif testid == 3:
            return self.toDeviceManager.getIdentifiers()
        else:
            raise CF.TestableObject.UnknownTest()
        return []

    def _onPush(self, data, typecode):
        if data == "message":
            self.eventSupplier.sendEvent(any.to_any("response"))
class SADUsesComponent_base(CF__POA.Resource, Resource):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Resource.__init__(self, identifier, execparams, loggerName=loggerName)
        self.threadControlLock = threading.RLock()
        self.process_thread = None
        # self.auto_start is deprecated and is only kept for API compatability
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False

    def initialize(self):
        Resource.initialize(self)

        # Instantiate the default implementations for all ports on this component
        self.port_comp_resource_in = PortCFResourceIn_i(
            self, "comp_resource_in")

        self.port_comp_resource_out = PortCFResourceOut_i(
            self, "comp_resource_out")

    def start(self):
        self.threadControlLock.acquire()
        try:
            Resource.start(self)
            if self.process_thread == None:
                self.process_thread = ProcessThread(target=self.process,
                                                    pause=self.PAUSE)
                self.process_thread.start()
        finally:
            self.threadControlLock.release()

    def process(self):
        """The process method should process a single "chunk" of data and then return.  This method will be called
            from the processing thread again, and again, and again until it returns FINISH or stop() is called on the
            component.  If no work is performed, then return NOOP"""
        raise NotImplementedError

    def stop(self):
        self.threadControlLock.acquire()
        try:
            process_thread = self.process_thread
            self.process_thread = None

            if process_thread != None:
                process_thread.stop()
                process_thread.join(self.TIMEOUT)
                if process_thread.isAlive():
                    raise CF.Resource.StopError(
                        CF.CF_NOTSET, "Processing thread did not die")
            Resource.stop(self)
        finally:
            self.threadControlLock.release()

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        self.threadControlLock.acquire()
        try:
            Resource.releaseObject(self)
        finally:
            self.threadControlLock.release()

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    def compareSRI(self, a, b):
        if a.hversion != b.hversion:
            return False
        if a.xstart != b.xstart:
            return False
        if a.xdelta != b.xdelta:
            return False
        if a.xunits != b.xunits:
            return False
        if a.subsize != b.subsize:
            return False
        if a.ystart != b.ystart:
            return False
        if a.ydelta != b.ydelta:
            return False
        if a.yunits != b.yunits:
            return False
        if a.mode != b.mode:
            return False
        if a.streamID != b.streamID:
            return False
        if a.blocking != b.blocking:
            return False
        if len(a.keywords) != len(b.keywords):
            return False
        for keyA, keyB in zip(a.keywords, b.keywords):
            if keyA.value._t != keyB.value._t:
                return False
            if keyA.value._v != keyB.value._v:
                return False
        return True

    # 'CF/Resource' port
    class PortCFResourceIn(CF__POA.Resource):
        """This class is a port template for the comp_resource_in port and
            should not be instantiated nor modified.
            
            The expectation is that the specific port implementation will extend 
            from this class instead of the base CORBA class CF__POA.Resource.
            """
        pass

    # 'CF/Resource' port
    class PortCFResourceOut(CF__POA.Port):
        """This class is a port template for the comp_resource_out port and
            should not be instantiated nor modified.
            
            The expectation is that the specific port implementation will extend 
            from this class instead of the base CORBA class CF__POA.Port.
            """
        pass

    port_comp_resource_in = providesport(
        name="comp_resource_in",
        repid="IDL:CF/Resource:1.0",
        type_="data",
    )

    port_comp_resource_out = usesport(
        name="comp_resource_out",
        repid="IDL:CF/Resource:1.0",
        type_="data",
    )

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    prop = simple_property(id_="prop",
                           type_="long",
                           defvalue=2,
                           mode="readwrite",
                           action="external",
                           kinds=("configure", ))
class through_base(CF__POA.Resource, Component, ThreadedComponent):
        # These values can be altered in the __init__ of your derived class

        PAUSE = 0.0125 # The amount of time to sleep if process return NOOP
        TIMEOUT = 5.0 # The amount of time to wait for the process thread to die when stop() is called
        DEFAULT_QUEUE_SIZE = 100 # The number of BulkIO packets that can be in the queue before pushPacket will block

        def __init__(self, identifier, execparams):
            loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0]
            Component.__init__(self, identifier, execparams, loggerName=loggerName)
            ThreadedComponent.__init__(self)

            # self.auto_start is deprecated and is only kept for API compatibility
            # with 1.7.X and 1.8.0 components.  This variable may be removed
            # in future releases
            self.auto_start = False
            # Instantiate the default implementations for all ports on this component
            self.port_input = PortCFLifeCycleIn_i(self, "input")
            self.port_output = PortCFLifeCycleOut_i(self, "output")

        def start(self):
            Component.start(self)
            ThreadedComponent.startThread(self, pause=self.PAUSE)

        def stop(self):
            Component.stop(self)
            if not ThreadedComponent.stopThread(self, self.TIMEOUT):
                raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die")

        def releaseObject(self):
            try:
                self.stop()
            except Exception:
                self._log.exception("Error stopping")
            Component.releaseObject(self)

        ######################################################################
        # PORTS
        # 
        # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file, 
        # or via the IDE.

        # 'CF/LifeCycle' port
        class PortCFLifeCycleIn(CF__POA.LifeCycle):
            """This class is a port template for the PortCFLifeCycleIn_i port and
            should not be instantiated nor modified.
            
            The expectation is that the specific port implementation will extend
            from this class instead of the base CORBA class CF__POA.LifeCycle.
            """
            pass

        # 'CF/LifeCycle' port
        class PortCFLifeCycleOut(ExtendedCF__POA.QueryablePort):
            """This class is a port template for the PortCFLifeCycleOut_i port and
            should not be instantiated nor modified.
            
            The expectation is that the specific port implementation will extend
            from this class instead of the base CORBA class ExtendedCF__POA.QueryablePort.
            """
            pass

        port_input = providesport(name="input",
                                  repid="IDL:CF/LifeCycle:1.0",
                                  type_="control")

        port_output = usesport(name="output",
                               repid="IDL:CF/LifeCycle:1.0",
                               type_="control")
示例#5
0
class PortDevice_impl(CF__POA.ExecutableDevice, ExecutableDevice):

    toTest = usesport("resource_out", "IDL:CF/Resource:1.0", type_="test")
    toDevMgr = usesport("devicemanager_out",
                        "IDL:CF/DeviceManager:1.0",
                        type_="test")
    fromOther = providesport("resource_in",
                             "IDL:CF/Resource:1.0",
                             type_="test")

    os_name = simple_property(id_='DCE:4a23ad60-0b25-4121-a630-68803a498f75',
                              type_='string',
                              name='os_name',
                              defvalue='Linux',
                              mode='readonly',
                              action='eq',
                              kinds=('allocation', ))

    processor_name = simple_property(
        id_='DCE:fefb9c66-d14a-438d-ad59-2cfd1adb272b',
        type_='string',
        name='processor_name',
        defvalue='i686',
        mode='readonly',
        action='eq',
        kinds=('allocation', ))

    memCapacity = simple_property(
        id_='DCE:8dcef419-b440-4bcf-b893-cab79b6024fb',
        type_='long',
        name='memCapacity',
        defvalue=100000000,
        mode='readonly',
        action='external',
        kinds=('allocation', ))

    BogoMipsCapacity = simple_property(
        id_='DCE:5636c210-0346-4df7-a5a3-8fd34c5540a8',
        type_='long',
        name='BogoMipsCapacity',
        defvalue=100000000,
        mode='readonly',
        action='external',
        kinds=(u'allocation', ))

    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        ExecutableDevice.__init__(self, devmgr, uuid, label, softwareProfile,
                                  compositeDevice, execparams)

    def initialize(self):
        ExecutableDevice.initialize(self)
        self.toTest = testOut_i(self, "resource_out")
        self.toDevMgr = devicemanagerOut_i(self, "devicemanager_out")
        self.fromOther = fromOther_i(self, "resource_in")

    def runTest(self, testid, properties):
        if testid == 0:
            return self.toTest.getIdentifiers()
        elif testid == 1:
            return self.toDevMgr.getIdentifiers()
        else:
            raise CF.TestableObject.UnknownTest('unknown test: ' + str(id))
        return []

    def allocate_memCapacity(self, value):
        if self.memCapacity < value:
            return False
        self.memCapacity = self.memCapacity - value
        return True

    def allocate_BogoMipsCapacity(self, value):
        if self.BogoMipsCapacity < value:
            return False
        self.BogoMipsCapacity = self.BogoMipsCapacity - value
        return True

    def deallocate_memCapacity(self, value):
        self.memCapacity = self.memCapacity + value

    def deallocate_BogoMipsCapacity(self, value):
        self.BogoMipsCapacity = self.BogoMipsCapacity + value

    def updateUsageState(self):
        # Update usage state
        if self.memCapacity == 0 and self.BogoMipsCapacity == 0:
            self._usageState = CF.Device.BUSY
        elif self.memCapacity == 100000000 and self.BogoMipsCapacity == 100000000:
            self._usageState = CF.Device.IDLE
        else:
            self._usageState = CF.Device.ACTIVE
class cf_1535_p1_base(CF__POA.Resource, Component, ThreadedComponent):
        # These values can be altered in the __init__ of your derived class

        PAUSE = 0.0125 # The amount of time to sleep if process return NOOP
        TIMEOUT = 5.0 # The amount of time to wait for the process thread to die when stop() is called
        DEFAULT_QUEUE_SIZE = 100 # The number of BulkIO packets that can be in the queue before pushPacket will block

        def __init__(self, identifier, execparams):
            loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0]
            Component.__init__(self, identifier, execparams, loggerName=loggerName)
            ThreadedComponent.__init__(self)

            # self.auto_start is deprecated and is only kept for API compatibility
            # with 1.7.X and 1.8.0 components.  This variable may be removed
            # in future releases
            self.auto_start = False
            # Instantiate the default implementations for all ports on this component
            self.port_d1 = bulkio.InLongPort("d1", maxsize=self.DEFAULT_QUEUE_SIZE)
            self.port_d3 = bulkio.OutLongPort("d3")

        def start(self):
            Component.start(self)
            ThreadedComponent.startThread(self, pause=self.PAUSE)

        def stop(self):
            Component.stop(self)
            if not ThreadedComponent.stopThread(self, self.TIMEOUT):
                raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die")

        def releaseObject(self):
            try:
                self.stop()
            except Exception:
                self._log.exception("Error stopping")
            Component.releaseObject(self)

        ######################################################################
        # PORTS
        # 
        # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file, 
        # or via the IDE.

        port_d1 = providesport(name="d1",
                               repid="IDL:BULKIO/dataLong:1.0",
                               type_="data")

        port_d3 = usesport(name="d3",
                           repid="IDL:BULKIO/dataLong:1.0",
                           type_="data")

        ######################################################################
        # PROPERTIES
        # 
        # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
        # or by using the IDE.
        p1 = simple_property(id_="p1",
                             name="p1",
                             type_="string",
                             mode="readwrite",
                             action="external",
                             kinds=("property",),
                             description="""can you dig it { ( [""")


        window = simple_property(id_="window",
                                 name="window",
                                 type_="string",
                                 mode="readwrite",
                                 action="external",
                                 kinds=("property",))


        freq = simple_property(id_="freq",
                               name="freq",
                               type_="float",
                               defvalue=0.0,
                               mode="readwrite",
                               action="external",
                               kinds=("property",))


        s1 = simpleseq_property(id_="s1",
                                name="s1",
                                type_="long",
                                defvalue=[],
                                mode="readwrite",
                                action="external",
                                kinds=("property",))


        class St1(object):
            a1 = simple_property(
                                 id_="st1::a1",
                                 name="a1",
                                 type_="string")
        
            b1 = simple_property(
                                 id_="st1::b1",
                                 name="b1",
                                 type_="float")
        
            def __init__(self, **kw):
                """Construct an initialized instance of this struct definition"""
                for classattr in type(self).__dict__.itervalues():
                    if isinstance(classattr, (simple_property, simpleseq_property)):
                        classattr.initialize(self)
                for k,v in kw.items():
                    setattr(self,k,v)
        
            def __str__(self):
                """Return a string representation of this structure"""
                d = {}
                d["a1"] = self.a1
                d["b1"] = self.b1
                return str(d)
        
            @classmethod
            def getId(cls):
                return "st1"
        
            @classmethod
            def isStruct(cls):
                return True
        
            def getMembers(self):
                return [("a1",self.a1),("b1",self.b1)]

        st1 = struct_property(id_="st1",
                              name="st1",
                              structdef=St1,
                              configurationkind=("property",),
                              mode="readwrite")


        class Ss1St1(object):
            a1 = simple_property(
                                 id_="ss1::st1::a1",
                                 name="a1",
                                 type_="string")
        
            b1 = simple_property(
                                 id_="ss1::st1::b1",
                                 name="b1",
                                 type_="float")
        
            def __init__(self, a1="", b1=0.0):
                self.a1 = a1
                self.b1 = b1
        
            def __str__(self):
                """Return a string representation of this structure"""
                d = {}
                d["a1"] = self.a1
                d["b1"] = self.b1
                return str(d)
        
            @classmethod
            def getId(cls):
                return "ss1::st1"
        
            @classmethod
            def isStruct(cls):
                return True
        
            def getMembers(self):
                return [("a1",self.a1),("b1",self.b1)]

        ss1 = structseq_property(id_="ss1",
                                 name="ss1",
                                 structdef=Ss1St1,
                                 defvalue=[],
                                 configurationkind=("property",),
                                 mode="readwrite")
class Python_Ports_base(CF__POA.Resource, Resource):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Resource.__init__(self, identifier, execparams, loggerName=loggerName)
        self.threadControlLock = threading.RLock()
        self.process_thread = None
        # self.auto_start is deprecated and is only kept for API compatability
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False

    def initialize(self):
        Resource.initialize(self)

        self.port_dataCharIn = bulkio.InCharPort("dataCharIn")
        self.port_dataOctetIn = bulkio.InOctetPort("dataOctetIn")
        self.port_dataShortIn = bulkio.InShortPort("dataShortIn")
        self.port_dataUShortIn = bulkio.InUShortPort("dataUShortIn")
        self.port_dataLongIn = bulkio.InLongPort("dataLongIn")
        self.port_dataULongIn = bulkio.InULongPort("dataULongIn")
        self.port_dataLongLongIn = bulkio.InLongLongPort("dataLongLongIn")
        self.port_dataULongLongIn = bulkio.InULongLongPort("dataULongLongIn")
        self.port_dataFloatIn = bulkio.InFloatPort("dataFloatIn")
        self.port_dataDoubleIn = bulkio.InDoublePort("dataDoubleIn")
        self.port_dataFileIn = bulkio.InFilePort("dataFileIn")
        self.port_dataXMLIn = bulkio.InXMLPort("dataXMLIn")
        self.port_dataSDDSIn = bulkio.InSDDSPort("dataSDDSIn")

        self.port_dataCharOut = bulkio.OutCharPort("dataCharOut")
        self.port_dataOctetOut = bulkio.OutOctetPort("dataOctetOut")
        self.port_dataShortOut = bulkio.OutShortPort("dataShortOut")
        self.port_dataUShortOut = bulkio.OutUShortPort("dataUShortOut")
        self.port_dataLongOut = bulkio.OutLongPort("dataLongOut")
        self.port_dataULongOut = bulkio.OutULongPort("dataULongOut")
        self.port_dataLongLongOut = bulkio.OutLongLongPort("dataLongLongOut")
        self.port_dataULongLongOut = bulkio.OutULongLongPort(
            "dataULongLongOut")
        self.port_dataFloatOut = bulkio.OutFloatPort("dataFloatOut")
        self.port_dataDoubleOut = bulkio.OutDoublePort("dataDoubleOut")
        self.port_dataFileOut = bulkio.OutFilePort("dataFileOut")
        self.port_dataXMLOut = bulkio.OutXMLPort("dataXMLOut")
        self.port_dataSDDSOut = bulkio.OutSDDSPort("dataSDDSOut")

        self.port_propEvent = PropertyEventSupplier(self)

    def start(self):
        self.threadControlLock.acquire()
        try:
            Resource.start(self)
            if self.process_thread == None:
                self.process_thread = ProcessThread(target=self.process,
                                                    pause=self.PAUSE)
                self.process_thread.start()
        finally:
            self.threadControlLock.release()

    def process(self):
        """The process method should process a single "chunk" of data and then return.  This method will be called
            from the processing thread again, and again, and again until it returns FINISH or stop() is called on the
            component.  If no work is performed, then return NOOP"""
        raise NotImplementedError

    def stop(self):
        self.threadControlLock.acquire()
        try:
            process_thread = self.process_thread
            self.process_thread = None

            if process_thread != None:
                process_thread.stop()
                process_thread.join(self.TIMEOUT)
                if process_thread.isAlive():
                    raise CF.Resource.StopError(
                        CF.CF_NOTSET, "Processing thread did not die")
            Resource.stop(self)
        finally:
            self.threadControlLock.release()

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        self.threadControlLock.acquire()
        try:
            Resource.releaseObject(self)
        finally:
            self.threadControlLock.release()

    port_dataCharIn = providesport(
        name="dataCharIn",
        repid="IDL:BULKIO/dataChar:1.0",
        type_="control",
    )

    port_dataOctetIn = providesport(
        name="dataOctetIn",
        repid="IDL:BULKIO/dataOctet:1.0",
        type_="control",
    )

    port_dataShortIn = providesport(
        name="dataShortIn",
        repid="IDL:BULKIO/dataShort:1.0",
        type_="control",
    )

    port_dataUShortIn = providesport(
        name="dataUShortIn",
        repid="IDL:BULKIO/dataUshort:1.0",
        type_="control",
    )

    port_dataLongIn = providesport(
        name="dataLongIn",
        repid="IDL:BULKIO/dataLong:1.0",
        type_="control",
    )

    port_dataULongIn = providesport(
        name="dataULongIn",
        repid="IDL:BULKIO/dataUlong:1.0",
        type_="control",
    )

    port_dataLongLongIn = providesport(
        name="dataLongLongIn",
        repid="IDL:BULKIO/dataLongLong:1.0",
        type_="control",
    )

    port_dataULongLongIn = providesport(
        name="dataULongLongIn",
        repid="IDL:BULKIO/dataUlongLong:1.0",
        type_="control",
    )

    port_dataFloatIn = providesport(
        name="dataFloatIn",
        repid="IDL:BULKIO/dataFloat:1.0",
        type_="control",
    )

    port_dataDoubleIn = providesport(
        name="dataDoubleIn",
        repid="IDL:BULKIO/dataDouble:1.0",
        type_="control",
    )

    port_dataFileIn = providesport(
        name="dataFileIn",
        repid="IDL:BULKIO/dataFile:1.0",
        type_="control",
    )

    port_dataXMLIn = providesport(
        name="dataXMLIn",
        repid="IDL:BULKIO/dataXML:1.0",
        type_="control",
    )

    port_dataSDDSIn = providesport(
        name="dataSDDSIn",
        repid="IDL:BULKIO/dataSDDS:1.0",
        type_="data",
    )

    port_dataCharOut = usesport(
        name="dataCharOut",
        repid="IDL:BULKIO/dataChar:1.0",
        type_="control",
    )

    port_dataOctetOut = usesport(
        name="dataOctetOut",
        repid="IDL:BULKIO/dataOctet:1.0",
        type_="control",
    )

    port_dataShortOut = usesport(
        name="dataShortOut",
        repid="IDL:BULKIO/dataShort:1.0",
        type_="control",
    )

    port_dataUShortOut = usesport(
        name="dataUShortOut",
        repid="IDL:BULKIO/dataUshort:1.0",
        type_="control",
    )

    port_dataLongOut = usesport(
        name="dataLongOut",
        repid="IDL:BULKIO/dataLong:1.0",
        type_="control",
    )

    port_dataULongOut = usesport(
        name="dataULongOut",
        repid="IDL:BULKIO/dataUlong:1.0",
        type_="control",
    )

    port_dataLongLongOut = usesport(
        name="dataLongLongOut",
        repid="IDL:BULKIO/dataLongLong:1.0",
        type_="control",
    )

    port_dataULongLongOut = usesport(
        name="dataULongLongOut",
        repid="IDL:BULKIO/dataUlongLong:1.0",
        type_="control",
    )

    port_dataFloatOut = usesport(
        name="dataFloatOut",
        repid="IDL:BULKIO/dataFloat:1.0",
        type_="control",
    )

    port_dataDoubleOut = usesport(
        name="dataDoubleOut",
        repid="IDL:BULKIO/dataDouble:1.0",
        type_="control",
    )

    port_dataFileOut = usesport(
        name="dataFileOut",
        repid="IDL:BULKIO/dataFile:1.0",
        type_="control",
    )

    port_dataXMLOut = usesport(
        name="dataXMLOut",
        repid="IDL:BULKIO/dataXML:1.0",
        type_="control",
    )

    port_dataSDDSOut = usesport(
        name="dataSDDSOut",
        repid="IDL:BULKIO/dataSDDS:1.0",
        type_="control",
    )

    port_propEvent = usesport(
        name="propEvent",
        repid="IDL:omg.org/CosEventChannelAdmin/EventChannel:1.0",
        type_="responses",
    )
示例#8
0
class multiout_attachable_base(CF__POA.Resource, Resource, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Resource.__init__(self, identifier, execparams, loggerName=loggerName)
        ThreadedComponent.__init__(self)

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this component
        self.port_dataSDDS_in = bulkio.InSDDSPort("dataSDDS_in")
        self.port_dataVITA49_in = bulkio.InVITA49Port("dataVITA49_in")
        self.port_dataFloat_in = bulkio.InFloatPort(
            "dataFloat_in", maxsize=self.DEFAULT_QUEUE_SIZE)
        self.port_dataSDDS_out = bulkio.OutSDDSPort("dataSDDS_out")
        self.port_dataVITA49_out = bulkio.OutVITA49Port("dataVITA49_out")
        self.addPropertyChangeListener('connectionTable',
                                       self.updated_connectionTable)

    def start(self):
        Resource.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def updated_connectionTable(self, id, oldval, newval):
        self.port_dataSDDS_out.updateConnectionFilter(newval)
        self.port_dataVITA49_out.updateConnectionFilter(newval)

    def stop(self):
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")
        Resource.stop(self)

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        Resource.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_dataSDDS_in = providesport(name="dataSDDS_in",
                                    repid="IDL:BULKIO/dataSDDS:1.0",
                                    type_="control")

    port_dataVITA49_in = providesport(name="dataVITA49_in",
                                      repid="IDL:BULKIO/dataVITA49:1.0",
                                      type_="control")

    port_dataFloat_in = providesport(name="dataFloat_in",
                                     repid="IDL:BULKIO/dataFloat:1.0",
                                     type_="control")

    port_dataSDDS_out = usesport(name="dataSDDS_out",
                                 repid="IDL:BULKIO/dataSDDS:1.0",
                                 type_="control")

    port_dataVITA49_out = usesport(name="dataVITA49_out",
                                   repid="IDL:BULKIO/dataVITA49:1.0",
                                   type_="control")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    packets_ingested = simple_property(id_="packets_ingested",
                                       name="packets_ingested",
                                       type_="ushort",
                                       defvalue=0,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))

    class CallbackStats(object):
        num_sdds_attaches = simple_property(id_="num_sdds_attaches",
                                            type_="ushort")

        num_sdds_detaches = simple_property(id_="num_sdds_detaches",
                                            type_="ushort")

        num_vita49_attaches = simple_property(id_="num_vita49_attaches",
                                              type_="ushort")

        num_vita49_detaches = simple_property(id_="num_vita49_detaches",
                                              type_="ushort")

        num_new_sri_callbacks = simple_property(id_="num_new_sri_callbacks",
                                                type_="ushort")

        num_sri_change_callbacks = simple_property(
            id_="num_sri_change_callbacks", type_="ushort")

        def __init__(self, **kw):
            """Construct an initialized instance of this struct definition"""
            for attrname, classattr in type(self).__dict__.items():
                if type(classattr) == simple_property:
                    classattr.initialize(self)
            for k, v in kw.items():
                setattr(self, k, v)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["num_sdds_attaches"] = self.num_sdds_attaches
            d["num_sdds_detaches"] = self.num_sdds_detaches
            d["num_vita49_attaches"] = self.num_vita49_attaches
            d["num_vita49_detaches"] = self.num_vita49_detaches
            d["num_new_sri_callbacks"] = self.num_new_sri_callbacks
            d["num_sri_change_callbacks"] = self.num_sri_change_callbacks
            return str(d)

        def getId(self):
            return "callback_stats"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("num_sdds_attaches", self.num_sdds_attaches),
                    ("num_sdds_detaches", self.num_sdds_detaches),
                    ("num_vita49_attaches", self.num_vita49_attaches),
                    ("num_vita49_detaches", self.num_vita49_detaches),
                    ("num_new_sri_callbacks", self.num_new_sri_callbacks),
                    ("num_sri_change_callbacks", self.num_sri_change_callbacks)
                    ]

    callback_stats = struct_property(id_="callback_stats",
                                     structdef=CallbackStats,
                                     configurationkind=("configure", ),
                                     mode="readwrite")

    connectionTable = structseq_property(
        id_="connectionTable",
        structdef=bulkio.connection_descriptor_struct,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")

    class SDDSStreamDefinition(object):
        id = simple_property(id_="sdds::id", name="id", type_="string")

        multicastAddress = simple_property(id_="sdds::multicastAddress",
                                           name="multicastAddress",
                                           type_="string",
                                           defvalue="0.0.0.0")

        vlan = simple_property(id_="sdds::vlan", name="vlan", type_="ulong")

        port = simple_property(id_="sdds::port", name="port", type_="ulong")

        sampleRate = simple_property(id_="sdds::sampleRate",
                                     name="sampleRate",
                                     type_="ulong")

        timeTagValid = simple_property(id_="sdds::timeTagValid",
                                       name="timeTagValid",
                                       type_="boolean")

        privateInfo = simple_property(id_="sdds::privateInfo",
                                      name="privateInfo",
                                      type_="string")

        def __init__(self,
                     id="",
                     multicastAddress="0.0.0.0",
                     vlan=0,
                     port=0,
                     sampleRate=0,
                     timeTagValid=False,
                     privateInfo=""):
            self.id = id
            self.multicastAddress = multicastAddress
            self.vlan = vlan
            self.port = port
            self.sampleRate = sampleRate
            self.timeTagValid = timeTagValid
            self.privateInfo = privateInfo

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["id"] = self.id
            d["multicastAddress"] = self.multicastAddress
            d["vlan"] = self.vlan
            d["port"] = self.port
            d["sampleRate"] = self.sampleRate
            d["timeTagValid"] = self.timeTagValid
            d["privateInfo"] = self.privateInfo
            return str(d)

        def getId(self):
            return "SDDSStreamDefinition"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("id", self.id),
                    ("multicastAddress", self.multicastAddress),
                    ("vlan", self.vlan), ("port", self.port),
                    ("sampleRate", self.sampleRate),
                    ("timeTagValid", self.timeTagValid),
                    ("privateInfo", self.privateInfo)]

    SDDSStreamDefinitions = structseq_property(
        id_="SDDSStreamDefinitions",
        structdef=SDDSStreamDefinition,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")

    class VITA49StreamDefinition(object):
        id = simple_property(id_="vita49::id", name="id", type_="string")

        ip_address = simple_property(id_="vita49::ip_address",
                                     name="ip_address",
                                     type_="string",
                                     defvalue="0.0.0.0")

        vlan = simple_property(id_="vita49::vlan", name="vlan", type_="ulong")

        port = simple_property(id_="vita49::port", name="port", type_="ulong")

        valid_data_format = simple_property(id_="vita49::valid_data_format",
                                            name="valid_data_format",
                                            type_="boolean")

        packing_method_processing_efficient = simple_property(
            id_="vita49::packing_method_processing_efficient",
            name="packing_method_processing_efficient",
            type_="boolean")

        repeating = simple_property(id_="vita49::repeating",
                                    name="repeating",
                                    type_="boolean")

        event_tag_size = simple_property(id_="vita49::event_tag_size",
                                         name="event_tag_size",
                                         type_="long")

        channel_tag_size = simple_property(id_="vita49::channel_tag_size",
                                           name="channel_tag_size",
                                           type_="long")

        item_packing_field_size = simple_property(
            id_="vita49::item_packing_field_size",
            name="item_packing_field_size",
            type_="long")

        data_item_size = simple_property(id_="vita49::data_item_size",
                                         name="data_item_size",
                                         type_="long")

        repeat_count = simple_property(id_="vita49::repeat_count",
                                       name="repeat_count",
                                       type_="long")

        vector_size = simple_property(id_="vita49::vector_size",
                                      name="vector_size",
                                      type_="long")

        def __init__(self,
                     id="",
                     ip_address="0.0.0.0",
                     vlan=0,
                     port=0,
                     valid_data_format=False,
                     packing_method_processing_efficient=False,
                     repeating=False,
                     event_tag_size=0,
                     channel_tag_size=0,
                     item_packing_field_size=0,
                     data_item_size=0,
                     repeat_count=0,
                     vector_size=0):
            self.id = id
            self.ip_address = ip_address
            self.vlan = vlan
            self.port = port
            self.valid_data_format = valid_data_format
            self.packing_method_processing_efficient = packing_method_processing_efficient
            self.repeating = repeating
            self.event_tag_size = event_tag_size
            self.channel_tag_size = channel_tag_size
            self.item_packing_field_size = item_packing_field_size
            self.data_item_size = data_item_size
            self.repeat_count = repeat_count
            self.vector_size = vector_size

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["id"] = self.id
            d["ip_address"] = self.ip_address
            d["vlan"] = self.vlan
            d["port"] = self.port
            d["valid_data_format"] = self.valid_data_format
            d["packing_method_processing_efficient"] = self.packing_method_processing_efficient
            d["repeating"] = self.repeating
            d["event_tag_size"] = self.event_tag_size
            d["channel_tag_size"] = self.channel_tag_size
            d["item_packing_field_size"] = self.item_packing_field_size
            d["data_item_size"] = self.data_item_size
            d["repeat_count"] = self.repeat_count
            d["vector_size"] = self.vector_size
            return str(d)

        def getId(self):
            return "VITA49StreamDefinition"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("id", self.id), ("ip_address", self.ip_address),
                    ("vlan", self.vlan), ("port", self.port),
                    ("valid_data_format", self.valid_data_format),
                    ("packing_method_processing_efficient",
                     self.packing_method_processing_efficient),
                    ("repeating", self.repeating),
                    ("event_tag_size", self.event_tag_size),
                    ("channel_tag_size", self.channel_tag_size),
                    ("item_packing_field_size", self.item_packing_field_size),
                    ("data_item_size", self.data_item_size),
                    ("repeat_count", self.repeat_count),
                    ("vector_size", self.vector_size)]

    VITA49StreamDefinitions = structseq_property(
        id_="VITA49StreamDefinitions",
        structdef=VITA49StreamDefinition,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")

    class SddsAttachment(object):
        streamId = simple_property(id_="sdds::streamId",
                                   name="streamId",
                                   type_="string")

        attachId = simple_property(id_="sdds::attachId",
                                   name="attachId",
                                   type_="string")

        port = simple_property(id_="sdds::rec_port",
                               name="port",
                               type_="ulong")

        def __init__(self, streamId="", attachId="", port=0):
            self.streamId = streamId
            self.attachId = attachId
            self.port = port

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["streamId"] = self.streamId
            d["attachId"] = self.attachId
            d["port"] = self.port
            return str(d)

        def getId(self):
            return "sdds_attachment"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("streamId", self.streamId), ("attachId", self.attachId),
                    ("port", self.port)]

    received_sdds_attachments = structseq_property(
        id_="received_sdds_attachments",
        structdef=SddsAttachment,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")

    class Vita49Attachment(object):
        streamId = simple_property(id_="vita49::streamId",
                                   name="streamId",
                                   type_="string")

        attachId = simple_property(id_="vita49::attachId",
                                   name="attachId",
                                   type_="string")

        port = simple_property(id_="vita49::rec_port",
                               name="port",
                               type_="ulong")

        def __init__(self, streamId="", attachId="", port=0):
            self.streamId = streamId
            self.attachId = attachId
            self.port = port

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["streamId"] = self.streamId
            d["attachId"] = self.attachId
            d["port"] = self.port
            return str(d)

        def getId(self):
            return "vita49_attachment"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("streamId", self.streamId), ("attachId", self.attachId),
                    ("port", self.port)]

    received_vita49_attachments = structseq_property(
        id_="received_vita49_attachments",
        structdef=Vita49Attachment,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")
示例#9
0
class control_writes_base(CF__POA.Resource, Component, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Component.__init__(self, identifier, execparams, loggerName=loggerName)
        ThreadedComponent.__init__(self)

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this component
        self.port_request = MessageConsumerPort(thread_sleep=0.1, parent=self)
        self.port_file_io_status = MessageConsumerPort(thread_sleep=0.1,
                                                       parent=self)
        self.port_response = MessageSupplierPort()

    def start(self):
        Component.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        Component.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        Component.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_request = providesport(name="request",
                                repid="IDL:ExtendedEvent/MessageEvent:1.0",
                                type_="control")

    port_file_io_status = providesport(
        name="file_io_status",
        repid="IDL:ExtendedEvent/MessageEvent:1.0",
        type_="control")

    port_response = usesport(name="response",
                             repid="IDL:ExtendedEvent/MessageEvent:1.0",
                             type_="control")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    ageoff = simple_property(id_="ageoff",
                             type_="float",
                             defvalue=600.0,
                             mode="readwrite",
                             action="external",
                             kinds=("property", ),
                             description="""seconds""")

    class CutRequest(object):
        time_begin = simple_property(id_="cut_request::time_begin",
                                     name="time_begin",
                                     type_="double")

        time_end = simple_property(id_="cut_request::time_end",
                                   name="time_end",
                                   type_="double")

        freq_begin = simple_property(id_="cut_request::freq_begin",
                                     name="freq_begin",
                                     type_="double")

        freq_end = simple_property(id_="cut_request::freq_end",
                                   name="freq_end",
                                   type_="double")

        request_id = simple_property(id_="cut_request::request_id",
                                     name="request_id",
                                     type_="string")

        def __init__(self, **kw):
            """Construct an initialized instance of this struct definition"""
            for classattr in type(self).__dict__.itervalues():
                if isinstance(classattr,
                              (simple_property, simpleseq_property)):
                    classattr.initialize(self)
            for k, v in kw.items():
                setattr(self, k, v)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["time_begin"] = self.time_begin
            d["time_end"] = self.time_end
            d["freq_begin"] = self.freq_begin
            d["freq_end"] = self.freq_end
            d["request_id"] = self.request_id
            return str(d)

        @classmethod
        def getId(cls):
            return "cut_request"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [
                ("time_begin", self.time_begin), ("time_end", self.time_end),
                ("freq_begin", self.freq_begin), ("freq_end", self.freq_end),
                ("request_id", self.request_id)
            ]

    cut_request = struct_property(id_="cut_request",
                                  structdef=CutRequest,
                                  configurationkind=("message", ),
                                  mode="readwrite")

    class CutResponse(object):
        request_id = simple_property(id_="cut_response::request_id",
                                     name="request_id",
                                     type_="string")

        file_location = simple_property(id_="cut_response::file_location",
                                        name="file_location",
                                        type_="string")

        def __init__(self, **kw):
            """Construct an initialized instance of this struct definition"""
            for classattr in type(self).__dict__.itervalues():
                if isinstance(classattr,
                              (simple_property, simpleseq_property)):
                    classattr.initialize(self)
            for k, v in kw.items():
                setattr(self, k, v)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["request_id"] = self.request_id
            d["file_location"] = self.file_location
            return str(d)

        @classmethod
        def getId(cls):
            return "cut_response"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("request_id", self.request_id),
                    ("file_location", self.file_location)]

    cut_response = struct_property(id_="cut_response",
                                   structdef=CutResponse,
                                   configurationkind=("message", ),
                                   mode="readwrite")

    class FileIoMessage(object):
        file_operation = simple_property(id_="file_io_message::file_operation",
                                         name="file_operation",
                                         type_="string",
                                         defvalue="OPEN")

        stream_id = simple_property(id_="file_io_message::stream_id",
                                    name="stream_id",
                                    type_="string")

        filename = simple_property(id_="file_io_message::filename",
                                   name="filename",
                                   type_="string")

        def __init__(self, **kw):
            """Construct an initialized instance of this struct definition"""
            for classattr in type(self).__dict__.itervalues():
                if isinstance(classattr,
                              (simple_property, simpleseq_property)):
                    classattr.initialize(self)
            for k, v in kw.items():
                setattr(self, k, v)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["file_operation"] = self.file_operation
            d["stream_id"] = self.stream_id
            d["filename"] = self.filename
            return str(d)

        @classmethod
        def getId(cls):
            return "file_io_message"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("file_operation", self.file_operation),
                    ("stream_id", self.stream_id), ("filename", self.filename)]

    file_io_message = struct_property(
        id_="file_io_message",
        structdef=FileIoMessage,
        configurationkind=("message", ),
        mode="readwrite",
        description="""The structure representing a file IO message.""")
示例#10
0
                raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die")

        def releaseObject(self):
            try:
                self.stop()
            except Exception:
                self._log.exception("Error stopping")
            Component.releaseObject(self)

        ######################################################################
        # PORTS
        # 
        # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file, 
        # or via the IDE.

        port_in = providesport(name="in",
                               repid="IDL:BULKIO/dataFloat:1.0",
                               type_="data")

        port_out = usesport(name="out",
                            repid="IDL:BULKIO/dataFloat:1.0",
                            type_="data")

        ######################################################################
        # PROPERTIES
        # 
        # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
        # or by using the IDE.


示例#11
0
class analogTuner_base(CF__POA.Device, FrontendTunerDevice,
                       analog_tuner_delegation, rfinfo_delegation,
                       ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        FrontendTunerDevice.__init__(self, devmgr, uuid, label,
                                     softwareProfile, compositeDevice,
                                     execparams)
        ThreadedComponent.__init__(self)

        self.listeners = {}
        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 devices.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this device
        self.port_RFInfo_in = frontend.InRFInfoPort("RFInfo_in")
        self.port_AnalogTuner_in = frontend.InAnalogTunerPort("AnalogTuner_in")
        self.port_RFInfo_out = frontend.OutRFInfoPort("RFInfo_out")
        self.device_kind = "FRONTEND::TUNER"
        self.frontend_listener_allocation = frontend.fe_types.frontend_listener_allocation(
        )
        self.frontend_tuner_allocation = frontend.fe_types.frontend_tuner_allocation(
        )

    def start(self):
        FrontendTunerDevice.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        FrontendTunerDevice.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        FrontendTunerDevice.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_RFInfo_in = providesport(name="RFInfo_in",
                                  repid="IDL:FRONTEND/RFInfo:1.0",
                                  type_="data")

    port_AnalogTuner_in = providesport(name="AnalogTuner_in",
                                       repid="IDL:FRONTEND/AnalogTuner:1.0",
                                       type_="control")

    port_RFInfo_out = usesport(name="RFInfo_out",
                               repid="IDL:FRONTEND/RFInfo:1.0",
                               type_="data")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    class frontend_tuner_status_struct_struct(
            frontend.default_frontend_tuner_status_struct_struct):
        def __init__(self,
                     allocation_id_csv="",
                     bandwidth=0.0,
                     center_frequency=0.0,
                     enabled=False,
                     group_id="",
                     rf_flow_id="",
                     sample_rate=0.0,
                     tuner_type=""):
            frontend.default_frontend_tuner_status_struct_struct.__init__(
                self,
                allocation_id_csv=allocation_id_csv,
                bandwidth=bandwidth,
                center_frequency=center_frequency,
                enabled=enabled,
                group_id=group_id,
                rf_flow_id=rf_flow_id,
                sample_rate=sample_rate,
                tuner_type=tuner_type)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["allocation_id_csv"] = self.allocation_id_csv
            d["bandwidth"] = self.bandwidth
            d["center_frequency"] = self.center_frequency
            d["enabled"] = self.enabled
            d["group_id"] = self.group_id
            d["rf_flow_id"] = self.rf_flow_id
            d["sample_rate"] = self.sample_rate
            d["tuner_type"] = self.tuner_type
            return str(d)

        @classmethod
        def getId(cls):
            return "FRONTEND::tuner_status_struct"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return frontend.default_frontend_tuner_status_struct_struct.getMembers(
                self) + []

    # Rebind tuner status property with custom struct definition
    frontend_tuner_status = FrontendTunerDevice.frontend_tuner_status.rebind()
    frontend_tuner_status.structdef = frontend_tuner_status_struct_struct

    def frontendTunerStatusChanged(self, oldValue, newValue):
        pass

    def getTunerStatus(self, allocation_id):
        tuner_id = self.getTunerMapping(allocation_id)
        if tuner_id < 0:
            raise FRONTEND.FrontendException(
                ("ERROR: ID: " + str(allocation_id) +
                 " IS NOT ASSOCIATED WITH ANY TUNER!"))
        return [
            CF.DataType(id=self.frontend_tuner_status[tuner_id].getId(),
                        value=self.frontend_tuner_status[tuner_id]._toAny())
        ]

    def assignListener(self, listen_alloc_id, allocation_id):
        # find control allocation_id
        existing_alloc_id = allocation_id
        if self.listeners.has_key(existing_alloc_id):
            existing_alloc_id = self.listeners[existing_alloc_id]
        self.listeners[listen_alloc_id] = existing_alloc_id

    def removeListener(self, listen_alloc_id):
        if self.listeners.has_key(listen_alloc_id):
            del self.listeners[listen_alloc_id]

    def removeAllocationIdRouting(self, tuner_id):
        pass
示例#12
0
class ExampleComponent_base(CF__POA.Resource, Resource):
        # These values can be altered in the __init__ of your derived class

        PAUSE = 0.0125 # The amount of time to sleep if process return NOOP
        TIMEOUT = 5.0 # The amount of time to wait for the process thread to die when stop() is called
        DEFAULT_QUEUE_SIZE = 100 # The number of BulkIO packets that can be in the queue before pushPacket will block
        
        def __init__(self, identifier, execparams):
            loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0]
            Resource.__init__(self, identifier, execparams, loggerName=loggerName)
            self.process_thread = None
            self.auto_start = False
            
        def initialize(self):
            Resource.initialize(self)
            
            # Instantiate the default implementations for all ports on this component
            self.port_inputPort = PortBULKIODataFloatIn_i(self, "inputPort", self.DEFAULT_QUEUE_SIZE)

            self.port_outputPort = PortBULKIODataFloatOut_i(self, "outputPort")

        def start(self):
            Resource.start(self)
            if self.process_thread == None:
                self.process_thread = ProcessThread(target=self.process, pause=self.PAUSE)
                self.process_thread.start()

        def process(self):
            """The process method should process a single "chunk" of data and then return.  This method will be called
            from the processing thread again, and again, and again until it returns FINISH or stop() is called on the
            component.  If no work is performed, then return NOOP"""
            raise NotImplementedError

        def stop(self):
            # Technically not thread-safe but close enough for now
            process_thread = self.process_thread
            self.process_thread = None

            if process_thread != None:
                process_thread.stop()
                process_thread.join(self.TIMEOUT)
                if process_thread.isAlive():
                    raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die")
            Resource.stop(self)

        def releaseObject(self):
            try:
                self.stop()
            except Exception:
                self._log.exception("Error stopping")
            Resource.releaseObject(self)

        ######################################################################
        # PORTS
        # 
        # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file, 
        # or via the IDE.
        
        def compareSRI(self, a, b):
            if a.hversion != b.hversion:
                return False
            if a.xstart != b.xstart:
                return False
            if a.xdelta != b.xdelta:
                return False
            if a.xunits != b.xunits:
                return False
            if a.subsize != b.subsize:
                return False
            if a.ystart != b.ystart:
                return False
            if a.ydelta != b.ydelta:
                return False
            if a.yunits != b.yunits:
                return False
            if a.mode != b.mode:
                return False
            if a.streamID != b.streamID:
                return False
            if a.blocking != b.blocking:
                return False
            if len(a.keywords) != len(b.keywords):
                return False
            for keyA, keyB in zip(a.keywords, b.keywords):
                if keyA.value._t != keyB.value._t:
                    return False
                if keyA.value._v != keyB.value._v:
                    return False
            return True

        # 'BULKIO/dataFloat' port
        class PortBULKIODataFloatIn(BULKIO__POA.dataFloat):
            """This class is a port template for the inputPort port and
            should not be instantiated nor modified.
            
            The expectation is that the specific port implementation will extend 
            from this class instead of the base CORBA class BULKIO__POA.dataFloat.
            """
            pass


        # 'BULKIO/dataFloat' port
        class PortBULKIODataFloatOut(BULKIO__POA.UsesPortStatisticsProvider):
            """This class is a port template for the outputPort port and
            should not be instantiated nor modified.
            
            The expectation is that the specific port implementation will extend 
            from this class instead of the base CORBA class CF__POA.Port.
            """
            pass

        port_inputPort = providesport(name="inputPort",
                                            repid="IDL:BULKIO/dataFloat:1.0",
                                            type_="data",)

        port_outputPort = usesport(name="outputPort",
                                            repid="IDL:BULKIO/dataFloat:1.0",
                                            type_="data",)        

        ######################################################################
        # PROPERTIES
        # 
        # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
        # or by using the IDE.       
        frequency = simple_property(id_="frequency",
                                          type_="float",
                                          units="Hz", 
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        samples = simple_property(id_="samples",
                                          type_="long",
                                          defvalue=3,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )
示例#13
0
class PropertyApi_base(CF__POA.Resource, Component, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Component.__init__(self, identifier, execparams, loggerName=loggerName)
        ThreadedComponent.__init__(self)

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this component
        self.port_dataFloat_in = bulkio.InFloatPort(
            "dataFloat_in", maxsize=self.DEFAULT_QUEUE_SIZE)
        self.port_dataFloat_in._portLog = self._baseLog.getChildLogger(
            'dataFloat_in', 'ports')
        self.port_dataFloat_out = bulkio.OutFloatPort("dataFloat_out")
        self.port_dataFloat_out._portLog = self._baseLog.getChildLogger(
            'dataFloat_out', 'ports')

    def start(self):
        Component.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        Component.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._baseLog.exception("Error stopping")
        Component.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_dataFloat_in = providesport(name="dataFloat_in",
                                     repid="IDL:BULKIO/dataFloat:1.0",
                                     type_="data")

    port_dataFloat_out = usesport(name="dataFloat_out",
                                  repid="IDL:BULKIO/dataFloat:1.0",
                                  type_="data")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    simp_seq_c = simpleseq_property(id_="simp_seq_c",
                                    name="simp_seq_c",
                                    type_="string",
                                    defvalue=["c_1", "c_2"],
                                    mode="readwrite",
                                    action="external",
                                    kinds=("property", ))

    simp_seq_d = simpleseq_property(id_="simp_seq_d",
                                    name="simp_seq_d",
                                    type_="string",
                                    defvalue=["d_1", "d_2"],
                                    mode="readwrite",
                                    action="external",
                                    kinds=("property", ))

    class StructA(object):
        simple_a = simple_property(id_="struct_a::simple_a",
                                   name="simple_a",
                                   type_="string",
                                   defvalue="simp_a")

        simpseq_a1 = simpleseq_property(id_="struct_a::simpseq_a1",
                                        name="simpseq_a1",
                                        type_="string",
                                        defvalue=["a1_1", "a2_2"])

        simpseq_a2 = simpleseq_property(id_="struct_a::simpseq_a2",
                                        name="simpseq_a2",
                                        type_="string",
                                        defvalue=[])

        def __init__(self, **kw):
            """Construct an initialized instance of this struct definition"""
            for classattr in type(self).__dict__.itervalues():
                if isinstance(classattr,
                              (simple_property, simpleseq_property)):
                    classattr.initialize(self)
            for k, v in kw.items():
                setattr(self, k, v)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["simple_a"] = self.simple_a
            d["simpseq_a1"] = self.simpseq_a1
            d["simpseq_a2"] = self.simpseq_a2
            return str(d)

        @classmethod
        def getId(cls):
            return "struct_a"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("simple_a", self.simple_a),
                    ("simpseq_a1", self.simpseq_a1),
                    ("simpseq_a2", self.simpseq_a2)]

    struct_a = struct_property(id_="struct_a",
                               name="struct_a",
                               structdef=StructA,
                               configurationkind=("property", ),
                               mode="readwrite")

    class StructB(object):
        simple_b = simple_property(id_="struct_seq_b::simple_b",
                                   name="simple_b",
                                   type_="string",
                                   defvalue="simp_b")

        simp_seq_b1 = simpleseq_property(id_="struct_seq_b::simp_seq_b1",
                                         name="simp_seq_b1",
                                         type_="string",
                                         defvalue=[])

        simp_seq_b2 = simpleseq_property(id_="struct_seq_b::simp_seq_b2",
                                         name="simp_seq_b2",
                                         type_="string",
                                         defvalue=["b2_1", "b2_2"])

        def __init__(self,
                     simple_b="simp_b",
                     simp_seq_b1=[],
                     simp_seq_b2=["b2_1", "b2_2"]):
            self.simple_b = simple_b
            self.simp_seq_b1 = simp_seq_b1
            self.simp_seq_b2 = simp_seq_b2

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["simple_b"] = self.simple_b
            d["simp_seq_b1"] = self.simp_seq_b1
            d["simp_seq_b2"] = self.simp_seq_b2
            return str(d)

        @classmethod
        def getId(cls):
            return "struct_seq_b::struct_b"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("simple_b", self.simple_b),
                    ("simp_seq_b1", self.simp_seq_b1),
                    ("simp_seq_b2", self.simp_seq_b2)]

    struct_seq_b = structseq_property(id_="struct_seq_b",
                                      name="struct_seq_b",
                                      structdef=StructB,
                                      defvalue=[
                                          StructB(simple_b="simp_b",
                                                  simp_seq_b1=[""],
                                                  simp_seq_b2=["b2_1", "b2_2"])
                                      ],
                                      configurationkind=("property", ),
                                      mode="readwrite")

    class StructE(object):
        simple_e = simple_property(id_="struct_seq_e::simple_e",
                                   name="simple_e",
                                   type_="string",
                                   defvalue="simp_e")

        simpseq_e1 = simpleseq_property(id_="struct_seq_e::simpseq_e1",
                                        name="simpseq_e1",
                                        type_="string",
                                        defvalue=["e1_1", "e1_2"])

        simpseq_e2 = simpleseq_property(id_="struct_seq_e::simpseq_e2",
                                        name="simpseq_e2",
                                        type_="string",
                                        defvalue=[])

        def __init__(self,
                     simple_e="simp_e",
                     simpseq_e1=["e1_1", "e1_2"],
                     simpseq_e2=[]):
            self.simple_e = simple_e
            self.simpseq_e1 = simpseq_e1
            self.simpseq_e2 = simpseq_e2

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["simple_e"] = self.simple_e
            d["simpseq_e1"] = self.simpseq_e1
            d["simpseq_e2"] = self.simpseq_e2
            return str(d)

        @classmethod
        def getId(cls):
            return "struct_seq_e::struct_e"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("simple_e", self.simple_e),
                    ("simpseq_e1", self.simpseq_e1),
                    ("simpseq_e2", self.simpseq_e2)]

    struct_seq_e = structseq_property(id_="struct_seq_e",
                                      name="struct_seq_e",
                                      structdef=StructE,
                                      defvalue=[
                                          StructE(simple_e="simp_e",
                                                  simpseq_e1=["e1_1", "e1_2"],
                                                  simpseq_e2=[""]),
                                          StructE(simple_e="simp_e",
                                                  simpseq_e1=["e1_1", "e1_2"],
                                                  simpseq_e2=[""])
                                      ],
                                      configurationkind=("property", ),
                                      mode="readwrite")
示例#14
0
class fcalc_base(CF__POA.Resource, Resource, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Resource.__init__(self, identifier, execparams, loggerName=loggerName)
        ThreadedComponent.__init__(self)

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this component
        self.port_a = bulkio.InFloatPort("a", maxsize=self.DEFAULT_QUEUE_SIZE)
        self.port_b = bulkio.InFloatPort("b", maxsize=self.DEFAULT_QUEUE_SIZE)
        self.port_out = bulkio.OutFloatPort("out")

    def start(self):
        Resource.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")
        Resource.stop(self)

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        Resource.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_a = providesport(name="a",
                          repid="IDL:BULKIO/dataFloat:1.0",
                          type_="data")

    port_b = providesport(name="b",
                          repid="IDL:BULKIO/dataFloat:1.0",
                          type_="data")

    port_out = usesport(name="out",
                        repid="IDL:BULKIO/dataFloat:1.0",
                        type_="data")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    equation = simple_property(
        id_="equation",
        type_="string",
        mode="readwrite",
        action="external",
        kinds=("configure", ),
        description=
        """A string representing an equation you want to implement in this component.  "a" represents the data on input a and "b" represents the data on b.  Calculation is performed on a sample by sample basis.
        
                                   An example equation would be "math.sin(a+b)+random.random()"
        
                                   Any operation which is supported in python is supported here.  Furthermore, use the import property to import more modules (including perhpase custom modules with custom functions) """
    )

    useAsri = simple_property(
        id_="useAsri",
        type_="boolean",
        defvalue=True,
        mode="readwrite",
        action="external",
        kinds=("execparam", ),
        description="""Use input's A sri as the output sri. False = B""")

    import_ = simpleseq_property(
        id_="import",
        type_="string",
        defvalue=[
            "math",
            "random",
        ],
        mode="readwrite",
        action="external",
        kinds=("configure", ),
        description=
        """python modules (including perhapse custom modules) you want to import to use in your equation"""
    )
示例#15
0
class AVS4000_base(CF__POA.Device, FrontendTunerDevice,
                   digital_tuner_delegation, rfinfo_delegation,
                   ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        print("--> AVS4000_base.__init__()")

        FrontendTunerDevice.__init__(self, devmgr, uuid, label,
                                     softwareProfile, compositeDevice,
                                     execparams)
        ThreadedComponent.__init__(self)

        self.listeners = {}
        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 devices.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this device
        self.port_RFInfo_in = frontend.InRFInfoPort("RFInfo_in", self)
        self.port_RFInfo_in._portLog = self._baseLog.getChildLogger(
            'RFInfo_in', 'ports')
        self.port_DigitalTuner_in = frontend.InDigitalTunerPort(
            "DigitalTuner_in", self)
        self.port_DigitalTuner_in._portLog = self._baseLog.getChildLogger(
            'DigitalTuner_in', 'ports')
        self.port_dataShort_out = bulkio.OutShortPort("dataShort_out")
        self.port_dataShort_out._portLog = self._baseLog.getChildLogger(
            'dataShort_out', 'ports')
        self.device_kind = "FRONTEND::TUNER"
        self.device_model = "AVS-4000"
        self.frontend_listener_allocation = frontend.fe_types.frontend_listener_allocation(
        )
        self.frontend_tuner_allocation = frontend.fe_types.frontend_tuner_allocation(
        )

        print("<-- AVS4000_Base.__init__()")

    def start(self):
        self._baseLog.info("--> start()")

        FrontendTunerDevice.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

        self._baseLog.info("<-- start()")

    def stop(self):
        self._baseLog.info("--> stop()")

        FrontendTunerDevice.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            self._baseLog.info("<-- stop()")

            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

        self._baseLog.info("<-- stop()")

    def releaseObject(self):
        self._baseLog.info("--> releaseObject()")

        try:
            self.stop()
        except Exception:
            self._baseLog.exception("Error stopping")

        FrontendTunerDevice.releaseObject(self)

        self._baseLog.info("<-- releaseObject()")

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_RFInfo_in = providesport(name="RFInfo_in",
                                  repid="IDL:FRONTEND/RFInfo:1.0",
                                  type_="data")

    port_DigitalTuner_in = providesport(name="DigitalTuner_in",
                                        repid="IDL:FRONTEND/DigitalTuner:1.0",
                                        type_="control")

    port_dataShort_out = usesport(
        name="dataShort_out",
        repid="IDL:BULKIO/dataShort:1.0",
        type_="data",
        description="""This port delivers complex 16 bit I/Q data """)

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    class frontend_tuner_status_struct_struct(
            frontend.default_frontend_tuner_status_struct_struct):
        complex = simple_property(id_="FRONTEND::tuner_status::complex",
                                  name="complex",
                                  type_="boolean")

        decimation = simple_property(id_="FRONTEND::tuner_status::decimation",
                                     name="decimation",
                                     type_="long")

        gain = simple_property(id_="FRONTEND::tuner_status::gain",
                               name="gain",
                               type_="double")

        tuner_number = simple_property(
            id_="FRONTEND::tuner_status::tuner_number",
            name="tuner_number",
            type_="short")

        def __init__(self,
                     allocation_id_csv="",
                     bandwidth=0.0,
                     center_frequency=0.0,
                     complex=False,
                     decimation=0,
                     enabled=False,
                     gain=0.0,
                     group_id="",
                     rf_flow_id="",
                     sample_rate=0.0,
                     tuner_number=0,
                     tuner_type=""):

            frontend.default_frontend_tuner_status_struct_struct.__init__(
                self,
                allocation_id_csv=allocation_id_csv,
                bandwidth=bandwidth,
                center_frequency=center_frequency,
                enabled=enabled,
                group_id=group_id,
                rf_flow_id=rf_flow_id,
                sample_rate=sample_rate,
                tuner_type=tuner_type)
            self.complex = complex
            self.decimation = decimation
            self.gain = gain
            self.tuner_number = tuner_number

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["allocation_id_csv"] = self.allocation_id_csv
            d["bandwidth"] = self.bandwidth
            d["center_frequency"] = self.center_frequency
            d["complex"] = self.complex
            d["decimation"] = self.decimation
            d["enabled"] = self.enabled
            d["gain"] = self.gain
            d["group_id"] = self.group_id
            d["rf_flow_id"] = self.rf_flow_id
            d["sample_rate"] = self.sample_rate
            d["tuner_number"] = self.tuner_number
            d["tuner_type"] = self.tuner_type
            return str(d)

        @classmethod
        def getId(cls):
            return "FRONTEND::tuner_status_struct"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return frontend.default_frontend_tuner_status_struct_struct.getMembers(
                self) + [("complex", self.complex),
                         ("decimation", self.decimation), ("gain", self.gain),
                         ("tuner_number", self.tuner_number)]

    class avs4000_output_configuration___struct(object):
        tuner_number = simple_property(
            id_="avs4000_output_configuration::tuner_number",
            name="tuner_number",
            type_="long",
            defvalue=0)

        output_format = simple_property(
            id_="avs4000_output_configuration::output_format",
            name="output_format",
            type_="string",
            defvalue="COMPLEX_Format")

        output_source = simple_property(
            id_="avs4000_output_configuration::output_source",
            name="output_source",
            type_="string",
            defvalue="TCP_Source")

        def __init__(self,
                     tuner_number=0,
                     output_format="COMPLEX_Format",
                     output_source="TCP_Source"):

            print("--> avs4000_output_configuration___struct.__init__()")
            self.tuner_number = tuner_number
            self.output_format = output_format
            self.output_source = output_source
            print("<-- avs4000_output_configuration___struct.__init__()")

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["tuner_number"] = self.tuner_number
            d["output_format"] = self.output_format
            d["output_source"] = self.output_source
            return str(d)

        @classmethod
        def getId(cls):
            return "avs4000_output_configuration::"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            print("--> avs4000_output_configuration___struct.get_Members()")
            print("    {}".format(self))
            print("<-- avs4000_output_configuration___struct.get_Members()")
            return [("tuner_number", self.tuner_number),
                    ("output_format", self.output_format),
                    ("output_source", self.output_source)]

    avs4000_output_configuration = structseq_property(
        id_="avs4000_output_configuration",
        structdef=avs4000_output_configuration___struct,
        defvalue=[
            avs4000_output_configuration___struct(
                tuner_number=0,
                output_format="VITA49_Format",
                output_source="TCP_Source")
        ],
        configurationkind=("property", ),
        mode="readwrite")

    # Rebind tuner status property with custom struct definition
    frontend_tuner_status = FrontendTunerDevice.frontend_tuner_status.rebind()
    frontend_tuner_status.structdef = frontend_tuner_status_struct_struct

    def frontendTunerStatusChanged(self, oldValue, newValue):
        self._baseLog.info("--> frontendTunerStatusChanged()")

        self._baseLog.info("<-- frontendTunerStatusChanged()")
        pass

    def getTunerStatus(self, allocation_id):
        self._baseLog.info("--> getTunerStatus()")

        tuner_id = self.getTunerMapping(allocation_id)

        if tuner_id < 0:
            self._baseLog.info("<-- getTunerStatus()")

            raise FRONTEND.FrontendException(
                ("ERROR: ID: " + str(allocation_id) +
                 " IS NOT ASSOCIATED WITH ANY TUNER!"))

        _props = self.query([
            CF.DataType(id='FRONTEND::tuner_status', value=_any.to_any(None))
        ])

        self._baseLog.info("<-- getTunerStatus()")

        return _props[0].value._v[tuner_id]._v

    def assignListener(self, listen_alloc_id, allocation_id):
        # find control allocation_id

        existing_alloc_id = allocation_id
        if self.listeners.has_key(existing_alloc_id):
            existing_alloc_id = self.listeners[existing_alloc_id]
        self.listeners[listen_alloc_id] = existing_alloc_id

    def removeListener(self, listen_alloc_id):
        if self.listeners.has_key(listen_alloc_id):
            del self.listeners[listen_alloc_id]

    def removeAllocationIdRouting(self, tuner_id):
        pass
class dbwriter_base(CF__POA.Resource, Component, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, identifier, execparams):
        loggerName = (execparams['NAME_BINDING'].replace('/',
                                                         '.')).rsplit("_",
                                                                      1)[0]
        Component.__init__(self, identifier, execparams, loggerName=loggerName)
        ThreadedComponent.__init__(self)

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 components.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this component
        self.port_dataFloat_in = MessageConsumerPort(thread_sleep=0.1,
                                                     parent=self)
        self.port_dataFloat_in2 = MessageConsumerPort(thread_sleep=0.1,
                                                      parent=self)

    def start(self):
        Component.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        Component.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        Component.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_dataFloat_in = providesport(
        name="dataFloat_in",
        repid="IDL:ExtendedEvent/MessageEvent:1.0",
        type_="control")

    port_dataFloat_in2 = providesport(
        name="dataFloat_in2",
        repid="IDL:ExtendedEvent/MessageEvent:1.0",
        type_="control")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    class FromUpToInsert(object):
        X = simple_property(id_="X", type_="float")

        Y = simple_property(id_="Y", type_="float")

        def __init__(self, **kw):
            """Construct an initialized instance of this struct definition"""
            for classattr in type(self).__dict__.itervalues():
                if isinstance(classattr,
                              (simple_property, simpleseq_property)):
                    classattr.initialize(self)
            for k, v in kw.items():
                setattr(self, k, v)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["X"] = self.X
            d["Y"] = self.Y
            return str(d)

        @classmethod
        def getId(cls):
            return "fromUpToInsert"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("X", self.X), ("Y", self.Y)]

    fromUpToInsert = struct_property(id_="fromUpToInsert",
                                     structdef=FromUpToInsert,
                                     configurationkind=("message", ),
                                     mode="readwrite")

    class FromCentToDB(object):
        ave = simple_property(id_="ave", type_="float")

        lat = simple_property(id_="lat", type_="float")

        long = simple_property(id_="long", type_="float")

        freq = simple_property(id_="freq", type_="float")

        aoa = simple_property(id_="aoa", type_="octet")

        node = simple_property(id_="node", type_="octet")

        wave = simple_property(id_="wave", type_="float")

        comp = simple_property(id_="comp", type_="octet")

        def __init__(self, **kw):
            """Construct an initialized instance of this struct definition"""
            for classattr in type(self).__dict__.itervalues():
                if isinstance(classattr,
                              (simple_property, simpleseq_property)):
                    classattr.initialize(self)
            for k, v in kw.items():
                setattr(self, k, v)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["ave"] = self.ave
            d["lat"] = self.lat
            d["long"] = self.long
            d["freq"] = self.freq
            d["aoa"] = self.aoa
            d["node"] = self.node
            d["wave"] = self.wave
            d["comp"] = self.comp
            return str(d)

        @classmethod
        def getId(cls):
            return "fromCentToDB"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("ave", self.ave), ("lat", self.lat), ("long", self.long),
                    ("freq", self.freq), ("aoa", self.aoa),
                    ("node", self.node), ("wave", self.wave),
                    ("comp", self.comp)]

    fromCentToDB = struct_property(id_="fromCentToDB",
                                   structdef=FromCentToDB,
                                   configurationkind=("property", ),
                                   mode="readwrite")
class DeviceStub_base(CF__POA.Device, Device, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        Device.__init__(self, devmgr, uuid, label, softwareProfile,
                        compositeDevice, execparams)
        ThreadedComponent.__init__(self)

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 devices.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this device
        self.port_dataDouble_in = bulkio.InDoublePort(
            "dataDouble_in", maxsize=self.DEFAULT_QUEUE_SIZE)
        self.port_dataFloat_in = bulkio.InFloatPort(
            "dataFloat_in", maxsize=self.DEFAULT_QUEUE_SIZE)
        self.port_dataFloat_out = bulkio.OutFloatPort("dataFloat_out")
        self.port_dataDouble_out = bulkio.OutDoublePort("dataDouble_out")

    def start(self):
        Device.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        Device.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        Device.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_dataDouble_in = providesport(name="dataDouble_in",
                                      repid="IDL:BULKIO/dataDouble:1.0",
                                      type_="data")

    port_dataFloat_in = providesport(name="dataFloat_in",
                                     repid="IDL:BULKIO/dataFloat:1.0",
                                     type_="data")

    port_dataFloat_out = usesport(name="dataFloat_out",
                                  repid="IDL:BULKIO/dataFloat:1.0",
                                  type_="data")

    port_dataDouble_out = usesport(name="dataDouble_out",
                                   repid="IDL:BULKIO/dataDouble:1.0",
                                   type_="data")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    device_kind = simple_property(
        id_="DCE:cdc5ee18-7ceb-4ae6-bf4c-31f983179b4d",
        name="device_kind",
        type_="string",
        mode="readonly",
        action="eq",
        kinds=("allocation", "configure"),
        description="""This specifies the device kind""")

    device_model = simple_property(
        id_="DCE:0f99b2e4-9903-4631-9846-ff349d18ecfb",
        name="device_model",
        type_="string",
        mode="readonly",
        action="eq",
        kinds=("allocation", "configure"),
        description=""" This specifies the specific device""")
示例#18
0
class fei_exc_src_base(CF__POA.Device, FrontendTunerDevice,
                       digital_tuner_delegation, rfinfo_delegation,
                       rfsource_delegation, gps_delegation, nav_delegation,
                       ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

    PAUSE = 0.0125  # The amount of time to sleep if process return NOOP
    TIMEOUT = 5.0  # The amount of time to wait for the process thread to die when stop() is called
    DEFAULT_QUEUE_SIZE = 100  # The number of BulkIO packets that can be in the queue before pushPacket will block

    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        FrontendTunerDevice.__init__(self, devmgr, uuid, label,
                                     softwareProfile, compositeDevice,
                                     execparams)
        ThreadedComponent.__init__(self)

        self.listeners = {}
        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 devices.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this device
        self.port_RFInfo_in = frontend.InRFInfoPort("RFInfo_in", self)
        self.port_DigitalTuner_in = frontend.InDigitalScanningTunerPort(
            "DigitalTuner_in", self)
        self.port_GPS_in = frontend.InGPSPort("GPS_in", self)
        self.port_NavData_in = frontend.InNavDataPort("NavData_in", self)
        self.port_RFSource_in = frontend.InRFSourcePort("RFSource_in", self)
        self.port_dataDouble_out = bulkio.OutDoublePort("dataDouble_out")
        self.addPropertyChangeListener('connectionTable',
                                       self.updated_connectionTable)
        self.device_kind = "FRONTEND::TUNER"
        self.frontend_listener_allocation = frontend.fe_types.frontend_listener_allocation(
        )
        self.frontend_tuner_allocation = frontend.fe_types.frontend_tuner_allocation(
        )

    def start(self):
        FrontendTunerDevice.start(self)
        ThreadedComponent.startThread(self, pause=self.PAUSE)

    def stop(self):
        FrontendTunerDevice.stop(self)
        if not ThreadedComponent.stopThread(self, self.TIMEOUT):
            raise CF.Resource.StopError(CF.CF_NOTSET,
                                        "Processing thread did not die")

    def updated_connectionTable(self, id, oldval, newval):
        self.port_dataDouble_out.updateConnectionFilter(newval)

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        FrontendTunerDevice.releaseObject(self)

    ######################################################################
    # PORTS
    #
    # DO NOT ADD NEW PORTS HERE.  You can add ports in your derived class, in the SCD xml file,
    # or via the IDE.

    port_RFInfo_in = providesport(name="RFInfo_in",
                                  repid="IDL:FRONTEND/RFInfo:1.0",
                                  type_="data")

    port_DigitalTuner_in = providesport(name="DigitalTuner_in",
                                        repid="IDL:FRONTEND/DigitalTuner:1.0",
                                        type_="control")

    port_GPS_in = providesport(name="GPS_in",
                               repid="IDL:FRONTEND/GPS:1.0",
                               type_="control")

    port_NavData_in = providesport(name="NavData_in",
                                   repid="IDL:FRONTEND/NavData:1.0",
                                   type_="control")

    port_RFSource_in = providesport(name="RFSource_in",
                                    repid="IDL:FRONTEND/RFSource:1.0",
                                    type_="control")

    port_dataDouble_out = usesport(name="dataDouble_out",
                                   repid="IDL:BULKIO/dataDouble:1.0",
                                   type_="data")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    class frontend_tuner_status_struct_struct(
            frontend.default_frontend_tuner_status_struct_struct):
        def __init__(self,
                     allocation_id_csv="",
                     bandwidth=0.0,
                     center_frequency=0.0,
                     enabled=False,
                     group_id="",
                     rf_flow_id="",
                     sample_rate=0.0,
                     tuner_type=""):
            frontend.default_frontend_tuner_status_struct_struct.__init__(
                self,
                allocation_id_csv=allocation_id_csv,
                bandwidth=bandwidth,
                center_frequency=center_frequency,
                enabled=enabled,
                group_id=group_id,
                rf_flow_id=rf_flow_id,
                sample_rate=sample_rate,
                tuner_type=tuner_type)

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["allocation_id_csv"] = self.allocation_id_csv
            d["bandwidth"] = self.bandwidth
            d["center_frequency"] = self.center_frequency
            d["enabled"] = self.enabled
            d["group_id"] = self.group_id
            d["rf_flow_id"] = self.rf_flow_id
            d["sample_rate"] = self.sample_rate
            d["tuner_type"] = self.tuner_type
            return str(d)

        @classmethod
        def getId(cls):
            return "FRONTEND::tuner_status_struct"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return frontend.default_frontend_tuner_status_struct_struct.getMembers(
                self) + []

    connectionTable = structseq_property(
        id_="connectionTable",
        structdef=bulkio.connection_descriptor_struct,
        defvalue=[],
        configurationkind=("property", ),
        mode="readonly")

    # Rebind tuner status property with custom struct definition
    frontend_tuner_status = FrontendTunerDevice.frontend_tuner_status.rebind()
    frontend_tuner_status.structdef = frontend_tuner_status_struct_struct

    def frontendTunerStatusChanged(self, oldValue, newValue):
        pass

    def getTunerStatus(self, allocation_id):
        tuner_id = self.getTunerMapping(allocation_id)
        if tuner_id < 0:
            raise FRONTEND.FrontendException(
                ("ERROR: ID: " + str(allocation_id) +
                 " IS NOT ASSOCIATED WITH ANY TUNER!"))
        return [
            CF.DataType(id=self.frontend_tuner_status[tuner_id].getId(),
                        value=self.frontend_tuner_status[tuner_id]._toAny())
        ]

    def assignListener(self, listen_alloc_id, allocation_id):
        # find control allocation_id
        existing_alloc_id = allocation_id
        if self.listeners.has_key(existing_alloc_id):
            existing_alloc_id = self.listeners[existing_alloc_id]
        self.listeners[listen_alloc_id] = existing_alloc_id

        old_table = self.connectionTable
        new_entries = []
        for entry in self.connectionTable:
            if entry.connection_id == existing_alloc_id:
                tmp = bulkio.connection_descriptor_struct()
                tmp.connection_id = listen_alloc_id
                tmp.stream_id = entry.stream_id
                tmp.port_name = entry.port_name
                new_entries.append(tmp)

        for new_entry in new_entries:
            foundEntry = False
            for entry in self.connectionTable:
                if entry.connection_id == new_entry.connection_id and \
                   entry.stream_id == entry.stream_id and \
                   entry.port_name == entry.port_name:
                    foundEntry = True
                    break

            if not foundEntry:
                self.connectionTable.append(new_entry)

        self.connectionTableChanged(old_table, self.connectionTable)

    def connectionTableChanged(self, oldValue, newValue):
        self.port_dataDouble_out.updateConnectionFilter(newValue)

    def removeListener(self, listen_alloc_id):
        if self.listeners.has_key(listen_alloc_id):
            del self.listeners[listen_alloc_id]

        old_table = self.connectionTable
        for entry in list(self.connectionTable):
            if entry.connection_id == listen_alloc_id:
                self.connectionTable.remove(entry)

        # Check to see if port "port_dataDouble_out" has a connection for this listener
        tmp = self.port_dataDouble_out._get_connections()
        for i in range(len(self.port_dataDouble_out._get_connections())):
            connection_id = tmp[i].connectionId
            if connection_id == listen_alloc_id:
                self.port_dataDouble_out.disconnectPort(connection_id)
        self.connectionTableChanged(old_table, self.connectionTable)

    def removeAllocationIdRouting(self, tuner_id):
        allocation_id = self.getControlAllocationId(tuner_id)
        old_table = self.connectionTable
        for entry in list(self.connectionTable):
            if entry.connection_id == allocation_id:
                self.connectionTable.remove(entry)

        for key, value in self.listeners.items():
            if (value == allocation_id):
                for entry in list(self.connectionTable):
                    if entry.connection_id == key:
                        self.connectionTable.remove(entry)

        self.connectionTableChanged(old_table, self.connectionTable)

    def removeStreamIdRouting(self, stream_id, allocation_id):
        old_table = self.connectionTable
        for entry in list(self.connectionTable):
            if allocation_id == "":
                if entry.stream_id == stream_id:
                    self.connectionTable.remove(entry)
            else:
                if entry.stream_id == stream_id and entry.connection_id == allocation_id:
                    self.connectionTable.remove(entry)

        for key, value in self.listeners.items():
            if (value == allocation_id):
                for entry in list(self.connectionTable):
                    if entry.connection_id == key and entry.stream_id == stream_id:
                        self.connectionTable.remove(entry)

        self.connectionTableChanged(old_table, self.connectionTable)

    def matchAllocationIdToStreamId(self, allocation_id, stream_id, port_name):
        if port_name != "":
            for entry in list(self.connectionTable):
                if entry.port_name != port_name:
                    continue
                if entry.stream_id != stream_id:
                    continue
                if entry.connection_id != allocation_id:
                    continue
                # all three match. This is a repeat
                return

            old_table = self.connectionTable
            tmp = bulkio.connection_descriptor_struct()
            tmp.connection_id = allocation_id
            tmp.port_name = port_name
            tmp.stream_id = stream_id
            self.connectionTable.append(tmp)
            self.connectionTableChanged(old_table, self.connectionTable)
            return

        old_table = self.connectionTable
        tmp = bulkio.connection_descriptor_struct()
        tmp.connection_id = allocation_id
        tmp.port_name = "port_dataDouble_out"
        tmp.stream_id = stream_id
        self.connectionTable.append(tmp)
        self.connectionTableChanged(old_table, self.connectionTable)