Class: Orocos::RubyTasks::TaskContext::LocalTaskContext
- Inherits:
-
Object
- Object
- Orocos::RubyTasks::TaskContext::LocalTaskContext
- Defined in:
- lib/orocos/ruby_tasks/task_context.rb,
ext/rorocos/ruby_task_context.cc
Overview
Internal handler used to represent the local RTT::TaskContext object
It is created from Ruby as it handles the RTT::TaskContext pointer
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
- String
-
the task name.
-
#remote_task ⇒ Object
readonly
- Orocos::TaskContext
-
the remote task.
Class Method Summary collapse
Instance Method Summary collapse
- #do_create_attribute(klass, port_name, orocos_type_name) ⇒ Object
- #do_create_port(klass, port_name, orocos_type_name) ⇒ Object
- #do_create_property(klass, port_name, orocos_type_name) ⇒ Object
- #do_remove_port(_port_name) ⇒ Object
- #exception ⇒ Object
-
#initialize(name) ⇒ LocalTaskContext
constructor
A new instance of LocalTaskContext.
- #ior ⇒ Object
- #model_name=(name) ⇒ Object
Constructor Details
#initialize(name) ⇒ LocalTaskContext
Returns a new instance of LocalTaskContext
17 18 19 |
# File 'lib/orocos/ruby_tasks/task_context.rb', line 17 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
- String
-
the task name
15 16 17 |
# File 'lib/orocos/ruby_tasks/task_context.rb', line 15 def name @name end |
#remote_task ⇒ Object (readonly)
- Orocos::TaskContext
-
the remote task
13 14 15 |
# File 'lib/orocos/ruby_tasks/task_context.rb', line 13 def remote_task @remote_task end |
Class Method Details
.new(_name) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'ext/rorocos/ruby_task_context.cc', line 177
static VALUE local_task_context_new(VALUE klass, VALUE _name)
{
std::string name = StringValuePtr(_name);
LocalTaskContext* ruby_task = new LocalTaskContext(name);
RTT::corba::CorbaDispatcher::Instance(ruby_task->ports(), ORO_SCHED_OTHER, RTT::os::LowestPriority);
RTT::corba::TaskContextServer::Create(ruby_task);
VALUE rlocal_task = Data_Wrap_Struct(cLocalTaskContext, 0, delete_local_task_context, new RLocalTaskContext(ruby_task));
rb_obj_call_init(rlocal_task, 1, &_name);
return rlocal_task;
}
|
Instance Method Details
#do_create_attribute(klass, port_name, orocos_type_name) ⇒ Object
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'ext/rorocos/ruby_task_context.cc', line 311
static VALUE local_task_context_create_attribute(VALUE _task, VALUE _klass, VALUE _attribute_name, VALUE _type_name)
{
std::string attribute_name = StringValuePtr(_attribute_name);
std::string type_name = StringValuePtr(_type_name);
RTT::types::TypeInfo* ti = get_type_info(type_name);
if (!ti)
rb_raise(rb_eArgError, "type %s is not registered on the RTT type system", type_name.c_str());
RTT::types::ValueFactoryPtr factory = ti->getValueFactory();
if (!factory)
rb_raise(rb_eArgError, "it seems that the typekit for %s does not include the necessary factory", type_name.c_str());
RTT::base::AttributeBase* attribute = factory->buildAttribute(attribute_name);
VALUE ruby_attribute = Data_Wrap_Struct(_klass, 0, delete_rtt_ruby_attribute, attribute);
local_task_context(_task).addAttribute(*attribute);
VALUE args[4] = { rb_iv_get(_task, "@remote_task"), _attribute_name, _type_name };
rb_obj_call_init(ruby_attribute, 3, args);
return ruby_attribute;
}
|
#do_create_port(klass, port_name, orocos_type_name) ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'ext/rorocos/ruby_task_context.cc', line 241
static VALUE local_task_context_create_port(VALUE _task, VALUE _is_output, VALUE _klass, VALUE _port_name, VALUE _type_name)
{
std::string port_name = StringValuePtr(_port_name);
std::string type_name = StringValuePtr(_type_name);
RTT::types::TypeInfo* ti = get_type_info(type_name);
if (!ti)
rb_raise(rb_eArgError, "type %s is not registered on the RTT type system", type_name.c_str());
RTT::types::ConnFactoryPtr factory = ti->getPortFactory();
if (!factory)
rb_raise(rb_eArgError, "it seems that the typekit for %s does not include the necessary factory", type_name.c_str());
RTT::base::PortInterface* port;
VALUE ruby_port;
if (RTEST(_is_output))
port = factory->outputPort(port_name);
else
port = factory->inputPort(port_name);
ruby_port = Data_Wrap_Struct(_klass, 0, delete_rtt_ruby_port, port);
local_task_context(_task).ports()->addPort(*port);
VALUE args[4] = { rb_iv_get(_task, "@remote_task"), _port_name, _type_name, Qnil };
rb_obj_call_init(ruby_port, 4, args);
return ruby_port;
}
|
#do_create_property(klass, port_name, orocos_type_name) ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'ext/rorocos/ruby_task_context.cc', line 286
static VALUE local_task_context_create_property(VALUE _task, VALUE _klass, VALUE _property_name, VALUE _type_name)
{
std::string property_name = StringValuePtr(_property_name);
std::string type_name = StringValuePtr(_type_name);
RTT::types::TypeInfo* ti = get_type_info(type_name);
if (!ti)
rb_raise(rb_eArgError, "type %s is not registered on the RTT type system", type_name.c_str());
RTT::types::ValueFactoryPtr factory = ti->getValueFactory();
if (!factory)
rb_raise(rb_eArgError, "it seems that the typekit for %s does not include the necessary factory", type_name.c_str());
RTT::base::PropertyBase* property = factory->buildProperty(property_name, "");
VALUE ruby_property = Data_Wrap_Struct(_klass, 0, delete_rtt_ruby_property, property);
local_task_context(_task).addProperty(*property);
VALUE args[4] = { rb_iv_get(_task, "@remote_task"), _property_name, _type_name };
rb_obj_call_init(ruby_property, 3, args);
return ruby_property;
}
|
#do_remove_port(_port_name) ⇒ Object
267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'ext/rorocos/ruby_task_context.cc', line 267
static VALUE local_task_context_remove_port(VALUE obj, VALUE _port_name)
{
std::string port_name = StringValuePtr(_port_name);
LocalTaskContext& task(local_task_context(obj));
RTT::DataFlowInterface& di(*task.ports());
RTT::base::PortInterface* port = di.getPort(port_name);
if (!port)
rb_raise(rb_eArgError, "task %s has no port named %s", task.getName().c_str(), port_name.c_str());
// Workaround a bug in RTT. The port's data flow interface is not reset
port->setInterface(0);
di.removePort(port_name);
return Qnil;
}
|
#exception ⇒ Object
231 232 233 234 235 |
# File 'ext/rorocos/ruby_task_context.cc', line 231
static VALUE local_task_context_exception(VALUE _task)
{
local_task_context(_task).exception();
return Qnil;
}
|
#ior ⇒ Object
197 198 199 200 201 202 |
# File 'ext/rorocos/ruby_task_context.cc', line 197
static VALUE local_task_context_ior(VALUE _task)
{
LocalTaskContext& task = local_task_context(_task);
std::string ior = RTT::corba::TaskContextServer::getIOR(&task);
return rb_str_new(ior.c_str(), ior.length());
}
|
#model_name=(name) ⇒ Object
225 226 227 228 229 |
# File 'ext/rorocos/ruby_task_context.cc', line 225
static VALUE local_task_context_set_model_name(VALUE _task, VALUE name)
{
local_task_context(_task).setModelName(StringValuePtr(name));
return Qnil;
}
|