Class: Syskit::NetworkGeneration::DataFlowComputation::Trigger
- Defined in:
- lib/syskit/network_generation/dataflow_computation.rb
Overview
Stores propagation information for the algorithm
This class stores a list of ports on which changes will should cause a call to #propagate_task. It is used as values in DataFlowComputation#triggering_connections
Constant Summary collapse
- USE_ALL =
all triggers must have final information
0
- USE_ANY =
at least one trigger must have final information
1
- USE_PARTIAL =
can use any added info from any trigger (implies USE_ANY)
2
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
The propagation mode, as one of USE_ALL, USE_ANY and USE_PARTIAL constants.
-
#ports ⇒ Object
readonly
The list of triggering ports, as [task, port_name] pairs.
Instance Method Summary collapse
-
#initialize(ports, mode) ⇒ Trigger
constructor
A new instance of Trigger.
-
#ports_to_propagate(state) ⇒ Object
Called by the algorithm to determine which ports should be propagated given a certain algorithm state
state
. - #pretty_print(pp) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ports, mode) ⇒ Trigger
Returns a new instance of Trigger
96 97 98 |
# File 'lib/syskit/network_generation/dataflow_computation.rb', line 96 def initialize(ports, mode) @ports, @mode = ports, mode end |
Instance Attribute Details
#mode ⇒ Object (readonly)
The propagation mode, as one of USE_ALL, USE_ANY and USE_PARTIAL constants. See constant documentation for more details.
94 95 96 |
# File 'lib/syskit/network_generation/dataflow_computation.rb', line 94 def mode @mode end |
#ports ⇒ Object (readonly)
The list of triggering ports, as [task, port_name] pairs
90 91 92 |
# File 'lib/syskit/network_generation/dataflow_computation.rb', line 90 def ports @ports end |
Instance Method Details
#ports_to_propagate(state) ⇒ Object
Called by the algorithm to determine which ports should be propagated given
a certain algorithm state state
.
state
is a DataFlowComputation object. Only the
#has_information_for_port? and #has_final_information_for_port? methods are
used.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/syskit/network_generation/dataflow_computation.rb', line 106 def ports_to_propagate(state) if ports.empty? return [], false end complete = false candidates = [] ports.each do |args| if state.has_final_information_for_port?(*args) complete = true candidates << args elsif mode == USE_ALL return [], false elsif state.has_information_for_port?(*args) complete = false if mode == USE_PARTIAL candidates << args end end end if mode == USE_ALL if !complete return [] end return ports, true else return candidates, complete end end |
#pretty_print(pp) ⇒ Object
142 143 144 145 146 147 148 149 150 |
# File 'lib/syskit/network_generation/dataflow_computation.rb', line 142 def pretty_print(pp) mode = %w{ALL ANY PARTIAL}[self.mode] pp.text mode pp.breakable pp.seplist(ports) do |portdef| task, port = *portdef pp.text "#{task}.#{port}" end end |
#to_s ⇒ Object
137 138 139 140 |
# File 'lib/syskit/network_generation/dataflow_computation.rb', line 137 def to_s modes = %w{ALL ANY PARTIAL} "#<Trigger: mode=#{modes[mode]} ports=#{ports.map { |t, p| "#{t}.#{p}" }.sort.join(",")}>" end |