Class: RSMP::TLC::SignalPlan

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_timeObject

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_bandsObject (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

#numberObject (readonly)

Returns the value of attribute number.



7
8
9
# File 'lib/rsmp/tlc/signal_plan.rb', line 7

def number
  @number
end

#statesObject (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_stringObject



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