Пример #1
0
    def __call__(self, *args, **kwargs):
        timeout = kwargs.get("timeout", CALL_TIMEOUT)
        wait = kwargs.get("wait", True)
        from_cache = kwargs.get("from_cache", False)
        if from_cache:
            # CACHE_DEV
            source_type = Tango.DevSource[2]
        else:
            # DEV
            source_type = Tango.DevSource[0]

        if not args:
            argin = CORBA.Any(CORBA.NullTypeCode(), None)
        else:
            argin = python2any(args[0], self.cmd_type)

        # timeout is only took into account when we wait for result
        tango_call_greenlet = gevent.spawn(do_tango_cmd_call,
                                           self.name,
                                           self.cmd_type,
                                           self.cmd_call,
                                           argin,
                                           source_type,
                                           wait,
                                           timeout if wait else None,
                                           parent_proxy=self.proxy)

        if wait:
            return tango_call_greenlet.get()
        else:
            return tango_call_greenlet
Пример #2
0
def python2any(data, data_type=None, force_array=False, attr=False):
    if attr:
        typeEnum2str = globals()["attrTypeEnum2str"]
    else:
        typeEnum2str = globals()["typeEnum2str"]

    data_type_name, array_data_type_name = typeEnum2str[data_type]

    if data_type_name == "DevVarDoubleStringArray":
        # data is supposed to be a tuple with a list of doubles and a list of strings
        data = {"dvalue": data[0], "svalue": data[1]}
    elif data_type_name == "DevVarLongStringArray":
        # data is supposed to be a tuple with a list of longs and a list of strings
        data = {"lvalue": data[0], "svalue": data[1]}

    if force_array:
        data_type_name = array_data_type_name
        data = [data]

    return CORBA.Any(CORBA.typecode("IDL:Tango/%s:1.0" % data_type_name), data)
Пример #3
0
def main(argv):
    """ Do it! """

    print 'Initialising the ORB...'

    # Initialise the ORB.
    orb = CORBA.ORB_init(argv, CORBA.ORB_ID)

    # Get a reference to the initial naming service context.
    ctx = CORBA.ORB_init().resolve_initial_references("NameService")

    # The 'pathname' of the context that holds the thermometer references.
    path = [
        CosNaming.NameComponent('SVM', ''),
        CosNaming.NameComponent('SVMMODULE', ''),
        CosNaming.NameComponent('test', '')
    ]

    # Lookup the temperatures of the thermometers in rooms 101-105, and then
    # force a lookup on a non-existent name "106"!
    for room in ["inf_0"]:
        # Create a naming service 'name' for the thermometer.
        name = path + [CosNaming.NameComponent(room, '')]

        try:
            # Lookup the thermometer in the naming service.
            thermometer = ctx.resolve(name)

            # Make sure the object implements the expected interface!
            if not thermometer._is_a(CORBA.id(test.inf_0)):
                raise 'This is not a Thermometer!'

            # Call the server!
            thermometer.p('e', [CORBA.Any(CORBA.TC_string, 'hello')])

        except CosNaming.NamingContext.NotFound:
            print 'No thermometer in room', room

    return 0