class ticket_cf_1066_comp_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


        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.
                

        ######################################################################
        # 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.       
        simple_prop = simple_property(id_="simple_prop",
                                          type_="string",
                                          defvalue="default_value",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        seq_prop = simpleseq_property(id_="seq_prop",  
                                          type_="short",
                                          defvalue=(111,222,333),
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )
        class StructProp(object):
            prop_one = simple_property(id_="prop_one",
                                          type_="boolean",
                                          defvalue=True,
                                          )
            prop_two = simple_property(id_="prop_two",
                                          type_="string",
                                          defvalue="This is another default value",
                                          )
            prop_three = simple_property(id_="prop_three",
                                          type_="float",
                                          defvalue=555,
                                          )
        
            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["prop_one"] = self.prop_one
                d["prop_two"] = self.prop_two
                d["prop_three"] = self.prop_three
                return str(d)

            def getId(self):
                return "struct_prop"

            def isStruct(self):
                return True

            def getMembers(self):
                return [("prop_one",self.prop_one),("prop_two",self.prop_two),("prop_three",self.prop_three)]

        
        struct_prop = struct_property(id_="struct_prop",
                                          structdef=StructProp,
                                          configurationkind=("configure",),
                                          mode="readwrite"
                                          )
        class TmpStruct(object):
            prop_four = simple_property(id_="prop_four",
                                          type_="string",
                                          defvalue="yet another default",
                                          )
            prop_five = simple_property(id_="prop_five",
                                          type_="long",
                                          defvalue=246,
                                          )
            prop_six = simple_property(id_="prop_six",
                                          type_="double",
                                          defvalue=135,
                                          )
        
            def __init__(self, prop_four="", prop_five=0, prop_six=0):
                self.prop_four = prop_four
                self.prop_five = prop_five
                self.prop_six = prop_six

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

            def getId(self):
                return "tmp_struct"

            def isStruct(self):
                return True

            def getMembers(self):
                return [("prop_four",self.prop_four),("prop_five",self.prop_five),("prop_six",self.prop_six)]

                
        struct_seq_prop = structseq_property(id_="struct_seq_prop",
                                          structdef=TmpStruct,                          
                                          defvalue=[],
                                          configurationkind=("configure",),
                                          mode="readwrite"
                                          )
Exemplo n.º 2
0
class TestPythonPropsRange_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

    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.

    ######################################################################
    # 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.
    my_octet_name = simple_property(id_="my_octet",
                                    name="my_octet_name",
                                    type_="octet",
                                    defvalue=1,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))

    my_short_name = simple_property(id_="my_short",
                                    name="my_short_name",
                                    type_="short",
                                    defvalue=2,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))

    my_ushort_name = simple_property(id_="my_ushort",
                                     name="my_ushort_name",
                                     type_="ushort",
                                     defvalue=3,
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))

    my_long_name = simple_property(id_="my_long",
                                   name="my_long_name",
                                   type_="long",
                                   defvalue=4,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))

    my_ulong_name = simple_property(id_="my_ulong",
                                    name="my_ulong_name",
                                    type_="ulong",
                                    defvalue=5,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))

    my_longlong_name = simple_property(id_="my_longlong",
                                       name="my_longlong_name",
                                       type_="longlong",
                                       defvalue=6,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))

    my_ulonglong_name = simple_property(id_="my_ulonglong",
                                        name="my_ulonglong_name",
                                        type_="ulonglong",
                                        defvalue=7,
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))

    seq_octet_name = simpleseq_property(id_="seq_octet",
                                        name="seq_octet_name",
                                        type_="octet",
                                        defvalue=[
                                            1,
                                            2,
                                        ],
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))

    seq_short_name = simpleseq_property(id_="seq_short",
                                        name="seq_short_name",
                                        type_="short",
                                        defvalue=[
                                            1,
                                            2,
                                        ],
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))

    seq_ushort_name = simpleseq_property(id_="seq_ushort",
                                         name="seq_ushort_name",
                                         type_="ushort",
                                         defvalue=[
                                             1,
                                             2,
                                         ],
                                         mode="readwrite",
                                         action="external",
                                         kinds=("configure", ))

    seq_long_name = simpleseq_property(id_="seq_long",
                                       name="seq_long_name",
                                       type_="long",
                                       defvalue=[
                                           1,
                                           2,
                                       ],
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))

    seq_ulong_name = simpleseq_property(id_="seq_ulong",
                                        name="seq_ulong_name",
                                        type_="ulong",
                                        defvalue=[
                                            1,
                                            2,
                                        ],
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))

    seq_longlong_name = simpleseq_property(id_="seq_longlong",
                                           name="seq_longlong_name",
                                           type_="longlong",
                                           defvalue=[
                                               1,
                                               2,
                                           ],
                                           mode="readwrite",
                                           action="external",
                                           kinds=("configure", ))

    seq_ulonglong_name = simpleseq_property(id_="seq_ulonglong",
                                            name="seq_ulonglong_name",
                                            type_="ulonglong",
                                            defvalue=[
                                                1,
                                                2,
                                            ],
                                            mode="readwrite",
                                            action="external",
                                            kinds=("configure", ))

    seq_char_name = simpleseq_property(id_="seq_char",
                                       name="seq_char_name",
                                       type_="char",
                                       defvalue=[
                                           'a',
                                           'b',
                                       ],
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))

    class MyStructName(object):
        struct_octet_name = simple_property(id_="struct_octet",
                                            name="struct_octet_name",
                                            type_="octet",
                                            defvalue=1)

        struct_short_name = simple_property(id_="struct_short",
                                            name="struct_short_name",
                                            type_="short",
                                            defvalue=2)

        struct_ushort_name = simple_property(id_="struct_ushort",
                                             name="struct_ushort_name",
                                             type_="ushort",
                                             defvalue=3)

        struct_long_name = simple_property(id_="struct_long",
                                           name="struct_long_name",
                                           type_="long",
                                           defvalue=4)

        struct_ulong_name = simple_property(id_="struct_ulong",
                                            name="struct_ulong_name",
                                            type_="ulong",
                                            defvalue=5)

        struct_longlong_name = simple_property(id_="struct_longlong",
                                               name="struct_longlong_name",
                                               type_="longlong",
                                               defvalue=6)

        struct_ulonglong_name = simple_property(id_="struct_ulonglong",
                                                name="struct_ulonglong_name",
                                                type_="ulonglong",
                                                defvalue=7)

        struct_seq_octet_name = simpleseq_property(
            id_="struct_seq_octet",
            name="struct_seq_octet_name",
            type_="octet",
            defvalue=[
                1,
                2,
            ])

        struct_seq_short_name = simpleseq_property(
            id_="struct_seq_short",
            name="struct_seq_short_name",
            type_="short",
            defvalue=[
                1,
                2,
            ])

        struct_seq_ushort_name = simpleseq_property(
            id_="struct_seq_ushort",
            name="struct_seq_ushort_name",
            type_="ushort",
            defvalue=[
                1,
                2,
            ])

        struct_seq_long_name = simpleseq_property(id_="struct_seq_long",
                                                  name="struct_seq_long_name",
                                                  type_="long",
                                                  defvalue=[
                                                      1,
                                                      2,
                                                  ])

        struct_seq_ulong_name = simpleseq_property(
            id_="struct_seq_ulong",
            name="struct_seq_ulong_name",
            type_="ulong",
            defvalue=[
                1,
                2,
            ])

        struct_seq_longlong_name = simpleseq_property(
            id_="struct_seq_longlong",
            name="struct_seq_longlong_name",
            type_="longlong",
            defvalue=[
                1,
                2,
            ])

        struct_seq_ulonglong_name = simpleseq_property(
            id_="struct_seq_ulonglong",
            name="struct_seq_ulonglong_name",
            type_="ulonglong",
            defvalue=[
                1,
                2,
            ])

        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 or type(
                        classattr) == 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["struct_octet_name"] = self.struct_octet_name
            d["struct_short_name"] = self.struct_short_name
            d["struct_ushort_name"] = self.struct_ushort_name
            d["struct_long_name"] = self.struct_long_name
            d["struct_ulong_name"] = self.struct_ulong_name
            d["struct_longlong_name"] = self.struct_longlong_name
            d["struct_ulonglong_name"] = self.struct_ulonglong_name
            d["struct_seq_octet_name"] = self.struct_seq_octet_name
            d["struct_seq_short_name"] = self.struct_seq_short_name
            d["struct_seq_ushort_name"] = self.struct_seq_ushort_name
            d["struct_seq_long_name"] = self.struct_seq_long_name
            d["struct_seq_ulong_name"] = self.struct_seq_ulong_name
            d["struct_seq_longlong_name"] = self.struct_seq_longlong_name
            d["struct_seq_ulonglong_name"] = self.struct_seq_ulonglong_name
            return str(d)

        def getId(self):
            return "my_struct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [
                ("struct_octet_name", self.struct_octet_name),
                ("struct_short_name", self.struct_short_name),
                ("struct_ushort_name", self.struct_ushort_name),
                ("struct_long_name", self.struct_long_name),
                ("struct_ulong_name", self.struct_ulong_name),
                ("struct_longlong_name", self.struct_longlong_name),
                ("struct_ulonglong_name", self.struct_ulonglong_name),
                ("struct_seq_octet_name", self.struct_seq_octet_name),
                ("struct_seq_short_name", self.struct_seq_short_name),
                ("struct_seq_ushort_name", self.struct_seq_ushort_name),
                ("struct_seq_long_name", self.struct_seq_long_name),
                ("struct_seq_ulong_name", self.struct_seq_ulong_name),
                ("struct_seq_longlong_name", self.struct_seq_longlong_name),
                ("struct_seq_ulonglong_name", self.struct_seq_ulonglong_name)
            ]

    my_struct_name = struct_property(id_="my_struct",
                                     name="my_struct_name",
                                     structdef=MyStructName,
                                     configurationkind=("configure", ),
                                     mode="readwrite")

    class SsStructName(object):
        ss_octet_name = simple_property(id_="ss_octet",
                                        name="ss_octet_name",
                                        type_="octet")

        ss_short_name = simple_property(id_="ss_short",
                                        name="ss_short_name",
                                        type_="short")

        ss_ushort_name = simple_property(id_="ss_ushort",
                                         name="ss_ushort_name",
                                         type_="ushort")

        ss_long_name = simple_property(id_="ss_long",
                                       name="ss_long_name",
                                       type_="long")

        ss_ulong_name = simple_property(id_="ss_ulong",
                                        name="ss_ulong_name",
                                        type_="ulong")

        ss_longlong_name = simple_property(id_="ss_longlong",
                                           name="ss_longlong_name",
                                           type_="longlong")

        ss_ulonglong_name = simple_property(id_="ss_ulonglong",
                                            name="ss_ulonglong_name",
                                            type_="ulonglong")

        ss_seq_octet_name = simpleseq_property(id_="ss_seq_octet",
                                               name="ss_seq_octet_name",
                                               type_="octet")

        ss_seq_short_name = simpleseq_property(id_="ss_seq_short",
                                               name="ss_seq_short_name",
                                               type_="short")

        ss_seq_ushort_name = simpleseq_property(id_="ss_seq_ushort",
                                                name="ss_seq_ushort_name",
                                                type_="ushort")

        ss_seq_long_name = simpleseq_property(id_="ss_seq_long",
                                              name="ss_seq_long_name",
                                              type_="long")

        ss_seq_ulong_name = simpleseq_property(id_="ss_seq_ulong",
                                               name="ss_seq_ulong_name",
                                               type_="ulong")

        ss_seq_longlong_name = simpleseq_property(id_="ss_seq_longlong",
                                                  name="ss_seq_longlong_name",
                                                  type_="longlong")

        ss_seq_ulonglong_name = simpleseq_property(
            id_="ss_seq_ulonglong",
            name="ss_seq_ulonglong_name",
            type_="ulonglong")

        def __init__(self,
                     ss_octet_name=0,
                     ss_short_name=0,
                     ss_ushort_name=0,
                     ss_long_name=0,
                     ss_ulong_name=0,
                     ss_longlong_name=0,
                     ss_ulonglong_name=0,
                     ss_seq_octet_name=0,
                     ss_seq_short_name=0,
                     ss_seq_ushort_name=0,
                     ss_seq_long_name=0,
                     ss_seq_ulong_name=0,
                     ss_seq_longlong_name=0,
                     ss_seq_ulonglong_name=0):
            self.ss_octet_name = ss_octet_name
            self.ss_short_name = ss_short_name
            self.ss_ushort_name = ss_ushort_name
            self.ss_long_name = ss_long_name
            self.ss_ulong_name = ss_ulong_name
            self.ss_longlong_name = ss_longlong_name
            self.ss_ulonglong_name = ss_ulonglong_name
            self.ss_seq_octet_name = ss_seq_octet_name
            self.ss_seq_short_name = ss_seq_short_name
            self.ss_seq_ushort_name = ss_seq_ushort_name
            self.ss_seq_long_name = ss_seq_long_name
            self.ss_seq_ulong_name = ss_seq_ulong_name
            self.ss_seq_longlong_name = ss_seq_longlong_name
            self.ss_seq_ulonglong_name = ss_seq_ulonglong_name

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["ss_octet_name"] = self.ss_octet_name
            d["ss_short_name"] = self.ss_short_name
            d["ss_ushort_name"] = self.ss_ushort_name
            d["ss_long_name"] = self.ss_long_name
            d["ss_ulong_name"] = self.ss_ulong_name
            d["ss_longlong_name"] = self.ss_longlong_name
            d["ss_ulonglong_name"] = self.ss_ulonglong_name
            d["ss_seq_octet_name"] = self.ss_seq_octet_name
            d["ss_seq_short_name"] = self.ss_seq_short_name
            d["ss_seq_ushort_name"] = self.ss_seq_ushort_name
            d["ss_seq_long_name"] = self.ss_seq_long_name
            d["ss_seq_ulong_name"] = self.ss_seq_ulong_name
            d["ss_seq_longlong_name"] = self.ss_seq_longlong_name
            d["ss_seq_ulonglong_name"] = self.ss_seq_ulonglong_name
            return str(d)

        def getId(self):
            return "ss_struct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("ss_octet_name", self.ss_octet_name),
                    ("ss_short_name", self.ss_short_name),
                    ("ss_ushort_name", self.ss_ushort_name),
                    ("ss_long_name", self.ss_long_name),
                    ("ss_ulong_name", self.ss_ulong_name),
                    ("ss_longlong_name", self.ss_longlong_name),
                    ("ss_ulonglong_name", self.ss_ulonglong_name),
                    ("ss_seq_octet_name", self.ss_seq_octet_name),
                    ("ss_seq_short_name", self.ss_seq_short_name),
                    ("ss_seq_ushort_name", self.ss_seq_ushort_name),
                    ("ss_seq_long_name", self.ss_seq_long_name),
                    ("ss_seq_ulong_name", self.ss_seq_ulong_name),
                    ("ss_seq_longlong_name", self.ss_seq_longlong_name),
                    ("ss_seq_ulonglong_name", self.ss_seq_ulonglong_name)]

    my_structseq_name = structseq_property(
        id_="my_structseq",
        name="my_structseq_name",
        structdef=SsStructName,
        defvalue=[
            SsStructName(0, 1, 2, 3, 4, 5, 6, [1, 2], [3, 4], [5, 6], [7, 8],
                         [9, 10], [11, 12], [13, 14]),
            SsStructName(7, 8, 9, 10, 11, 12, 13, [15, 16], [17, 18], [19, 20],
                         [21, 22], [23, 24], [25, 26], [27, 28])
        ],
        configurationkind=("configure", ),
        mode="readwrite")
Exemplo n.º 3
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)
class TestComplexProps_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

    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.

    ######################################################################
    # 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.
    complexBooleanProp = simple_property(id_="complexBooleanProp",
                                         type_="boolean",
                                         defvalue=complex(0, 1),
                                         complex=True,
                                         mode="readwrite",
                                         action="external",
                                         kinds=("configure", ))
    complexULongProp = simple_property(id_="complexULongProp",
                                       type_="ulong",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexShortProp = simple_property(id_="complexShortProp",
                                       type_="short",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexFloatProp = simple_property(id_="complexFloatProp",
                                       type_="float",
                                       defvalue=complex(4.0, 5.0),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexOctetProp = simple_property(id_="complexOctetProp",
                                       type_="octet",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexCharProp = simple_property(id_="complexCharProp",
                                      type_="char",
                                      defvalue=complex(4, 5),
                                      complex=True,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    complexUShort = simple_property(id_="complexUShort",
                                    type_="ushort",
                                    defvalue=complex(4, 5),
                                    complex=True,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    complexDouble = simple_property(id_="complexDouble",
                                    type_="double",
                                    defvalue=complex(4.0, 5.0),
                                    complex=True,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    complexLong = simple_property(id_="complexLong",
                                  type_="long",
                                  defvalue=complex(4, 5),
                                  complex=True,
                                  mode="readwrite",
                                  action="external",
                                  kinds=("configure", ))
    complexLongLong = simple_property(id_="complexLongLong",
                                      type_="longlong",
                                      defvalue=complex(4, 5),
                                      complex=True,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    complexULongLong = simple_property(id_="complexULongLong",
                                       type_="ulonglong",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexFloatSequence = simpleseq_property(id_="complexFloatSequence",
                                              type_="float",
                                              defvalue=[
                                                  complex(4.0, 5.0),
                                                  complex(4.0, 5.0),
                                                  complex(4.0, 5.0),
                                              ],
                                              complex=True,
                                              mode="readwrite",
                                              action="external",
                                              kinds=("configure", ))

    class Float(object):
        FloatStructMember = simple_property(
            id_="FloatStructMember",
            type_="float",
            defvalue=4.0,
        )

        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["FloatStructMember"] = self.FloatStructMember
            return str(d)

        def getId(self):
            return "FloatStruct"

        def isStruct(self):
            return True

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

    FloatStruct = struct_property(id_="FloatStruct",
                                  structdef=Float,
                                  configurationkind=("configure", ),
                                  mode="readwrite")

    class ComplexFloat(object):
        complexFloatStructMember = simple_property(
            id_="complexFloatStructMember",
            type_="float",
            defvalue=complex(4.0, 5.0),
            complex=True,
        )

        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["complexFloatStructMember"] = self.complexFloatStructMember
            return str(d)

        def getId(self):
            return "complexFloatStruct"

        def isStruct(self):
            return True

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

    complexFloatStruct = struct_property(id_="complexFloatStruct",
                                         structdef=ComplexFloat,
                                         configurationkind=("configure", ),
                                         mode="readwrite")

    class FloatStructSequenceMember(object):
        FloatStructSequenceMemberMemember = simple_property(
            id_="FloatStructSequenceMemberMemember",
            type_="float",
            defvalue=4.0,
        )

        def __init__(self, FloatStructSequenceMemberMemember=4.0):
            self.FloatStructSequenceMemberMemember = FloatStructSequenceMemberMemember

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

        def getId(self):
            return "FloatStructSequenceMember"

        def isStruct(self):
            return True

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

    FloatStructSequence = structseq_property(
        id_="FloatStructSequence",
        structdef=FloatStructSequenceMember,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")

    class ComplexFloatStructSequenceMember(object):
        complexFloatStructSequenceMemberMemember = simple_property(
            id_="complexFloatStructSequenceMemberMemember",
            type_="float",
            defvalue=complex(4.0, 5.0),
            complex=True,
        )

        def __init__(self,
                     complexFloatStructSequenceMemberMemember=complex(
                         4.0, 5.0)):
            self.complexFloatStructSequenceMemberMemember = complexFloatStructSequenceMemberMemember

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

        def getId(self):
            return "complexFloatStructSequenceMember"

        def isStruct(self):
            return True

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

    complexFloatStructSequence = structseq_property(
        id_="complexFloatStructSequence",
        structdef=ComplexFloatStructSequenceMember,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")
Exemplo n.º 5
0
                                   mode="readonly",
                                   action="eq",
                                   kinds=("allocation","configure"),
                                   description=""" This specifies the specific device"""
                                   )
    frontend_video_allocation = struct_property(id_="FRONTEND::video_allocation",
                                                name="frontend_video_allocation",
                                                structdef=frontend_video_allocation,
                                                configurationkind=("allocation",),
                                                mode="readwrite",
                                                description="""Frontend Interfaces v2.0 main allocation structure"""
                                                )
    frontend_listener_allocation = struct_property(id_="FRONTEND::listener_allocation",
                                                   name="frontend_listener_allocation",
                                                   structdef=frontend_listener_allocation,
                                                   configurationkind=("allocation",),
                                                   mode="readwrite",
                                                   description="""Allocates a listener (subscriber) based off a previous allocation """
                                                   )
    frontend_video_status = structseq_property(id_="FRONTEND::video_status",
                                               name="frontend_video_status",
                                               structdef=default_frontend_video_status_struct_struct,
                                               defvalue=[],
                                               configurationkind=("configure",),
                                               mode="readonly",
                                               description="""Frontend Interfaces v2.0 status structure. One element for every frontend resource (receiver, transmitter) configured on this hardware"""
                                               )


    
class BasicTestDevice(CF__POA.AggregateExecutableDevice, ExecutableDevice,
                      AggregateDevice):
    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        ExecutableDevice.__init__(self, devmgr, uuid, label, softwareProfile,
                                  compositeDevice, execparams, PROPERTIES)
        AggregateDevice.__init__(self)
        self._props["memCapacity"] = 100000000
        self._props["BogoMipsCapacity"] = 100000000
        self._props["nicCapacity"] = 100.0
        self._props["fakeCapacity"] = 3
        self._props["execparams"] = " ".join(
            ["%s %s" % x for x in execparams.items()])

    def initialize(self):
        # change the no_default_prop to be not None to ensure that the device manager
        # doesn't configure properties with no value (i.e. test_NoConfigureNilDeviceProperties)
        self._props["no_default_prop"] = "not_none"

    def execute(self, name, options, parameters):
        retval = ExecutableDevice.execute(self, name, options, parameters)
        for option in options:
            if option.id == 'STACK_SIZE':
                self._props['check_STACK_SIZE'] = option.value._v
            elif option.id == 'PRIORITY':
                self._props['check_PRIORITY'] = option.value._v
        return retval

    # See BasicChildDevice for an example of manually dealing with allocate/deallocate
    def allocate_fakeCapacity(self, value):
        if self._props["fakeCapacity"] < value:
            return False
        self._props["fakeCapacity"] = self._props["fakeCapacity"] - value
        return True

    def allocate_nicCapacity(self, value):
        if self._props["nicCapacity"] < value:
            return False
        self._props["nicCapacity"] = self._props["nicCapacity"] - value
        return True

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

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

    def deallocate_fakeCapacity(self, value):
        self._props["fakeCapacity"] = self._props["fakeCapacity"] + value

    def deallocate_nicCapacity(self, value):
        self._props["nicCapacity"] = self._props["nicCapacity"] + value

    def deallocate_memCapacity(self, value):
        self._props["memCapacity"] = self._props["memCapacity"] + value

    def deallocate_BogoMipsCapacity(self, value):
        self._props[
            "BogoMipsCapacity"] = self._props["BogoMipsCapacity"] + value

    def allocate_allocStruct(self, value):
        if value > self.allocStruct:
            return False

        self.allocStruct -= value
        return True

    def deallocate_allocStruct(self, value):
        self.allocStruct += value

    def allocate_passwordStruct(self, value):
        if value == self.passwordStruct:
            return True
        else:
            self._log.error("Wrong allocation property value")

    def updateUsageState(self):
        # Update usage state
        if self._props["memCapacity"] == 0 and self._props[
                "BogoMipsCapacity"] == 0:
            self._usageState = CF.Device.BUSY
        elif self._props["memCapacity"] == 100000000 and self._props[
                "BogoMipsCapacity"] == 100000000:
            self._usageState = CF.Device.IDLE
        else:
            self._usageState = CF.Device.ACTIVE

    class SomeStruct(object):
        field1 = simple_property(id_="item1",
                                 type_="string",
                                 defvalue="value1")
        field2 = simple_property(id_="item2", type_="long", defvalue=100)
        field3 = simple_property(id_="item3", type_="double", defvalue=3.14156)

    struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f",
                             name="struct_test",
                             structdef=SomeStruct)

    class PasswordStruct(object):
        password = simple_property(id_="password",
                                   type_="string",
                                   defvalue="abracadabra")

        def __eq__(self, other):
            return self.password == other.password

    passwordStruct = struct_property(
        id_="DCE:a5a6ab83-d2a8-4350-ac4d-05b40ee93838",
        name="passwordStruct",
        configurationkind=("allocation"),
        structdef=PasswordStruct)

    class AllocStruct(object):
        long_capacity = simple_property(id_="long_capacity",
                                        type_="long",
                                        defvalue=100)
        float_capacity = simple_property(id_="float_capacity",
                                         type_="float",
                                         defvalue=1.0)
        struct_simple_seq = simpleseq_property(id_="struct_simple_seq",
                                               type_="short",
                                               defvalue=[50, 500])

        def __gt__(self, other):
            return (self.long_capacity > other.long_capacity
                    or self.float_capacity > other.float_capacity)

        def __iadd__(self, other):
            self.long_capacity += other.long_capacity
            self.float_capacity += other.float_capacity
            self.struct_simple_seq[0] += other.struct_simple_seq[0]
            self.struct_simple_seq[1] += other.struct_simple_seq[1]
            return self

        def __isub__(self, other):
            self.long_capacity -= other.long_capacity
            self.float_capacity -= other.float_capacity
            self.struct_simple_seq[0] -= other.struct_simple_seq[0]
            self.struct_simple_seq[1] -= other.struct_simple_seq[1]
            return self

    allocStruct = struct_property(
        id_="DCE:001fad60-b4b3-4ed2-94cb-40e1d956bf4f",
        name="allocStruct",
        configurationkind=("configure", "allocation"),
        structdef=AllocStruct)

    structseq = structseq_property(
        id_="DCE:e836f007-5821-4671-b05a-e0ff5147fe86",
        name="structseq_test",
        structdef=SomeStruct,
        defvalue=[])

    hex_props = simpleseq_property(id_="hex_props",
                                   name="hex_props",
                                   type_='short',
                                   defvalue=(0x01, 0x02))
Exemplo n.º 7
0
class TestComponentProperty_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 compatibility
        # 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

    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.

    ######################################################################
    # 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.
    my_long_enum = simple_property(id_="my_long_enum",
                                   type_="long",
                                   defvalue=11,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    simpleExecparam = simple_property(id_="simpleExecparam",
                                      type_="float",
                                      defvalue=1.0,
                                      mode="readwrite",
                                      action="eq",
                                      kinds=("execparam", ))
    seqTest = simpleseq_property(id_="seqTest",
                                 type_="char",
                                 defvalue=[
                                     'a',
                                     'b',
                                     'c',
                                 ],
                                 mode="readwrite",
                                 action="external",
                                 kinds=("configure", ))

    class MyStruct(object):
        bool_true = simple_property(
            id_="bool_true",
            type_="boolean",
            defvalue=True,
        )
        bool_false = simple_property(
            id_="bool_false",
            type_="boolean",
        )
        bool_empty = simple_property(
            id_="bool_empty",
            type_="boolean",
        )
        long_s = simple_property(
            id_="long_s",
            type_="long",
        )
        str_s = simple_property(
            id_="str_s",
            type_="string",
        )
        enum_bool = simple_property(
            id_="enum_bool",
            type_="boolean",
        )
        enum_str = simple_property(
            id_="enum_str",
            type_="string",
        )
        enum_long = simple_property(
            id_="enum_long",
            type_="long",
        )
        es__3 = simple_property(
            id_="es::3",
            type_="long",
        )

        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["bool_true"] = self.bool_true
            d["bool_false"] = self.bool_false
            d["bool_empty"] = self.bool_empty
            d["long_s"] = self.long_s
            d["str_s"] = self.str_s
            d["enum_bool"] = self.enum_bool
            d["enum_str"] = self.enum_str
            d["enum_long"] = self.enum_long
            d["es__3"] = self.es__3
            return str(d)

        def getId(self):
            return "my_struct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("bool_true", self.bool_true),
                    ("bool_false", self.bool_false),
                    ("bool_empty", self.bool_empty), ("long_s", self.long_s),
                    ("str_s", self.str_s), ("enum_bool", self.enum_bool),
                    ("enum_str", self.enum_str), ("enum_long", self.enum_long),
                    ("es__3", self.es__3)]

    my_struct = struct_property(id_="my_struct",
                                structdef=MyStruct,
                                configurationkind=("configure", ),
                                mode="readwrite")

    class Tests(object):
        b = simple_property(
            id_="b",
            type_="ulonglong",
            defvalue=32,
        )
        t = simple_property(
            id_="t",
            type_="string",
            defvalue="dfdasfas",
        )

        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["b"] = self.b
            d["t"] = self.t
            return str(d)

        def getId(self):
            return "tests"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("b", self.b), ("t", self.t)]

    tests = struct_property(id_="tests",
                            structdef=Tests,
                            configurationkind=("configure", ),
                            mode="readwrite")

    class StructsTest(object):
        simpleShort = simple_property(
            id_="simpleShort",
            type_="short",
            defvalue=3,
        )
        simpleFloat = simple_property(
            id_="simpleFloat",
            type_="long",
            defvalue=2,
        )

        def __init__(self, simpleShort=3, simpleFloat=2):
            self.simpleShort = simpleShort
            self.simpleFloat = simpleFloat

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

        def getId(self):
            return "structsTest"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("simpleShort", self.simpleShort),
                    ("simpleFloat", self.simpleFloat)]

    structSeqTest = structseq_property(
        id_="structSeqTest",
        structdef=StructsTest,
        defvalue=[StructsTest(3, 2), StructsTest(3, 2)],
        configurationkind=("allocation", "configure"),
        mode="readwrite")
Exemplo n.º 8
0
class Sandbox_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

    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.

    ######################################################################
    # 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.
    my_bool_true = simple_property(id_="my_bool_true",
                                   type_="boolean",
                                   defvalue=True,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    my_bool_false = simple_property(id_="my_bool_false",
                                    type_="boolean",
                                    defvalue=False,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_bool_empty = simple_property(id_="my_bool_empty",
                                    type_="boolean",
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_long = simple_property(id_="my_long",
                              type_="long",
                              defvalue=10,
                              mode="readwrite",
                              action="external",
                              kinds=("configure", ))
    my_long_empty = simple_property(id_="my_long_empty",
                                    type_="long",
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_str = simple_property(id_="my_str",
                             type_="string",
                             defvalue="Hello World!",
                             mode="readwrite",
                             action="external",
                             kinds=("configure", ))
    my_str_empty = simple_property(id_="my_str_empty",
                                   type_="string",
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    my_long_enum = simple_property(id_="my_long_enum",
                                   type_="long",
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    my_str_enum = simple_property(id_="my_str_enum",
                                  type_="string",
                                  mode="readwrite",
                                  action="external",
                                  kinds=("configure", ))
    my_bool_enum = simple_property(id_="my_bool_enum",
                                   type_="boolean",
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    escape__simple = simple_property(id_="escape::simple",
                                     type_="long",
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    readonly_simp = simple_property(id_="readonly_simp",
                                    type_="string",
                                    defvalue="Read only simple prop",
                                    mode="readonly",
                                    action="external",
                                    kinds=("configure", ))
    my_seq_bool = simpleseq_property(id_="my_seq_bool",
                                     type_="boolean",
                                     defvalue=(True, False),
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    my_seq_str = simpleseq_property(id_="my_seq_str",
                                    type_="string",
                                    defvalue=("one", "", "three"),
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    readonly_seq = simpleseq_property(id_="readonly_seq",
                                      type_="string",
                                      defvalue=("read only",
                                                "sequence property"),
                                      mode="readonly",
                                      action="external",
                                      kinds=("configure", ))

    class MyStruct(object):
        bool_true = simple_property(
            id_="bool_true",
            type_="boolean",
            defvalue=True,
        )
        bool_false = simple_property(
            id_="bool_false",
            type_="boolean",
            defvalue=False,
        )
        bool_empty = simple_property(
            id_="bool_empty",
            type_="boolean",
        )
        long_s = simple_property(
            id_="long_s",
            type_="long",
        )
        str_s = simple_property(
            id_="str_s",
            type_="string",
        )
        enum_bool = simple_property(
            id_="enum_bool",
            type_="boolean",
        )
        enum_str = simple_property(
            id_="enum_str",
            type_="string",
        )
        enum_long = simple_property(
            id_="enum_long",
            type_="long",
        )
        es__3 = simple_property(
            id_="es::3",
            type_="long",
        )

        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["bool_true"] = self.bool_true
            d["bool_false"] = self.bool_false
            d["bool_empty"] = self.bool_empty
            d["long_s"] = self.long_s
            d["str_s"] = self.str_s
            d["enum_bool"] = self.enum_bool
            d["enum_str"] = self.enum_str
            d["enum_long"] = self.enum_long
            d["es__3"] = self.es__3
            return str(d)

        def getId(self):
            return "my_struct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("bool_true", self.bool_true),
                    ("bool_false", self.bool_false),
                    ("bool_empty", self.bool_empty), ("long_s", self.long_s),
                    ("str_s", self.str_s), ("enum_bool", self.enum_bool),
                    ("enum_str", self.enum_str), ("enum_long", self.enum_long),
                    ("es__3", self.es__3)]

    my_struct = struct_property(id_="my_struct",
                                structdef=MyStruct,
                                configurationkind=("configure", ),
                                mode="readwrite")

    class EscapeStruct(object):
        es__1 = simple_property(
            id_="es::1",
            type_="long",
        )
        es__2 = simple_property(
            id_="es::2",
            type_="long",
        )
        normal = simple_property(
            id_="normal",
            type_="long",
        )

        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["es__1"] = self.es__1
            d["es__2"] = self.es__2
            d["normal"] = self.normal
            return str(d)

        def getId(self):
            return "escape::struct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("es__1", self.es__1), ("es__2", self.es__2),
                    ("normal", self.normal)]

    escape__struct = struct_property(id_="escape::struct",
                                     structdef=EscapeStruct,
                                     configurationkind=("configure", ),
                                     mode="readwrite")

    class ReadonlyStruct(object):
        readonly_struct_simp = simple_property(
            id_="readonly_struct_simp",
            type_="string",
            defvalue="read only struct property",
        )

        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["readonly_struct_simp"] = self.readonly_struct_simp
            return str(d)

        def getId(self):
            return "readonly_struct"

        def isStruct(self):
            return True

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

    readonly_struct = struct_property(id_="readonly_struct",
                                      structdef=ReadonlyStruct,
                                      configurationkind=("configure", ),
                                      mode="readonly")

    class StructGood(object):
        simp__bad = simple_property(
            id_="simp::bad",
            type_="long",
        )
        simp_bool = simple_property(
            id_="simp_bool",
            type_="boolean",
        )

        def __init__(self, simp__bad=0, simp_bool=False):
            self.simp__bad = simp__bad
            self.simp_bool = simp_bool

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

        def getId(self):
            return "struct_good"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("simp__bad", self.simp__bad),
                    ("simp_bool", self.simp_bool)]

    my_struct_seq = structseq_property(
        id_="my_struct_seq",
        structdef=StructGood,
        defvalue=[StructGood(0, False),
                  StructGood(0, False)],
        configurationkind=("configure", ),
        mode="readwrite")

    class EsSs(object):
        val__1 = simple_property(
            id_="val::1",
            type_="long",
        )
        val_2 = simple_property(
            id_="val_2",
            type_="string",
        )

        def __init__(self, val__1=0, val_2=""):
            self.val__1 = val__1
            self.val_2 = val_2

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

        def getId(self):
            return "es::ss"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("val__1", self.val__1), ("val_2", self.val_2)]

    escape__structseq = structseq_property(id_="escape::structseq",
                                           structdef=EsSs,
                                           defvalue=[EsSs(0, ""),
                                                     EsSs(0, "")],
                                           configurationkind=("configure", ),
                                           mode="readwrite")

    class ReadonlySs(object):
        readonly_s = simple_property(
            id_="readonly_s",
            type_="string",
        )

        def __init__(self, readonly_s=""):
            self.readonly_s = readonly_s

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

        def getId(self):
            return "readonly_ss"

        def isStruct(self):
            return True

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

    readonly_structseq = structseq_property(
        id_="readonly_structseq",
        structdef=ReadonlySs,
        defvalue=[ReadonlySs("read only"),
                  ReadonlySs("struct seq property")],
        configurationkind=("configure", ),
        mode="readonly")
Exemplo n.º 9
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")
class TestComplexProps_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

    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.

    ######################################################################
    # 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.
    complexBooleanProp = simple_property(id_="complexBooleanProp",
                                         type_="boolean",
                                         defvalue=complex(0, 1),
                                         complex=True,
                                         mode="readwrite",
                                         action="external",
                                         kinds=("property", ))

    complexULongProp = simple_property(id_="complexULongProp",
                                       type_="ulong",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("property", ))

    complexShortProp = simple_property(id_="complexShortProp",
                                       type_="short",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("property", ))

    complexFloatProp = simple_property(id_="complexFloatProp",
                                       type_="float",
                                       defvalue=complex(4.0, 5.0),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("property", ))

    complexOctetProp = simple_property(id_="complexOctetProp",
                                       type_="octet",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("property", ))

    complexUShort = simple_property(id_="complexUShort",
                                    type_="ushort",
                                    defvalue=complex(4, 5),
                                    complex=True,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("property", ))

    complexDouble = simple_property(id_="complexDouble",
                                    type_="double",
                                    defvalue=complex(4.0, 5.0),
                                    complex=True,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("property", ))

    complexLong = simple_property(id_="complexLong",
                                  type_="long",
                                  defvalue=complex(4, 5),
                                  complex=True,
                                  mode="readwrite",
                                  action="external",
                                  kinds=("property", ))

    complexLongLong = simple_property(id_="complexLongLong",
                                      type_="longlong",
                                      defvalue=complex(4, 5),
                                      complex=True,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("property", ))

    complexULongLong = simple_property(id_="complexULongLong",
                                       type_="ulonglong",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("property", ))

    complexFloatSequence = simpleseq_property(
        id_="complexFloatSequence",
        type_="float",
        defvalue=[complex(6.0, 7.0),
                  complex(4.0, 5.0),
                  complex(4.0, 5.0)],
        complex=True,
        mode="readwrite",
        action="external",
        kinds=("property", ))

    class _Float(object):
        FloatStructMember = simple_property(id_="FloatStructMember",
                                            type_="float",
                                            defvalue=6.0)

        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["FloatStructMember"] = self.FloatStructMember
            return str(d)

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

        @classmethod
        def isStruct(cls):
            return True

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

    FloatStruct = struct_property(id_="FloatStruct",
                                  structdef=_Float,
                                  configurationkind=("property", ),
                                  mode="readwrite")

    class ComplexFloat(object):
        complexFloatStructMember = simple_property(
            id_="complexFloatStructMember",
            type_="float",
            defvalue=complex(6.0, 7.0),
            complex=True)

        complex_float_seq = simpleseq_property(
            id_="complexFloatStruct::complex_float_seq",
            name="complex_float_seq",
            type_="float",
            defvalue=[complex(3.0, 2.0)],
            complex=True)

        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["complexFloatStructMember"] = self.complexFloatStructMember
            d["complex_float_seq"] = self.complex_float_seq
            return str(d)

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("complexFloatStructMember",
                     self.complexFloatStructMember),
                    ("complex_float_seq", self.complex_float_seq)]

    complexFloatStruct = struct_property(id_="complexFloatStruct",
                                         structdef=ComplexFloat,
                                         configurationkind=("property", ),
                                         mode="readwrite")

    class _FloatStructSequenceMember(object):
        FloatStructSequenceMemberMemember = simple_property(
            id_="FloatStructSequenceMemberMemember",
            type_="float",
            defvalue=6.0)

        float_seq = simpleseq_property(id_="FloatStructSequence::float_seq",
                                       name="float_seq",
                                       type_="float",
                                       defvalue=[3.0])

        def __init__(self,
                     FloatStructSequenceMemberMemember=6.0,
                     float_seq=[3.0]):
            self.FloatStructSequenceMemberMemember = FloatStructSequenceMemberMemember
            self.float_seq = float_seq

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

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("FloatStructSequenceMemberMemember",
                     self.FloatStructSequenceMemberMemember),
                    ("float_seq", self.float_seq)]

    FloatStructSequence = structseq_property(
        id_="FloatStructSequence",
        structdef=_FloatStructSequenceMember,
        defvalue=[],
        configurationkind=("property", ),
        mode="readwrite")

    class ComplexFloatStructSequenceMember(object):
        complexFloatStructSequenceMemberMemember = simple_property(
            id_="complexFloatStructSequenceMemberMemember",
            type_="float",
            defvalue=complex(6.0, 5.0),
            complex=True)

        complex_float_seq = simpleseq_property(
            id_="complexFloatStructSequence::complex_float_seq",
            name="complex_float_seq",
            type_="float",
            defvalue=[complex(3.0, 2.0)],
            complex=True)

        def __init__(self,
                     complexFloatStructSequenceMemberMemember=complex(
                         6.0, 5.0),
                     complex_float_seq=[complex(3.0, 2.0)]):
            self.complexFloatStructSequenceMemberMemember = complexFloatStructSequenceMemberMemember
            self.complex_float_seq = complex_float_seq

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

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("complexFloatStructSequenceMemberMemember",
                     self.complexFloatStructSequenceMemberMemember),
                    ("complex_float_seq", self.complex_float_seq)]

    complexFloatStructSequence = structseq_property(
        id_="complexFloatStructSequence",
        structdef=ComplexFloatStructSequenceMember,
        defvalue=[],
        configurationkind=("property", ),
        mode="readwrite")
class TestAllPropTypes_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


        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.
                

        ######################################################################
        # 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.       
        simple_string = simple_property(id_="simple_string",
                                          type_="string",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_boolean = simple_property(id_="simple_boolean",
                                          type_="boolean",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_ulong = simple_property(id_="simple_ulong",
                                          type_="ulong",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
#        simple_objref = simple_property(id_="simple_objref",
#                                          type_="objref",
#                                          mode="readwrite",
#                                          action="external",
#                                          kinds=("configure",)
#                                          )       
        simple_short = simple_property(id_="simple_short",
                                          type_="short",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_float = simple_property(id_="simple_float",
                                          type_="float",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_octet = simple_property(id_="simple_octet",
                                          type_="octet",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_char = simple_property(id_="simple_char",
                                          type_="char",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_ushort = simple_property(id_="simple_ushort",
                                          type_="ushort",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_double = simple_property(id_="simple_double",
                                          type_="double",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_long = simple_property(id_="simple_long",
                                          type_="long",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_longlong = simple_property(id_="simple_longlong",
                                          type_="longlong",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_ulonglong = simple_property(id_="simple_ulonglong",
                                          type_="ulonglong",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_string = simpleseq_property(id_="simple_sequence_string",  
                                          type_="string",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_boolean = simpleseq_property(id_="simple_sequence_boolean",  
                                          type_="boolean",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_ulong = simpleseq_property(id_="simple_sequence_ulong",  
                                          type_="ulong",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
#        simple_sequence_objref = simpleseq_property(id_="simple_sequence_objref",  
#                                          type_="objref",
#                                          defvalue=None,
#                                          mode="readwrite",
#                                          action="external",
#                                          kinds=("configure",)
#                                          ) 
        simple_sequence_short = simpleseq_property(id_="simple_sequence_short",  
                                          type_="short",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_float = simpleseq_property(id_="simple_sequence_float",  
                                          type_="float",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_octet = simpleseq_property(id_="simple_sequence_octet",  
                                          type_="octet",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_char = simpleseq_property(id_="simple_sequence_char",  
                                          type_="char",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_ushort = simpleseq_property(id_="simple_sequence_ushort",  
                                          type_="ushort",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_double = simpleseq_property(id_="simple_sequence_double",  
                                          type_="double",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_long = simpleseq_property(id_="simple_sequence_long",  
                                          type_="long",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_longlong = simpleseq_property(id_="simple_sequence_longlong",  
                                          type_="longlong",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_ulonglong = simpleseq_property(id_="simple_sequence_ulonglong",  
                                          type_="ulonglong",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )
        class StructVars(object):
            struct_string = simple_property(id_="struct_string",
                                          type_="string",
                                          )
            struct_boolean = simple_property(id_="struct_boolean",
                                          type_="boolean",
                                          )
            struct_ulong = simple_property(id_="struct_ulong",
                                          type_="ulong",
                                          )
#            struct_objref = simple_property(id_="struct_objref",
#                                          type_="objref",
#                                          )
            struct_short = simple_property(id_="struct_short",
                                          type_="short",
                                          )
            struct_float = simple_property(id_="struct_float",
                                          type_="float",
                                          )
            struct_octet = simple_property(id_="struct_octet",
                                          type_="octet",
                                          )
            struct_char = simple_property(id_="struct_char",
                                          type_="char",
                                          )
            struct_ushort = simple_property(id_="struct_ushort",
                                          type_="ushort",
                                          )
            struct_double = simple_property(id_="struct_double",
                                          type_="double",
                                          )
            struct_long = simple_property(id_="struct_long",
                                          type_="long",
                                          )
            struct_longlong = simple_property(id_="struct_longlong",
                                          type_="longlong",
                                          )
            struct_ulonglong = simple_property(id_="struct_ulonglong",
                                          type_="ulonglong",
                                          )
        
            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["struct_string"] = self.struct_string
                d["struct_boolean"] = self.struct_boolean
                d["struct_ulong"] = self.struct_ulong
#                d["struct_objref"] = self.struct_objref
                d["struct_short"] = self.struct_short
                d["struct_float"] = self.struct_float
                d["struct_octet"] = self.struct_octet
                d["struct_char"] = self.struct_char
                d["struct_ushort"] = self.struct_ushort
                d["struct_double"] = self.struct_double
                d["struct_long"] = self.struct_long
                d["struct_longlong"] = self.struct_longlong
                d["struct_ulonglong"] = self.struct_ulonglong
                return str(d)

            def getId(self):
                return "struct_vars"

            def isStruct(self):
                return True

            def getMembers(self):
                return [("struct_string",self.struct_string),("struct_boolean",self.struct_boolean),("struct_ulong",self.struct_ulong),#("struct_objref",self.struct_objref),
("struct_short",self.struct_short),("struct_float",self.struct_float),("struct_octet",self.struct_octet),("struct_char",self.struct_char),("struct_ushort",self.struct_ushort),("struct_double",self.struct_double),("struct_long",self.struct_long),("struct_longlong",self.struct_longlong),("struct_ulonglong",self.struct_ulonglong)]

        
        struct_vars = struct_property(id_="struct_vars",
                                          structdef=StructVars,
                                          configurationkind=("configure",),
                                          mode="readwrite"
                                          )
        class StructSeqVars(object):
            struct_seq_string = simple_property(id_="struct_seq_string",
                                          type_="string",
                                          )
            struct_seq_boolean = simple_property(id_="struct_seq_boolean",
                                          type_="boolean",
                                          )
            struct_seq_ulong = simple_property(id_="struct_seq_ulong",
                                          type_="ulong",
                                          )
#            struct_seq_objref = simple_property(id_="struct_seq_objref",
#                                          type_="objref",
#                                          )
            struct_seq_short = simple_property(id_="struct_seq_short",
                                          type_="short",
                                          )
            struct_seq_float = simple_property(id_="struct_seq_float",
                                          type_="float",
                                          )
            struct_seq_octet = simple_property(id_="struct_seq_octet",
                                          type_="octet",
                                          )
            struct_seq_char = simple_property(id_="struct_seq_char",
                                          type_="char",
                                          )
            struct_seq_ushort = simple_property(id_="struct_seq_ushort",
                                          type_="ushort",
                                          )
            struct_seq_double = simple_property(id_="struct_seq_double",
                                          type_="double",
                                          )
            struct_seq_long = simple_property(id_="struct_seq_long",
                                          type_="long",
                                          )
            struct_seq_longlong = simple_property(id_="struct_seq_longlong",
                                          type_="longlong",
                                          )
            struct_seq_ulonglong = simple_property(id_="struct_seq_ulonglong",
                                          type_="ulonglong",
                                          )
        
            def __init__(self, struct_seq_string="", struct_seq_boolean=False, struct_seq_ulong=0, struct_seq_objref="", struct_seq_short=0, struct_seq_float=0, struct_seq_octet=0, struct_seq_char="", struct_seq_ushort=0, struct_seq_double=0, struct_seq_long=0, struct_seq_longlong=0, struct_seq_ulonglong=0):
                self.struct_seq_string = struct_seq_string
                self.struct_seq_boolean = struct_seq_boolean
                self.struct_seq_ulong = struct_seq_ulong
                self.struct_seq_objref = struct_seq_objref
                self.struct_seq_short = struct_seq_short
                self.struct_seq_float = struct_seq_float
                self.struct_seq_octet = struct_seq_octet
                self.struct_seq_char = struct_seq_char
                self.struct_seq_ushort = struct_seq_ushort
                self.struct_seq_double = struct_seq_double
                self.struct_seq_long = struct_seq_long
                self.struct_seq_longlong = struct_seq_longlong
                self.struct_seq_ulonglong = struct_seq_ulonglong

            def __str__(self):
                """Return a string representation of this structure"""
                d = {}
                d["struct_seq_string"] = self.struct_seq_string
                d["struct_seq_boolean"] = self.struct_seq_boolean
                d["struct_seq_ulong"] = self.struct_seq_ulong
                d["struct_seq_objref"] = self.struct_seq_objref
                d["struct_seq_short"] = self.struct_seq_short
                d["struct_seq_float"] = self.struct_seq_float
                d["struct_seq_octet"] = self.struct_seq_octet
                d["struct_seq_char"] = self.struct_seq_char
                d["struct_seq_ushort"] = self.struct_seq_ushort
                d["struct_seq_double"] = self.struct_seq_double
                d["struct_seq_long"] = self.struct_seq_long
                d["struct_seq_longlong"] = self.struct_seq_longlong
                d["struct_seq_ulonglong"] = self.struct_seq_ulonglong
                return str(d)

            def getId(self):
                return "struct_seq_vars"

            def isStruct(self):
                return True

            def getMembers(self):
                return [("struct_seq_string",self.struct_seq_string),("struct_seq_boolean",self.struct_seq_boolean),("struct_seq_ulong",self.struct_seq_ulong),("struct_seq_objref",self.struct_seq_objref),("struct_seq_short",self.struct_seq_short),("struct_seq_float",self.struct_seq_float),("struct_seq_octet",self.struct_seq_octet),("struct_seq_char",self.struct_seq_char),("struct_seq_ushort",self.struct_seq_ushort),("struct_seq_double",self.struct_seq_double),("struct_seq_long",self.struct_seq_long),("struct_seq_longlong",self.struct_seq_longlong),("struct_seq_ulonglong",self.struct_seq_ulonglong)]

                
        struct_seq = structseq_property(id_="struct_seq",
                                          structdef=StructSeqVars,                          
                                          defvalue=[],
                                          configurationkind=("configure",),
                                          mode="readwrite"
                                          )
Exemplo n.º 12
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
Exemplo n.º 13
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")
Exemplo n.º 14
0
class TestStructDep(CF__POA.Resource, Resource):
    """Python component for testing properties"""

    prop1 = simple_property(id_="DCE:b8f43ac8-26b5-40b3-9102-d127b84f9e4b",
                            name="string_prop",
                            type_="string",
                            action="external",
                            kinds=("configure", ))

    prop2 = simpleseq_property(
        id_="DCE:10b3364d-f035-4639-8e7f-02ac4706f5c7[]",
        name="stringseq_prop",
        type_="string",
        action="external",
        kinds=("configure", ))

    prop3 = simple_property(id_="float_capacity",
                            name="float_capacity",
                            type_="float",
                            action="external",
                            kinds=("configure", ),
                            defvalue=0.123)

    prop4 = simple_property(id_="test_double",
                            name="test_double",
                            type_="double",
                            action="external",
                            kinds=("configure", ),
                            defvalue=1.234)

    class SomeStruct(object):
        field1 = simple_property(id_="long_capacity",
                                 type_="long",
                                 defvalue=100)
        field2 = simple_property(id_="another_float_capacity",
                                 type_="float",
                                 defvalue=1.234)

    struct = struct_property(id_="struct_test",
                             name="struct_test",
                             structdef=SomeStruct)

    class MulticastAddress(object):
        ip_address = simple_property(id_="ip_address", type_="string")
        port = simple_property(id_="port", type_="ushort")

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

    multicasts = structseq_property(
        id_="DCE:897a5489-f680-46a8-a698-e36fd8bbae80[]",
        name="multicasts",
        structdef=MulticastAddress,
        defvalue=[
            MulticastAddress("127.0.0.1", 6800),
            MulticastAddress("127.0.0.1", 42000)
        ])

    magicword = simple_property(
        id_="magicword",
        name="magicword",
        type_="string",
        action="external",
        kinds=("configure", ),
        defvalue="nada - better change me when you create me")

    def __init__(self, identifier, execparams):
        Resource.__init__(self, identifier, execparams)
class comp_prop_special_char_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

    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.

    ######################################################################
    # 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 MyBase(object):
        my_element = simple_property(id_="my:element",
                                     type_="string",
                                     defvalue="foo")

        my_stuff = simple_property(id_="my.stuff",
                                   type_="string",
                                   defvalue="bar")

        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["my_element"] = self.my_element
            d["my_stuff"] = self.my_stuff
            return str(d)

        @classmethod
        def getId(cls):
            return "my:base"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("my_element", self.my_element),
                    ("my_stuff", self.my_stuff)]

    my_base = struct_property(id_="my:base",
                              structdef=MyBase,
                              configurationkind=("property", ),
                              mode="readwrite")

    class MyStr(object):
        my_seq_my_str_my_prop = simple_property(id_="my_seq:my_str:my_prop",
                                                type_="string",
                                                defvalue="qwe")

        def __init__(self, my_seq_my_str_my_prop="qwe"):
            self.my_seq_my_str_my_prop = my_seq_my_str_my_prop

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

        @classmethod
        def getId(cls):
            return "my:str"

        @classmethod
        def isStruct(cls):
            return True

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

    my_seq = structseq_property(id_="my:seq",
                                structdef=MyStr,
                                defvalue=[],
                                configurationkind=("property", ),
                                mode="readwrite")
                d["tuner_number"] = self.tuner_number
                return str(d)
        
            def getId(self):
                return "frontend_tuner_status_struct"
        
            def isStruct(self):
                return True
        
            def getMembers(self):
                return [("tuner_type",self.tuner_type),("allocation_id_csv",self.allocation_id_csv),("center_frequency",self.center_frequency),("bandwidth",self.bandwidth),("sample_rate",self.sample_rate),("group_id",self.group_id),("rf_flow_id",self.rf_flow_id),("enabled",self.enabled),("bandwidth_tolerance",self.bandwidth_tolerance),("sample_rate_tolerance",self.sample_rate_tolerance),("complex",self.complex),("gain",self.gain),("agc",self.agc),("valid",self.valid),("available_frequency",self.available_frequency),("available_bandwidth",self.available_bandwidth),("available_gain",self.available_gain),("available_sample_rate",self.available_sample_rate),("reference_source",self.reference_source),("output_format",self.output_format),("output_multicast",self.output_multicast),("output_vlan",self.output_vlan),("output_port",self.output_port),("decimation",self.decimation),("tuner_number",self.tuner_number)]

        frontend_tuner_status = structseq_property(id_="FRONTEND::tuner_status",
                                                   name="frontend_tuner_status",
                                                   structdef=FrontendTunerStatusStruct,
                                                   defvalue=[],
                                                   configurationkind=("configure",),
                                                   mode="readonly",
                                                   description="""Frontend Interfaces v2.0 status structure. One element for every frontend resource (receiver, transmitter) configured on this hardware"""
                                                   )
        class SimChannelStruct(object):
            tuner_type = simple_property(id_="sim::tuner_type",
                                         name="tuner_type",
                                         type_="string",
                                         defvalue="RX_DIGITIZER",
                                         )
            freq_min = simple_property(id_="sim::freq_min",
                                       name="freq_min",
                                       type_="double",
                                       )
            freq_max = simple_property(id_="sim::freq_max",
                                       name="freq_max",
class writeonly_py_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

        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.

        ######################################################################
        # 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",),
                                      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",),
                                       description=""" This specifies the specific device""")


        foo = simple_property(id_="foo",
                              type_="string",
                              defvalue="something",
                              mode="writeonly",
                              action="external",
                              kinds=("allocation",))


        foo_seq = simpleseq_property(id_="foo_seq",
                                     type_="string",
                                     defvalue=["abc"                                             ],
                                     mode="writeonly",
                                     action="external",
                                     kinds=("allocation",))


        class FooStruct(object):
            abc = simple_property(
                                  id_="abc",
                                  
                                  type_="string",
                                  defvalue="def"
                                  )
        
            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["abc"] = self.abc
                return str(d)
        
            @classmethod
            def getId(cls):
                return "foo_struct"
        
            @classmethod
            def isStruct(cls):
                return True
        
            def getMembers(self):
                return [("abc",self.abc)]

        foo_struct = struct_property(id_="foo_struct",
                                     structdef=FooStruct,
                                     configurationkind=("allocation",),
                                     mode="writeonly")


        class Ghi(object):
            jkl = simple_property(
                                  id_="jkl",
                                  
                                  type_="string")
        
            def __init__(self, jkl=""):
                self.jkl = jkl
        
            def __str__(self):
                """Return a string representation of this structure"""
                d = {}
                d["jkl"] = self.jkl
                return str(d)
        
            @classmethod
            def getId(cls):
                return "ghi"
        
            @classmethod
            def isStruct(cls):
                return True
        
            def getMembers(self):
                return [("jkl",self.jkl)]

        foo_struct_seq = structseq_property(id_="foo_struct_seq",
                                            structdef=Ghi,
                                            defvalue=[Ghi(jkl="mno")],
                                            configurationkind=("allocation",),
                                            mode="writeonly")
class default_kinds_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

    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.

    ######################################################################
    # 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.
    long_prop = simple_property(id_="long_prop",
                                type_="long",
                                defvalue=0,
                                mode="readwrite",
                                action="external",
                                kinds=("configure", ))

    floatseq_prop = simpleseq_property(id_="floatseq_prop",
                                       type_="float",
                                       defvalue=None,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))

    class StructProp(object):
        string_field = simple_property(id_="struct_prop::string_field",
                                       name="string_field",
                                       type_="string")

        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["string_field"] = self.string_field
            return str(d)

        def getId(self):
            return "struct_prop"

        def isStruct(self):
            return True

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

    struct_prop = struct_property(id_="struct_prop",
                                  structdef=StructProp,
                                  configurationkind=("configure", ),
                                  mode="readwrite")

    class Endpoint(object):
        address = simple_property(id_="endpoints::endpoint::address",
                                  name="address",
                                  type_="string",
                                  defvalue="")

        port = simple_property(id_="endpoints::endpoint::port",
                               name="port",
                               type_="short",
                               defvalue=0)

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

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

        def getId(self):
            return "endpoints::endpoint"

        def isStruct(self):
            return True

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

    endpoints = structseq_property(id_="endpoints",
                                   structdef=Endpoint,
                                   defvalue=[],
                                   configurationkind=("configure", ),
                                   mode="readwrite")
Exemplo n.º 19
0
class PropertyComponent_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 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_propEvent = PropertyEventSupplier(self)

    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

    port_propEvent = usesport(
        name="propEvent",
        repid="IDL:omg.org/CosEventChannelAdmin/EventChannel:1.0",
        type_="responses",
    )

    ######################################################################
    # 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.
    simplePropStr = simple_property(id_="simplePropStr",
                                    type_="string",
                                    defvalue="Hello",
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", "event"))
    simplePropBoolean = simple_property(id_="simplePropBoolean",
                                        type_="boolean",
                                        defvalue=True,
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))
    simplePropUlong = simple_property(id_="simplePropUlong",
                                      type_="ulong",
                                      defvalue=1,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    simplePropObjRef = simple_property(id_="simplePropObjRef",
                                       type_="objref",
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    simplePropShort = simple_property(id_="simplePropShort",
                                      type_="short",
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    simplePropFloat = simple_property(id_="simplePropFloat",
                                      type_="float",
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    simplePropOctet = simple_property(id_="simplePropOctet",
                                      type_="octet",
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    simplePropChar = simple_property(id_="simplePropChar",
                                     type_="char",
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    simplePropUShort = simple_property(id_="simplePropUShort",
                                       type_="ushort",
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    simplePropDouble = simple_property(id_="simplePropDouble",
                                       type_="double",
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    simplePropLong = simple_property(id_="simplePropLong",
                                     type_="long",
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    simplePropLongLong = simple_property(id_="simplePropLongLong",
                                         type_="longlong",
                                         mode="readwrite",
                                         action="external",
                                         kinds=("configure", ))
    simplePropUlonglong = simple_property(id_="simplePropUlonglong",
                                          type_="ulonglong",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure", ))
    simpleEnum = simple_property(id_="simpleEnum",
                                 type_="string",
                                 defvalue="hello",
                                 mode="readwrite",
                                 action="external",
                                 kinds=("configure", ))
    simpleReadOnly = simple_property(id_="simpleReadOnly",
                                     type_="string",
                                     defvalue="READ ONLY VALUE",
                                     mode="readonly",
                                     action="external",
                                     kinds=("configure", ))
    seqPropStr = simpleseq_property(id_="seqPropStr",
                                    type_="string",
                                    defvalue=("test", "test1", "test3"),
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    seqPropBoolean = simpleseq_property(id_="seqPropBoolean",
                                        type_="boolean",
                                        defvalue=None,
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))
    seqPropULong = simpleseq_property(id_="seqPropULong",
                                      type_="ulong",
                                      defvalue=None,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    seqPropObjRef = simpleseq_property(id_="seqPropObjRef",
                                       type_="objref",
                                       defvalue=None,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    seqPropShort = simpleseq_property(id_="seqPropShort",
                                      type_="short",
                                      defvalue=None,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    seqPropFloat = simpleseq_property(id_="seqPropFloat",
                                      type_="float",
                                      defvalue=None,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    seqPropOctet = simpleseq_property(id_="seqPropOctet",
                                      type_="octet",
                                      defvalue=None,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    seqPropChar = simpleseq_property(id_="seqPropChar",
                                     type_="char",
                                     defvalue=None,
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    seqPropUShort = simpleseq_property(id_="seqPropUShort",
                                       type_="ushort",
                                       defvalue=None,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    seqPropDouble = simpleseq_property(id_="seqPropDouble",
                                       type_="double",
                                       defvalue=None,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    seqPropLong = simpleseq_property(id_="seqPropLong",
                                     type_="long",
                                     defvalue=None,
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    seqPropLongLong = simpleseq_property(id_="seqPropLongLong",
                                         type_="longlong",
                                         defvalue=None,
                                         mode="readwrite",
                                         action="external",
                                         kinds=("configure", ))
    seqPropulonglong = simpleseq_property(id_="seqPropulonglong",
                                          type_="ulonglong",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure", ))

    class StructProp(object):
        structSimpleStr = simple_property(
            id_="structSimpleStr",
            type_="string",
        )
        structSimpleBoolean = simple_property(
            id_="structSimpleBoolean",
            type_="boolean",
        )
        structSimpleulong = simple_property(
            id_="structSimpleulong",
            type_="ulong",
        )
        structSimpleObjRef = simple_property(
            id_="structSimpleObjRef",
            type_="objref",
        )
        structSimpleShort = simple_property(
            id_="structSimpleShort",
            type_="short",
        )
        structSimpleFloat = simple_property(
            id_="structSimpleFloat",
            type_="float",
        )
        structSimpleOctet = simple_property(
            id_="structSimpleOctet",
            type_="octet",
        )
        structSimpleChar = simple_property(
            id_="structSimpleChar",
            type_="char",
        )
        structSimpleushort = simple_property(
            id_="structSimpleushort",
            type_="ushort",
        )
        structSimpledouble = simple_property(
            id_="structSimpledouble",
            type_="double",
        )
        structSimplelong = simple_property(
            id_="structSimplelong",
            type_="long",
        )
        structSimplelonglong = simple_property(
            id_="structSimplelonglong",
            type_="longlong",
        )
        structSimpleulonglong = simple_property(
            id_="structSimpleulonglong",
            type_="ulonglong",
        )
        structSimpleEnum = simple_property(
            id_="structSimpleEnum",
            type_="double",
            defvalue=1.5,
        )

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

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["structSimpleStr"] = self.structSimpleStr
            d["structSimpleBoolean"] = self.structSimpleBoolean
            d["structSimpleulong"] = self.structSimpleulong
            d["structSimpleObjRef"] = self.structSimpleObjRef
            d["structSimpleShort"] = self.structSimpleShort
            d["structSimpleFloat"] = self.structSimpleFloat
            d["structSimpleOctet"] = self.structSimpleOctet
            d["structSimpleChar"] = self.structSimpleChar
            d["structSimpleushort"] = self.structSimpleushort
            d["structSimpledouble"] = self.structSimpledouble
            d["structSimplelong"] = self.structSimplelong
            d["structSimplelonglong"] = self.structSimplelonglong
            d["structSimpleulonglong"] = self.structSimpleulonglong
            d["structSimpleEnum"] = self.structSimpleEnum
            return str(d)

        def getId(self):
            return "structProp"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("structSimpleStr", self.structSimpleStr),
                    ("structSimpleBoolean", self.structSimpleBoolean),
                    ("structSimpleulong", self.structSimpleulong),
                    ("structSimpleObjRef", self.structSimpleObjRef),
                    ("structSimpleShort", self.structSimpleShort),
                    ("structSimpleFloat", self.structSimpleFloat),
                    ("structSimpleOctet", self.structSimpleOctet),
                    ("structSimpleChar", self.structSimpleChar),
                    ("structSimpleushort", self.structSimpleushort),
                    ("structSimpledouble", self.structSimpledouble),
                    ("structSimplelong", self.structSimplelong),
                    ("structSimplelonglong", self.structSimplelonglong),
                    ("structSimpleulonglong", self.structSimpleulonglong),
                    ("structSimpleEnum", self.structSimpleEnum)]

    structProp = struct_property(id_="structProp",
                                 structdef=StructProp,
                                 configurationkind=("configure", ),
                                 mode="readwrite")

    class StructSeq(object):
        structSeqSimple = simple_property(
            id_="structSeqSimple",
            type_="string",
        )
        structSeqSimpleBoolean = simple_property(
            id_="structSeqSimpleBoolean",
            type_="boolean",
        )
        structSeqSimpleUlong = simple_property(
            id_="structSeqSimpleUlong",
            type_="ulong",
        )
        structSeqSimpleObjecRef = simple_property(
            id_="structSeqSimpleObjecRef",
            type_="objref",
        )
        structSeqSimpleShort = simple_property(
            id_="structSeqSimpleShort",
            type_="short",
        )
        structSeqFloat = simple_property(
            id_="structSeqFloat",
            type_="float",
        )
        structSeqSimpleOctet = simple_property(
            id_="structSeqSimpleOctet",
            type_="octet",
        )
        structSeqSimpleChar = simple_property(
            id_="structSeqSimpleChar",
            type_="char",
        )
        structSeqSimpleushort = simple_property(
            id_="structSeqSimpleushort",
            type_="ushort",
        )
        structSeqSimpleDouble = simple_property(
            id_="structSeqSimpleDouble",
            type_="double",
        )
        structSeqSimpleLong = simple_property(
            id_="structSeqSimpleLong",
            type_="long",
        )
        structSeqSimpleLongLong = simple_property(
            id_="structSeqSimpleLongLong",
            type_="longlong",
        )
        structSeqSimpleULongLong = simple_property(
            id_="structSeqSimpleULongLong",
            type_="ulonglong",
        )
        structSeqSimpleEnum = simple_property(
            id_="structSeqSimpleEnum",
            type_="string",
            defvalue="3",
        )

        def __init__(self,
                     structSeqSimple="",
                     structSeqSimpleBoolean=False,
                     structSeqSimpleUlong=0,
                     structSeqSimpleObjecRef="",
                     structSeqSimpleShort=0,
                     structSeqFloat=0,
                     structSeqSimpleOctet=0,
                     structSeqSimpleChar="",
                     structSeqSimpleushort=0,
                     structSeqSimpleDouble=0,
                     structSeqSimpleLong=0,
                     structSeqSimpleLongLong=0,
                     structSeqSimpleULongLong=0,
                     structSeqSimpleEnum=""):
            self.structSeqSimple = structSeqSimple
            self.structSeqSimpleBoolean = structSeqSimpleBoolean
            self.structSeqSimpleUlong = structSeqSimpleUlong
            self.structSeqSimpleObjecRef = structSeqSimpleObjecRef
            self.structSeqSimpleShort = structSeqSimpleShort
            self.structSeqFloat = structSeqFloat
            self.structSeqSimpleOctet = structSeqSimpleOctet
            self.structSeqSimpleChar = structSeqSimpleChar
            self.structSeqSimpleushort = structSeqSimpleushort
            self.structSeqSimpleDouble = structSeqSimpleDouble
            self.structSeqSimpleLong = structSeqSimpleLong
            self.structSeqSimpleLongLong = structSeqSimpleLongLong
            self.structSeqSimpleULongLong = structSeqSimpleULongLong
            self.structSeqSimpleEnum = structSeqSimpleEnum

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["structSeqSimple"] = self.structSeqSimple
            d["structSeqSimpleBoolean"] = self.structSeqSimpleBoolean
            d["structSeqSimpleUlong"] = self.structSeqSimpleUlong
            d["structSeqSimpleObjecRef"] = self.structSeqSimpleObjecRef
            d["structSeqSimpleShort"] = self.structSeqSimpleShort
            d["structSeqFloat"] = self.structSeqFloat
            d["structSeqSimpleOctet"] = self.structSeqSimpleOctet
            d["structSeqSimpleChar"] = self.structSeqSimpleChar
            d["structSeqSimpleushort"] = self.structSeqSimpleushort
            d["structSeqSimpleDouble"] = self.structSeqSimpleDouble
            d["structSeqSimpleLong"] = self.structSeqSimpleLong
            d["structSeqSimpleLongLong"] = self.structSeqSimpleLongLong
            d["structSeqSimpleULongLong"] = self.structSeqSimpleULongLong
            d["structSeqSimpleEnum"] = self.structSeqSimpleEnum
            return str(d)

        def getId(self):
            return "structSeqStruct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("structSeqSimple", self.structSeqSimple),
                    ("structSeqSimpleBoolean", self.structSeqSimpleBoolean),
                    ("structSeqSimpleUlong", self.structSeqSimpleUlong),
                    ("structSeqSimpleObjecRef", self.structSeqSimpleObjecRef),
                    ("structSeqSimpleShort", self.structSeqSimpleShort),
                    ("structSeqFloat", self.structSeqFloat),
                    ("structSeqSimpleOctet", self.structSeqSimpleOctet),
                    ("structSeqSimpleChar", self.structSeqSimpleChar),
                    ("structSeqSimpleushort", self.structSeqSimpleushort),
                    ("structSeqSimpleDouble", self.structSeqSimpleDouble),
                    ("structSeqSimpleLong", self.structSeqSimpleLong),
                    ("structSeqSimpleLongLong", self.structSeqSimpleLongLong),
                    ("structSeqSimpleULongLong",
                     self.structSeqSimpleULongLong),
                    ("structSeqSimpleEnum", self.structSeqSimpleEnum)]

    structSeq = structseq_property(id_="structSeq",
                                   structdef=StructSeq,
                                   defvalue=[],
                                   configurationkind=("configure", ),
                                   mode="readwrite")
Exemplo n.º 20
0
        mode="readonly",
        action="eq",
        kinds=("allocation", "configure"),
        description=""" This specifies the specific device""")
    frontend_video_allocation = struct_property(
        id_="FRONTEND::video_allocation",
        name="frontend_video_allocation",
        structdef=frontend_video_allocation,
        configurationkind=("allocation", ),
        mode="readwrite",
        description="""Frontend Interfaces v2.0 main allocation structure""")
    frontend_listener_allocation = struct_property(
        id_="FRONTEND::listener_allocation",
        name="frontend_listener_allocation",
        structdef=frontend_listener_allocation,
        configurationkind=("allocation", ),
        mode="readwrite",
        description=
        """Allocates a listener (subscriber) based off a previous allocation """
    )
    frontend_video_status = structseq_property(
        id_="FRONTEND::video_status",
        name="frontend_video_status",
        structdef=default_frontend_video_status_struct_struct,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readonly",
        description=
        """Frontend Interfaces v2.0 status structure. One element for every frontend resource (receiver, transmitter) configured on this hardware"""
    )
Exemplo n.º 21
0
class TestPythonProps (CF__POA.Resource, Resource):
    """Python component for testing properties"""

    prop1 = simple_property(id_="DCE:b8f43ac8-26b5-40b3-9102-d127b84f9e4b",
                            name="string_prop",
                            type_="string",
                            action="external",
                            kinds=("configure",))

    prop2 = simpleseq_property(id_="DCE:10b3364d-f035-4639-8e7f-02ac4706f5c7[]",
                               name="stringseq_prop",
                               type_="string",
                               action="external",
                               kinds=("configure",))

    prop3 = simple_property(id_="test_float",
                            name="test_float",
                            type_="float",
                            action="external",
                            kinds=("configure",),
                            defvalue=1.234)

    prop4 = simple_property(id_="test_double",
                            name="test_double",
                            type_="double",
                            action="external",
                            kinds=("configure",),
                            defvalue=1.234)

    class SomeStruct(object):
        field1 = simple_property(id_="item1",
                type_="string",
                defvalue="value1")
        field2 = simple_property(id_="item2",
                type_="long",
                defvalue=100)
        field3 = simple_property(id_="item3",
                type_="double",
                defvalue=3.14156)
        field4 = simple_property(id_="item4",
                type_="float",
                defvalue=1.234)

    struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f", 
                            name="struct_test", 
                            structdef=SomeStruct)

    class MulticastAddress(object):
        ip_address = simple_property(id_="ip_address", type_="string")
        port = simple_property(id_="port", type_="ushort")

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


    multicasts = structseq_property(id_="DCE:897a5489-f680-46a8-a698-e36fd8bbae80[]",
                                    name="multicasts",
                                    structdef=MulticastAddress,
                                    defvalue=[MulticastAddress("127.0.0.1", 6800), MulticastAddress("127.0.0.1", 42000)])

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

    def runTest(self, test, props):
        if test == 0:
            # Inject values directly into property storage to allow testing of
            # bad conditions (invalid values)
            for dt in props:
                try:
                    self._props[dt.id] = from_any(dt.value)
                except KeyError:
                    pass
        return []
Exemplo n.º 22
0
class BadReleaseBefore(CF__POA.AggregateExecutableDevice, ExecutableDevice,
                       AggregateDevice):
    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        ExecutableDevice.__init__(self, devmgr, uuid, label, softwareProfile,
                                  compositeDevice, execparams, PROPERTIES)
        AggregateDevice.__init__(self)
        self._props["memCapacity"] = 100000000
        self._props["BogoMipsCapacity"] = 100000000
        self._props["nicCapacity"] = 100.0
        self._props["fakeCapacity"] = 3
        self._props["execparams"] = " ".join(
            ["%s %s" % x for x in execparams.items()])

    def execute(self, name, options, parameters):
        retval = ExecutableDevice.execute(self, name, options, parameters)
        for option in options:
            if option.id == 'STACK_SIZE':
                self._props['check_STACK_SIZE'] = option.value._v
            elif option.id == 'PRIORITY':
                self._props['check_PRIORITY'] = option.value._v
        return retval

    # See BasicChildDevice for an example of manually dealing with allocate/deallocate
    def allocate_fakeCapacity(self, value):
        if self._props["fakeCapacity"] < value:
            return False
        self._props["fakeCapacity"] = self._props["fakeCapacity"] - value
        return True

    def allocate_nicCapacity(self, value):
        if self._props["nicCapacity"] < value:
            return False
        self._props["nicCapacity"] = self._props["nicCapacity"] - value
        return True

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

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

    def deallocate_fakeCapacity(self, value):
        self._props["fakeCapacity"] = self._props["fakeCapacity"] + value

    def deallocate_nicCapacity(self, value):
        self._props["nicCapacity"] = self._props["nicCapacity"] + value

    def deallocate_memCapacity(self, value):
        self._props["memCapacity"] = self._props["memCapacity"] + value

    def deallocate_BogoMipsCapacity(self, value):
        self._props[
            "BogoMipsCapacity"] = self._props["BogoMipsCapacity"] + value

    def allocate_allocStruct(self, value):
        if value > self.allocStruct:
            return False

        self.allocStruct -= value
        return True

    def deallocate_allocStruct(self, value):
        self.allocStruct += value

    def updateUsageState(self):
        # Update usage state
        if self._props["memCapacity"] == 0 and self._props[
                "BogoMipsCapacity"] == 0:
            self._usageState = CF.Device.BUSY
        elif self._props["memCapacity"] == 100000000 and self._props[
                "BogoMipsCapacity"] == 100000000:
            self._usageState = CF.Device.IDLE
        else:
            self._usageState = CF.Device.ACTIVE

    def releaseObject(self):
        a = b
        ExecutableDevice.releaseObject(self)

    class SomeStruct(object):
        field1 = simple_property(id_="item1",
                                 type_="string",
                                 defvalue="value1")
        field2 = simple_property(id_="item2", type_="long", defvalue=100)
        field3 = simple_property(id_="item3", type_="double", defvalue=3.14156)

    struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f",
                             name="struct_test",
                             structdef=SomeStruct)

    class AllocStruct(object):
        long_capacity = simple_property(id_="long_capacity",
                                        type_="long",
                                        defvalue=100)
        float_capacity = simple_property(id_="float_capacity",
                                         type_="float",
                                         defvalue=1.0)

        def __gt__(self, other):
            if self.long_capacity <= other.long_capacity:
                return False
            if self.float_capacity <= other.float_capacity:
                return False
            return True

        def __iadd__(self, other):
            self.long_capacity += other.long_capacity
            self.float_capacity += other.float_capacity
            return self

        def __isub__(self, other):
            self.long_capacity -= other.long_capacity
            self.float_capacity -= other.float_capacity
            return self

    allocStruct = struct_property(
        id_="DCE:001fad60-b4b3-4ed2-94cb-40e1d956bf4f",
        name="allocStruct",
        configurationkind=("configure", "allocation"),
        structdef=AllocStruct)

    structseq = structseq_property(
        id_="DCE:e836f007-5821-4671-b05a-e0ff5147fe86",
        name="structseq_test",
        structdef=SomeStruct,
        defvalue=[])
Exemplo n.º 23
0
class TestPythonPropsRange_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

    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.

    ######################################################################
    # 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.
    my_octet_name = simple_property(id_="my_octet",
                                    name="my_octet_name",
                                    type_="octet",
                                    defvalue=1,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_short_name = simple_property(id_="my_short",
                                    name="my_short_name",
                                    type_="short",
                                    defvalue=2,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_ushort_name = simple_property(id_="my_ushort",
                                     name="my_ushort_name",
                                     type_="ushort",
                                     defvalue=3,
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    my_long_name = simple_property(id_="my_long",
                                   name="my_long_name",
                                   type_="long",
                                   defvalue=4,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    my_ulong_name = simple_property(id_="my_ulong",
                                    name="my_ulong_name",
                                    type_="ulong",
                                    defvalue=5,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_longlong_name = simple_property(id_="my_longlong",
                                       name="my_longlong_name",
                                       type_="longlong",
                                       defvalue=6,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    my_ulonglong_name = simple_property(id_="my_ulonglong",
                                        name="my_ulonglong_name",
                                        type_="ulonglong",
                                        defvalue=7,
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))
    seq_octet_name = simpleseq_property(id_="seq_octet",
                                        name="seq_octet_name",
                                        type_="octet",
                                        defvalue="\x01\x02",
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))
    seq_short_name = simpleseq_property(id_="seq_short",
                                        name="seq_short_name",
                                        type_="short",
                                        defvalue=(1, 2),
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))
    seq_ushort_name = simpleseq_property(id_="seq_ushort",
                                         name="seq_ushort_name",
                                         type_="ushort",
                                         defvalue=(1, 2),
                                         mode="readwrite",
                                         action="external",
                                         kinds=("configure", ))
    seq_long_name = simpleseq_property(id_="seq_long",
                                       name="seq_long_name",
                                       type_="long",
                                       defvalue=(1, 2),
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    seq_ulong_name = simpleseq_property(id_="seq_ulong",
                                        name="seq_ulong_name",
                                        type_="ulong",
                                        defvalue=(1, 2),
                                        mode="readwrite",
                                        action="external",
                                        kinds=("configure", ))
    seq_longlong_name = simpleseq_property(id_="seq_longlong",
                                           name="seq_longlong_name",
                                           type_="longlong",
                                           defvalue=(1, 2),
                                           mode="readwrite",
                                           action="external",
                                           kinds=("configure", ))
    seq_ulonglong_name = simpleseq_property(id_="seq_ulonglong",
                                            name="seq_ulonglong_name",
                                            type_="ulonglong",
                                            defvalue=(1, 2),
                                            mode="readwrite",
                                            action="external",
                                            kinds=("configure", ))
    seq_char_name = simpleseq_property(id_="seq_char",
                                       name="seq_char_name",
                                       type_="char",
                                       defvalue="ab",
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))

    class MyStructName(object):
        struct_octet_name = simple_property(
            id_="struct_octet",
            name="struct_octet_name",
            type_="octet",
            defvalue=1,
        )
        struct_short_name = simple_property(
            id_="struct_short",
            name="struct_short_name",
            type_="short",
            defvalue=2,
        )
        struct_ushort_name = simple_property(
            id_="struct_ushort",
            name="struct_ushort_name",
            type_="ushort",
            defvalue=3,
        )
        struct_long_name = simple_property(
            id_="struct_long",
            name="struct_long_name",
            type_="long",
            defvalue=4,
        )
        struct_ulong_name = simple_property(
            id_="struct_ulong",
            name="struct_ulong_name",
            type_="ulong",
            defvalue=5,
        )
        struct_longlong_name = simple_property(
            id_="struct_longlong",
            name="struct_longlong_name",
            type_="longlong",
            defvalue=6,
        )
        struct_ulonglong_name = simple_property(
            id_="struct_ulonglong",
            name="struct_ulonglong_name",
            type_="ulonglong",
            defvalue=7,
        )

        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["struct_octet_name"] = self.struct_octet_name
            d["struct_short_name"] = self.struct_short_name
            d["struct_ushort_name"] = self.struct_ushort_name
            d["struct_long_name"] = self.struct_long_name
            d["struct_ulong_name"] = self.struct_ulong_name
            d["struct_longlong_name"] = self.struct_longlong_name
            d["struct_ulonglong_name"] = self.struct_ulonglong_name
            return str(d)

        def getId(self):
            return "my_struct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("struct_octet_name", self.struct_octet_name),
                    ("struct_short_name", self.struct_short_name),
                    ("struct_ushort_name", self.struct_ushort_name),
                    ("struct_long_name", self.struct_long_name),
                    ("struct_ulong_name", self.struct_ulong_name),
                    ("struct_longlong_name", self.struct_longlong_name),
                    ("struct_ulonglong_name", self.struct_ulonglong_name)]

    my_struct_name = struct_property(id_="my_struct",
                                     name="my_struct_name",
                                     structdef=MyStructName,
                                     configurationkind=("configure", ),
                                     mode="readwrite")

    class SsStructName(object):
        ss_octet_name = simple_property(
            id_="ss_octet",
            name="ss_octet_name",
            type_="octet",
        )
        ss_short_name = simple_property(
            id_="ss_short",
            name="ss_short_name",
            type_="short",
        )
        ss_ushort_name = simple_property(
            id_="ss_ushort",
            name="ss_ushort_name",
            type_="ushort",
        )
        ss_long_name = simple_property(
            id_="ss_long",
            name="ss_long_name",
            type_="long",
        )
        ss_ulong_name = simple_property(
            id_="ss_ulong",
            name="ss_ulong_name",
            type_="ulong",
        )
        ss_longlong_name = simple_property(
            id_="ss_longlong",
            name="ss_longlong_name",
            type_="longlong",
        )
        ss_ulonglong_name = simple_property(
            id_="ss_ulonglong",
            name="ss_ulonglong_name",
            type_="ulonglong",
        )

        def __init__(self,
                     ss_octet_name=0,
                     ss_short_name=0,
                     ss_ushort_name=0,
                     ss_long_name=0,
                     ss_ulong_name=0,
                     ss_longlong_name=0,
                     ss_ulonglong_name=0):
            self.ss_octet_name = ss_octet_name
            self.ss_short_name = ss_short_name
            self.ss_ushort_name = ss_ushort_name
            self.ss_long_name = ss_long_name
            self.ss_ulong_name = ss_ulong_name
            self.ss_longlong_name = ss_longlong_name
            self.ss_ulonglong_name = ss_ulonglong_name

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["ss_octet_name"] = self.ss_octet_name
            d["ss_short_name"] = self.ss_short_name
            d["ss_ushort_name"] = self.ss_ushort_name
            d["ss_long_name"] = self.ss_long_name
            d["ss_ulong_name"] = self.ss_ulong_name
            d["ss_longlong_name"] = self.ss_longlong_name
            d["ss_ulonglong_name"] = self.ss_ulonglong_name
            return str(d)

        def getId(self):
            return "ss_struct"

        def isStruct(self):
            return True

        def getMembers(self):
            return [("ss_octet_name", self.ss_octet_name),
                    ("ss_short_name", self.ss_short_name),
                    ("ss_ushort_name", self.ss_ushort_name),
                    ("ss_long_name", self.ss_long_name),
                    ("ss_ulong_name", self.ss_ulong_name),
                    ("ss_longlong_name", self.ss_longlong_name),
                    ("ss_ulonglong_name", self.ss_ulonglong_name)]

    my_structseq_name = structseq_property(
        id_="my_structseq",
        name="my_structseq_name",
        structdef=SsStructName,
        defvalue=[
            SsStructName(0, 1, 2, 3, 4, 5, 6),
            SsStructName(7, 8, 9, 10, 11, 12, 13)
        ],
        configurationkind=("configure", ),
        mode="readwrite")
class NicExecDevice_base(CF__POA.ExecutableDevice, ExecutableDevice,
                         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):
        ExecutableDevice.__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

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

    def stop(self):
        ExecutableDevice.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")
        ExecutableDevice.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.

    ######################################################################
    # 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",
        defvalue="GPP",
        mode="readonly",
        action="eq",
        kinds=("allocation", ),
        description="""This specifies the device kind""")

    device_model = simple_property(
        id_="DCE:0f99b2e4-9903-4631-9846-ff349d18ecfb",
        name="device_model",
        type_="string",
        defvalue="NicExecDevice",
        mode="readonly",
        action="eq",
        kinds=("allocation", ),
        description=""" This specifies the specific device""")

    processor_name = simple_property(
        id_="DCE:9B445600-6C7F-11d4-A226-0050DA314CD6",
        name="processor_name",
        type_="string",
        defvalue="x86_64",
        mode="readonly",
        action="eq",
        kinds=("allocation", ),
        description="""SCA required property describing the CPU type""")

    os_name = simple_property(
        id_="DCE:80BF17F0-6C7F-11d4-A226-0050DA314CD6",
        name="os_name",
        type_="string",
        defvalue="Linux",
        mode="readonly",
        action="eq",
        kinds=("allocation", ),
        description=
        """SCA required property describing the Operating System Name""")

    os_version = simple_property(
        id_="DCE:0f3a9a37-a342-43d8-9b7f-78dc6da74192",
        name="os_version",
        type_="string",
        mode="readonly",
        action="eq",
        kinds=("allocation", ),
        description=
        """SCA required property describing the Operating System Version""")

    nic_list = simpleseq_property(id_="nic_list",
                                  type_="string",
                                  defvalue=[],
                                  mode="readonly",
                                  action="external",
                                  kinds=("property", ))

    class NicAllocation(object):
        identifier = simple_property(id_="nic_allocation::identifier",
                                     name="identifier",
                                     type_="string",
                                     defvalue="")

        interface = simple_property(id_="nic_allocation::interface",
                                    name="interface",
                                    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["identifier"] = self.identifier
            d["interface"] = self.interface
            return str(d)

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("identifier", self.identifier),
                    ("interface", self.interface)]

    nic_allocation = struct_property(id_="nic_allocation",
                                     structdef=NicAllocation,
                                     configurationkind=("allocation", ),
                                     mode="readwrite")

    class NicAllocationStatusStruct(object):
        identifier = simple_property(id_="nic_allocation_status::identifier",
                                     name="identifier",
                                     type_="string")

        interface = simple_property(id_="nic_allocation_status::interface",
                                    name="interface",
                                    type_="string")

        def __init__(self, identifier="", interface=""):
            self.identifier = identifier
            self.interface = interface

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

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("identifier", self.identifier),
                    ("interface", self.interface)]

    nic_allocation_status = structseq_property(
        id_="nic_allocation_status",
        structdef=NicAllocationStatusStruct,
        defvalue=[],
        configurationkind=("property", ),
        mode="readonly")
class AllPropertyTypesComponent_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

    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.

    ######################################################################
    # 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.
    simpleString = simple_property(id_="simpleString",
                                   name="simpleString",
                                   type_="string",
                                   defvalue="simpleStringTest",
                                   mode="readwrite",
                                   action="external",
                                   kinds=("property", ))

    simpleBool = simple_property(id_="simpleBool",
                                 name="simpleBool",
                                 type_="boolean",
                                 defvalue=True,
                                 mode="readwrite",
                                 action="external",
                                 kinds=("property", ))

    simpleDouble = simple_property(id_="simpleDouble",
                                   name="simpleDouble",
                                   type_="double",
                                   defvalue=123.456,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("property", ))

    simpleShort = simple_property(id_="simpleShort",
                                  name="simpleShort",
                                  type_="short",
                                  defvalue=123,
                                  mode="readwrite",
                                  action="external",
                                  kinds=("property", ))

    readOnlyString = simple_property(id_="readOnlyString",
                                     name="readOnlyString",
                                     type_="string",
                                     defvalue="doNotChangeMe",
                                     mode="readonly",
                                     action="external",
                                     kinds=("property", ))

    simpleSeqString = simpleseq_property(id_="simpleSeqString",
                                         name="simpleSeqString",
                                         type_="string",
                                         defvalue=[
                                             "simpleSeqStringTest1",
                                             "simpleSeqStringTest2",
                                             "simpleSeqStringTest3"
                                         ],
                                         mode="readwrite",
                                         action="external",
                                         kinds=("property", ))

    simpleSeqBool = simpleseq_property(id_="simpleSeqBool",
                                       name="simpleSeqBool",
                                       type_="boolean",
                                       defvalue=[True, False, True],
                                       mode="readwrite",
                                       action="external",
                                       kinds=("property", ))

    simpleSeqDouble = simpleseq_property(
        id_="simpleSeqDouble",
        name="simpleSeqDouble",
        type_="double",
        defvalue=[234.56700000000001, 345.678, 456.78899999999999],
        mode="readwrite",
        action="external",
        kinds=("property", ))

    simpleSeqShort = simpleseq_property(id_="simpleSeqShort",
                                        name="simpleSeqShort",
                                        type_="short",
                                        defvalue=[234, 345, 456],
                                        mode="readwrite",
                                        action="external",
                                        kinds=("property", ))

    class StructString(object):
        structSimpleString = simple_property(id_="structSimpleString",
                                             name="structSimpleString",
                                             type_="string",
                                             defvalue="structSimpleStringTest")

        structSimpleSeqString = simpleseq_property(
            id_="structSimpleSeqString",
            name="structSimpleSeqString",
            type_="string",
            defvalue=[
                "structSeqSimpleStringTest1", "structSeqSimpleStringTest2",
                "structSeqSimpleStringTest3"
            ])

        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["structSimpleString"] = self.structSimpleString
            d["structSimpleSeqString"] = self.structSimpleSeqString
            return str(d)

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSimpleString", self.structSimpleString),
                    ("structSimpleSeqString", self.structSimpleSeqString)]

    structString = struct_property(id_="structString",
                                   name="structString",
                                   structdef=StructString,
                                   configurationkind=("property", ),
                                   mode="readwrite")

    class StructBool(object):
        structSimpleBool = simple_property(id_="structSimpleBool",
                                           name="structSimpleBool",
                                           type_="boolean",
                                           defvalue=False)

        structSimpleSeqBool = simpleseq_property(id_="structSimpleSeqBool",
                                                 name="structSimpleSeqBool",
                                                 type_="boolean",
                                                 defvalue=[False, True, False])

        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["structSimpleBool"] = self.structSimpleBool
            d["structSimpleSeqBool"] = self.structSimpleSeqBool
            return str(d)

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSimpleBool", self.structSimpleBool),
                    ("structSimpleSeqBool", self.structSimpleSeqBool)]

    structBool = struct_property(id_="structBool",
                                 name="structBool",
                                 structdef=StructBool,
                                 configurationkind=("property", ),
                                 mode="readwrite")

    class StructDouble(object):
        structSimpleDouble = simple_property(id_="structSimpleDouble",
                                             name="structSimpleDouble",
                                             type_="double",
                                             defvalue=987.654)

        structSimpleSeqDouble = simpleseq_property(
            id_="structSimpleSeqDouble",
            name="structSimpleSeqDouble",
            type_="double",
            defvalue=[
                876.54300000000001, 765.43200000000002, 654.32100000000003
            ])

        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["structSimpleDouble"] = self.structSimpleDouble
            d["structSimpleSeqDouble"] = self.structSimpleSeqDouble
            return str(d)

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSimpleDouble", self.structSimpleDouble),
                    ("structSimpleSeqDouble", self.structSimpleSeqDouble)]

    structDouble = struct_property(id_="structDouble",
                                   name="structDouble",
                                   structdef=StructDouble,
                                   configurationkind=("property", ),
                                   mode="readwrite")

    class StructShort(object):
        structSimpleShort = simple_property(id_="structSimpleShort",
                                            name="structSimpleShort",
                                            type_="short",
                                            defvalue=987)

        structSimpleSeqShort = simpleseq_property(id_="structSimpleSeqShort",
                                                  name="structSimpleSeqShort",
                                                  type_="short",
                                                  defvalue=[876, 765, 654])

        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["structSimpleShort"] = self.structSimpleShort
            d["structSimpleSeqShort"] = self.structSimpleSeqShort
            return str(d)

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSimpleShort", self.structSimpleShort),
                    ("structSimpleSeqShort", self.structSimpleSeqShort)]

    structShort = struct_property(id_="structShort",
                                  name="structShort",
                                  structdef=StructShort,
                                  configurationkind=("property", ),
                                  mode="readwrite")

    class StructSeqStructString(object):
        structSeqStructSimpleString = simple_property(
            id_="structSeqStructSimpleString",
            name="structSeqStructSimpleString",
            type_="string",
            defvalue="structSeqStructSimpleStringTest")

        structSeqStructSimpleSeqString = simpleseq_property(
            id_="structSeqStructSimpleSeqString",
            name="structSeqStructSimpleSeqString",
            type_="string",
            defvalue=[
                "structSeqStructSimpleStringTest1",
                "structSeqStructSimpleStringTest2",
                "structSeqStructSimpleStringTest3"
            ])

        def __init__(
            self,
            structSeqStructSimpleString="structSeqStructSimpleStringTest",
            structSeqStructSimpleSeqString=[
                "structSeqStructSimpleStringTest1",
                "structSeqStructSimpleStringTest2",
                "structSeqStructSimpleStringTest3"
            ]):
            self.structSeqStructSimpleString = structSeqStructSimpleString
            self.structSeqStructSimpleSeqString = structSeqStructSimpleSeqString

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

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSeqStructSimpleString",
                     self.structSeqStructSimpleString),
                    ("structSeqStructSimpleSeqString",
                     self.structSeqStructSimpleSeqString)]

    structSeqString = structseq_property(
        id_="structSeqString",
        name="structSeqString",
        structdef=StructSeqStructString,
        defvalue=[
            StructSeqStructString(
                structSeqStructSimpleString="structSeqStructSimpleStringTest",
                structSeqStructSimpleSeqString=[
                    "structSeqStructSimpleStringTest1",
                    "structSeqStructSimpleStringTest2",
                    "structSeqStructSimpleStringTest3"
                ])
        ],
        configurationkind=("property", ),
        mode="readwrite")

    class StructSeqStructBool(object):
        structSeqStructSimpleBool = simple_property(
            id_="structSeqStructSimpleBool",
            name="structSeqStructSimpleBool",
            type_="boolean",
            defvalue=True)

        structSeqStructSimpleSeqBool = simpleseq_property(
            id_="structSeqStructSimpleSeqBool",
            name="structSeqStructSimpleSeqBool",
            type_="boolean",
            defvalue=[True, True, False])

        def __init__(self,
                     structSeqStructSimpleBool=True,
                     structSeqStructSimpleSeqBool=[True, True, False]):
            self.structSeqStructSimpleBool = structSeqStructSimpleBool
            self.structSeqStructSimpleSeqBool = structSeqStructSimpleSeqBool

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

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSeqStructSimpleBool",
                     self.structSeqStructSimpleBool),
                    ("structSeqStructSimpleSeqBool",
                     self.structSeqStructSimpleSeqBool)]

    structSeqBool = structseq_property(
        id_="structSeqBool",
        name="structSeqBool",
        structdef=StructSeqStructBool,
        defvalue=[
            StructSeqStructBool(
                structSeqStructSimpleBool=True,
                structSeqStructSimpleSeqBool=[True, True, False])
        ],
        configurationkind=("property", ),
        mode="readwrite")

    class StructSeqStructDouble(object):
        structSeqStructSimpleDouble = simple_property(
            id_="structSeqStructSimpleDouble",
            name="structSeqStructSimpleDouble",
            type_="double",
            defvalue=12.34)

        structSeqStructSimpleSeqDouble = simpleseq_property(
            id_="structSeqStructSimpleSeqDouble",
            name="structSeqStructSimpleSeqDouble",
            type_="double",
            defvalue=[
                23.449999999999999, 34.560000000000002, 45.670000000000002
            ])

        def __init__(self,
                     structSeqStructSimpleDouble=12.34,
                     structSeqStructSimpleSeqDouble=[
                         23.449999999999999, 34.560000000000002,
                         45.670000000000002
                     ]):
            self.structSeqStructSimpleDouble = structSeqStructSimpleDouble
            self.structSeqStructSimpleSeqDouble = structSeqStructSimpleSeqDouble

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

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSeqStructSimpleDouble",
                     self.structSeqStructSimpleDouble),
                    ("structSeqStructSimpleSeqDouble",
                     self.structSeqStructSimpleSeqDouble)]

    structSeqDouble = structseq_property(
        id_="structSeqDouble",
        name="structSeqDouble",
        structdef=StructSeqStructDouble,
        defvalue=[
            StructSeqStructDouble(structSeqStructSimpleDouble=12.34,
                                  structSeqStructSimpleSeqDouble=[
                                      23.449999999999999, 34.560000000000002,
                                      45.670000000000002
                                  ])
        ],
        configurationkind=("property", ),
        mode="readwrite")

    class StructSeqStructShort(object):
        structSeqStructSimpleShort = simple_property(
            id_="structSeqStructSimpleShort",
            name="structSeqStructSimpleShort",
            type_="short",
            defvalue=12)

        structSeqStructSimpleSeqShort = simpleseq_property(
            id_="structSeqStructSimpleSeqShort",
            name="structSeqStructSimpleSeqShort",
            type_="short",
            defvalue=[23, 34, 45])

        def __init__(self,
                     structSeqStructSimpleShort=12,
                     structSeqStructSimpleSeqShort=[23, 34, 45]):
            self.structSeqStructSimpleShort = structSeqStructSimpleShort
            self.structSeqStructSimpleSeqShort = structSeqStructSimpleSeqShort

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

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

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("structSeqStructSimpleShort",
                     self.structSeqStructSimpleShort),
                    ("structSeqStructSimpleSeqShort",
                     self.structSeqStructSimpleSeqShort)]

    structSeqShort = structseq_property(
        id_="structSeqShort",
        name="structSeqShort",
        structdef=StructSeqStructShort,
        defvalue=[
            StructSeqStructShort(structSeqStructSimpleShort=12,
                                 structSeqStructSimpleSeqShort=[23, 34, 45])
        ],
        configurationkind=("property", ),
        mode="readwrite")
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 PropertyChangeEvents(CF__POA.Resource, Resource):
    """
    Example component to send property change events to an EventChannel port.
    """

    myprop = simple_property(id_="myprop",
                             type_="long",
                             name="myprop",
                             defvalue=0,
                             mode="readwrite",
                             action="external",
                             kinds=("configure", "event"))

    anotherprop = simple_property(id_="anotherprop",
                                  type_="long",
                                  name="anotherprop",
                                  defvalue=0,
                                  mode="readwrite",
                                  action="external",
                                  kinds=("configure", ))

    propEvent = usesport(name="propEvent",
                         repid="IDL:CosEventChannelAdmin/EventChannel:1.0",
                         type_="data")

    seqprop = simpleseq_property(id_="seqprop",
                                 type_="float",
                                 defvalue=None,
                                 mode="readwrite",
                                 action="external",
                                 kinds=("configure", "event"))

    class SomeStruct(object):
        some_number = simple_property(
            id_="some_number",
            type_="double",
        )
        some_string = simple_property(
            id_="some_string",
            type_="string",
        )

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

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

        def isStruct(self):
            return True

        def getMembers(self):
            return [("some_number", self.some_number),
                    ("some_string", self.some_string)]

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

    def initialize(self):
        self.propEvent = PropertyEventSupplier(self)

    some_struct = struct_property(id_="some_struct",
                                  structdef=SomeStruct,
                                  configurationkind=("configure", "event"),
                                  mode="readwrite")
    structseq_prop = structseq_property(id_="structseq_prop",
                                        structdef=SomeStruct,
                                        defvalue=[],
                                        configurationkind=("configure",
                                                           "event"),
                                        mode="readwrite")

    def start(self):
        self.myprop = 123
        self.anotherprop = 123
        self.seqprop = [1.0]
        self.some_struct.some_number = 123.0
        tmp = self.SomeStruct()
        tmp.some_number = 2.0
        tmp.some_string = "another string"
        newval = copy.deepcopy(self.structseq_prop)
        newval.append(tmp)
        self.structseq_prop = newval

    def runTest(self, testid, properties):
        if testid == 1061:
            # Ticket #1061: Ensure that if an eventable struct or struct sequence
            # has None for both the current and prior values, sendChangedPropertiesEvent
            # does not raise an exception.

            # Save values of struct and struct sequence properties
            saved_struct = copy.deepcopy(self.some_struct)
            saved_structseq = copy.deepcopy(self.structseq_prop)

            self.some_struct = None
            self.saved_structseq = None
            try:
                # Send two consecutive property change events so that the current
                # and saved values are both None.
                self.propEvent.sendChangedPropertiesEvent()
                self.propEvent.sendChangedPropertiesEvent()
                success = True
            except:
                success = False
            results = [CF.DataType('1061', any.to_any(success))]

            # Restore saved state
            self.some_struct = saved_struct
            self.saved_structseq = saved_structseq
        else:
            raise CF.TestableObject.UnknownTest('No test %d' % testid)
        return results
Exemplo n.º 28
0
class TestPythonProps (CF__POA.Resource, Resource):
    """Python component for testing properties"""

    prop1 = simple_property(id_="DCE:b8f43ac8-26b5-40b3-9102-d127b84f9e4b",
                            name="string_prop",
                            type_="string",
                            action="external",
                            kinds=("configure",))

    prop2 = simpleseq_property(id_="DCE:10b3364d-f035-4639-8e7f-02ac4706f5c7[]",
                               name="stringseq_prop",
                               type_="string",
                               action="external",
                               kinds=("configure",),
                               defvalue=[])

    class SomeStruct(object):
        field1 = simple_property(id_="item1",
                                type_="string",
                                defvalue=None)
        field2 = simple_property(id_="item2",
                                type_="long",
                                defvalue=None)
        field3 = simple_property(id_="item3",
                                type_="double",
                                defvalue=None)

    struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f", 
                            name="struct_test", 
                            structdef=SomeStruct)

    class MulticastAddress(object):
        ip_address = simple_property(id_="ip_address", type_="string")
        port = simple_property(id_="port", type_="ushort")

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


    multicasts = structseq_property(id_="DCE:897a5489-f680-46a8-a698-e36fd8bbae80[]",
                                    name="multicasts",
                                    structdef=MulticastAddress,
                                    defvalue=[])

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


    def initialize(self):
        Resource.initialize(self)
        self.prop1 = "MyDefault1"
        self.prop2.append("1")
        self.prop2.append("2")
        self.prop2.append("3")

        self.struct.field1 = "StructDefault"
        self.struct.field2 = 100
        self.struct.field3 = 1.0

        self.multicasts.append(TestPythonProps.MulticastAddress("127.0.0.1", 123))
        self.multicasts.append(TestPythonProps.MulticastAddress("127.0.0.1", 456))