class Orocos::RubyTasks::LocalOutputPort
Public Instance Methods
connected?()
click to toggle source
Whether the port seem to be connected to something
Calls superclass method
# File lib/orocos/ruby_tasks/ports.rb, line 197 def connected? Orocos.allow_blocking_calls do super end end
do_write(p1, p2)
click to toggle source
static VALUE local_output_port_write(VALUE _local_port, VALUE type_name, VALUE rb_typelib_value)
{
RTT::base::OutputPortInterface& local_port = get_wrapped<RTT::base::OutputPortInterface>(_local_port);
Typelib::Value value = typelib_get(rb_typelib_value);
orogen_transports::TypelibMarshallerBase* transport = 0;
RTT::types::TypeInfo* ti = get_type_info(StringValuePtr(type_name));
if (ti && ti->hasProtocol(orogen_transports::TYPELIB_MARSHALLER_ID))
{
transport =
dynamic_cast<orogen_transports::TypelibMarshallerBase*>(ti->getProtocol(orogen_transports::TYPELIB_MARSHALLER_ID));
}
if (!transport)
{
RTT::base::DataSourceBase::shared_ptr ds =
ti->buildReference(value.getData());
local_port.write(ds);
}
else
{
orogen_transports::TypelibMarshallerBase::Handle* handle =
transport->createHandle();
transport->setTypelibSample(handle, static_cast<uint8_t*>(value.getData()));
RTT::base::DataSourceBase::shared_ptr ds =
transport->getDataSource(handle);
local_port.write(ds);
transport->deleteHandle(handle);
}
return local_port.connected() ? Qtrue : Qfalse;
}
remove()
click to toggle source
Remove this port from the underlying task context
# File lib/orocos/ruby_tasks/ports.rb, line 173 def remove task.remove_port(self) end
write(data)
click to toggle source
Write a sample on this output port
If the data type is a struct, the sample can be provided either as a Typelib instance object or as a hash.
In the first case, one can do:
value = port.new_sample # Get a new sample from the port value.field = 10 value.other_field = "a_string" input_writer.write(value)
In the second case,
input_writer.write(:field => 10, :other_field => "a_string")
# File lib/orocos/ruby_tasks/ports.rb, line 191 def write(data) data = Typelib.from_ruby(data, type) do_write(orocos_type_name, data) end