Class: RSMP::TLC::SignalPlan
- Inherits:
-
Object
- Object
- RSMP::TLC::SignalPlan
- Defined in:
- lib/rsmp/tlc/signal_plan.rb
Overview
A Traffic Light Controller Signal Plan. A signal plan is a description of how all signal groups should change state over time.
Instance Attribute Summary collapse
-
#dynamic_bands ⇒ Object
readonly
Returns the value of attribute dynamic_bands.
-
#nr ⇒ Object
readonly
Returns the value of attribute nr.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
Instance Method Summary collapse
- #dynamic_bands_string ⇒ Object
- #get_band(band) ⇒ Object
-
#initialize(nr:, states:, dynamic_bands:) ⇒ SignalPlan
constructor
A new instance of SignalPlan.
- #set_band(band, value) ⇒ Object
Constructor Details
#initialize(nr:, states:, dynamic_bands:) ⇒ SignalPlan
Returns a new instance of SignalPlan.
8 9 10 11 12 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 8 def initialize nr:, states:, dynamic_bands: @nr = nr @states = states @dynamic_bands = dynamic_bands || {} end |
Instance Attribute Details
#dynamic_bands ⇒ Object (readonly)
Returns the value of attribute dynamic_bands.
7 8 9 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 7 def dynamic_bands @dynamic_bands end |
#nr ⇒ Object (readonly)
Returns the value of attribute nr.
7 8 9 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 7 def nr @nr end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
7 8 9 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 7 def states @states end |
Instance Method Details
#dynamic_bands_string ⇒ Object
14 15 16 17 18 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 14 def dynamic_bands_string str = @dynamic_bands.map { |band,value| "#{nr}-#{band}-#{value}" }.join(',') return nil if str == '' str end |
#get_band(band) ⇒ Object
24 25 26 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 24 def get_band band @dynamic_bands[ band.to_i ] end |
#set_band(band, value) ⇒ Object
20 21 22 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 20 def set_band band, value @dynamic_bands[ band.to_i ] = value.to_i end |