@@ -4,7 +4,8 | |||
|
4 | 4 | |
|
5 | 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): | |
|
7 | # def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500): | |
|
8 | def __init__(self,ipSource="localhost", ipDestino="100.100.12.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500): | |
|
8 | 9 | |
|
9 | 10 | self.ipSource = ipSource |
|
10 | 11 | self.ipDestino = ipDestino |
@@ -93,36 +94,61 | |||
|
93 | 94 | |
|
94 | 95 | self.__writeReport(enaModules2) |
|
95 | 96 | return enaModules2 |
|
97 | ||
|
98 | def __ConnectionWithControlModules(self,data,cmd,id): | |
|
96 | 99 | |
|
100 | self.commClientObj.open_socket() | |
|
101 | ip = "192.168.1." + str(id) | |
|
102 | self.commClientObj.sendData(cmd, data, ip) | |
|
103 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() | |
|
104 | self.commClientObj.close_socket() | |
|
105 | ||
|
106 | return tmp | |
|
107 | ||
|
108 | def __All2Blocks(self,input): | |
|
109 | ||
|
110 | rx_frame_lst = input.split('\n',2) | |
|
111 | ||
|
112 | header = rx_frame_lst[0] + "\n" | |
|
113 | control_modules_str = rx_frame_lst[2] | |
|
114 | control_modules_lst = control_modules_str.split("------\n") | |
|
115 | ||
|
116 | return header, control_modules_lst | |
|
117 | ||
|
118 | ||
|
97 | 119 | def __sendFile2Modules(self,cmd): |
|
98 | 120 | |
|
99 | 121 | #Needed for the loop |
|
100 | rx_frame_list = self.rx_buffer.split('\n',2) | |
|
122 | header, control_modules_lst = self.__All2Blocks(self.rx_buffer) | |
|
101 | 123 | correct = 0 |
|
102 | failure = 0 | |
|
103 | header = rx_frame_list[0] + "\n" | |
|
104 | str_control_modules = rx_frame_list[2] | |
|
105 | ||
|
106 | lst_control_modules = str_control_modules.split("------\n") | |
|
107 | ||
|
108 | # enaModules = self.checkAntenna() | |
|
109 | # enaModules = [11,12,13,14] | |
|
110 | 124 | |
|
111 | 125 | for id in range(1,65): |
|
112 | 126 | |
|
113 | 127 | if id not in self.enaModules: |
|
114 | 128 | continue |
|
115 | #tcp client needed | |
|
116 | self.commClientObj.open_socket() | |
|
117 | ip = "192.168.1." + str(id) | |
|
118 | self.commClientObj.sendData(cmd, header + lst_control_modules[id-1], ip) | |
|
119 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() | |
|
120 | self.commClientObj.close_socket() | |
|
121 | 129 | |
|
122 | if tmp == "OK": | |
|
130 | if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK": | |
|
123 | 131 | correct = correct + 1 |
|
124 | else: | |
|
125 | failure = failure + 1 | |
|
132 | ||
|
133 | if correct == len(self.enaModules): | |
|
134 | rpta = "OK" | |
|
135 | else: | |
|
136 | rpta = "Failure" | |
|
137 | ||
|
138 | return rpta | |
|
139 | ||
|
140 | def __changeBeam(self, cmd): | |
|
141 | ||
|
142 | correct = 0 | |
|
143 | # enaModules = self.checkAntenna() | |
|
144 | # enaModules = [11,12,13,14] | |
|
145 | ||
|
146 | for id in range(1,65): | |
|
147 | if id not in self.enaModules: | |
|
148 | continue | |
|
149 | ||
|
150 | if self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) == "OK": | |
|
151 | correct = correct + 1 | |
|
126 | 152 | |
|
127 | 153 | if correct == len(self.enaModules): |
|
128 | 154 | rpta = "OK" |
@@ -130,11 +156,10 | |||
|
130 | 156 | rpta = "Failure" |
|
131 | 157 | |
|
132 | 158 | return rpta |
|
133 | ||
|
134 |
def __ |
|
|
135 | ||
|
136 | correct = 0 | |
|
137 | failure = 0 | |
|
159 | ||
|
160 | def __getControlModuleStatus(self, cmd): | |
|
161 | ||
|
162 | all_blocks = "" | |
|
138 | 163 | # enaModules = self.checkAntenna() |
|
139 | 164 | # enaModules = [11,12,13,14] |
|
140 | 165 | |
@@ -142,43 +167,11 | |||
|
142 | 167 | if id not in self.enaModules: |
|
143 | 168 | continue |
|
144 | 169 | |
|
145 | self.commClientObj.open_socket() | |
|
146 | ip = "192.168.1." + str(id) | |
|
147 | self.commClientObj.sendData(cmd, self.rx_buffer, ip) | |
|
148 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() | |
|
149 | self.commClientObj.close_socket() | |
|
170 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
|
150 | 171 | |
|
151 | if tmp == "OK": | |
|
152 | correct = correct + 1 | |
|
153 | else: | |
|
154 | failure = failure + 1 | |
|
155 | ||
|
156 | if correct == len(self.enaModules): | |
|
157 | rpta = "OK" | |
|
158 | else: | |
|
159 | rpta = "Failure" | |
|
160 | ||
|
161 | return rpta | |
|
162 | ||
|
163 | def __getControlModuleStatus(self, cmd): | |
|
164 | ||
|
165 | content_str = "" | |
|
166 | # enaModules = self.checkAntenna() | |
|
167 | # enaModules = [11,12,13,14] | |
|
168 | ||
|
169 | for id in range(1,65): | |
|
170 | if id not in self.enaModules: | |
|
171 | continue | |
|
172 | ||
|
173 | self.commClientObj.open_socket() | |
|
174 | ip = "192.168.1." + str(id) | |
|
175 | self.commClientObj.sendData(cmd, self.rx_buffer, ip) | |
|
176 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() | |
|
177 | self.commClientObj.close_socket() | |
|
178 | ||
|
179 | content_str = content_str + tmp | |
|
172 | all_blocks = all_blocks + one_block | |
|
180 | 173 | #Using tx buffer |
|
181 |
self.tx_buffer = |
|
|
174 | self.tx_buffer = all_blocks | |
|
182 | 175 | |
|
183 | 176 | def __getConnectionStatus(self): |
|
184 | 177 |
General Comments 0
You need to be logged in to leave comments.
Login now