@@ -1,99 +1,99 | |||
|
1 | 1 | import library3 No newline at end of file |
|
2 | 2 | import os.path No newline at end of file |
|
3 | 3 | No newline at end of file |
|
4 | 4 | class ABSClient(object): No newline at end of file |
|
5 | 5 | No newline at end of file |
|
6 | 6 | def __init__(self,ipSource="192.168.1.117", iDSource="Clnt_01", ipDestino="192.168.1.117", iDDestino = "CeCnMod", portDestino=7000): No newline at end of file |
|
7 | 7 | No newline at end of file |
|
8 | 8 | self.ipSource = ipSource No newline at end of file |
|
9 | 9 | self.iDSource = iDSource No newline at end of file |
|
10 | 10 | self.ipDestino = ipDestino No newline at end of file |
|
11 | 11 | self.iDDestino = iDDestino No newline at end of file |
|
12 | 12 | self.portDestino = portDestino No newline at end of file |
|
13 | 13 | No newline at end of file |
|
14 | 14 | self.createObjects() No newline at end of file |
|
15 | 15 | No newline at end of file |
|
16 | 16 | def createObjects(self): No newline at end of file |
|
17 | 17 | No newline at end of file |
|
18 | 18 | self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino) No newline at end of file |
|
19 | 19 | #self.wFiles = library3.FilesStuff() No newline at end of file |
|
20 | 20 | No newline at end of file |
|
21 | 21 | def __ConnectionWithCentralControl(self, cmd, data): No newline at end of file |
|
22 | 22 | No newline at end of file |
|
23 | 23 | self.commObj.open_socket() No newline at end of file |
|
24 | 24 | self.commObj.sendData(cmd = cmd, data = data, ipDestino = self.ipDestino) No newline at end of file |
|
25 | 25 | ipSource, ipDestino, cmd, output = self.commObj.waitData() No newline at end of file |
|
26 | 26 | self.commObj.close_socket() No newline at end of file |
|
27 | 27 | No newline at end of file |
|
28 | 28 | return output No newline at end of file |
|
29 | 29 | No newline at end of file |
|
30 | 30 | # def abs2ControlModuleFormatFile(self, filename): No newline at end of file |
|
31 | 31 | # No newline at end of file |
|
32 | 32 | # #From matriz to control module format No newline at end of file |
|
33 | 33 | # self.wFiles.toCentralControlFormat(filename) No newline at end of file |
|
34 | 34 | # FileName = "CentralControlFormat.txt" No newline at end of file |
|
35 | 35 | # F_Obj = open(FileName,"r") No newline at end of file |
|
36 | 36 | # FileList = F_Obj.readlines() No newline at end of file |
|
37 | 37 | # F_Obj.close() No newline at end of file |
|
38 | 38 | # FileStr = "".join(FileList) No newline at end of file |
|
39 | 39 | # No newline at end of file |
|
40 | 40 | # return FileStr No newline at end of file |
|
41 | 41 | No newline at end of file |
|
42 | 42 | def sendFile(self, filename): No newline at end of file |
|
43 | 43 | No newline at end of file |
|
44 | 44 | data = self.__readFile(filename) No newline at end of file |
|
45 | 45 | answer = self.__ConnectionWithCentralControl(cmd = "SNDF", data = data) No newline at end of file |
|
46 | 46 | return answer No newline at end of file |
|
47 | 47 | No newline at end of file |
|
48 | 48 | def changeBeam(self, newBeam): No newline at end of file |
|
49 | 49 | No newline at end of file |
|
50 | 50 | answer = self.__ConnectionWithCentralControl(cmd = "CHGB", data = newBeam) No newline at end of file |
|
51 | 51 | return answer No newline at end of file |
|
52 | 52 | No newline at end of file |
|
53 | 53 | def __writeFile(self, filename, data): No newline at end of file |
|
54 | 54 | No newline at end of file |
|
55 | 55 | fobj = open(filename,"w") No newline at end of file |
|
56 | 56 | fobj.writelines(data) No newline at end of file |
|
57 | 57 | fobj.close() No newline at end of file |
|
58 | 58 | No newline at end of file |
|
59 | 59 | def __readFile(self, filename): No newline at end of file |
|
60 | 60 | No newline at end of file |
|
61 | 61 | fobj = open(filename,"r") No newline at end of file |
|
62 | 62 | listData = fobj.readlines() No newline at end of file |
|
63 | 63 | fobj.close() No newline at end of file |
|
64 | 64 | tmp = "".join(listData) No newline at end of file |
|
65 | 65 | #Adding filename to the begining of the data No newline at end of file |
|
66 | 66 | newfilename = os.path.split(filename)[1] No newline at end of file |
|
67 | 67 | #data = filename + '\n' + tmp No newline at end of file |
|
68 | 68 | data = newfilename + '\n' + tmp No newline at end of file |
|
69 | 69 | return data No newline at end of file |
|
70 | 70 | No newline at end of file |
|
71 | 71 | No newline at end of file |
|
72 | 72 | def getControlModuleStatus(self, data): No newline at end of file |
|
73 | 73 | No newline at end of file |
|
74 | 74 | data = self.__ConnectionWithCentralControl(cmd = "ANST", data = data) No newline at end of file |
|
75 | 75 | self.__writeFile("report.txt", data) No newline at end of file |
|
76 | 76 | No newline at end of file |
|
77 | 77 | def getControlModulePhase(self, opt, u = "50", pw = "10"): No newline at end of file |
|
78 | 78 | No newline at end of file |
|
79 | 79 | if opt == '0': No newline at end of file |
|
80 | 80 | data = self.__ConnectionWithCentralControl(cmd = "LWPH", data = u + '/' + pw + '/') No newline at end of file |
|
81 | 81 | elif opt == '1': No newline at end of file |
|
82 | 82 | data = self.__ConnectionWithCentralControl(cmd = "BGPH", data = u + '/' + pw + '/') No newline at end of file |
|
83 | 83 | elif opt == '2': No newline at end of file |
|
84 | 84 | data = self.__ConnectionWithCentralControl(cmd = "cBPH", data = u + '/' + pw + '/') No newline at end of file |
|
85 | 85 | else: No newline at end of file |
|
86 | 86 | data = self.__ConnectionWithCentralControl(cmd = "cLPH", data = u + '/' + pw + '/') No newline at end of file |
|
87 | 87 | # self.__writeFile("report.txt", data) No newline at end of file |
|
88 | 88 | No newline at end of file |
|
89 | 89 | def getConnectionStatus(self): No newline at end of file |
|
90 | 90 | No newline at end of file |
|
91 | 91 | data = self.__ConnectionWithCentralControl(cmd = "NTST", data = "none") No newline at end of file |
|
92 | 92 | self.__writeFile("connection_status.txt", data) No newline at end of file |
|
93 | 93 | No newline at end of file |
|
94 | 94 | if __name__ == '__main__': No newline at end of file |
|
95 | 95 | No newline at end of file |
|
96 | 96 | filename = "experimento1.abs" No newline at end of file |
|
97 | 97 | No newline at end of file |
|
98 | 98 | absObj = ABSClient() |
|
99 | No newline at end of file | |
|
99 | absObj.sendFile(filename) No newline at end of file |
@@ -1,399 +1,400 | |||
|
1 | 1 | import os No newline at end of file |
|
2 | 2 | import library3 No newline at end of file |
|
3 | 3 | import time No newline at end of file |
|
4 | 4 | import threading No newline at end of file |
|
5 | 5 | No newline at end of file |
|
6 | 6 | class ABSServer: No newline at end of file |
|
7 | 7 | No newline at end of file |
|
8 | 8 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500, rx_buffer = "default"): No newline at end of file |
|
9 | 9 | No newline at end of file |
|
10 | 10 | self.ipSource = ipSource No newline at end of file |
|
11 | 11 | self.ipDestino = ipDestino No newline at end of file |
|
12 | 12 | self.portDestino = portDestino No newline at end of file |
|
13 | 13 | No newline at end of file |
|
14 | 14 | self.ipDestino2 = ipDestino2 No newline at end of file |
|
15 | 15 | self.portDestino2 = portDestino2 No newline at end of file |
|
16 | 16 | No newline at end of file |
|
17 | 17 | self.tx_buffer = "default" No newline at end of file |
|
18 | 18 | # self.rx_buffer = "default" No newline at end of file |
|
19 | 19 | self.rx_buffer = rx_buffer No newline at end of file |
|
20 | 20 | self.enaModules = [] No newline at end of file |
|
21 | 21 | self.bits = [] No newline at end of file |
|
22 | 22 | self.phase = [] No newline at end of file |
|
23 | 23 | self.txFile = [] No newline at end of file |
|
24 | 24 | self.rxFile = [] No newline at end of file |
|
25 | 25 | No newline at end of file |
|
26 | 26 | self.createObjects() No newline at end of file |
|
27 | 27 | No newline at end of file |
|
28 | 28 | print "Checking control modules, please wait ..." |
|
29 | No newline at end of file | |
|
29 | self.enaModules = self.checkAntenna() No newline at end of file | |
|
No newline at end of file | ||
|
30 | self.enaModules = [1,12] No newline at end of file | |
|
30 | 31 | print "Starting automatic control module status." No newline at end of file |
|
31 | 32 | self.__StartingAutomaticControlModules() No newline at end of file |
|
32 | 33 | self.__AutomaticControlModules() No newline at end of file |
|
33 | 34 | No newline at end of file |
|
34 | 35 | def createObjects(self): No newline at end of file |
|
35 | 36 | No newline at end of file |
|
36 | 37 | asServer = True No newline at end of file |
|
37 | 38 | self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer) No newline at end of file |
|
38 | 39 | self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2) No newline at end of file |
|
39 | 40 | self.wFiles = library3.FilesStuff() No newline at end of file |
|
40 | 41 | No newline at end of file |
|
41 | 42 | def waitRequest(self): No newline at end of file |
|
42 | 43 | No newline at end of file |
|
43 | 44 | #Using rx buffer No newline at end of file |
|
44 | 45 | # ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() No newline at end of file |
|
45 | 46 | ipSource, ipDestino, cmd, rx_buffer = self.commServerObj.waitData() No newline at end of file |
|
46 | 47 | No newline at end of file |
|
47 | 48 | if cmd == "SNDF": No newline at end of file |
|
48 | 49 | datarpta = self.__sendFile2Modules(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
49 | 50 | No newline at end of file |
|
50 | 51 | if cmd == "GETF": No newline at end of file |
|
51 | 52 | datarpta = self.__getFileFromModules(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
52 | 53 | No newline at end of file |
|
53 | 54 | if cmd == "CHGB": No newline at end of file |
|
54 | 55 | datarpta = self.__changeBeam(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
55 | 56 | No newline at end of file |
|
56 | 57 | if cmd == "ANST": No newline at end of file |
|
57 | 58 | datarpta = self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
58 | 59 | No newline at end of file |
|
59 | 60 | if cmd == "BGPH": No newline at end of file |
|
60 | 61 | datarpta = self.__getControlModuleBigPhase(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
61 | 62 | No newline at end of file |
|
62 | 63 | if cmd == "LWPH": No newline at end of file |
|
63 | 64 | datarpta = self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
64 | 65 | No newline at end of file |
|
65 | 66 | if cmd == "NTST": No newline at end of file |
|
66 | 67 | datarpta = self.__getConnectionStatus(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
67 | 68 | No newline at end of file |
|
68 | 69 | self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) No newline at end of file |
|
69 | 70 | No newline at end of file |
|
70 | 71 | def checkModule(self, address): No newline at end of file |
|
71 | 72 | No newline at end of file |
|
72 | 73 | cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" No newline at end of file |
|
73 | 74 | status = os.system(cmd) No newline at end of file |
|
74 | 75 | No newline at end of file |
|
75 | 76 | if status == 256: No newline at end of file |
|
76 | 77 | return False No newline at end of file |
|
77 | 78 | No newline at end of file |
|
78 | 79 | return True No newline at end of file |
|
79 | 80 | No newline at end of file |
|
80 | 81 | def __writeReport(self, enaModules): No newline at end of file |
|
81 | 82 | No newline at end of file |
|
82 | 83 | status_array = ["Status of modules\n"] No newline at end of file |
|
83 | 84 | status_array.append("----------------\n") No newline at end of file |
|
84 | 85 | No newline at end of file |
|
85 | 86 | for address in range(1,65): No newline at end of file |
|
86 | 87 | if address in enaModules: No newline at end of file |
|
87 | 88 | status_array.append("192.168.1." + str(address) + " [1 1]\n") No newline at end of file |
|
88 | 89 | else: No newline at end of file |
|
89 | 90 | status_array.append("192.168.1." + str(address) + " [0 0]\n") No newline at end of file |
|
90 | 91 | No newline at end of file |
|
91 | 92 | filename = "module_status.txt" No newline at end of file |
|
92 | 93 | self.__writeFile(filename,status_array) No newline at end of file |
|
93 | 94 | # f = open("module_status.txt","w") No newline at end of file |
|
94 | 95 | # f.writelines(status_array) No newline at end of file |
|
95 | 96 | # f.close() No newline at end of file |
|
96 | 97 | No newline at end of file |
|
97 | 98 | No newline at end of file |
|
98 | 99 | def __CreateFile(self, filename): No newline at end of file |
|
99 | 100 | No newline at end of file |
|
100 | 101 | fobj = open(filename,"w") No newline at end of file |
|
101 | 102 | fobj.close() No newline at end of file |
|
102 | 103 | No newline at end of file |
|
103 | 104 | def __writeNewFile(self, filename, data): No newline at end of file |
|
104 | 105 | No newline at end of file |
|
105 | 106 | fobj = open(filename,"w") No newline at end of file |
|
106 | 107 | fobj.writelines(data) No newline at end of file |
|
107 | 108 | fobj.close() No newline at end of file |
|
108 | 109 | No newline at end of file |
|
109 | 110 | def __writeFile(self, filename, data): No newline at end of file |
|
110 | 111 | No newline at end of file |
|
111 | 112 | fobj = open(filename,"a") No newline at end of file |
|
112 | 113 | fobj.writelines(data) No newline at end of file |
|
113 | 114 | fobj.close() No newline at end of file |
|
114 | 115 | No newline at end of file |
|
115 | 116 | def checkAntenna(self): No newline at end of file |
|
116 | 117 | No newline at end of file |
|
117 | 118 | """ No newline at end of file |
|
118 | 119 | Direccion de los modulos de las antenas: No newline at end of file |
|
119 | 120 | No newline at end of file |
|
120 | 121 | Norte : 01-16 No newline at end of file |
|
121 | 122 | Este : 17-32 No newline at end of file |
|
122 | 123 | Oeste: : 33-48 No newline at end of file |
|
123 | 124 | Sur : 49-64 No newline at end of file |
|
124 | 125 | No newline at end of file |
|
125 | 126 | """ No newline at end of file |
|
126 | 127 | No newline at end of file |
|
127 | 128 | enaModules2 = [] No newline at end of file |
|
128 | 129 | No newline at end of file |
|
129 | 130 | for address in range(1,65): No newline at end of file |
|
130 | 131 | if self.checkModule(address): No newline at end of file |
|
131 | 132 | enaModules2.append(address) No newline at end of file |
|
132 | 133 | No newline at end of file |
|
133 | 134 | self.__writeReport(enaModules2) No newline at end of file |
|
134 | 135 | return enaModules2 No newline at end of file |
|
135 | 136 | No newline at end of file |
|
136 | 137 | def __ConnectionWithControlModules(self,data,cmd,id): No newline at end of file |
|
137 | 138 | No newline at end of file |
|
138 | 139 | self.commClientObj.open_socket() No newline at end of file |
|
139 | 140 | ip = "192.168.1." + str(id) No newline at end of file |
|
140 | 141 | self.commClientObj.sendData(cmd, data, ip) No newline at end of file |
|
141 | 142 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() No newline at end of file |
|
142 | 143 | self.commClientObj.close_socket() No newline at end of file |
|
143 | 144 | No newline at end of file |
|
144 | 145 | return tmp No newline at end of file |
|
145 | 146 | No newline at end of file |
|
146 | 147 | def abs2ControlModuleFormatFile(self, filename): No newline at end of file |
|
147 | 148 | No newline at end of file |
|
148 | 149 | #From matriz to control module format No newline at end of file |
|
149 | 150 | self.wFiles.toCentralControlFormat(filename) No newline at end of file |
|
150 | 151 | FileName = "CentralControlFormat.txt" No newline at end of file |
|
151 | 152 | F_Obj = open(FileName,"r") No newline at end of file |
|
152 | 153 | FileList = F_Obj.readlines() No newline at end of file |
|
153 | 154 | F_Obj.close() No newline at end of file |
|
154 | 155 | FileStr = "".join(FileList) No newline at end of file |
|
155 | 156 | No newline at end of file |
|
156 | 157 | return FileStr No newline at end of file |
|
157 | 158 | No newline at end of file |
|
158 | 159 | def __All2Blocks(self,input): No newline at end of file |
|
159 | 160 | No newline at end of file |
|
160 | 161 | rx_frame_lst = input.split('\n',2) No newline at end of file |
|
161 | 162 | No newline at end of file |
|
162 | 163 | header = rx_frame_lst[0] + "\n" No newline at end of file |
|
163 | 164 | control_modules_str = rx_frame_lst[2] No newline at end of file |
|
164 | 165 | control_modules_lst = control_modules_str.split("------\n") No newline at end of file |
|
165 | 166 | No newline at end of file |
|
166 | 167 | return header, control_modules_lst No newline at end of file |
|
167 | 168 | No newline at end of file |
|
168 | 169 | No newline at end of file |
|
169 | 170 | def __sendFile2Modules(self,cmd, rx_buffer): No newline at end of file |
|
170 | 171 | No newline at end of file |
|
171 | 172 | # rx_buffer_lst = self.rx_buffer.split('\n',1) No newline at end of file |
|
172 | 173 | rx_buffer_lst = rx_buffer.split('\n',1) No newline at end of file |
|
173 | 174 | #Getting the filename from the begining of data No newline at end of file |
|
174 | 175 | filename = rx_buffer_lst[0] No newline at end of file |
|
175 | 176 | tmp = rx_buffer_lst[1] No newline at end of file |
|
176 | 177 | self.__writeFile(filename,tmp) No newline at end of file |
|
177 | 178 | data = self.abs2ControlModuleFormatFile(filename) No newline at end of file |
|
178 | 179 | #Needed for the loop No newline at end of file |
|
179 | 180 | header, control_modules_lst = self.__All2Blocks(data) No newline at end of file |
|
180 | 181 | correct = 0 No newline at end of file |
|
181 | 182 | No newline at end of file |
|
182 | 183 | for id in range(1,65): No newline at end of file |
|
183 | 184 | No newline at end of file |
|
184 | 185 | if id not in self.enaModules: No newline at end of file |
|
185 | 186 | continue No newline at end of file |
|
186 | 187 | No newline at end of file |
|
187 | 188 | if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK": No newline at end of file |
|
188 | 189 | correct = correct + 1 No newline at end of file |
|
189 | 190 | No newline at end of file |
|
190 | 191 | if correct == len(self.enaModules): No newline at end of file |
|
191 | 192 | rpta = "OK" No newline at end of file |
|
192 | 193 | else: No newline at end of file |
|
193 | 194 | rpta = "Failure" No newline at end of file |
|
194 | 195 | No newline at end of file |
|
195 | 196 | return rpta No newline at end of file |
|
196 | 197 | No newline at end of file |
|
197 | 198 | def __getFileFromModules(self, cmd, rx_buffer): No newline at end of file |
|
198 | 199 | No newline at end of file |
|
199 | 200 | for id in range(1,65): No newline at end of file |
|
200 | 201 | if id not in self.enaModules: No newline at end of file |
|
201 | 202 | continue No newline at end of file |
|
202 | 203 | No newline at end of file |
|
203 | 204 | file = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
204 | 205 | del self.rxFile[id-1] No newline at end of file |
|
205 | 206 | self.rxFile.insert(id-1, file) No newline at end of file |
|
206 | 207 | No newline at end of file |
|
207 | 208 | def __changeBeam(self, cmd, rx_buffer): No newline at end of file |
|
208 | 209 | No newline at end of file |
|
209 | 210 | correct = 0 No newline at end of file |
|
210 | 211 | # enaModules = self.checkAntenna() No newline at end of file |
|
211 | 212 | # enaModules = [11,12,13,14] No newline at end of file |
|
212 | 213 | No newline at end of file |
|
213 | 214 | for id in range(1,65): No newline at end of file |
|
214 | 215 | if id not in self.enaModules: No newline at end of file |
|
215 | 216 | continue No newline at end of file |
|
216 | 217 | No newline at end of file |
|
217 | 218 | if self.__ConnectionWithControlModules(rx_buffer,cmd,id) == "OK": No newline at end of file |
|
218 | 219 | correct = correct + 1 No newline at end of file |
|
219 | 220 | No newline at end of file |
|
220 | 221 | if correct == len(self.enaModules): No newline at end of file |
|
221 | 222 | rpta = "OK" No newline at end of file |
|
222 | 223 | else: No newline at end of file |
|
223 | 224 | rpta = "Failure" No newline at end of file |
|
224 | 225 | No newline at end of file |
|
225 | 226 | return rpta No newline at end of file |
|
226 | 227 | No newline at end of file |
|
227 | 228 | def __getControlModuleStatus(self, cmd, rx_buffer): No newline at end of file |
|
228 | 229 | No newline at end of file |
|
229 | 230 | # all_blocks = "" No newline at end of file |
|
230 | 231 | # all_blocks = [] No newline at end of file |
|
231 | 232 | # enaModules = self.checkAntenna() No newline at end of file |
|
232 | 233 | # enaModules = [11,12,13,14] No newline at end of file |
|
233 | 234 | No newline at end of file |
|
234 | 235 | for id in range(1,65): No newline at end of file |
|
235 | 236 | if id not in self.enaModules: No newline at end of file |
|
236 | 237 | continue No newline at end of file |
|
237 | 238 | No newline at end of file |
|
238 | 239 | bits = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
239 | 240 | del self.bits[id-1] No newline at end of file |
|
240 | 241 | self.bits.insert(id-1, bits) No newline at end of file |
|
241 | 242 | No newline at end of file |
|
242 | 243 | # all_blocks.append(one_block) No newline at end of file |
|
243 | 244 | #Using tx buffer No newline at end of file |
|
244 | 245 | No newline at end of file |
|
245 | 246 | # return all_blocks No newline at end of file |
|
246 | 247 | No newline at end of file |
|
247 | 248 | def __getControlModuleBigPhase(self, cmd, rx_buffer): No newline at end of file |
|
248 | 249 | No newline at end of file |
|
249 | 250 | # all_blocks = "" No newline at end of file |
|
250 | 251 | all_blocks = [] No newline at end of file |
|
251 | 252 | # enaModules = self.checkAntenna() No newline at end of file |
|
252 | 253 | # enaModules = [11,12,13,14] No newline at end of file |
|
253 | 254 | No newline at end of file |
|
254 | 255 | for id in range(1,65): No newline at end of file |
|
255 | 256 | if id not in self.enaModules: No newline at end of file |
|
256 | 257 | continue No newline at end of file |
|
257 | 258 | No newline at end of file |
|
258 | 259 | one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
259 | 260 | No newline at end of file |
|
260 | 261 | # all_blocks = all_blocks + one_block No newline at end of file |
|
261 | 262 | all_blocks.append(one_block) No newline at end of file |
|
262 | 263 | #Using tx buffer No newline at end of file |
|
263 | 264 | return all_blocks No newline at end of file |
|
264 | 265 | No newline at end of file |
|
265 | 266 | def __getControlModuleLowPhase(self, cmd, rx_buffer): No newline at end of file |
|
266 | 267 | No newline at end of file |
|
267 | 268 | # all_blocks = "" No newline at end of file |
|
268 | 269 | # all_blocks = [] No newline at end of file |
|
269 | 270 | # enaModules = self.checkAntenna() No newline at end of file |
|
270 | 271 | # enaModules = [11,12,13,14] No newline at end of file |
|
271 | 272 | No newline at end of file |
|
272 | 273 | for id in range(1,65): No newline at end of file |
|
273 | 274 | if id not in self.enaModules: No newline at end of file |
|
274 | 275 | continue No newline at end of file |
|
275 | 276 | No newline at end of file |
|
276 | 277 | phase = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
277 | 278 | del self.phase[id-1] No newline at end of file |
|
278 | 279 | self.phase.insert(id-1, phase) No newline at end of file |
|
279 | 280 | # all_blocks = all_blocks + one_block No newline at end of file |
|
280 | 281 | # all_blocks.append(one_block) No newline at end of file |
|
281 | 282 | #Using tx buffer No newline at end of file |
|
282 | 283 | # return all_blocks No newline at end of file |
|
283 | 284 | No newline at end of file |
|
284 | 285 | def __getConnectionStatus(self, cmd, rx_buffer): No newline at end of file |
|
285 | 286 | No newline at end of file |
|
286 | 287 | ena = self.checkAntenna() No newline at end of file |
|
287 | 288 | print ena No newline at end of file |
|
288 | 289 | self.enaModules = ena No newline at end of file |
|
289 | 290 | No newline at end of file |
|
290 | 291 | blockLst = [] No newline at end of file |
|
291 | 292 | No newline at end of file |
|
292 | 293 | for id in range(1,65): No newline at end of file |
|
293 | 294 | if id not in self.enaModules: No newline at end of file |
|
294 | 295 | continue No newline at end of file |
|
295 | 296 | No newline at end of file |
|
296 | 297 | blockStr = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
297 | 298 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") No newline at end of file |
|
298 | 299 | #Using tx buffer No newline at end of file |
|
299 | 300 | all_blocks = "".join(blockLst) No newline at end of file |
|
300 | 301 | No newline at end of file |
|
301 | 302 | return all_blocks No newline at end of file |
|
302 | 303 | No newline at end of file |
|
303 | 304 | def getConnectionStatus(self, cmd): No newline at end of file |
|
304 | 305 | No newline at end of file |
|
305 | 306 | ena = self.checkAntenna() No newline at end of file |
|
306 | 307 | self.enaModules = ena No newline at end of file |
|
307 | 308 | No newline at end of file |
|
308 | 309 | blockLst = [] No newline at end of file |
|
309 | 310 | No newline at end of file |
|
310 | 311 | for id in range(1,65): No newline at end of file |
|
311 | 312 | if id not in self.enaModules: No newline at end of file |
|
312 | 313 | continue No newline at end of file |
|
313 | 314 | No newline at end of file |
|
314 | 315 | blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) No newline at end of file |
|
315 | 316 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") No newline at end of file |
|
316 | 317 | #Using tx buffer No newline at end of file |
|
317 | 318 | self.tx_buffer = "".join(blockLst) No newline at end of file |
|
318 | 319 | print self.tx_buffer No newline at end of file |
|
319 | 320 | No newline at end of file |
|
320 | 321 | return self.tx_buffer No newline at end of file |
|
321 | 322 | No newline at end of file |
|
322 | 323 | def getControlModuleStatus(self, cmd): No newline at end of file |
|
323 | 324 | No newline at end of file |
|
324 | 325 | all_blocks = "" No newline at end of file |
|
325 | 326 | # enaModules = self.checkAntenna() No newline at end of file |
|
326 | 327 | # enaModules = [11,12,13,14] No newline at end of file |
|
327 | 328 | No newline at end of file |
|
328 | 329 | for id in range(1,65): No newline at end of file |
|
329 | 330 | if id not in self.enaModules: No newline at end of file |
|
330 | 331 | continue No newline at end of file |
|
331 | 332 | No newline at end of file |
|
332 | 333 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) No newline at end of file |
|
333 | 334 | No newline at end of file |
|
334 | 335 | all_blocks = all_blocks + one_block No newline at end of file |
|
335 | 336 | #Using tx buffer No newline at end of file |
|
336 | 337 | print all_blocks No newline at end of file |
|
337 | 338 | self.tx_buffer = all_blocks No newline at end of file |
|
338 | 339 | No newline at end of file |
|
339 | 340 | return all_blocks No newline at end of file |
|
340 | 341 | No newline at end of file |
|
341 | 342 | def __StartingAutomaticControlModules(self): No newline at end of file |
|
342 | 343 | No newline at end of file |
|
343 | 344 | #Starting file No newline at end of file |
|
344 | 345 | self.__CreateFile("Monitoring.txt") No newline at end of file |
|
345 | 346 | # data = "MOD.\t BITS\t\t PHASE\n" No newline at end of file |
|
346 | 347 | # self.__writeFile("Monitoring.txt", data) No newline at end of file |
|
347 | 348 | #Starting lists No newline at end of file |
|
348 | 349 | self.txFile = list("------\n------\n------\n" for i in range(64)) No newline at end of file |
|
349 | 350 | self.rxFile = list("------\n------\n------\n" for i in range(64)) No newline at end of file |
|
350 | 351 | self.bits = list("------\n------\n------\n" for i in range(64)) No newline at end of file |
|
351 | 352 | self.phase = list("----- -----\n----- -----\n----- -----\n" for i in range(64)) No newline at end of file |
|
352 | 353 | No newline at end of file |
|
353 | 354 | def __AutomaticControlModules(self): No newline at end of file |
|
354 | 355 | No newline at end of file |
|
355 | 356 | cmd = "GETF" No newline at end of file |
|
356 | 357 | rx_buffer = "experimento1.ab1" + "\n" No newline at end of file |
|
357 | 358 | self.__getFileFromModules(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
358 | 359 | No newline at end of file |
|
359 | 360 | print self.rxFile No newline at end of file |
|
360 | 361 | No newline at end of file |
|
361 | 362 | cmd = "ANST" No newline at end of file |
|
362 | 363 | rx_buffer = "1" No newline at end of file |
|
363 | 364 | self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
364 | 365 | No newline at end of file |
|
365 | 366 | cmd = "LWPH" No newline at end of file |
|
366 | 367 | rx_buffer = "0" No newline at end of file |
|
367 | 368 | self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
368 | 369 | print "Saving file..." No newline at end of file |
|
369 | 370 | No newline at end of file |
|
370 | 371 | No newline at end of file |
|
371 | 372 | print self.bits No newline at end of file |
|
372 | 373 | print self.phase No newline at end of file |
|
373 | 374 | No newline at end of file |
|
374 | 375 | self.__WritingMonitoringFile() No newline at end of file |
|
375 | 376 | No newline at end of file |
|
376 | 377 | threading.Timer(60, self.__AutomaticControlModules).start() No newline at end of file |
|
377 | 378 | No newline at end of file |
|
378 | 379 | def __WritingMonitoringFile(self): No newline at end of file |
|
379 | 380 | filename = "Monitoring.txt" No newline at end of file |
|
380 | 381 | data = '===============================' + '\n' No newline at end of file |
|
381 | 382 | self.__writeFile(filename, data) No newline at end of file |
|
382 | 383 | data = time.strftime('\t' + "%d%b%Y %I:%M:%S %p" + '\n', time.localtime()) No newline at end of file |
|
383 | 384 | self.__writeFile(filename, data) No newline at end of file |
|
384 | 385 | data = "MOD.\t BITS\t\t PHASE\n" No newline at end of file |
|
385 | 386 | self.__writeFile(filename, data) No newline at end of file |
|
386 | 387 | data = '===============================' + '\n' No newline at end of file |
|
387 | 388 | self.__writeFile(filename, data) No newline at end of file |
|
388 | 389 | for i in range(64): No newline at end of file |
|
389 | 390 | tmp = self.bits[i].split('\n',3) No newline at end of file |
|
390 | 391 | self.__writeFile(filename, ' ' + str(i + 1) + '\t\t' + tmp[2]) No newline at end of file |
|
391 | 392 | tmp = self.phase[i].split('\n',3) No newline at end of file |
|
392 | 393 | self.__writeFile(filename, '\t\t' + tmp[2] + '\n') No newline at end of file |
|
393 | 394 | No newline at end of file |
|
394 | 395 | if __name__ == '__main__': No newline at end of file |
|
395 | 396 | No newline at end of file |
|
396 | 397 | absObj = ABSServer() No newline at end of file |
|
397 | 398 | No newline at end of file |
|
398 | 399 | while 1: No newline at end of file |
|
399 | 400 | absObj.waitRequest() No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now