Class: Syskit::InputWriter
- Inherits:
-
PortAccessor
- Object
- PortAccessor
- Syskit::InputWriter
- Defined in:
- lib/syskit/port.rb
Overview
A data writer for a port attached to a component
Instance Attribute Summary collapse
-
#writer ⇒ Orocos::InputWriter
readonly
The actual data writer itself.
Attributes inherited from PortAccessor
#actual_port, #policy, #port, #resolved_port
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #disconnect ⇒ Object
- #model ⇒ Object
- #new_sample ⇒ Object
- #ready? ⇒ Boolean
-
#resolve(main, port) ⇒ Object
private
Resolves the underlying writer object.
-
#write(sample) ⇒ Boolean
Write a sample on the associated port.
Methods inherited from PortAccessor
Constructor Details
This class inherits a constructor from Syskit::PortAccessor
Instance Attribute Details
#writer ⇒ Orocos::InputWriter (readonly)
The actual data writer itself
363 364 365 |
# File 'lib/syskit/port.rb', line 363 def writer @writer end |
Instance Method Details
#connected? ⇒ Boolean
373 374 375 |
# File 'lib/syskit/port.rb', line 373 def connected? writer && writer.connected? end |
#disconnect ⇒ Object
377 378 379 380 381 382 383 384 385 386 |
# File 'lib/syskit/port.rb', line 377 def disconnect @disconnected = true if actual_writer = self.writer actual_port.component.execution_engine.promise(description: "disconnect #{self}") do begin actual_writer.disconnect rescue Orocos::ComError end end.on_success { @writer = nil }.execute end end |
#model ⇒ Object
365 366 367 |
# File 'lib/syskit/port.rb', line 365 def model Models::InputWriter.new(port.model, policy) end |
#new_sample ⇒ Object
408 409 410 |
# File 'lib/syskit/port.rb', line 408 def new_sample @port.new_sample end |
#ready? ⇒ Boolean
369 370 371 |
# File 'lib/syskit/port.rb', line 369 def ready? writer && actual_port.component.running? end |
#resolve(main, port) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resolves the underlying writer object
391 392 393 |
# File 'lib/syskit/port.rb', line 391 def resolve(main, port) super(main, port, :writer) { |w| @writer = w } end |
#write(sample) ⇒ Boolean
Write a sample on the associated port
399 400 401 402 403 404 405 406 |
# File 'lib/syskit/port.rb', line 399 def write(sample) if ready? writer.write(sample) else Typelib.from_ruby(sample, port.type) nil end end |