class default_kinds_base(CF__POA.Resource, Resource, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

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

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

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

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

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

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

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

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

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

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

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

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

        def getId(self):
            return "struct_prop"

        def isStruct(self):
            return True

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

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

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

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

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

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

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

        def isStruct(self):
            return True

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

    endpoints = structseq_property(id_="endpoints",
                                   structdef=Endpoint,
                                   defvalue=[],
                                   configurationkind=("configure", ),
                                   mode="readwrite")
예제 #2
0
class TestPythonProps(CF__POA.Resource, Resource):
    """Python component for testing properties"""

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

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

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

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

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

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

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

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

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

    def __init__(self, identifier, execparams):
        Resource.__init__(self, identifier, execparams)
예제 #3
0
class CommandWrapperSubProcess_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()])
        command = "python"
        args = [
            command,
            "components/CommandWrapperSubProcess/executables/FirstChild.py"
        ]
        sp = subprocess.Popen(args, executable=command, cwd=os.getcwd())

    #####################################
    # Implement the Resource interface
    def start(self):
        pass

    def stop(self):
        pass

    ######################################
    # 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",))

    somelonglongprop = simple_property(\
        id_='DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc',
        type_="longlong",
        name="somelonglongprop",
        defvalue=12345678901)

    somelonglongprop2 = simple_property(\
        id_='DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1',
        type_="longlong",
        name="somelonglongprop2",
        defvalue=12345678901)

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

    struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f",
                             name="struct_test",
                             structdef=SomeStruct)
class writeonly_py_base(CF__POA.Device, Device, ThreadedComponent):
        # These values can be altered in the __init__ of your derived class

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

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

            # self.auto_start is deprecated and is only kept for API compatibility
            # with 1.7.X and 1.8.0 devices.  This variable may be removed
            # in future releases
            self.auto_start = False
            # Instantiate the default implementations for all ports on this device

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

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

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

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

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


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


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


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


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

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


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

        foo_struct_seq = structseq_property(id_="foo_struct_seq",
                                            structdef=Ghi,
                                            defvalue=[Ghi(jkl="mno")],
                                            configurationkind=("allocation",),
                                            mode="writeonly")
class BasicTestDevice(CF__POA.AggregateExecutableDevice, ExecutableDevice,
                      AggregateDevice):
    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        ExecutableDevice.__init__(self, devmgr, uuid, label, softwareProfile,
                                  compositeDevice, execparams, PROPERTIES)
        AggregateDevice.__init__(self)
        self._props["memCapacity"] = 100000000
        self._props["BogoMipsCapacity"] = 100000000
        self._props["nicCapacity"] = 100.0
        self._props["fakeCapacity"] = 3
        self._props["execparams"] = " ".join(
            ["%s %s" % x for x in execparams.items()])

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

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

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

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

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

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

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

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

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

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

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

        self.allocStruct -= value
        return True

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    hex_props = simpleseq_property(id_="hex_props",
                                   name="hex_props",
                                   type_='short',
                                   defvalue=(0x01, 0x02))
예제 #6
0
class CommandWrapper_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 = "CommandWrapper"
        Resource.__init__(self, identifier, execparams, loggerName=loggerName)
        self._pid = None
        self.execparams = 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)
        Resource.start(self)

    def stop(self):
        self._log.debug("stop()")
        try:
            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
        finally:
            Resource.stop(self)

    # CF::LifeCycle
    def initialize(self):
        self.fromOther = fromOther_i(self, "resource_in")

    # CF::PortSupplier
    def getPort(self, name):
        if name == "resource_in":
            return self.fromOther._this()
    
    ######################################
    # 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)

    configure_prop_notset = simple_property(\
        id_='configure_prop_notset',
        type_="double",
        name="configure_prop_notset",
        kinds=("property"))

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

    execparams = simpleseq_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",))

    somelonglongprop = simple_property(\
        id_='DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc',
        type_="longlong",
        name="somelonglongprop",
        defvalue=12345678901)

    somelonglongprop2 = simple_property(\
        id_='DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1',
        type_="longlong",
        name="somelonglongprop2",
        defvalue=12345678901)

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

    struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f", 
                            name="struct_test", 
                            structdef=SomeStruct)
class cf_1535_p1_base(CF__POA.Resource, Component, ThreadedComponent):
        # These values can be altered in the __init__ of your derived class

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

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

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

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

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

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

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

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

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

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


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


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


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


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

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


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

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

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

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

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

        # Instantiate the default implementations for all ports on this component

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

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

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

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

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

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

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    my_bool_true = simple_property(id_="my_bool_true",
                                   type_="boolean",
                                   defvalue=True,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    my_bool_false = simple_property(id_="my_bool_false",
                                    type_="boolean",
                                    defvalue=False,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_bool_empty = simple_property(id_="my_bool_empty",
                                    type_="boolean",
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_long = simple_property(id_="my_long",
                              type_="long",
                              defvalue=10,
                              mode="readwrite",
                              action="external",
                              kinds=("configure", ))
    my_long_empty = simple_property(id_="my_long_empty",
                                    type_="long",
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    my_str = simple_property(id_="my_str",
                             type_="string",
                             defvalue="Hello World!",
                             mode="readwrite",
                             action="external",
                             kinds=("configure", ))
    my_str_empty = simple_property(id_="my_str_empty",
                                   type_="string",
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    my_long_enum = simple_property(id_="my_long_enum",
                                   type_="long",
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    my_str_enum = simple_property(id_="my_str_enum",
                                  type_="string",
                                  mode="readwrite",
                                  action="external",
                                  kinds=("configure", ))
    my_bool_enum = simple_property(id_="my_bool_enum",
                                   type_="boolean",
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure", ))
    escape__simple = simple_property(id_="escape::simple",
                                     type_="long",
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    readonly_simp = simple_property(id_="readonly_simp",
                                    type_="string",
                                    defvalue="Read only simple prop",
                                    mode="readonly",
                                    action="external",
                                    kinds=("configure", ))
    my_seq_bool = simpleseq_property(id_="my_seq_bool",
                                     type_="boolean",
                                     defvalue=(True, False),
                                     mode="readwrite",
                                     action="external",
                                     kinds=("configure", ))
    my_seq_str = simpleseq_property(id_="my_seq_str",
                                    type_="string",
                                    defvalue=("one", "", "three"),
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    readonly_seq = simpleseq_property(id_="readonly_seq",
                                      type_="string",
                                      defvalue=("read only",
                                                "sequence property"),
                                      mode="readonly",
                                      action="external",
                                      kinds=("configure", ))

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

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

        def __str__(self):
            """Return a string representation of this structure"""
            d = {}
            d["bool_true"] = self.bool_true
            d["bool_false"] = self.bool_false
            d["bool_empty"] = self.bool_empty
            d["long_s"] = self.long_s
            d["str_s"] = self.str_s
            d["enum_bool"] = self.enum_bool
            d["enum_str"] = self.enum_str
            d["enum_long"] = self.enum_long
            d["es__3"] = self.es__3
            return str(d)

        def getId(self):
            return "my_struct"

        def isStruct(self):
            return True

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

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

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

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

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

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

        def isStruct(self):
            return True

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

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

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

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

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

        def getId(self):
            return "readonly_struct"

        def isStruct(self):
            return True

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

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

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

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

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

        def getId(self):
            return "struct_good"

        def isStruct(self):
            return True

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

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

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

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

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

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

        def isStruct(self):
            return True

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

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

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

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

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

        def getId(self):
            return "readonly_ss"

        def isStruct(self):
            return True

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

    readonly_structseq = structseq_property(
        id_="readonly_structseq",
        structdef=ReadonlySs,
        defvalue=[ReadonlySs("read only"),
                  ReadonlySs("struct seq property")],
        configurationkind=("configure", ),
        mode="readonly")
예제 #9
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 TestAllPropTypes_base(CF__POA.Resource, Resource):
        # These values can be altered in the __init__ of your derived class

        PAUSE = 0.0125 # The amount of time to sleep if process return NOOP
        TIMEOUT = 5.0 # The amount of time to wait for the process thread to die when stop() is called
        DEFAULT_QUEUE_SIZE = 100 # The number of BulkIO packets that can be in the queue before pushPacket will block
        
        def __init__(self, identifier, execparams):
            loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0]
            Resource.__init__(self, identifier, execparams, loggerName=loggerName)
            self.threadControlLock = threading.RLock()
            self.process_thread = None
            # self.auto_start is deprecated and is only kept for API compatability
            # with 1.7.X and 1.8.0 components.  This variable may be removed
            # in future releases
            self.auto_start = False
            
        def initialize(self):
            Resource.initialize(self)
            
            # Instantiate the default implementations for all ports on this component


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

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

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

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

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

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

        ######################################################################
        # PROPERTIES
        # 
        # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
        # or by using the IDE.       
        simple_string = simple_property(id_="simple_string",
                                          type_="string",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_boolean = simple_property(id_="simple_boolean",
                                          type_="boolean",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_ulong = simple_property(id_="simple_ulong",
                                          type_="ulong",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
#        simple_objref = simple_property(id_="simple_objref",
#                                          type_="objref",
#                                          mode="readwrite",
#                                          action="external",
#                                          kinds=("configure",)
#                                          )       
        simple_short = simple_property(id_="simple_short",
                                          type_="short",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_float = simple_property(id_="simple_float",
                                          type_="float",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_octet = simple_property(id_="simple_octet",
                                          type_="octet",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_char = simple_property(id_="simple_char",
                                          type_="char",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_ushort = simple_property(id_="simple_ushort",
                                          type_="ushort",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_double = simple_property(id_="simple_double",
                                          type_="double",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_long = simple_property(id_="simple_long",
                                          type_="long",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_longlong = simple_property(id_="simple_longlong",
                                          type_="longlong",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )       
        simple_ulonglong = simple_property(id_="simple_ulonglong",
                                          type_="ulonglong",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_string = simpleseq_property(id_="simple_sequence_string",  
                                          type_="string",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_boolean = simpleseq_property(id_="simple_sequence_boolean",  
                                          type_="boolean",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_ulong = simpleseq_property(id_="simple_sequence_ulong",  
                                          type_="ulong",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
#        simple_sequence_objref = simpleseq_property(id_="simple_sequence_objref",  
#                                          type_="objref",
#                                          defvalue=None,
#                                          mode="readwrite",
#                                          action="external",
#                                          kinds=("configure",)
#                                          ) 
        simple_sequence_short = simpleseq_property(id_="simple_sequence_short",  
                                          type_="short",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_float = simpleseq_property(id_="simple_sequence_float",  
                                          type_="float",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_octet = simpleseq_property(id_="simple_sequence_octet",  
                                          type_="octet",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_char = simpleseq_property(id_="simple_sequence_char",  
                                          type_="char",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_ushort = simpleseq_property(id_="simple_sequence_ushort",  
                                          type_="ushort",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_double = simpleseq_property(id_="simple_sequence_double",  
                                          type_="double",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_long = simpleseq_property(id_="simple_sequence_long",  
                                          type_="long",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_longlong = simpleseq_property(id_="simple_sequence_longlong",  
                                          type_="longlong",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        simple_sequence_ulonglong = simpleseq_property(id_="simple_sequence_ulonglong",  
                                          type_="ulonglong",
                                          defvalue=None,
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )
        class StructVars(object):
            struct_string = simple_property(id_="struct_string",
                                          type_="string",
                                          )
            struct_boolean = simple_property(id_="struct_boolean",
                                          type_="boolean",
                                          )
            struct_ulong = simple_property(id_="struct_ulong",
                                          type_="ulong",
                                          )
#            struct_objref = simple_property(id_="struct_objref",
#                                          type_="objref",
#                                          )
            struct_short = simple_property(id_="struct_short",
                                          type_="short",
                                          )
            struct_float = simple_property(id_="struct_float",
                                          type_="float",
                                          )
            struct_octet = simple_property(id_="struct_octet",
                                          type_="octet",
                                          )
            struct_char = simple_property(id_="struct_char",
                                          type_="char",
                                          )
            struct_ushort = simple_property(id_="struct_ushort",
                                          type_="ushort",
                                          )
            struct_double = simple_property(id_="struct_double",
                                          type_="double",
                                          )
            struct_long = simple_property(id_="struct_long",
                                          type_="long",
                                          )
            struct_longlong = simple_property(id_="struct_longlong",
                                          type_="longlong",
                                          )
            struct_ulonglong = simple_property(id_="struct_ulonglong",
                                          type_="ulonglong",
                                          )
        
            def __init__(self, **kw):
                """Construct an initialized instance of this struct definition"""
                for attrname, classattr in type(self).__dict__.items():
                    if type(classattr) == simple_property:
                        classattr.initialize(self)
                for k,v in kw.items():
                    setattr(self,k,v)

            def __str__(self):
                """Return a string representation of this structure"""
                d = {}
                d["struct_string"] = self.struct_string
                d["struct_boolean"] = self.struct_boolean
                d["struct_ulong"] = self.struct_ulong
#                d["struct_objref"] = self.struct_objref
                d["struct_short"] = self.struct_short
                d["struct_float"] = self.struct_float
                d["struct_octet"] = self.struct_octet
                d["struct_char"] = self.struct_char
                d["struct_ushort"] = self.struct_ushort
                d["struct_double"] = self.struct_double
                d["struct_long"] = self.struct_long
                d["struct_longlong"] = self.struct_longlong
                d["struct_ulonglong"] = self.struct_ulonglong
                return str(d)

            def getId(self):
                return "struct_vars"

            def isStruct(self):
                return True

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

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

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

            def getId(self):
                return "struct_seq_vars"

            def isStruct(self):
                return True

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

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

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

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

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

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

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

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

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

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

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

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

    def __init__(self, identifier, execparams):
        Resource.__init__(self, identifier, execparams)
class TestComplexProps_base(CF__POA.Resource, Resource):
    # These values can be altered in the __init__ of your derived class

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

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

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

        # Instantiate the default implementations for all ports on this component

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

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

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

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

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

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

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    complexBooleanProp = simple_property(id_="complexBooleanProp",
                                         type_="boolean",
                                         defvalue=complex(0, 1),
                                         complex=True,
                                         mode="readwrite",
                                         action="external",
                                         kinds=("configure", ))
    complexULongProp = simple_property(id_="complexULongProp",
                                       type_="ulong",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexShortProp = simple_property(id_="complexShortProp",
                                       type_="short",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexFloatProp = simple_property(id_="complexFloatProp",
                                       type_="float",
                                       defvalue=complex(4.0, 5.0),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexOctetProp = simple_property(id_="complexOctetProp",
                                       type_="octet",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexCharProp = simple_property(id_="complexCharProp",
                                      type_="char",
                                      defvalue=complex(4, 5),
                                      complex=True,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    complexUShort = simple_property(id_="complexUShort",
                                    type_="ushort",
                                    defvalue=complex(4, 5),
                                    complex=True,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    complexDouble = simple_property(id_="complexDouble",
                                    type_="double",
                                    defvalue=complex(4.0, 5.0),
                                    complex=True,
                                    mode="readwrite",
                                    action="external",
                                    kinds=("configure", ))
    complexLong = simple_property(id_="complexLong",
                                  type_="long",
                                  defvalue=complex(4, 5),
                                  complex=True,
                                  mode="readwrite",
                                  action="external",
                                  kinds=("configure", ))
    complexLongLong = simple_property(id_="complexLongLong",
                                      type_="longlong",
                                      defvalue=complex(4, 5),
                                      complex=True,
                                      mode="readwrite",
                                      action="external",
                                      kinds=("configure", ))
    complexULongLong = simple_property(id_="complexULongLong",
                                       type_="ulonglong",
                                       defvalue=complex(4, 5),
                                       complex=True,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure", ))
    complexFloatSequence = simpleseq_property(id_="complexFloatSequence",
                                              type_="float",
                                              defvalue=[
                                                  complex(4.0, 5.0),
                                                  complex(4.0, 5.0),
                                                  complex(4.0, 5.0),
                                              ],
                                              complex=True,
                                              mode="readwrite",
                                              action="external",
                                              kinds=("configure", ))

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

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

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

        def getId(self):
            return "FloatStruct"

        def isStruct(self):
            return True

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

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

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

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

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

        def getId(self):
            return "complexFloatStruct"

        def isStruct(self):
            return True

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

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

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

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

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

        def getId(self):
            return "FloatStructSequenceMember"

        def isStruct(self):
            return True

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

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

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

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

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

        def getId(self):
            return "complexFloatStructSequenceMember"

        def isStruct(self):
            return True

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

    complexFloatStructSequence = structseq_property(
        id_="complexFloatStructSequence",
        structdef=ComplexFloatStructSequenceMember,
        defvalue=[],
        configurationkind=("configure", ),
        mode="readwrite")
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")
class property_init_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.
    cmdline = simple_property(id_="cmdline",
                              type_="string",
                              defvalue="default",
                              mode="readwrite",
                              action="external",
                              kinds=("property", ))

    initial = simple_property(id_="initial",
                              type_="string",
                              defvalue="default",
                              mode="readwrite",
                              action="external",
                              kinds=("property", ))

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

    initialize_props = simpleseq_property(id_="initialize_props",
                                          type_="string",
                                          defvalue=[],
                                          mode="readwrite",
                                          action="external",
                                          kinds=("property", ))
 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)]
class NicExecDevice_base(CF__POA.ExecutableDevice, ExecutableDevice,
                         ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

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

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

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 devices.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this device

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

    nic_allocation_status = structseq_property(
        id_="nic_allocation_status",
        structdef=NicAllocationStatusStruct,
        defvalue=[],
        configurationkind=("property", ),
        mode="readonly")
 class 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)]
class ticket_cf_1066_comp_base(CF__POA.Resource, Resource):
        # These values can be altered in the __init__ of your derived class

        PAUSE = 0.0125 # The amount of time to sleep if process return NOOP
        TIMEOUT = 5.0 # The amount of time to wait for the process thread to die when stop() is called
        DEFAULT_QUEUE_SIZE = 100 # The number of BulkIO packets that can be in the queue before pushPacket will block
        
        def __init__(self, identifier, execparams):
            loggerName = (execparams['NAME_BINDING'].replace('/', '.')).rsplit("_", 1)[0]
            Resource.__init__(self, identifier, execparams, loggerName=loggerName)
            self.threadControlLock = threading.RLock()
            self.process_thread = None
            # self.auto_start is deprecated and is only kept for API compatability
            # with 1.7.X and 1.8.0 components.  This variable may be removed
            # in future releases
            self.auto_start = False
            
        def initialize(self):
            Resource.initialize(self)
            
            # Instantiate the default implementations for all ports on this component


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

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

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

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

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

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

        ######################################################################
        # PROPERTIES
        # 
        # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
        # or by using the IDE.       
        simple_prop = simple_property(id_="simple_prop",
                                          type_="string",
                                          defvalue="default_value",
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          ) 
        seq_prop = simpleseq_property(id_="seq_prop",  
                                          type_="short",
                                          defvalue=(111,222,333),
                                          mode="readwrite",
                                          action="external",
                                          kinds=("configure",)
                                          )
        class StructProp(object):
            prop_one = simple_property(id_="prop_one",
                                          type_="boolean",
                                          defvalue=True,
                                          )
            prop_two = simple_property(id_="prop_two",
                                          type_="string",
                                          defvalue="This is another default value",
                                          )
            prop_three = simple_property(id_="prop_three",
                                          type_="float",
                                          defvalue=555,
                                          )
        
            def __init__(self, **kw):
                """Construct an initialized instance of this struct definition"""
                for attrname, classattr in type(self).__dict__.items():
                    if type(classattr) == simple_property:
                        classattr.initialize(self)
                for k,v in kw.items():
                    setattr(self,k,v)

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

            def getId(self):
                return "struct_prop"

            def isStruct(self):
                return True

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

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

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

            def getId(self):
                return "tmp_struct"

            def isStruct(self):
                return True

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

                
        struct_seq_prop = structseq_property(id_="struct_seq_prop",
                                          structdef=TmpStruct,                          
                                          defvalue=[],
                                          configurationkind=("configure",),
                                          mode="readwrite"
                                          )
예제 #22
0
class PropertyApi_base(CF__POA.Resource, Component, ThreadedComponent):
    # These values can be altered in the __init__ of your derived class

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

        # self.auto_start is deprecated and is only kept for API compatibility
        # with 1.7.X and 1.8.0 devices.  This variable may be removed
        # in future releases
        self.auto_start = False
        # Instantiate the default implementations for all ports on this device

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

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

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

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

    ######################################################################
    # PROPERTIES
    #
    # DO NOT ADD NEW PROPERTIES HERE.  You can add properties in your derived class, in the PRF xml file
    # or by using the IDE.
    device_kind = simple_property(
        id_="device_kind",
        name="device_kind",
        type_="string",
        defvalue="TestDevice",
        mode="readonly",
        action="eq",
        kinds=("allocation", ),
        description="""This specifies the device kind""")

    device_model = simple_property(
        id_="device_model",
        name="device_model",
        type_="string",
        defvalue="NotARealDevice",
        mode="readonly",
        action="eq",
        kinds=("allocation", ),
        description=""" This specifies the specific device""")

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

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

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

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

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

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

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

    simpleSeqShort = simpleseq_property(id_="simpleSeqShort",
                                        name="simpleSeqShort",
                                        type_="short",
                                        defvalue=[2, 3, 4],
                                        mode="readwrite",
                                        action="external",
                                        kinds=("property", ))

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

        structSimpleSeqShort = simpleseq_property(id_="structSimpleSeqShort",
                                                  name="structSimpleSeqShort",
                                                  type_="short",
                                                  defvalue=[8, 7, 6])

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

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

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

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

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

        @classmethod
        def isStruct(cls):
            return True

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

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

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

        structSeqStructSimpleSeqShort = simpleseq_property(
            id_="structSeqStructSimpleSeqShort",
            name="structSeqStructSimpleSeqShort",
            type_="short",
            defvalue=[23, 24, 25])

        def __init__(self,
                     structSeqStructSimpleShort=22,
                     structSeqStructSimpleSeqShort=[23, 24, 25]):
            self.structSeqStructSimpleShort = structSeqStructSimpleShort
            self.structSeqStructSimpleSeqShort = structSeqStructSimpleSeqShort

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

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

        @classmethod
        def isStruct(cls):
            return True

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

    structSeqShort = structseq_property(
        id_="structSeqShort",
        name="structSeqShort",
        structdef=StructSeqStructShort,
        defvalue=[
            StructSeqStructShort(structSeqStructSimpleShort=12,
                                 structSeqStructSimpleSeqShort=[23, 34, 45])
        ],
        configurationkind=("property", ),
        mode="readwrite")
예제 #24
0
    # 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",
                                   action="external",
                                   kinds=("configure"))
    testsimpleseq = simpleseq_property(id_="testsimpleseq",
                                       name="testsimpleseq",
                                       type_="float",
                                       defvalue=None,
                                       mode="readwrite",
                                       action="external",
                                       kinds=("configure"))
 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",
                                   action="external",
                                   kinds=("configure")
                                   ) 
 testsimpleseq = simpleseq_property(id_="testsimpleseq",
                                   name="testsimpleseq",   
                                   type_="float",
                                   defvalue=None,
                                   mode="readwrite",
                                   action="external",
                                   kinds=("configure")
                                   )
예제 #26
0
class TestPythonProps (CF__POA.Resource, Resource):
    """Python component for testing properties"""

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

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

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

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

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

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


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

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


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

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

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