@@ -1,7 +1,9 | |||
|
1 | 1 | import os |
|
2 | 2 | import library3 |
|
3 | 3 | import time |
|
4 | from threading import Thread | |
|
4 | 5 | import threading |
|
6 | import Queue | |
|
5 | 7 | |
|
6 | 8 | class ABSServer: |
|
7 | 9 | |
@@ -26,8 +28,8 | |||
|
26 | 28 | self.createObjects() |
|
27 | 29 | |
|
28 | 30 | print "Checking control modules, please wait ..." |
|
29 |
|
|
|
30 | self.enaModules = [1,12] | |
|
31 | self.enaModules = self.checkAntenna() | |
|
32 | # self.enaModules = [1,12] | |
|
31 | 33 | print "Starting automatic control module status." |
|
32 | 34 | self.__StartingAutomaticControlModules() |
|
33 | 35 | self.__AutomaticControlModules() |
@@ -68,7 +70,7 | |||
|
68 | 70 | |
|
69 | 71 | self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) |
|
70 | 72 | |
|
71 | def checkModule(self, address): | |
|
73 | def __checkModule(self, address): | |
|
72 | 74 | |
|
73 | 75 | cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" |
|
74 | 76 | status = os.system(cmd) |
@@ -113,7 +115,7 | |||
|
113 | 115 | fobj.writelines(data) |
|
114 | 116 | fobj.close() |
|
115 | 117 | |
|
116 | def checkAntenna(self): | |
|
118 | def __checkAntenna(self): | |
|
117 | 119 | |
|
118 | 120 | """ |
|
119 | 121 | Direccion de los modulos de las antenas: |
@@ -133,6 +135,40 | |||
|
133 | 135 | |
|
134 | 136 | self.__writeReport(enaModules2) |
|
135 | 137 | return enaModules2 |
|
138 | ||
|
139 | def checkModule(self, arg, queue): | |
|
140 | cmd = "ping -c 1 -w 1 192.168.1."+ str(arg) + " >> /dev/null" | |
|
141 | status = os.system(cmd) | |
|
142 | if status == 256: | |
|
143 | result = "failed" | |
|
144 | else: | |
|
145 | result = "ok" | |
|
146 | queue.put({arg: result}) | |
|
147 | ||
|
148 | def checkAntenna(self): | |
|
149 | ||
|
150 | iD = range(1,256) | |
|
151 | q = Queue.Queue() | |
|
152 | threads = [] | |
|
153 | tOut = [] | |
|
154 | modules = [] | |
|
155 | ||
|
156 | for argument in iD: | |
|
157 | t = Thread(target=self.checkModule, args=(argument, q)) | |
|
158 | t.start() | |
|
159 | threads.append(t) | |
|
160 | ||
|
161 | for t in threads: | |
|
162 | t.join() | |
|
163 | ||
|
164 | for _ in range(len(iD)): | |
|
165 | tOut.append(q.get()) | |
|
166 | ||
|
167 | for i in tOut: | |
|
168 | if i.values()[0] == 'ok': | |
|
169 | modules.append(i.keys()[0]) | |
|
170 | ||
|
171 | return modules | |
|
136 | 172 | |
|
137 | 173 | def __ConnectionWithControlModules(self,data,cmd,id): |
|
138 | 174 |
General Comments 0
You need to be logged in to leave comments.
Login now