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
-
#cycle_time ⇒ Object
readonly
Returns the value of attribute cycle_time.
-
#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:, cycle_time:, states:, dynamic_bands:) ⇒ SignalPlan
constructor
A new instance of SignalPlan.
- #set_band(band, value) ⇒ Object
- #set_cycle_time(cycle_time) ⇒ Object
Constructor Details
#initialize(nr:, cycle_time:, states:, dynamic_bands:) ⇒ SignalPlan
Returns a new instance of SignalPlan.
8 9 10 11 12 13 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 8 def initialize nr:, cycle_time:, states:, dynamic_bands: @nr = nr @states = states @dynamic_bands = dynamic_bands || {} @cycle_time = cycle_time end |
Instance Attribute Details
#cycle_time ⇒ Object (readonly)
Returns the value of attribute cycle_time.
7 8 9 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 7 def cycle_time @cycle_time end |
#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
15 16 17 18 19 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 15 def dynamic_bands_string str = @dynamic_bands.map { |band,value| "#{nr}-#{band}-#{value}" }.join(',') return nil if str == '' str end |
#get_band(band) ⇒ Object
25 26 27 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 25 def get_band band @dynamic_bands[ band.to_i ] end |
#set_band(band, value) ⇒ Object
21 22 23 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 21 def set_band band, value @dynamic_bands[ band.to_i ] = value.to_i end |
#set_cycle_time(cycle_time) ⇒ Object
29 30 31 32 |
# File 'lib/rsmp/tlc/signal_plan.rb', line 29 def set_cycle_time cycle_time raise ArgumentError if cycle_time < 0 @cycle_time = cycle_time end |