Class: Alien::AlienReader

Inherits:
AlienConnection show all
Defined in:
lib/alien/alienreader.rb

Constant Summary collapse

@@methods_needed =
true

Instance Attribute Summary

Attributes inherited from AlienConnection

#raise_errors

Instance Method Summary collapse

Methods inherited from AlienConnection

#close, #connect, #connected, #open, #receive, #send, #sendreceive

Constructor Details

#initialize(methodsfile = File.join(File.dirname(__FILE__) , "readermethods.dat")) ⇒ AlienReader

call the AlienConnection initializer and build lots of the Getters/Setters from a reader methods file. Default value for the methods file will be the file, readermethods.txt found in the same directory as this file, alienreader.rb.



21
22
23
24
25
26
# File 'lib/alien/alienreader.rb', line 21

def initialize(methodsfile=File.join(File.dirname(__FILE__) , "readermethods.dat"))
  super()
  if @@methods_needed
    build_methods(methodsfile)
  end
end

Instance Method Details

#alien_tag_listObject



164
165
166
167
# File 'lib/alien/alienreader.rb', line 164

def alien_tag_list
  tl = AlienTagList.new(self.taglist)
  return tl
end

#blinkled(state1, state2, duration, count) ⇒ Object

Makes the reader blink its LEDs.

blinkled is a more complicated function call than an attribute. We just put the method in here rather than try to generate it dynamically.



138
139
140
# File 'lib/alien/alienreader.rb', line 138

def blinkled (state1, state2, duration, count)
  execute('blinkled=' + state1.to_s  + ' ' +  state2.to_s + ' ' + duration.to_s + ' ' +count.to_s)
end

#gpioObject

Returns the state of the reader’s external inputs



143
144
145
# File 'lib/alien/alienreader.rb', line 143

def gpio
  execute('externalinput?')
end

#gpio=(newvalue) ⇒ Object

Sets reader’s external outputs



148
149
150
# File 'lib/alien/alienreader.rb', line 148

def gpio=(newvalue)
  execute('externaloutput='+newvalue)
end

#service(service_name = "all", command = "status") ⇒ Object

Implements the Alien service command



160
161
162
# File 'lib/alien/alienreader.rb', line 160

def service(service_name ="all", command="status")
  sendreceive("service #{service_name} #{command}")
end

#upgradenow(opts = "") ⇒ Object

Executes the Alien UpgradeNow command. The opts parameter correspondst to the standard values passed to the UpgradeNow command. For example

rdr.upgradenow("force http://server.ip/firmware")


155
156
157
# File 'lib/alien/alienreader.rb', line 155

def upgradenow(opts="")
  sendreceive("upgradenow #{opts}", :timeout=>120)
end