@@ -1,86 +1,88 | |||||
1 | import library3 |
|
1 | import library3 | |
2 |
|
2 | |||
3 | class ABSClient: |
|
3 | class ABSClient: | |
4 |
|
4 | |||
5 | def __init__(self,ipSource="192.168.1.117", iDSource="Clnt_01", ipDestino="192.168.1.117", iDDestino = "CeCnMod", portDestino=7000): |
|
5 | def __init__(self,ipSource="192.168.1.117", iDSource="Clnt_01", ipDestino="192.168.1.117", iDDestino = "CeCnMod", portDestino=7000): | |
6 |
|
6 | |||
7 | self.ipSource = ipSource |
|
7 | self.ipSource = ipSource | |
8 | self.iDSource = iDSource |
|
8 | self.iDSource = iDSource | |
9 | self.ipDestino = ipDestino |
|
9 | self.ipDestino = ipDestino | |
10 | self.iDDestino = iDDestino |
|
10 | self.iDDestino = iDDestino | |
11 | self.portDestino = portDestino |
|
11 | self.portDestino = portDestino | |
12 |
|
12 | |||
13 | self.createObjects() |
|
13 | self.createObjects() | |
14 |
|
14 | |||
15 | def createObjects(self): |
|
15 | def createObjects(self): | |
16 |
|
16 | |||
17 | self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino) |
|
17 | self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino) | |
18 | # self.wFiles = library3.FilesStuff() |
|
18 | # self.wFiles = library3.FilesStuff() | |
19 |
|
19 | |||
20 | def __ConnectionWithCentralControl(self, cmd, data): |
|
20 | def __ConnectionWithCentralControl(self, cmd, data): | |
21 |
|
21 | |||
22 | self.commObj.open_socket() |
|
22 | self.commObj.open_socket() | |
23 | self.commObj.sendData(cmd = cmd, data = data, ipDestino = self.ipDestino) |
|
23 | self.commObj.sendData(cmd = cmd, data = data, ipDestino = self.ipDestino) | |
24 | ipSource, ipDestino, cmd, output = self.commObj.waitData() |
|
24 | ipSource, ipDestino, cmd, output = self.commObj.waitData() | |
25 | self.commObj.close_socket() |
|
25 | self.commObj.close_socket() | |
26 |
|
26 | |||
27 | return output |
|
27 | return output | |
28 |
|
28 | |||
29 | # def abs2ControlModuleFormatFile(self, filename): |
|
29 | # def abs2ControlModuleFormatFile(self, filename): | |
30 | # |
|
30 | # | |
31 | # #From matriz to control module format |
|
31 | # #From matriz to control module format | |
32 | # self.wFiles.toCentralControlFormat(filename) |
|
32 | # self.wFiles.toCentralControlFormat(filename) | |
33 | # FileName = "CentralControlFormat.txt" |
|
33 | # FileName = "CentralControlFormat.txt" | |
34 | # F_Obj = open(FileName,"r") |
|
34 | # F_Obj = open(FileName,"r") | |
35 | # FileList = F_Obj.readlines() |
|
35 | # FileList = F_Obj.readlines() | |
36 | # F_Obj.close() |
|
36 | # F_Obj.close() | |
37 | # FileStr = "".join(FileList) |
|
37 | # FileStr = "".join(FileList) | |
38 | # |
|
38 | # | |
39 | # return FileStr |
|
39 | # return FileStr | |
40 |
|
40 | |||
41 | def sendFile(self, filename): |
|
41 | def sendFile(self, filename): | |
42 |
|
42 | |||
43 | # data = self.abs2ControlModuleFormatFile(filename) |
|
43 | # data = self.abs2ControlModuleFormatFile(filename) | |
44 |
|
|
44 | tmp = self.__readFile(filename) | |
|
45 | #Sending content of file and the file name | |||
|
46 | data = filename + '\n' + tmp | |||
45 | self.__ConnectionWithCentralControl(cmd = "SNDF", data = data) |
|
47 | self.__ConnectionWithCentralControl(cmd = "SNDF", data = data) | |
46 |
|
48 | |||
47 | def changeBeam(self, newBeam): |
|
49 | def changeBeam(self, newBeam): | |
48 |
|
50 | |||
49 | self.__ConnectionWithCentralControl(cmd = "CHGB", data = newBeam) |
|
51 | self.__ConnectionWithCentralControl(cmd = "CHGB", data = newBeam) | |
50 |
|
52 | |||
51 | def __writeFile(self, filename, data): |
|
53 | def __writeFile(self, filename, data): | |
52 |
|
54 | |||
53 | fobj = open(filename,"w") |
|
55 | fobj = open(filename,"w") | |
54 | fobj.writelines(data) |
|
56 | fobj.writelines(data) | |
55 | fobj.close() |
|
57 | fobj.close() | |
56 |
|
58 | |||
57 | def __readFile(self, filename): |
|
59 | def __readFile(self, filename): | |
58 |
|
60 | |||
59 | fobj = open(filename,"r") |
|
61 | fobj = open(filename,"r") | |
60 | listData = fobj.readlines() |
|
62 | listData = fobj.readlines() | |
61 | fobj.close() |
|
63 | fobj.close() | |
62 | data = "".join(listData) |
|
64 | data = "".join(listData) | |
63 | return data |
|
65 | return data | |
64 |
|
66 | |||
65 |
|
67 | |||
66 | def getControlModuleStatus(self, data): |
|
68 | def getControlModuleStatus(self, data): | |
67 |
|
69 | |||
68 | data = self.__ConnectionWithCentralControl(cmd = "ANST", data = data) |
|
70 | data = self.__ConnectionWithCentralControl(cmd = "ANST", data = data) | |
69 | self.__writeFile("report.txt", data) |
|
71 | self.__writeFile("report.txt", data) | |
70 |
|
72 | |||
71 | def getControlModulePhase(self, data): |
|
73 | def getControlModulePhase(self, data): | |
72 |
|
74 | |||
73 | data = self.__ConnectionWithCentralControl(cmd = "ANPH", data = data) |
|
75 | data = self.__ConnectionWithCentralControl(cmd = "ANPH", data = data) | |
74 | # self.__writeFile("report.txt", data) |
|
76 | # self.__writeFile("report.txt", data) | |
75 |
|
77 | |||
76 | def getConnectionStatus(self): |
|
78 | def getConnectionStatus(self): | |
77 |
|
79 | |||
78 | data = self.__ConnectionWithCentralControl(cmd = "NTST", data = "none") |
|
80 | data = self.__ConnectionWithCentralControl(cmd = "NTST", data = "none") | |
79 | self.__writeFile("connection_status.txt", data) |
|
81 | self.__writeFile("connection_status.txt", data) | |
80 |
|
82 | |||
81 | if __name__ == '__main__': |
|
83 | if __name__ == '__main__': | |
82 |
|
84 | |||
83 | filename = "experimento1.abs" |
|
85 | filename = "experimento1.abs" | |
84 |
|
86 | |||
85 | absObj = ABSClient() |
|
87 | absObj = ABSClient() | |
86 | absObj.sendFile(filename) |
|
88 | absObj.sendFile(filename) |
@@ -1,287 +1,289 | |||||
1 | import os |
|
1 | import os | |
2 | import library3 |
|
2 | import library3 | |
3 | import time |
|
3 | import time | |
4 |
|
4 | |||
5 | class ABSServer: |
|
5 | class ABSServer: | |
6 |
|
6 | |||
7 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500, rx_buffer = "default"): |
|
7 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500, rx_buffer = "default"): | |
8 |
|
8 | |||
9 | self.ipSource = ipSource |
|
9 | self.ipSource = ipSource | |
10 | self.ipDestino = ipDestino |
|
10 | self.ipDestino = ipDestino | |
11 | self.portDestino = portDestino |
|
11 | self.portDestino = portDestino | |
12 |
|
12 | |||
13 | self.ipDestino2 = ipDestino2 |
|
13 | self.ipDestino2 = ipDestino2 | |
14 | self.portDestino2 = portDestino2 |
|
14 | self.portDestino2 = portDestino2 | |
15 |
|
15 | |||
16 | self.tx_buffer = "default" |
|
16 | self.tx_buffer = "default" | |
17 | # self.rx_buffer = "default" |
|
17 | # self.rx_buffer = "default" | |
18 | self.rx_buffer = rx_buffer |
|
18 | self.rx_buffer = rx_buffer | |
19 | self.enaModules = [] |
|
19 | self.enaModules = [] | |
20 |
|
20 | |||
21 | self.createObjects() |
|
21 | self.createObjects() | |
22 |
|
22 | |||
23 | def createObjects(self): |
|
23 | def createObjects(self): | |
24 |
|
24 | |||
25 | asServer = True |
|
25 | asServer = True | |
26 | self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer) |
|
26 | self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer) | |
27 | self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2) |
|
27 | self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2) | |
28 | self.wFiles = library3.FilesStuff() |
|
28 | self.wFiles = library3.FilesStuff() | |
29 |
|
29 | |||
30 | def waitRequest(self): |
|
30 | def waitRequest(self): | |
31 |
|
31 | |||
32 | #Using rx buffer |
|
32 | #Using rx buffer | |
33 | ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() |
|
33 | ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() | |
34 |
|
34 | |||
35 | if cmd == "SNDF": |
|
35 | if cmd == "SNDF": | |
36 | datarpta = self.__sendFile2Modules(cmd = cmd) |
|
36 | datarpta = self.__sendFile2Modules(cmd = cmd) | |
37 |
|
37 | |||
38 | if cmd == "CHGB": |
|
38 | if cmd == "CHGB": | |
39 | datarpta = self.__changeBeam(cmd = cmd) |
|
39 | datarpta = self.__changeBeam(cmd = cmd) | |
40 |
|
40 | |||
41 | if cmd == "ANST": |
|
41 | if cmd == "ANST": | |
42 | self.__getControlModuleStatus(cmd = cmd) |
|
42 | self.__getControlModuleStatus(cmd = cmd) | |
43 | #Using tx buffer |
|
43 | #Using tx buffer | |
44 | datarpta = self.tx_buffer |
|
44 | datarpta = self.tx_buffer | |
45 |
|
45 | |||
46 | if cmd == "ANPH": |
|
46 | if cmd == "ANPH": | |
47 | self.__getControlModulePhase(cmd = cmd) |
|
47 | self.__getControlModulePhase(cmd = cmd) | |
48 | #Using tx buffer |
|
48 | #Using tx buffer | |
49 | datarpta = self.tx_buffer |
|
49 | datarpta = self.tx_buffer | |
50 |
|
50 | |||
51 | if cmd == "NTST": |
|
51 | if cmd == "NTST": | |
52 | #Using tx buffer |
|
52 | #Using tx buffer | |
53 | datarpta = self.__getConnectionStatus(cmd = cmd) |
|
53 | datarpta = self.__getConnectionStatus(cmd = cmd) | |
54 |
|
54 | |||
55 | self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) |
|
55 | self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) | |
56 |
|
56 | |||
57 | def checkModule(self, address): |
|
57 | def checkModule(self, address): | |
58 |
|
58 | |||
59 | cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" |
|
59 | cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" | |
60 | status = os.system(cmd) |
|
60 | status = os.system(cmd) | |
61 |
|
61 | |||
62 | if status == 256: |
|
62 | if status == 256: | |
63 | return False |
|
63 | return False | |
64 |
|
64 | |||
65 | return True |
|
65 | return True | |
66 |
|
66 | |||
67 | def __writeReport(self, enaModules): |
|
67 | def __writeReport(self, enaModules): | |
68 |
|
68 | |||
69 | status_array = ["Status of modules\n"] |
|
69 | status_array = ["Status of modules\n"] | |
70 | status_array.append("----------------\n") |
|
70 | status_array.append("----------------\n") | |
71 |
|
71 | |||
72 | for address in range(1,65): |
|
72 | for address in range(1,65): | |
73 | if address in enaModules: |
|
73 | if address in enaModules: | |
74 | status_array.append("192.168.1." + str(address) + " [1 1]\n") |
|
74 | status_array.append("192.168.1." + str(address) + " [1 1]\n") | |
75 | else: |
|
75 | else: | |
76 | status_array.append("192.168.1." + str(address) + " [0 0]\n") |
|
76 | status_array.append("192.168.1." + str(address) + " [0 0]\n") | |
77 |
|
77 | |||
78 | filename = "module_status.txt" |
|
78 | filename = "module_status.txt" | |
79 | self.__writeFile(filename,status_array) |
|
79 | self.__writeFile(filename,status_array) | |
80 | # f = open("module_status.txt","w") |
|
80 | # f = open("module_status.txt","w") | |
81 | # f.writelines(status_array) |
|
81 | # f.writelines(status_array) | |
82 | # f.close() |
|
82 | # f.close() | |
83 |
|
83 | |||
84 |
|
84 | |||
85 | def __writeFile(self, filename, data): |
|
85 | def __writeFile(self, filename, data): | |
86 |
|
86 | |||
87 | fobj = open(filename,"w") |
|
87 | fobj = open(filename,"w") | |
88 | fobj.writelines(data) |
|
88 | fobj.writelines(data) | |
89 | fobj.close() |
|
89 | fobj.close() | |
90 |
|
90 | |||
91 | def checkAntenna(self): |
|
91 | def checkAntenna(self): | |
92 |
|
92 | |||
93 | """ |
|
93 | """ | |
94 | Direccion de los modulos de las antenas: |
|
94 | Direccion de los modulos de las antenas: | |
95 |
|
95 | |||
96 | Norte : 01-16 |
|
96 | Norte : 01-16 | |
97 | Este : 17-32 |
|
97 | Este : 17-32 | |
98 | Oeste: : 33-48 |
|
98 | Oeste: : 33-48 | |
99 | Sur : 49-64 |
|
99 | Sur : 49-64 | |
100 |
|
100 | |||
101 | """ |
|
101 | """ | |
102 |
|
102 | |||
103 | enaModules2 = [] |
|
103 | enaModules2 = [] | |
104 |
|
104 | |||
105 | for address in range(1,65): |
|
105 | for address in range(1,65): | |
106 | if self.checkModule(address): |
|
106 | if self.checkModule(address): | |
107 | enaModules2.append(address) |
|
107 | enaModules2.append(address) | |
108 |
|
108 | |||
109 | self.__writeReport(enaModules2) |
|
109 | self.__writeReport(enaModules2) | |
110 | return enaModules2 |
|
110 | return enaModules2 | |
111 |
|
111 | |||
112 | def __ConnectionWithControlModules(self,data,cmd,id): |
|
112 | def __ConnectionWithControlModules(self,data,cmd,id): | |
113 |
|
113 | |||
114 | self.commClientObj.open_socket() |
|
114 | self.commClientObj.open_socket() | |
115 | ip = "192.168.1." + str(id) |
|
115 | ip = "192.168.1." + str(id) | |
116 | self.commClientObj.sendData(cmd, data, ip) |
|
116 | self.commClientObj.sendData(cmd, data, ip) | |
117 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() |
|
117 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() | |
118 | self.commClientObj.close_socket() |
|
118 | self.commClientObj.close_socket() | |
119 |
|
119 | |||
120 | return tmp |
|
120 | return tmp | |
121 |
|
121 | |||
122 | def abs2ControlModuleFormatFile(self, filename): |
|
122 | def abs2ControlModuleFormatFile(self, filename): | |
123 |
|
123 | |||
124 | #From matriz to control module format |
|
124 | #From matriz to control module format | |
125 | self.wFiles.toCentralControlFormat(filename) |
|
125 | self.wFiles.toCentralControlFormat(filename) | |
126 | FileName = "CentralControlFormat.txt" |
|
126 | FileName = "CentralControlFormat.txt" | |
127 | F_Obj = open(FileName,"r") |
|
127 | F_Obj = open(FileName,"r") | |
128 | FileList = F_Obj.readlines() |
|
128 | FileList = F_Obj.readlines() | |
129 | F_Obj.close() |
|
129 | F_Obj.close() | |
130 | FileStr = "".join(FileList) |
|
130 | FileStr = "".join(FileList) | |
131 |
|
131 | |||
132 | return FileStr |
|
132 | return FileStr | |
133 |
|
133 | |||
134 | def __All2Blocks(self,input): |
|
134 | def __All2Blocks(self,input): | |
135 |
|
135 | |||
136 | rx_frame_lst = input.split('\n',2) |
|
136 | rx_frame_lst = input.split('\n',2) | |
137 |
|
137 | |||
138 | header = rx_frame_lst[0] + "\n" |
|
138 | header = rx_frame_lst[0] + "\n" | |
139 | control_modules_str = rx_frame_lst[2] |
|
139 | control_modules_str = rx_frame_lst[2] | |
140 | control_modules_lst = control_modules_str.split("------\n") |
|
140 | control_modules_lst = control_modules_str.split("------\n") | |
141 |
|
141 | |||
142 | return header, control_modules_lst |
|
142 | return header, control_modules_lst | |
143 |
|
143 | |||
144 |
|
144 | |||
145 | def __sendFile2Modules(self,cmd): |
|
145 | def __sendFile2Modules(self,cmd): | |
146 |
|
146 | |||
147 | filename = "tmp.txt" |
|
147 | rx_buffer_lst = self.rx_buffer.split('\n',1) | |
148 | self.__writeFile(filename,self.rx_buffer) |
|
148 | filename = rx_buffer_lst[0] | |
|
149 | tmp = rx_buffer_lst[1] | |||
|
150 | self.__writeFile(filename,tmp) | |||
149 | data = self.abs2ControlModuleFormatFile(filename) |
|
151 | data = self.abs2ControlModuleFormatFile(filename) | |
150 | #Needed for the loop |
|
152 | #Needed for the loop | |
151 | header, control_modules_lst = self.__All2Blocks(data) |
|
153 | header, control_modules_lst = self.__All2Blocks(data) | |
152 | correct = 0 |
|
154 | correct = 0 | |
153 |
|
155 | |||
154 | for id in range(1,65): |
|
156 | for id in range(1,65): | |
155 |
|
157 | |||
156 | if id not in self.enaModules: |
|
158 | if id not in self.enaModules: | |
157 | continue |
|
159 | continue | |
158 |
|
160 | |||
159 | if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK": |
|
161 | if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK": | |
160 | correct = correct + 1 |
|
162 | correct = correct + 1 | |
161 |
|
163 | |||
162 | if correct == len(self.enaModules): |
|
164 | if correct == len(self.enaModules): | |
163 | rpta = "OK" |
|
165 | rpta = "OK" | |
164 | else: |
|
166 | else: | |
165 | rpta = "Failure" |
|
167 | rpta = "Failure" | |
166 |
|
168 | |||
167 | return rpta |
|
169 | return rpta | |
168 |
|
170 | |||
169 | def __changeBeam(self, cmd): |
|
171 | def __changeBeam(self, cmd): | |
170 |
|
172 | |||
171 | correct = 0 |
|
173 | correct = 0 | |
172 | # enaModules = self.checkAntenna() |
|
174 | # enaModules = self.checkAntenna() | |
173 | # enaModules = [11,12,13,14] |
|
175 | # enaModules = [11,12,13,14] | |
174 |
|
176 | |||
175 | for id in range(1,65): |
|
177 | for id in range(1,65): | |
176 | if id not in self.enaModules: |
|
178 | if id not in self.enaModules: | |
177 | continue |
|
179 | continue | |
178 |
|
180 | |||
179 | if self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) == "OK": |
|
181 | if self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) == "OK": | |
180 | correct = correct + 1 |
|
182 | correct = correct + 1 | |
181 |
|
183 | |||
182 | if correct == len(self.enaModules): |
|
184 | if correct == len(self.enaModules): | |
183 | rpta = "OK" |
|
185 | rpta = "OK" | |
184 | else: |
|
186 | else: | |
185 | rpta = "Failure" |
|
187 | rpta = "Failure" | |
186 |
|
188 | |||
187 | return rpta |
|
189 | return rpta | |
188 |
|
190 | |||
189 | def __getControlModuleStatus(self, cmd): |
|
191 | def __getControlModuleStatus(self, cmd): | |
190 |
|
192 | |||
191 | all_blocks = "" |
|
193 | all_blocks = "" | |
192 | # enaModules = self.checkAntenna() |
|
194 | # enaModules = self.checkAntenna() | |
193 | # enaModules = [11,12,13,14] |
|
195 | # enaModules = [11,12,13,14] | |
194 |
|
196 | |||
195 | for id in range(1,65): |
|
197 | for id in range(1,65): | |
196 | if id not in self.enaModules: |
|
198 | if id not in self.enaModules: | |
197 | continue |
|
199 | continue | |
198 |
|
200 | |||
199 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) |
|
201 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
200 |
|
202 | |||
201 | all_blocks = all_blocks + one_block |
|
203 | all_blocks = all_blocks + one_block | |
202 | #Using tx buffer |
|
204 | #Using tx buffer | |
203 | print all_blocks |
|
205 | print all_blocks | |
204 | self.tx_buffer = all_blocks |
|
206 | self.tx_buffer = all_blocks | |
205 |
|
207 | |||
206 | def __getControlModulePhase(self, cmd): |
|
208 | def __getControlModulePhase(self, cmd): | |
207 |
|
209 | |||
208 | all_blocks = "" |
|
210 | all_blocks = "" | |
209 | # enaModules = self.checkAntenna() |
|
211 | # enaModules = self.checkAntenna() | |
210 | # enaModules = [11,12,13,14] |
|
212 | # enaModules = [11,12,13,14] | |
211 |
|
213 | |||
212 | for id in range(1,65): |
|
214 | for id in range(1,65): | |
213 | if id not in self.enaModules: |
|
215 | if id not in self.enaModules: | |
214 | continue |
|
216 | continue | |
215 |
|
217 | |||
216 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) |
|
218 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
217 |
|
219 | |||
218 | all_blocks = all_blocks + one_block |
|
220 | all_blocks = all_blocks + one_block | |
219 | #Using tx buffer |
|
221 | #Using tx buffer | |
220 | print all_blocks |
|
222 | print all_blocks | |
221 | self.tx_buffer = all_blocks |
|
223 | self.tx_buffer = all_blocks | |
222 |
|
224 | |||
223 | def __getConnectionStatus(self, cmd): |
|
225 | def __getConnectionStatus(self, cmd): | |
224 |
|
226 | |||
225 | ena = self.checkAntenna() |
|
227 | ena = self.checkAntenna() | |
226 | print ena |
|
228 | print ena | |
227 | self.enaModules = ena |
|
229 | self.enaModules = ena | |
228 |
|
230 | |||
229 | blockLst = [] |
|
231 | blockLst = [] | |
230 |
|
232 | |||
231 | for id in range(1,65): |
|
233 | for id in range(1,65): | |
232 | if id not in self.enaModules: |
|
234 | if id not in self.enaModules: | |
233 | continue |
|
235 | continue | |
234 |
|
236 | |||
235 | blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) |
|
237 | blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
236 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") |
|
238 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") | |
237 | #Using tx buffer |
|
239 | #Using tx buffer | |
238 | self.tx_buffer = "".join(blockLst) |
|
240 | self.tx_buffer = "".join(blockLst) | |
239 | print self.tx_buffer |
|
241 | print self.tx_buffer | |
240 |
|
242 | |||
241 | return self.tx_buffer |
|
243 | return self.tx_buffer | |
242 |
|
244 | |||
243 | def getConnectionStatus(self, cmd): |
|
245 | def getConnectionStatus(self, cmd): | |
244 |
|
246 | |||
245 | ena = self.checkAntenna() |
|
247 | ena = self.checkAntenna() | |
246 | self.enaModules = ena |
|
248 | self.enaModules = ena | |
247 |
|
249 | |||
248 | blockLst = [] |
|
250 | blockLst = [] | |
249 |
|
251 | |||
250 | for id in range(1,65): |
|
252 | for id in range(1,65): | |
251 | if id not in self.enaModules: |
|
253 | if id not in self.enaModules: | |
252 | continue |
|
254 | continue | |
253 |
|
255 | |||
254 | blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) |
|
256 | blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
255 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") |
|
257 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") | |
256 | #Using tx buffer |
|
258 | #Using tx buffer | |
257 | self.tx_buffer = "".join(blockLst) |
|
259 | self.tx_buffer = "".join(blockLst) | |
258 | print self.tx_buffer |
|
260 | print self.tx_buffer | |
259 |
|
261 | |||
260 | return self.tx_buffer |
|
262 | return self.tx_buffer | |
261 |
|
263 | |||
262 | def getControlModuleStatus(self, cmd): |
|
264 | def getControlModuleStatus(self, cmd): | |
263 |
|
265 | |||
264 | all_blocks = "" |
|
266 | all_blocks = "" | |
265 | # enaModules = self.checkAntenna() |
|
267 | # enaModules = self.checkAntenna() | |
266 | # enaModules = [11,12,13,14] |
|
268 | # enaModules = [11,12,13,14] | |
267 |
|
269 | |||
268 | for id in range(1,65): |
|
270 | for id in range(1,65): | |
269 | if id not in self.enaModules: |
|
271 | if id not in self.enaModules: | |
270 | continue |
|
272 | continue | |
271 |
|
273 | |||
272 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) |
|
274 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
273 |
|
275 | |||
274 | all_blocks = all_blocks + one_block |
|
276 | all_blocks = all_blocks + one_block | |
275 | #Using tx buffer |
|
277 | #Using tx buffer | |
276 | print all_blocks |
|
278 | print all_blocks | |
277 | self.tx_buffer = all_blocks |
|
279 | self.tx_buffer = all_blocks | |
278 |
|
280 | |||
279 | return all_blocks |
|
281 | return all_blocks | |
280 |
|
282 | |||
281 |
|
283 | |||
282 | if __name__ == '__main__': |
|
284 | if __name__ == '__main__': | |
283 |
|
285 | |||
284 | absObj = ABSServer() |
|
286 | absObj = ABSServer() | |
285 |
|
287 | |||
286 | while 1: |
|
288 | while 1: | |
287 | absObj.waitRequest() No newline at end of file |
|
289 | absObj.waitRequest() |
General Comments 0
You need to be logged in to leave comments.
Login now