Class: OroGen::Spec::OutputPort

Inherits:
Port
  • Object
show all
Defined in:
lib/orogen/spec/output_port.rb

Overview

Specification for an output port

Direct Known Subclasses

ROS::Spec::OutputTopic, DynamicOutputPort

Instance Attribute Summary collapse

Attributes inherited from Port

#name, #task, #type

Instance Method Summary collapse

Methods inherited from Port

compute_max_marshalling_size, #dynamic, #dynamic?, #each_interface_type, initialize_max_size_sample, #max_marshalling_size, #max_sizes, #orocos_type_name, #pretty_print, resolve_max_size_path, #static, #static?, #to_h, #type_name, validate_max_sizes_spec

Constructor Details

#initialize(*args) ⇒ OutputPort


5
6
7
8
9
10
11
12
13
# 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

Instance Attribute Details

#burst_periodObject (readonly)

Returns the value of attribute burst_period


16
17
18
# File 'lib/orogen/spec/output_port.rb', line 16

def burst_period
  @burst_period
end

#burst_sizeObject (readonly)

Returns the value of attribute burst_size


15
16
17
# File 'lib/orogen/spec/output_port.rb', line 15

def burst_size
  @burst_size
end

#triggered_on_updateObject

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


95
96
97
98
# File 'lib/orogen/spec/output_port.rb', line 95

def triggered_on_update
    @triggered_on_update = true
    self
end

Instance Method Details

#burst(size, period = 1) ⇒ Object

call-seq:

burst count, period -> self

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


52
53
54
55
56
# 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_triggersObject

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


59
60
61
62
63
64
65
# 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_ports) ⇒ Object

call-seq:

triggered_on input_port_name, input_port_name, ...

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.


76
77
78
79
80
81
82
83
84
85
86
# 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?Boolean

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


112
113
114
115
116
117
118
119
120
121
# 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_updateObject

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


103
104
105
106
# 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?Boolean

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


128
129
130
# File 'lib/orogen/spec/output_port.rb', line 128

def triggered_once_per_update?
    !!@triggered_once_per_update
end