Class: Orocos::SendHandle

Inherits:
Object
  • Object
show all
Defined in:
lib/orocos/operations.rb,
ext/rorocos/operations.cc

Overview

OperationHandle instances represent asynchronous operation calls. They are returned by Operation#sendop and TaskContext#sendop

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#orocos_return_typesObject (readonly)

Returns the value of attribute orocos_return_types


5
6
7
# File 'lib/orocos/operations.rb', line 5

def orocos_return_types
  @orocos_return_types
end

#return_valuesObject (readonly)

Returns the value of attribute return_values


6
7
8
# File 'lib/orocos/operations.rb', line 6

def return_values
  @return_values
end

Instance Method Details

#collectObject

Waits for the operation to finish and returns both its completion status and, if applicable, its return value(s)

Existing completion status are

Orocos::SEND_SUCCESS
Orocos::SEND_NOT_READY
Orocos::SEND_FAILURE

16
17
18
19
20
21
22
23
24
25
# File 'lib/orocos/operations.rb', line 16

def collect
    CORBA.refine_exceptions(self) do
        status = do_operation_collect(orocos_return_types, return_values)
        if return_values.empty?
            return status
        else
            return [status, *return_values]
        end
    end
end

#collect_if_doneObject

Returns the current status for the operation

If the operation is finished, and if it has a return value, then it returns

Orocos::SEND_SUCCESS, return_value1, return_value2, ...

Otherwise, returns either Orocos::SEND_NOT_READY (not yet processed) or Orocos::SEND_FAILURE (operation failed to be processed on the remote task)


37
38
39
40
41
42
43
44
45
46
# File 'lib/orocos/operations.rb', line 37

def collect_if_done
    CORBA.refine_exceptions(self) do
        status = do_operation_collect_if_done(orocos_return_types, return_values)
        if return_values.empty?
            return status
        else
            return [status, *return_values]
        end
    end
end

#do_operation_collect(result_type_names, results) ⇒ Object


126
127
128
129
130
131
132
133
134
135
136
# File 'ext/rorocos/operations.cc', line 126

static VALUE send_handle_collect(VALUE handle_, VALUE result_type_names, VALUE results)
{
    RSendHandle& handle = get_wrapped<RSendHandle>(handle_);
    CAnyArguments_var corba_result = new CAnyArguments;

    CSendStatus ss = corba_blocking_fct_call_with_result(boost::bind(&_objref_CSendHandle::collect,
                (CSendHandle_ptr)handle.handle,(CAnyArguments_out)corba_result));
    if (ss == RTT::corba::CSendSuccess)
        corba_args_to_ruby(result_type_names, results, corba_result);
    return INT2FIX(ss);
}

#do_operation_collect_if_done(result_type_names, results) ⇒ Object


114
115
116
117
118
119
120
121
122
123
124
# File 'ext/rorocos/operations.cc', line 114

static VALUE send_handle_collect_if_done(VALUE handle_, VALUE result_type_names, VALUE results)
{
    RSendHandle& handle = get_wrapped<RSendHandle>(handle_);
    CAnyArguments_var corba_result = new CAnyArguments;

    CSendStatus ss = corba_blocking_fct_call_with_result(boost::bind(&_objref_CSendHandle::collectIfDone,
                (CSendHandle_ptr)handle.handle,(CAnyArguments_out)corba_result));
    if (ss == RTT::corba::CSendSuccess)
        corba_args_to_ruby(result_type_names, results, corba_result);
    return INT2FIX(ss);
}