forked from saltastro/timDIMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gto900_guide.rb
executable file
·72 lines (60 loc) · 919 Bytes
/
gto900_guide.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env ruby
require 'GTO900'
require 'ast_utils'
scope = GTO900.new()
lines = IO.readlines("init_cen_all")
tol = 100.0
scope.set_center_rate(2)
side = scope.pier?
puts "Scope is #{side} of the pier.\n"
minx = 1000.0
maxx = 0.0
miny = 1000.0
maxy = 0.0
lines.each { |line|
x, y = line.split(' ')
x = x.to_f
y = y.to_f
if x > maxx
maxx = x
end
if x < minx
minx = x
end
if y > maxy
maxy = y
end
if y < miny
miny = y
end
}
if maxx > 320-tol
print "Move South."
scope.move('s')
end
if minx < tol
print "Move North."
scope.move('n')
end
if miny < tol
if side == 'West'
print "Move West."
scope.move('w')
else
print "Move East."
scope.move('e')
end
end
if maxy > 240-tol
if side == 'West'
print "Move East."
scope.move('e')
else
print "Move West."
scope.move('w')
end
end
sleep(1)
scope.haltall
sleep(1)
scope.close