Class: Enginevib::Main
- Inherits:
-
Object
- Object
- Enginevib::Main
- Includes:
- Launcher
- Defined in:
- lib/enginevib/main.rb
Overview
The main class. run is called when run from command line.
Constant Summary collapse
- DEADLINE =
30 milliseconds
30.0 / 1000.0
- TOLERANCE =
7 miliseconds
7.0 / 1000.0
- AVERAGE_SAMPLE_SIZE =
100 ticks
100
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#output ⇒ Object
Returns the value of attribute output.
-
#scheduler ⇒ Object
Returns the value of attribute scheduler.
-
#sensor ⇒ Object
Returns the value of attribute sensor.
-
#system ⇒ Object
Returns the value of attribute system.
Attributes included from Launcher
Instance Method Summary collapse
-
#initialize ⇒ Main
constructor
A new instance of Main.
- #initialize_components ⇒ Object
- #initialize_scheduler ⇒ Object
- #start_scheduler ⇒ Object
Methods included from Launcher
Constructor Details
#initialize ⇒ Main
Returns a new instance of Main.
11 12 13 14 15 |
# File 'lib/enginevib/main.rb', line 11 def initialize parse_arguments initialize_components initialize_scheduler end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
5 6 7 |
# File 'lib/enginevib/main.rb', line 5 def controller @controller end |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/enginevib/main.rb', line 5 def output @output end |
#scheduler ⇒ Object
Returns the value of attribute scheduler.
5 6 7 |
# File 'lib/enginevib/main.rb', line 5 def scheduler @scheduler end |
#sensor ⇒ Object
Returns the value of attribute sensor.
5 6 7 |
# File 'lib/enginevib/main.rb', line 5 def sensor @sensor end |
#system ⇒ Object
Returns the value of attribute system.
5 6 7 |
# File 'lib/enginevib/main.rb', line 5 def system @system end |
Instance Method Details
#initialize_components ⇒ Object
17 18 19 20 21 22 |
# File 'lib/enginevib/main.rb', line 17 def initialize_components @sensor = Sensor.new(@options[:serial_port], @options[:simulation_mode]) @output = Output.new @system = System.new @controller = Controller.new end |
#initialize_scheduler ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/enginevib/main.rb', line 24 def initialize_scheduler @scheduler = Scheduler.new(DEADLINE, TOLERANCE) do |stats| if @controller.inop sleep DEADLINE - TOLERANCE else data = @sensor.read computed_data = @system.compute(data) @output.refresh_display(computed_data, stats) end end end |
#start_scheduler ⇒ Object
36 37 38 |
# File 'lib/enginevib/main.rb', line 36 def start_scheduler @scheduler.start end |