-
Notifications
You must be signed in to change notification settings - Fork 2
/
MountSrv.py
executable file
·158 lines (122 loc) · 3.97 KB
/
MountSrv.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env python
import sys, traceback, Ice, os
Ice.loadSlice("HinOTORI.ice")
import HinOTORI
import config
class MountServer(Ice.Application):
def run(self,args):
self.shutdownOnInterrupt() # make sure clean up
adapter = self.communicator().createObjectAdapterWithEndpoints(
os.path.basename(__file__), "default -h %s -p %d"
% ( \
config.nodesetting["mount"]['ip'], \
config.nodesetting["mount"]['port'] \
))
if config.mount["mounttype"] == "KanataAzEl":
mount = KanataMount()
elif config.mount["mounttype"] == "HinOTORI":
mount = HinOTORIMount()
else:
mount = Mount()
adapter.add(mount, self.communicator().stringToIdentity("Mount"))
adapter.activate()
self.communicator().waitForShutdown()
return 0
class Mount(HinOTORI.Mount):
def __init__(self):
HinOTORI.Mount.__init__(self)
def GetRa(self,current=None):
return 0.
def GetDec(self,current=None):
return 0.
def GetAz(self,current=None):
return 0.
def GetEl(self,current=None):
return 0.
def SetRa(self,radeg,current=None):
pass
def SetDec(self,decdeg,current=None):
pass
def Goto(self,current=None):
pass
class HinOTORIMount(HinOTORI.Mount):
def __init__(self):
import mount
focusmodel=mount.FocusModel(0.,0.,0.,0.,0.,mount.FocusModel.TWO_LINES)
#### THE BELOW DEFINITION NO LONGER AVAILABLE BECAUSE IT IS FOR PREVIOUS MODEL ####
weatherstatus="./log/log.$date.txt" # need to define before passing below methods
weatherstatusfile= "./weather.out"
telstatus="./log/telescope_$date.status"
rainstatusfile="./rain.out"
status= mount.TelescopeStatus(telstatus,rainstatusfile)
weather=mount.WeatherStatus(weatherstatus, weatherstatusfile )
####
self.mount=mount.Telescope(config.mount["ip"],config.mount["port"],config.mount["t_point.txt"],status,weather,focusmodel,mount.Telescope.AUTO)
self.ra = self.GetRa()
self.dec= self.GetDec()
HinOTORI.Mount.__init__(self)
def GetRa(self,current=None):
return self.mount.getRA()
def GetCmdRa( self, current=None ):
return self.ra
def GetCmdDec( self, current=None ):
return self.dec
def GetDec(self,current=None):
return self.mount.getDec()
def GetAz(self,current=None):
return self.mount.getAz()
def GetEl(self,current=None):
return self.mount.getElv()
def SetRa(self,radeg,current=None):
self.radeg=radeg
def SetDec(self,decdeg,current=None):
self.decdeg=decdeg
def Goto(self,current=None):
self.mount.slew(self.radeg,self.decdeg)
return 0
def Move(self,da,dd,current=None):
# in arcsec
return self.mount.move(da,dd)
class KanataMount(HinOTORI.Mount):
def __init__(self):
HinOTORI.Mount.__init__(self)
os.system("/home/utsumi/src/kanata/a.out &")
def _getstatus(self):
import re
p=re.compile("TelPos_current")
s=re.compile("[\s]+")
fh=open(config.mount['status'])
pos=filter(lambda x: p.match(x) is not None, fh.readlines())
print s.split(pos[0][16:-1])
d1,ra,d2,dec,epoch=s.split(pos[0][16:-1])
self.ra=ra
self.dec=dec
d1,az,d2,el=s.split(pos[1][16:-1])
print az, el
self.az=az
self.el=el
fh.close()
def GetRa(self,current=None):
import ephem
self._getstatus()
return ephem.hours(self.ra)
def GetDec(self,current=None):
import ephem
self._getstatus()
return ephem.degrees(self.dec)
def GetAz(self,current=None):
self._getstatus()
return float(self.az)
def GetEl(self,current=None):
self._getstatus()
return float(self.el)
def SetRa(self,radeg,current=None):
pass
def SetDec(self,decdeg,current=None):
pass
def Goto(self,current=None):
pass
if __name__ == "__main__":
app = MountServer()
status = app.main(sys.argv)
sys.exit(status)