Class: SigmaKoki
- Inherits:
-
Object
- Object
- SigmaKoki
- Defined in:
- lib/rs232-sigmakoki.rb
Instance Attribute Summary collapse
-
#comm ⇒ Object
readonly
Returns the value of attribute comm.
Instance Method Summary collapse
-
#amove(*step_args) ⇒ Object
main command to rotate the plates (non-blocking) step1 and step2 are the final angular position (absolute move).
-
#amove!(*step_args) ⇒ Object
main command to rotate the plates (blocking) step1 and step2 are the final angular position (absolute move).
-
#busy? ⇒ Boolean
checks if the device is currently bury rotating.
-
#home! ⇒ Object
pulls back the rotating plates to mechanical origin (blocking).
-
#initialize(address, params = {}) ⇒ SigmaKoki
constructor
A new instance of SigmaKoki.
-
#jog(*args) ⇒ Object
initiates a continuous and slow rotation.
-
#move(step1, step2 = 0) ⇒ Object
main command to rotate the plates (non-blocking) step1 and step2 are the number of angle units to move (relative move).
-
#move!(step1, step2 = 0) ⇒ Object
main command to rotate the plates (blocking) step1 and step2 are the number of angle units to move (relative move).
-
#position ⇒ Object
gets current position of plates (length 2 array).
-
#position_of(chan) ⇒ Object
gets current position of plate 1 or 2.
-
#ready? ⇒ Boolean
checks if the device is idle.
-
#wait ⇒ Object
blocking wait until the device is free to execute command again.
Constructor Details
#initialize(address, params = {}) ⇒ SigmaKoki
Returns a new instance of SigmaKoki.
90 91 92 |
# File 'lib/rs232-sigmakoki.rb', line 90 def initialize address, params = {} @comm = RS232.new address, params end |
Instance Attribute Details
#comm ⇒ Object (readonly)
Returns the value of attribute comm.
94 95 96 |
# File 'lib/rs232-sigmakoki.rb', line 94 def comm @comm end |
Instance Method Details
#amove(*step_args) ⇒ Object
main command to rotate the plates (non-blocking) step1 and step2 are the final angular position (absolute move)
60 61 62 63 64 65 |
# File 'lib/rs232-sigmakoki.rb', line 60 def amove *step_args move *self.position.map { |x| y = step_args.shift (y.is_a? Fixnum) ? y-x : 0 } end |
#amove!(*step_args) ⇒ Object
main command to rotate the plates (blocking) step1 and step2 are the final angular position (absolute move)
69 70 71 72 |
# File 'lib/rs232-sigmakoki.rb', line 69 def amove! *step_args amove *step_args wait end |
#busy? ⇒ Boolean
checks if the device is currently bury rotating
26 27 28 |
# File 'lib/rs232-sigmakoki.rb', line 26 def busy? 'B' == self.busy[0] #gsub(' ','').split(',')[-1] end |
#home! ⇒ Object
pulls back the rotating plates to mechanical origin (blocking)
75 76 77 78 |
# File 'lib/rs232-sigmakoki.rb', line 75 def home! home wait end |
#jog(*args) ⇒ Object
initiates a continuous and slow rotation
36 37 38 39 |
# File 'lib/rs232-sigmakoki.rb', line 36 def jog *args @comm.write "J:W%s%s" % args[0..1] go end |
#move(step1, step2 = 0) ⇒ Object
main command to rotate the plates (non-blocking) step1 and step2 are the number of angle units to move (relative move)
43 44 45 46 47 48 49 |
# File 'lib/rs232-sigmakoki.rb', line 43 def move step1, step2 = 0 step1 = 0 if step1.nil? s1, s2 = step1 > 0 ? "+" : "-", step2 > 0 ? "+" : "-" command = "M:W%sP%i%sP%i" % [s1,step1.abs,s2,step2.abs] @comm.write command go end |
#move!(step1, step2 = 0) ⇒ Object
main command to rotate the plates (blocking) step1 and step2 are the number of angle units to move (relative move)
53 54 55 56 |
# File 'lib/rs232-sigmakoki.rb', line 53 def move! step1, step2 = 0 move step1, step2 wait end |
#position ⇒ Object
gets current position of plates (length 2 array)
81 82 83 |
# File 'lib/rs232-sigmakoki.rb', line 81 def position self.status.gsub(' ','').split(',').map{|x| x.to_i}[0..1] end |
#position_of(chan) ⇒ Object
gets current position of plate 1 or 2
86 87 88 |
# File 'lib/rs232-sigmakoki.rb', line 86 def position_of chan self.status.gsub(' ','').split(',')[chan-1].to_i end |
#ready? ⇒ Boolean
checks if the device is idle
21 22 23 |
# File 'lib/rs232-sigmakoki.rb', line 21 def ready? 'R' == self.busy[0] #gsub(' ','').split(',')[-1] end |
#wait ⇒ Object
blocking wait until the device is free to execute command again
31 32 33 |
# File 'lib/rs232-sigmakoki.rb', line 31 def wait sleep 0.2 while busy? end |