@@ -190,34 +190,57 class JARSConfiguration(Configuration): | |||
|
190 | 190 | |
|
191 | 191 | def status_device(self): |
|
192 | 192 | |
|
193 | try: | |
|
193 | 194 | answer = api.status(self.device.ip_address,self.device.port_address) |
|
194 | 195 | self.device.status = int(answer[0]) |
|
196 | self.device.save() | |
|
195 | 197 | self.message = answer[2:] |
|
198 | if self.device.status == 0: | |
|
199 | return False | |
|
200 | ||
|
201 | except Exception as e: | |
|
202 | self.device.status = 0 | |
|
203 | self.message = str(e) | |
|
196 | 204 | self.device.save() |
|
205 | return False | |
|
197 | 206 | |
|
198 |
return |
|
|
207 | return True | |
|
199 | 208 | |
|
200 | 209 | def stop_device(self): |
|
201 | 210 | |
|
211 | try: | |
|
202 | 212 | answer = api.stop(self.device.ip_address,self.device.port_address) |
|
203 | 213 | self.device.status = int(answer[0]) |
|
204 | 214 | self.message = answer[2:] |
|
205 | 215 | self.device.save() |
|
216 | if self.device.status == 0 or self.device.status == 1: | |
|
217 | return False | |
|
206 | 218 | |
|
207 | return self.device.status | |
|
219 | except Exception as e: | |
|
220 | self.device.status = 0 | |
|
221 | self.message = str(e) | |
|
222 | self.device.save() | |
|
223 | return False | |
|
224 | ||
|
225 | return True | |
|
208 | 226 | |
|
209 | 227 | def read_device(self): |
|
210 | 228 | |
|
229 | try: | |
|
211 | 230 | answer = api.read(self.device.ip_address,self.device.port_address) |
|
212 | 231 | self.device.status = int(answer[0]) |
|
213 | try: | |
|
232 | self.device.save() | |
|
233 | self.message = answer[2:] | |
|
234 | if self.device.status == 1: | |
|
235 | return False | |
|
214 | 236 | data = json.loads(answer[2:]) |
|
215 | 237 | parms = data['configurations']['jars'] |
|
238 | ||
|
216 | 239 | except: |
|
217 | 240 | self.device.status = 0 |
|
218 | 241 | self.device.save() |
|
219 | 242 | self.message = 'Could not read JARS configuration.' |
|
220 |
return |
|
|
243 | return False | |
|
221 | 244 | |
|
222 | 245 | #self.dict_to_parms(parms) |
|
223 | 246 | self.message = 'Current JARS configuration was read successfully.' |
@@ -227,6 +250,10 class JARSConfiguration(Configuration): | |||
|
227 | 250 | |
|
228 | 251 | def write_device(self): |
|
229 | 252 | |
|
253 | if self.device.status == 3: | |
|
254 | self.message = 'Could not configure device. Software Acquisition is running' | |
|
255 | return False | |
|
256 | ||
|
230 | 257 | data = self.experiment.parms_to_dict() |
|
231 | 258 | data = json.loads(data) |
|
232 | 259 | data['configurations']['dds'] ='' |
@@ -235,19 +262,42 class JARSConfiguration(Configuration): | |||
|
235 | 262 | data['configurations']['rc']['delays']='' |
|
236 | 263 | json_data = json.dumps(data) |
|
237 | 264 | |
|
265 | try: | |
|
238 | 266 | answer = api.configure(self.device.ip_address,self.device.port_address,json_data) |
|
239 | #print answer | |
|
240 | 267 | self.device.status = int(answer[0]) |
|
241 | 268 | self.message = answer[2:] |
|
269 | self.device.save() | |
|
270 | if self.device.status == 1: | |
|
271 | return False | |
|
272 | if self.device.status == 3: | |
|
273 | return False | |
|
242 | 274 | |
|
275 | except Exception as e: | |
|
276 | self.device.status = 0 | |
|
277 | self.message = str(e) | |
|
243 | 278 | self.device.save() |
|
279 | return False | |
|
244 | 280 | |
|
245 |
return |
|
|
281 | return True | |
|
246 | 282 | |
|
247 | 283 | |
|
248 | 284 | def start_device(self): |
|
249 | 285 | |
|
250 | self.write_device() | |
|
286 | try: | |
|
287 | answer = api.start(self.device.ip_address,self.device.port_address) | |
|
288 | self.device.status = int(answer[0]) | |
|
289 | self.message = answer[2:] | |
|
290 | self.device.save() | |
|
291 | if self.device.status == 1: | |
|
292 | return False | |
|
293 | ||
|
294 | except Exception as e: | |
|
295 | self.device.status = 0 | |
|
296 | self.message = str(e) | |
|
297 | self.device.save() | |
|
298 | return False | |
|
299 | ||
|
300 | return True | |
|
251 | 301 | |
|
252 | 302 | |
|
253 | 303 | def echo(self): |
General Comments 0
You need to be logged in to leave comments.
Login now