Class: Orocos::RubyTasks::LocalOutputPort
- Inherits:
-
OutputPort
- Object
- Port
- OutputPort
- Orocos::RubyTasks::LocalOutputPort
- Defined in:
- lib/orocos/ruby_tasks/ports.rb,
ext/rorocos/ruby_task_context.cc
Direct Known Subclasses
Constant Summary
Constants inherited from Port
Port::CONNECTION_POLICY_OPTIONS, Port::DEFAULT_CONNECTION_POLICY, Port::MQ_RTT_DEFAULT_QUEUE_LENGTH
Constants included from PortBase
PortBase::D_DIFFERENT_HOSTS, PortBase::D_SAME_HOST, PortBase::D_SAME_PROCESS, PortBase::D_UNKNOWN
Instance Attribute Summary
Attributes included from PortBase
#model, #name, #orocos_type_name, #task, #type
Instance Method Summary collapse
-
#connected? ⇒ Boolean
Whether the port seem to be connected to something.
- #do_write(type_name, rb_typelib_value) ⇒ Object
-
#remove ⇒ Object
Remove this port from the underlying task context.
-
#write(data) ⇒ Object
Write a sample on this output port.
Methods inherited from OutputPort
#connect_to, #disconnect_from, #do_connect_to, #pretty_print, #publish_on_ros, reader_class, #to_async, #to_proxy, #unpublish_from_ros
Methods included from OutputPortBase
#connect_to, #disconnect_from, #reader
Methods inherited from Port
#create_stream, #default_ros_topic_name, #disconnect_all, #do_create_stream, #do_disconnect_all, #do_disconnect_from, #do_remove_stream, #doc, #doc?, #handle_mq_transport, prepare_policy, #pretty_print, #refine_exceptions, #remove_stream, #to_orocos_port, transient_local_port_name, transport_name, #type_name, validate_policy
Methods included from PortBase
#==, #distance_to, #ensure_type_available, #full_name, #initialize, #log_metadata, #max_marshalling_size, #max_sizes, #new_sample, #to_s
Instance Method Details
#connected? ⇒ Boolean
Whether the port seem to be connected to something
197 198 199 200 201 |
# File 'lib/orocos/ruby_tasks/ports.rb', line 197 def connected? Orocos.allow_blocking_calls do super end end |
#do_write(type_name, rb_typelib_value) ⇒ Object
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'ext/rorocos/ruby_task_context.cc', line 396
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 ⇒ Object
Remove this port from the underlying task context
173 174 175 |
# File 'lib/orocos/ruby_tasks/ports.rb', line 173 def remove task.remove_port(self) end |
#write(data) ⇒ Object
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")
191 192 193 194 |
# 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 |