class OroGen::Spec::OutputPort

Specification for an output port

Attributes

burst_period[R]
burst_size[R]
triggered_on_update[W]

Used to write the #triggered_on_update flag directly. This should not be used in normal situations

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/orogen/spec/output_port.rb, line 5
def initialize(*args)
    super
    @sample_size  = 1
    @period = 1
    @burst_size   = 0
    @burst_period = 0
    @port_triggers = Set.new
    @triggered_on_update = nil
end

Public Instance Methods

burst count, period → self click to toggle source

Declares that a burst of data can occasionally be written to this port. count is the maximal number of samples that are pushed to this port at once, and period how often this burst can happen.

If the perid is set to 0, then it is assumed that the bursts happen 'every once in a while', i.e. that it can be assumed that the event is rare enough.

The default is no burst

# File lib/orogen/spec/output_port.rb, line 52
def burst(size, period = 1)
    @burst_size   = Integer(size)
    @burst_period = Integer(period)
    self
end
port_triggers() click to toggle source

The set of input ports that will cause a write on this output

# File lib/orogen/spec/output_port.rb, line 59
def port_triggers
    if @triggered_once_per_update
        return []
    end

    @port_triggers
end
triggered_on input_port_name, input_port_name, ... click to toggle source

Declares that this port will be written whenever a sample is received on the given input ports. The default is to consider that the port is written whenever updateHook() is called.

You may want to call triggered_on_update if the port will be written for each call to updateHook too.

# File lib/orogen/spec/output_port.rb, line 76
def triggered_on(*input_ports)
    input_ports = input_ports.to_set.map do |name|
        if !(p = task.find_input_port(name))
            raise ArgumentError, "#{name} is not an input port of #{self}"
        end
        p
    end

    @port_triggers |= input_ports
    self
end
triggered_on_update() click to toggle source

Declares that this port will be written for each call of the updateHook(). It is the default if triggered_on has not been called.

# File lib/orogen/spec/output_port.rb, line 95
def triggered_on_update
    @triggered_on_update = true
    self
end
triggered_on_update?() click to toggle source

True if the port will be written for the calls to updateHook() that are triggered by the activity.

See triggered_on_update and triggered_on

# File lib/orogen/spec/output_port.rb, line 112
def triggered_on_update?
    if @triggered_once_per_update then true
    elsif port_triggers.empty?
        # One can set triggered_on_update to false explicitely to
        # override the default
        @triggered_on_update != false
    else
        @triggered_on_update
    end
end
triggered_once_per_update() click to toggle source

Declares that at most one sample will be written per call to updateHook, regardless of the actual amount of samples that are waiting to be read by the task

# File lib/orogen/spec/output_port.rb, line 103
def triggered_once_per_update
    @triggered_once_per_update = true
    self
end
triggered_once_per_update?() click to toggle source

If true, this port will be written at most once per call to updateHook, regardless of the actual amount of samples that are waiting to be read by the task

The port period and burst are still used

# File lib/orogen/spec/output_port.rb, line 128
def triggered_once_per_update?
    !!@triggered_once_per_update
end