class Syskit::InputWriter

A data writer for a port attached to a component

Attributes

writer[R]

The actual data writer itself @return [Orocos::InputWriter]

Public Instance Methods

connected?() click to toggle source
# File lib/syskit/port.rb, line 329
def connected?
    writer && writer.connected?
end
disconnect() click to toggle source
# File lib/syskit/port.rb, line 333
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() click to toggle source
# File lib/syskit/port.rb, line 321
def model
    Models::InputWriter.new(port.model, policy)
end
new_sample() click to toggle source
# File lib/syskit/port.rb, line 364
def new_sample
    @port.new_sample
end
ready?() click to toggle source
# File lib/syskit/port.rb, line 325
def ready?
    writer && actual_port.component.running?
end
resolve(main, port) click to toggle source

@api private

Resolves the underlying writer object

Calls superclass method
# File lib/syskit/port.rb, line 347
def resolve(main, port)
    super(main, port, :writer) { |w| @writer = w }
end
write(sample) click to toggle source

Write a sample on the associated port

@return [Boolean] true if the writer was in a state that allowed

writing to the actual task, false otherwise
# File lib/syskit/port.rb, line 355
def write(sample)
    if ready?
        writer.write(sample)
    else
        Typelib.from_ruby(sample, port.type)
        nil
    end
end