@@ -190,34 +190,57 class JARSConfiguration(Configuration): | |||||
190 |
|
190 | |||
191 | def status_device(self): |
|
191 | def status_device(self): | |
192 |
|
192 | |||
|
193 | try: | |||
193 | answer = api.status(self.device.ip_address,self.device.port_address) |
|
194 | answer = api.status(self.device.ip_address,self.device.port_address) | |
194 | self.device.status = int(answer[0]) |
|
195 | self.device.status = int(answer[0]) | |
|
196 | self.device.save() | |||
195 | self.message = answer[2:] |
|
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 | self.device.save() |
|
204 | self.device.save() | |
|
205 | return False | |||
197 |
|
206 | |||
198 |
return |
|
207 | return True | |
199 |
|
208 | |||
200 | def stop_device(self): |
|
209 | def stop_device(self): | |
201 |
|
210 | |||
|
211 | try: | |||
202 | answer = api.stop(self.device.ip_address,self.device.port_address) |
|
212 | answer = api.stop(self.device.ip_address,self.device.port_address) | |
203 | self.device.status = int(answer[0]) |
|
213 | self.device.status = int(answer[0]) | |
204 | self.message = answer[2:] |
|
214 | self.message = answer[2:] | |
205 | self.device.save() |
|
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 | def read_device(self): |
|
227 | def read_device(self): | |
210 |
|
228 | |||
|
229 | try: | |||
211 | answer = api.read(self.device.ip_address,self.device.port_address) |
|
230 | answer = api.read(self.device.ip_address,self.device.port_address) | |
212 | self.device.status = int(answer[0]) |
|
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 | data = json.loads(answer[2:]) |
|
236 | data = json.loads(answer[2:]) | |
215 | parms = data['configurations']['jars'] |
|
237 | parms = data['configurations']['jars'] | |
|
238 | ||||
216 | except: |
|
239 | except: | |
217 | self.device.status = 0 |
|
240 | self.device.status = 0 | |
218 | self.device.save() |
|
241 | self.device.save() | |
219 | self.message = 'Could not read JARS configuration.' |
|
242 | self.message = 'Could not read JARS configuration.' | |
220 |
return |
|
243 | return False | |
221 |
|
244 | |||
222 | #self.dict_to_parms(parms) |
|
245 | #self.dict_to_parms(parms) | |
223 | self.message = 'Current JARS configuration was read successfully.' |
|
246 | self.message = 'Current JARS configuration was read successfully.' | |
@@ -227,6 +250,10 class JARSConfiguration(Configuration): | |||||
227 |
|
250 | |||
228 | def write_device(self): |
|
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 | data = self.experiment.parms_to_dict() |
|
257 | data = self.experiment.parms_to_dict() | |
231 | data = json.loads(data) |
|
258 | data = json.loads(data) | |
232 | data['configurations']['dds'] ='' |
|
259 | data['configurations']['dds'] ='' | |
@@ -235,19 +262,42 class JARSConfiguration(Configuration): | |||||
235 | data['configurations']['rc']['delays']='' |
|
262 | data['configurations']['rc']['delays']='' | |
236 | json_data = json.dumps(data) |
|
263 | json_data = json.dumps(data) | |
237 |
|
264 | |||
|
265 | try: | |||
238 | answer = api.configure(self.device.ip_address,self.device.port_address,json_data) |
|
266 | answer = api.configure(self.device.ip_address,self.device.port_address,json_data) | |
239 | #print answer |
|
|||
240 | self.device.status = int(answer[0]) |
|
267 | self.device.status = int(answer[0]) | |
241 | self.message = answer[2:] |
|
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 | self.device.save() |
|
278 | self.device.save() | |
|
279 | return False | |||
244 |
|
280 | |||
245 |
return |
|
281 | return True | |
246 |
|
282 | |||
247 |
|
283 | |||
248 | def start_device(self): |
|
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 | def echo(self): |
|
303 | def echo(self): |
@@ -39,7 +39,7 def jars_conf(request, id_conf): | |||||
39 |
|
39 | |||
40 | #kwargs['no_play'] = True |
|
40 | #kwargs['no_play'] = True | |
41 |
|
41 | |||
42 | kwargs['only_stop'] = True |
|
42 | #kwargs['only_stop'] = True | |
43 |
|
43 | |||
44 | ###### SIDEBAR ###### |
|
44 | ###### SIDEBAR ###### | |
45 | kwargs.update(sidebar(conf=conf)) |
|
45 | kwargs.update(sidebar(conf=conf)) |
General Comments 0
You need to be logged in to leave comments.
Login now