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