-
Notifications
You must be signed in to change notification settings - Fork 2
/
MountClient.py
executable file
·69 lines (59 loc) · 1.84 KB
/
MountClient.py
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
#!/usr/bin/env python
import sys, traceback, Ice, os
Ice.loadSlice("/home/utsumi/bin/HinOTORI.ice")
import HinOTORI
import argparse
sys.path.append("/home/utsumi/bin")
import config
import astropy.units as u
from astropy.coordinates import SkyCoord
status = 0
class MountClient(Ice.Application):
def run(self,args):
self.args=args
self.shutdownOnInterrupt()
self.parseoptions(args)
self.MountProcessor()
def MountProcessor(self):
"""
A class method to communicate with the telescope.
"""
obj = self.communicator().stringToProxy("Mount:default -h %s -p %d"
% ( \
config.nodesetting["mount"]['ip'], \
config.nodesetting["mount"]['port'] \
))
mount=HinOTORI.MountPrx.checkedCast(obj)
try:
ra=self.options.ra[0]
dec=self.options.dec[0]
print "Telescope will be moved to %lf %lf" % ( ra, dec )
mount.SetRa(ra)
mount.SetDec(dec)
mount.Goto()
except:
coord=SkyCoord(mount.GetRa(), mount.GetDec(),unit=u.degree)
print "Current telescope position in instrument coordinate"
print coord.ra.degree, coord.dec.degree
print coord.to_string("hmsdms")
return
def parseoptions(self,args):
"""
A class method to parse the argument
"""
parser = argparse.ArgumentParser(description='HinOTORI mount controller')
parser.add_argument('ra', metavar='ra', type=float, nargs=1,
help='specify a coordinate to be visited')
parser.add_argument('dec', metavar='dec', type=float, nargs=1,
help='specify a coordinate to be visited')
try:
options = parser.parse_args(args[1:])
self.options = options
except:
options = None
self.options = options
if __name__ == "__main__":
app = MountClient()
status = app.main(sys.argv)
#os.system("IsTelReady.py")
sys.exit(status)