/
tel_status.py
116 lines (93 loc) · 3.07 KB
/
tel_status.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
#import controller
import antenna_nanten_controller
import antenna_enc
import dome
#import dome_pos
import time
from datetime import datetime as dt
dtime = dt.now()
if dtime.month < 10:
month = '0' + str(dtime.month)
else:
month = str(dtime.month)
if dtime.day < 10:
day = '0' + str(dtime.day)
else:
day = str(dtime.day)
file = str(dtime.year) + month + day + '.txt'
f = open(file,"a")
tel = antenna_nanten_controller.antenna_monitor_client('172.20.0.11',8004)
enc = antenna_enc.enc_monitor_client('172.20.0.11',8002)
dome = dome.dome_monitor_client('172.20.0.11',8008)
#dome_pos = dome_pos.dome_pos_monitor_client('172.20.0.11',8006)
#for get status
import controller
ctrl = controller.controller()
del ctrl
while(1):
telstatus = tel.read_error()
telstatus2 = tel.read_status()
encstatus = enc.read_azel()
domestatus = dome.read_status()
domeposstatus = dome.read_domepos()
tv = time.time()
mjd = tv/24./3600. + 40587.0 # 40587.0 = MJD0
ntime = dt.now()
secofday = ntime.hour*60*60 + ntime.minute*60 + ntime.second + ntime.microsecond*0.000001
lst_g = 0.67239+1.00273781*(mjd-40000.0)
l_plb = -67.7222222222/360.0
lst_plb = lst_g + l_plb
lst_plb_i = int(lst_plb)
lst_plb -= lst_plb_i
lst_plb = 24.0*lst_plb
lst_hh = int(lst_plb)
lst_plb = 60.0*(lst_plb - lst_hh)
lst_mm = int(lst_plb)
lst_plb = 60.0*(lst_plb -lst_mm)
lst_ss = int(lst_plb)
lst_hh = "{0:02d}".format(lst_hh)
lst_mm = "{0:02d}".format(lst_mm)
lst_ss = "{0:02d}".format(lst_ss)
# limit check
if telstatus[4] == 0:
print 'soft limit cw\n'
if telstatus[5] == 0:
print 'soft limit ccw\n'
if telstatus[6] == 0:
print 'soft limit up\n'
if telstatus[7] == 0:
print 'soft limit down\n'
if telstatus[8] == 0:
print '1st limit cw\n'
if telstatus[9] == 0:
print '1st limit ccw\n'
if telstatus[10] == 0:
print '1st limit up\n'
if telstatus[11] == 0:
print '1st limit down\n'
if telstatus[12] == 0:
print '2nd limit cw\n'
if telstatus[13] == 0:
print '2nd limit ccw\n'
if telstatus[14] == 0:
print '2nd limit up\n'
if telstatus[15] == 0:
print '2nd limit down\n'
if telstatus[18] == 1:
print 'deviation error az\n'
if telstatus[19] == 1:
print 'deviation error el\n'
if telstatus[20] == 1:
print 'controller error az\n'
if telstatus[21] == 1:
print 'controller error el\n'
#if telstatus[22] == 1:
#print 'servo pack error az\n'
#if telstatus[23] == 1:
#print 'servo pack error el\n'
if telstatus[24] == 0:
print 'emergency switch\n'
log = "telescope: %s %s %s %s %s %5.0f %6.1f %s:%s:%s %5.2f %5.2f dome: door %s membrane: %s %s %5.2f" %(telstatus[0], telstatus[1], telstatus[2], telstatus[3], telstatus2, mjd, secofday, lst_hh, lst_mm, lst_ss, encstatus[0]/3600., encstatus[1]/3600., domestatus[1][1], domestatus[2][1], domestatus[3], domeposstatus/3600.,)
f.write(log + "\n")
print log
time.sleep(1.)