Class: NXT::Command::Output::Program

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/nxt/commands/program.rb

Constant Summary collapse

START_PROGRAM =
0x00
STOP_PROGRAM =
0x01
GET_CURRENT_PROGRAM_NAME =
0x11
@@command_type =
COMMAND_TYPES[:direct]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interface, name = nil) ⇒ Program

Returns a new instance of Program.



12
13
14
15
# File 'lib/nxt/commands/program.rb', line 12

def initialize(interface, name=nil)
  @interface = interface
  @name = name
end

Class Method Details

.get_running_name(interface) ⇒ Object



43
44
45
46
47
# File 'lib/nxt/commands/program.rb', line 43

def get_running_name(interface)
  response = send_command(interface, GET_CURRENT_PROGRAM_NAME)
  raise NXT::Exceptions::CommandError.new(response[:message]) if response[:status] != NXT::Errors::SUCCESS
  convert_data_to_string(response[:data])
end

.start(interface, name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/nxt/commands/program.rb', line 28

def start(interface, name)
  response = send_command(interface, START_PROGRAM, name)

  unless response[:status] == NXT::Errors::SUCCESS
    message = "#{response[:message]}; Try using '.rxe' as the filename extension"
    raise NXT::Exceptions::CommandError.new message
  end

  response
end

.stop(interface) ⇒ Object



39
40
41
# File 'lib/nxt/commands/program.rb', line 39

def stop(interface)
  send_command(interface, STOP_PROGRAM)
end

Instance Method Details

#startObject



17
18
19
# File 'lib/nxt/commands/program.rb', line 17

def start
  self.class.start(@interface, @name)
end

#stopObject



21
22
23
# File 'lib/nxt/commands/program.rb', line 21

def stop
  self.class.stop(@interface)
end