Class: RapiroWrapper::Commander

Inherits:
Object
  • Object
show all
Defined in:
lib/rapiro_wrapper/commander.rb

Overview

Commander class for RAPIRO

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device = '/dev/ttyAMA0') ⇒ Commander

Returns a new instance of Commander.



6
7
8
# File 'lib/rapiro_wrapper/commander.rb', line 6

def initialize(device = '/dev/ttyAMA0')
  @serial = SerialPort.new(device, 57_600)
end

Class Method Details

.dryrun(commands, duration = 10) ⇒ Object



20
21
22
# File 'lib/rapiro_wrapper/commander.rb', line 20

def self.dryrun(commands, duration = 10)
  RapiroWrapper::Command.new(commands).to_sequence(duration)
end

Instance Method Details

#execute!(commands, duration = 10) ⇒ Object



10
11
12
13
14
# File 'lib/rapiro_wrapper/commander.rb', line 10

def execute!(commands, duration = 10)
  write(sequences(commands, duration))
rescue
  write('#M0')
end

#sequences(commands, duration = 10) ⇒ Object



16
17
18
# File 'lib/rapiro_wrapper/commander.rb', line 16

def sequences(commands, duration = 10)
  RapiroWrapper::Command.new(commands).to_sequence(duration)
end

#write(sequences) ⇒ Object



24
25
26
# File 'lib/rapiro_wrapper/commander.rb', line 24

def write(sequences)
  @serial.write(sequences)
end