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
- #amove!(*step_args) ⇒ Object
- #busy? ⇒ Boolean
-
#initialize(address, params = {}) ⇒ SigmaKoki
constructor
A new instance of SigmaKoki.
- #jog(*args) ⇒ Object
-
#move(step1, step2 = 0) ⇒ Object
main command to rotate the plates.
- #move!(step1, step2 = 0) ⇒ Object
- #position ⇒ Object
- #position_of(chan) ⇒ Object
- #ready? ⇒ Boolean
- #wait ⇒ Object
Constructor Details
#initialize(address, params = {}) ⇒ SigmaKoki
Returns a new instance of SigmaKoki.
70 71 72 |
# File 'lib/rs232-sigmakoki.rb', line 70 def initialize address, params = {} @comm = RS232.new address, params end |
Instance Attribute Details
#comm ⇒ Object (readonly)
Returns the value of attribute comm.
74 75 76 |
# File 'lib/rs232-sigmakoki.rb', line 74 def comm @comm end |
Instance Method Details
#amove(*step_args) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/rs232-sigmakoki.rb', line 50 def amove *step_args move *self.position.map { |x| y = step_args.shif (y.is_a? Fixnum) ? y-x : 0 } end |
#amove!(*step_args) ⇒ Object
57 58 59 60 |
# File 'lib/rs232-sigmakoki.rb', line 57 def amove! *step_args amove *step_args wait end |
#busy? ⇒ Boolean
23 24 25 |
# File 'lib/rs232-sigmakoki.rb', line 23 def busy? 'B' == self.busy[0] #gsub(' ','').split(',')[-1] end |
#jog(*args) ⇒ Object
31 32 33 34 |
# File 'lib/rs232-sigmakoki.rb', line 31 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
37 38 39 40 41 42 43 |
# File 'lib/rs232-sigmakoki.rb', line 37 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
45 46 47 48 |
# File 'lib/rs232-sigmakoki.rb', line 45 def move! step1, step2 = 0 move step1, step2 wait end |
#position ⇒ Object
62 63 64 |
# File 'lib/rs232-sigmakoki.rb', line 62 def position self.status.gsub(' ','').split(',').map{|x| x.to_i}[0..1] end |
#position_of(chan) ⇒ Object
66 67 68 |
# File 'lib/rs232-sigmakoki.rb', line 66 def position_of chan self.status.gsub(' ','').split(',')[chan-1].to_i end |
#ready? ⇒ Boolean
19 20 21 |
# File 'lib/rs232-sigmakoki.rb', line 19 def ready? 'R' == self.busy[0] #gsub(' ','').split(',')[-1] end |
#wait ⇒ Object
27 28 29 |
# File 'lib/rs232-sigmakoki.rb', line 27 def wait sleep 0.2 while busy? end |