Ejemplo n.º 1
0
 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)
class log_test_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._baseLog.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""")
Ejemplo n.º 3
0
class py_prf_check_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.
    some_simple = simple_property(id_="some_simple",
                                  type_="string",
                                  mode="readwrite",
                                  action="external",
                                  kinds=("property", ))

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

    class SomeStruct(object):
        a = simple_property(id_="a", type_="string")

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

    some_struct = struct_property(id_="some_struct",
                                  structdef=SomeStruct,
                                  configurationkind=("property", ),
                                  mode="readwrite")

    class Foo(object):
        b = simple_property(id_="b", type_="string")

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

    some_struct_seq = structseq_property(id_="some_struct_seq",
                                         structdef=Foo,
                                         defvalue=[],
                                         configurationkind=("property", ),
                                         mode="readwrite")
 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)]
Ejemplo n.º 5
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")
class ticket_cf_939_dev_base(CF__POA.ExecutableDevice, ExecutableDevice):
    # 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)
        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):
        ExecutableDevice.initialize(self)

        # Instantiate the default implementations for all ports on this component

    def start(self):
        self.threadControlLock.acquire()
        try:
            ExecutableDevice.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")
            ExecutableDevice.stop(self)
        finally:
            self.threadControlLock.release()

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        self.threadControlLock.acquire()
        try:
            ExecutableDevice.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.
    device_kind = simple_property(
        id_="DCE:cdc5ee18-7ceb-4ae6-bf4c-31f983179b4d",
        name="device_kind",
        type_="string",
        mode="readonly",
        action="eq",
        kinds=("configure", "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=("configure", "allocation"),
        description="""This specifies the specific device""")
    os_version = simple_property(
        id_="DCE:0f3a9a37-a342-43d8-9b7f-78dc6da74192",
        name="os_version",
        type_="string",
        defvalue="1.2.3.el6.x86_64",
        mode="readwrite",
        action="eq",
        kinds=("allocation", ))
    os_name = simple_property(id_="DCE:80BF17F0-6C7F-11d4-A226-0050DA314CD6",
                              name="os_name",
                              type_="string",
                              defvalue="Linux",
                              mode="readwrite",
                              action="eq",
                              kinds=("allocation", ))
    processor_name = simple_property(
        id_="DCE:9B445600-6C7F-11d4-A226-0050DA314CD6",
        name="processor_name",
        type_="string",
        defvalue="x86_64",
        mode="readwrite",
        action="eq",
        kinds=("allocation", ))
Ejemplo n.º 7
0
class test_collocation_device_base(CF__POA.ExecutableDevice, ExecutableDevice):
    # 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)
        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):
        ExecutableDevice.initialize(self)

        # Instantiate the default implementations for all ports on this component
        self.port_propEvent = PropertyEventSupplier(self)

    def start(self):
        self.threadControlLock.acquire()
        try:
            ExecutableDevice.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")
            ExecutableDevice.stop(self)
        finally:
            self.threadControlLock.release()

    def releaseObject(self):
        try:
            self.stop()
        except Exception:
            self._log.exception("Error stopping")
        self.threadControlLock.acquire()
        try:
            ExecutableDevice.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.
    class RedhawkReservationRequest(object):
        redhawk__reservation_request__obj_id = simple_property(
            id_="redhawk::reservation_request::obj_id", type_="string")

        redhawk__reservation_request__kinds = simpleseq_property(
            id_="redhawk::reservation_request::kinds",
            type_="string",
            defvalue=[])

        redhawk__reservation_request__values = simpleseq_property(
            id_="redhawk::reservation_request::values",
            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["redhawk__reservation_request__obj_id"] = self.redhawk__reservation_request__obj_id
            d["redhawk__reservation_request__kinds"] = self.redhawk__reservation_request__kinds
            d["redhawk__reservation_request__values"] = self.redhawk__reservation_request__values
            return str(d)

        @classmethod
        def getId(cls):
            return "redhawk::reservation_request"

        @classmethod
        def isStruct(cls):
            return True

        def getMembers(self):
            return [("redhawk__reservation_request__obj_id",
                     self.redhawk__reservation_request__obj_id),
                    ("redhawk__reservation_request__kinds",
                     self.redhawk__reservation_request__kinds),
                    ("redhawk__reservation_request__values",
                     self.redhawk__reservation_request__values)]

    redhawk__reservation_request = struct_property(
        id_="redhawk::reservation_request",
        structdef=RedhawkReservationRequest,
        configurationkind=("allocation", ),
        mode="readwrite")
    device_kind = simple_property(
        id_="DCE:cdc5ee18-7ceb-4ae6-bf4c-31f983179b4d",
        name="device_kind",
        type_="string",
        mode="readonly",
        action="eq",
        kinds=("configure", "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=("configure", "allocation"),
        description="""This specifies the specific device""")
    supported_components = simple_property(id_="supported_components",
                                           name="supported_components",
                                           type_="short",
                                           defvalue=4,
                                           mode="readwrite",
                                           action="external",
                                           kinds=("configure", "allocation"))
    additional_supported_components = simple_property(
        id_="additional_supported_components",
        name="additional_supported_components",
        type_="short",
        defvalue=4,
        mode="readwrite",
        action="external",
        kinds=("configure", "allocation"))
    os_name = simple_property(id_="DCE:4a23ad60-0b25-4121-a630-68803a498f75",
                              name="os_name",
                              type_="string",
                              defvalue="Linux",
                              mode="readwrite",
                              action="eq",
                              kinds=("configure", "allocation"))
    allocation_attempts = simple_property(id_="allocation_attempts",
                                          name="allocation_attempts",
                                          type_="ulong",
                                          defvalue=0,
                                          mode="readonly",
                                          action="external",
                                          kinds=("configure", ))
Ejemplo n.º 8
0
class HardLimit_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_out = bulkio.OutFloatPort("dataFloat_out")

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

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

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

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

    port_dataFloat_in = providesport(
        name="dataFloat_in",
        repid="IDL:BULKIO/dataFloat:1.0",
        type_="data",
        description=
        """Float input port for data before hard limit is applied. """)

    port_dataFloat_out = usesport(
        name="dataFloat_out",
        repid="IDL:BULKIO/dataFloat:1.0",
        type_="data",
        description=
        """Float output port for data after hard limit is applied. """)

    ######################################################################
    # 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.
    upper_limit = simple_property(
        id_="upper_limit",
        type_="float",
        defvalue=1.0,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description="""Sets the upper limit threshold""")

    lower_limit = simple_property(
        id_="lower_limit",
        type_="float",
        defvalue=-1.0,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description="""Sets the lower limit threshold""")
Ejemplo n.º 9
0
    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 SADUsesDevice_base(CF__POA.ExecutableDevice, ExecutableDevice):
    # 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)
        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):
        ExecutableDevice.initialize(self)

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

        self.port_dev_resource_out = PortCFResourceOut_i(
            self, "dev_resource_out")

    def start(self):
        self.threadControlLock.acquire()
        try:
            ExecutableDevice.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")
            ExecutableDevice.stop(self)
        finally:
            self.threadControlLock.release()

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

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

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

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

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

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

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

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    device_kind = simple_property(
        id_="DCE:cdc5ee18-7ceb-4ae6-bf4c-31f983179b4d",
        name="device_kind",
        type_="string",
        mode="readonly",
        action="eq",
        kinds=("configure", "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=("configure", "allocation"),
        description="""This specifies the specific device""")
    device_id = simple_property(id_="device_id",
                                type_="string",
                                defvalue="USES_DEV",
                                mode="readwrite",
                                action="eq",
                                kinds=("configure", "allocation"))
    simple_alloc = simple_property(id_="simple_alloc",
                                   type_="long",
                                   defvalue=10,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", "allocation"))
Ejemplo n.º 11
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")
Ejemplo n.º 12
0
    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)]
Ejemplo n.º 13
0
    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)]
        ######################################################################
        # 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=("configure","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=("configure","allocation"),
                                          description="""This specifies the specific device""" 
                                          )       
        nil_property = simple_property(id_="nil_property",
                                          name="nil_property", 
                                          type_="float",
                                          mode="readwrite",
Ejemplo n.º 15
0
class fcalc_base(CF__POA.Resource, Resource, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

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

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

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

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

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

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

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

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

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

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

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

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

    import_ = simpleseq_property(
        id_="import",
        type_="string",
        defvalue=[
            "math",
            "random",
        ],
        mode="readwrite",
        action="external",
        kinds=("configure", ),
        description=
        """python modules (including perhapse custom modules) you want to import to use in your equation"""
    )
Ejemplo n.º 16
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 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")
Ejemplo n.º 18
0
    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)]
        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)]
Ejemplo n.º 20
0
class SigGen_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_out = bulkio.OutFloatPort("dataFloat_out")
        self.port_dataFloat_out._portLog = self._baseLog.getChildLogger(
            'dataFloat_out', 'ports')
        self.port_dataShort_out = bulkio.OutShortPort("dataShort_out")
        self.port_dataShort_out._portLog = self._baseLog.getChildLogger(
            'dataShort_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_out = usesport(name="dataFloat_out",
                                  repid="IDL:BULKIO/dataFloat:1.0",
                                  type_="data")

    port_dataShort_out = usesport(name="dataShort_out",
                                  repid="IDL:BULKIO/dataShort:1.0",
                                  type_="data")

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    frequency = simple_property(
        id_="frequency",
        type_="double",
        defvalue=1000.0,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description=
        """rate at which the periodic output waveforms repeat.  This value is ignored for aperiodic waveforms."""
    )

    sample_rate = simple_property(
        id_="sample_rate",
        type_="double",
        defvalue=5000.0,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description="""sampling rate for output data.""")

    magnitude = simple_property(id_="magnitude",
                                type_="double",
                                defvalue=100.0,
                                mode="readwrite",
                                action="external",
                                kinds=("property", ),
                                description="""amplitude of output data""")

    shape = simple_property(id_="shape",
                            type_="string",
                            defvalue="sine",
                            mode="readwrite",
                            action="external",
                            kinds=("property", ),
                            description="""determine output data type""")

    xfer_len = simple_property(
        id_="xfer_len",
        type_="long",
        defvalue=1000,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description="""number of samples of output data per output packet""")

    throttle = simple_property(
        id_="throttle",
        type_="boolean",
        defvalue=True,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description=
        """Throttles the output data rate to approximately sample_rate""")

    stream_id = simple_property(
        id_="stream_id",
        type_="string",
        defvalue="SigGen Stream",
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description="""bulkio sri streamID for this data source.""")

    chan_rf = simple_property(
        id_="chan_rf",
        type_="double",
        defvalue=-1.0,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description=
        """Sets the CHAN_RF SRI keyword. Set to -1 if not desired.""")

    col_rf = simple_property(
        id_="col_rf",
        type_="double",
        defvalue=-1.0,
        mode="readwrite",
        action="external",
        kinds=("property", ),
        description="""Sets the COL_RF SRI keyword. Set to -1 if not desired."""
    )

    sri_blocking = simple_property(id_="sri_blocking",
                                   type_="boolean",
                                   defvalue=False,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("property", ))

    use_complex = simple_property(id_="use_complex",
                                  name="use_complex",
                                  type_="long",
                                  defvalue=1,
                                  mode="readwrite",
                                  action="external",
                                  kinds=("property", ))
        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)]
Ejemplo n.º 22
0
class cmdline_py_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.
    readonly_cmdline = simple_property(id_="readonly_cmdline",
                                       type_="string",
                                       mode="readonly",
                                       action="external",
                                       kinds=("property", ))

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

    writeonly_cmdline = simple_property(id_="writeonly_cmdline",
                                        type_="string",
                                        mode="writeonly",
                                        action="external",
                                        kinds=("property", ))
Ejemplo n.º 23
0
class ticket_462_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.
    over_simple = simple_property(id_="over_simple",
                                  type_="string",
                                  mode="readwrite",
                                  action="external",
                                  kinds=("configure", ))
    another_simple = simple_property(id_="another_simple",
                                     type_="short",
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    over_sequence = simpleseq_property(id_="over_sequence",
                                       type_="string",
                                       defvalue=None,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))

    class OverStruct(object):
        a_simple = simple_property(
            id_="a_simple",
            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["a_simple"] = self.a_simple
            return str(d)

        def getId(self):
            return "over_struct"

        def isStruct(self):
            return True

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

    over_struct = struct_property(id_="over_struct",
                                  structdef=OverStruct,
                                  configurationkind=("configure", ),
                                  mode="readwrite")

    class TemplateStruct(object):
        a_number = simple_property(
            id_="a_number",
            type_="short",
        )
        a_word = simple_property(
            id_="a_word",
            type_="string",
        )

        def __init__(self, a_number=0, a_word=""):
            self.a_number = a_number
            self.a_word = a_word

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

        def getId(self):
            return "template_struct"

        def isStruct(self):
            return True

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

    over_struct_seq = structseq_property(id_="over_struct_seq",
                                         structdef=TemplateStruct,
                                         defvalue=[],
                                         configurationkind=("configure", ),
                                         mode="readwrite")
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")
Ejemplo n.º 25
0
class PortDevice_impl(CF__POA.ExecutableDevice, ExecutableDevice):

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

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

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

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

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

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

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

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

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

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

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

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

    def updateUsageState(self):
        # Update usage state
        if self.memCapacity == 0 and self.BogoMipsCapacity == 0:
            self._usageState = CF.Device.BUSY
        elif self.memCapacity == 100000000 and self.BogoMipsCapacity == 100000000:
            self._usageState = CF.Device.IDLE
        else:
            self._usageState = CF.Device.ACTIVE
 class 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)]
Ejemplo n.º 27
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)

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

    simple_utctime = simple_property(id_="simple_utctime",
                                     name="simple_utctime",
                                     type_="utctime",
                                     defvalue="2017:2:1::14:01:00.123",
                                     mode="readwrite",
                                     action="external",
                                     kinds=("property", ))

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

    seq_utctime = simpleseq_property(id_="seq_utctime",
                                     name="seq_utctime",
                                     type_="utctime",
                                     mode="readwrite",
                                     action="external",
                                     kinds=("property", ))

    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

    def reset_utcCallback(self, id, old_value, new_value):
        self.simple_utctime = rhtime.now()

    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)
        self.addPropertyChangeListener('reset_utctime', self.reset_utcCallback)

    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 []
Ejemplo n.º 28
0
class CommandWrapperSPDDep_i(CF__POA.Resource, Resource):
    """This component simply ensures that all other components in the waveform get started and
    stopped together."""

    # The signal to send and the number of seconds (max) to wait
    # for the process to actually exit before trying the next signals.
    # None means wait until the process dies (which we have to do to
    # avoid creating zombie processes
    STOP_SIGNALS = ((signal.SIGINT, 1), (signal.SIGTERM, 5), (signal.SIGKILL,
                                                              None))

    def __init__(self, identifier, execparams):
        loggerName = execparams['NAME_BINDING'].replace('/', '.')
        Resource.__init__(self, identifier, execparams, loggerName=loggerName)
        self._pid = None
        self.execparams = " ".join(["%s %s" % x for x in execparams.items()])

    #####################################
    # Implement the Resource interface
    def start(self):
        self._log.debug("start()")
        if self.get_commandAlive() == False:
            command = self._props["command"]
            args = copy.copy(self._props["args"])
            args.insert(0, command)
            self._log.debug("start %s %r", command, args)
            self._pid = os.spawnv(os.P_NOWAIT, command, args)
            self._log.debug("spawned %s", self._pid)

    def stop(self):
        self._log.debug("stop()")
        if self.get_commandAlive() == True:
            for sig, timeout in self.STOP_SIGNALS:
                try:
                    os.kill(self._pid, sig)
                except OSError:
                    self._pid = None
                    return
                if timeout != None:
                    giveup_time = time.time() + timeout
                    while os.waitpid(self._pid, os.WNOHANG) == (0, 0):
                        time.sleep(0.1)
                        if time.time() > giveup_time:
                            break
                else:
                    # Wait until there is a response
                    os.waitpid(self._pid, 0)
            self._pid = None

    ######################################
    # Implement specific property setters/getters
    def get_commandAlive(self):
        if self._pid != None:
            try:
                os.kill(self._pid, 0)
                if os.waitpid(self._pid, os.WNOHANG) == (0, 0):
                    return True
                else:
                    return False
            except OSError:
                pass
        return False

    command = simple_property(\
        id_='DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e',
        type_="string",
        name="command",
        defvalue="/bin/echo")

    commandAlive = simple_property(\
        id_='DCE:95f19cb8-679e-48fb-bece-dc199ef45f20',
        type_="boolean",
        name="commandAlive",
        defvalue=False,
        mode="readonly",
        fget=get_commandAlive)

    someprop = simple_property(\
        id_='DCE:fa8c5924-845c-484a-81df-7941f2c5baa9',
        type_="long",
        name="someprop",
        defvalue=10)

    someprop2 = simple_property(\
        id_='DCE:cf623573-a09d-4fb1-a2ae-24b0b507115d',
        type_="double",
        name="someprop2",
        defvalue=50.0)

    someprop3 = simple_property(\
        id_='DCE:6ad84383-49cf-4017-b7ca-0ec4c4917952',
        type_="double",
        name="someprop3")

    execparams = simple_property(\
        id_='DCE:85d133fd-1658-4e4d-b3ff-1443cd44c0e2',
        type_="string",
        name="execparams")

    execparam1 = simple_property(\
        id_='EXEC_PARAM_1',
        type_="string",
        name="Parameter 1",
        defvalue="Test1",
        kinds=("execparam"))

    execparam2 = simple_property(\
        id_='EXEC_PARAM_2',
        type_="long",
        name="Parameter 2",
        defvalue=2,
        kinds=("execparam"))

    execparam3 = simple_property(\
        id_='EXEC_PARAM_3',
        type_="float",
        name="Parameter 3",
        defvalue=3.125,
        kinds=("execparam"),
        mode="readonly")

    someobjref = simple_property(\
        id_='SOMEOBJREF',
        type_="objref",
        name="Object Ref",
        defvalue=None,
        kinds=("execparam"),
        mode="writeonly")

    someobjref = simpleseq_property(\
        id_='DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53',
        type_="string",
        name="args",
        defvalue=("Hello World",))

    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)
Ejemplo n.º 29
0
class frontend_tuner_allocation(object):
    tuner_type = simple_property(
        id_="FRONTEND::tuner_allocation::tuner_type",
        name="tuner_type",
        type_="string",
    )
    allocation_id = simple_property(
        id_="FRONTEND::tuner_allocation::allocation_id",
        name="allocation_id",
        type_="string",
    )
    center_frequency = simple_property(
        id_="FRONTEND::tuner_allocation::center_frequency",
        name="center_frequency",
        type_="double",
    )
    bandwidth = simple_property(
        id_="FRONTEND::tuner_allocation::bandwidth",
        name="bandwidth",
        type_="double",
    )
    bandwidth_tolerance = simple_property(
        id_="FRONTEND::tuner_allocation::bandwidth_tolerance",
        name="bandwidth_tolerance",
        type_="double",
        defvalue=10.0,
    )
    sample_rate = simple_property(
        id_="FRONTEND::tuner_allocation::sample_rate",
        name="sample_rate",
        type_="double",
    )
    sample_rate_tolerance = simple_property(
        id_="FRONTEND::tuner_allocation::sample_rate_tolerance",
        name="sample_rate_tolerance",
        type_="double",
        defvalue=10.0,
    )
    device_control = simple_property(
        id_="FRONTEND::tuner_allocation::device_control",
        name="device_control",
        type_="boolean",
        defvalue=True,
    )
    group_id = simple_property(
        id_="FRONTEND::tuner_allocation::group_id",
        name="group_id",
        type_="string",
    )
    rf_flow_id = simple_property(
        id_="FRONTEND::tuner_allocation::rf_flow_id",
        name="rf_flow_id",
        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["tuner_type"] = self.tuner_type
        d["allocation_id"] = self.allocation_id
        d["center_frequency"] = self.center_frequency
        d["bandwidth"] = self.bandwidth
        d["bandwidth_tolerance"] = self.bandwidth_tolerance
        d["sample_rate"] = self.sample_rate
        d["sample_rate_tolerance"] = self.sample_rate_tolerance
        d["device_control"] = self.device_control
        d["group_id"] = self.group_id
        d["rf_flow_id"] = self.rf_flow_id
        return str(d)

    def getId(self):
        return "FRONTEND::tuner_allocation"

    def isStruct(self):
        return True

    def getProp(self):
        content = []
        for member in self.getMembers():
            content.append(
                CF.DataType(id=member[0], value=_any.to_any(member[1])))
        retval = CF.DataType(id=self.getId(), value=_any.to_any(content))
        return retval

    def getMembers(self):
        return [("FRONTEND::tuner_allocation::tuner_type", self.tuner_type),
                ("FRONTEND::tuner_allocation::allocation_id",
                 self.allocation_id),
                ("FRONTEND::tuner_allocation::center_frequency",
                 self.center_frequency),
                ("FRONTEND::tuner_allocation::bandwidth", self.bandwidth),
                ("FRONTEND::tuner_allocation::bandwidth_tolerance",
                 self.bandwidth_tolerance),
                ("FRONTEND::tuner_allocation::sample_rate", self.sample_rate),
                ("FRONTEND::tuner_allocation::sample_rate_tolerance",
                 self.sample_rate_tolerance),
                ("FRONTEND::tuner_allocation::device_control",
                 self.device_control),
                ("FRONTEND::tuner_allocation::group_id", self.group_id),
                ("FRONTEND::tuner_allocation::rf_flow_id", self.rf_flow_id)]
                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, e:
                self._log.exception("Error stopping: " + str(e))
            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.       
        startCounter = simple_property(id_="startCounter",
                                          type_="short",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure")
                                          )
Ejemplo n.º 31
0
class default_frontend_tuner_status_struct_struct(object):
    tuner_type = simple_property(
        id_="FRONTEND::tuner_status::tuner_type",
        name="tuner_type",
        type_="string",
    )
    allocation_id_csv = simple_property(
        id_="FRONTEND::tuner_status::allocation_id_csv",
        name="allocation_id_csv",
        type_="string",
    )
    center_frequency = simple_property(
        id_="FRONTEND::tuner_status::center_frequency",
        name="center_frequency",
        type_="double",
    )
    bandwidth = simple_property(
        id_="FRONTEND::tuner_status::bandwidth",
        name="bandwidth",
        type_="double",
    )
    sample_rate = simple_property(
        id_="FRONTEND::tuner_status::sample_rate",
        name="sample_rate",
        type_="double",
    )
    group_id = simple_property(
        id_="FRONTEND::tuner_status::group_id",
        name="group_id",
        type_="string",
    )
    rf_flow_id = simple_property(
        id_="FRONTEND::tuner_status::rf_flow_id",
        name="rf_flow_id",
        type_="string",
    )
    enabled = simple_property(
        id_="FRONTEND::tuner_status::enabled",
        name="enabled",
        type_="boolean",
    )

    def __init__(self,
                 tuner_type="",
                 allocation_id_csv="",
                 center_frequency=0.0,
                 bandwidth=0.0,
                 sample_rate=0.0,
                 group_id="",
                 rf_flow_id="",
                 enabled=False):
        self.tuner_type = tuner_type
        self.allocation_id_csv = allocation_id_csv
        self.center_frequency = center_frequency
        self.bandwidth = bandwidth
        self.sample_rate = sample_rate
        self.group_id = group_id
        self.rf_flow_id = rf_flow_id
        self.enabled = enabled

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

    def getId(self):
        return "frontend_tuner_status_struct"

    def isStruct(self):
        return True

    def getProp(self):
        content = []
        for member in self.getMembers():
            content.append(
                CF.DataType(id=member[0], value=_any.to_any(member[1])))
        retval = CF.DataType(id=self.getId(), value=_any.to_any(content))
        return retval

    def getMembers(self):
        return [("FRONTEND::tuner_status::tuner_type", self.tuner_type),
                ("FRONTEND::tuner_status::allocation_id_csv",
                 self.allocation_id_csv),
                ("FRONTEND::tuner_status::center_frequency",
                 self.center_frequency),
                ("FRONTEND::tuner_status::bandwidth", self.bandwidth),
                ("FRONTEND::tuner_status::sample_rate", self.sample_rate),
                ("FRONTEND::tuner_status::group_id", self.group_id),
                ("FRONTEND::tuner_status::rf_flow_id", self.rf_flow_id),
                ("FRONTEND::tuner_status::enabled", self.enabled)]
Ejemplo n.º 32
0
     print "\tyunits:",  sri.yunits
     print "\tmode:",  sri.mode
     print "\tstreamID:",  sri.streamID
     for keyword in sri.keywords:
         print "\t KEYWORD KEY/VAL ::",  keywords.id << ":",  any.from_any(keywords.value)
         
 ######################################################################
 # 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="FRONTEND::VIDEO",
                               mode="readonly",
                               action="eq",
                               kinds=("allocation","configure"),
                               description="""This specifies the device kind"""
                               )
 device_model = simple_property(id_="DCE:0f99b2e4-9903-4631-9846-ff349d18ecfb",
                                name="device_model",
                                type_="string",
                                defvalue="",
                                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",
Ejemplo n.º 33
0
            except Exception, e:
                self._log.exception("Unexpected exception.")
                notSet.append(prop)

    def registerPropertyListener(self, obj, prop_ids, interval):
        # TODO
        pass

    def unregisterPropertyListener(self, id):
        # TODO
        pass

    p1 = properties.simple_property(id_="p1",
                             name="p1",
                             type_="string",
                             mode="readwrite",
                             action="external",
                             kinds=("configure",),
                             description=""" """)


    p2 = properties.simple_property(id_="p2",
                         name="p2",
                             type_="long",
                             mode="readwrite",
                             action="external",
                             kinds=("configure",))


if __name__ == '__main__':
    start_service(S2_pre, thread_policy=PortableServer.SINGLE_THREAD_MODEL)