##// END OF EJS Templates
Update models.py (generator, pedestal, usrp tx, ursp rx, experiments
eynilupu -
r398:e746ceb18854
parent child
Show More
@@ -102,8 +102,6 class GeneratorConfiguration(Configuration):
102 102 def status_device(self):
103 103
104 104 try:
105 #self.device.status = 0
106 #payload = self.request('status')
107 105 payload = requests.get(self.device.url())
108 106
109 107 if payload:
@@ -146,9 +144,7 class GeneratorConfiguration(Configuration):
146 144 def stop_device(self):
147 145
148 146 try:
149 self.selector = 0
150 self.save()
151 payload = {"enable": self.selector}
147 payload = {"enable": 0}
152 148
153 149 json_trmode_selector = json.dumps(payload)
154 150 base64_trmode_selector = base64.standard_b64encode(json_trmode_selector.encode('ascii'))
@@ -287,14 +287,11 class Experiment(PolymorphicModel):
287 287
288 288 try:
289 289 proc_url = 'http://'+os.environ['PROC_SITE']+'/start'
290 data['pedestal'] = self.pedestal.jsonify()
291 data['usrp_rx'] = self.reception_rx.jsonify()
292 data['usrp_tx'] = self.transmission_tx.jsonify()
293 r = requests.post(proc_url, json=data)
294 self.reception_rx.start_device()
295 self.pedestal.start_device()
290 data['usrp_rx'] = self.reception_rx.start_device()
291 data['pedestal'] = self.pedestal.start_device()
296 292 self.generator_start()
297 self.transmission_tx.start_device()
293 data['usrp_tx'] = self.transmission_tx.start_device()
294 requests.post(proc_url, json=data)
298 295
299 296 except:
300 297 return 0
@@ -309,14 +306,14 class Experiment(PolymorphicModel):
309 306
310 307 try:
311 308 proc_url = 'http://'+os.environ['PROC_SITE']+'/stop'
312 r = requests.get(proc_url)
309 requests.get(proc_url)
313 310 self.reception_rx.stop_device()
314 311 self.pedestal.stop_device()
315 312 self.generator.stop_device()
316 313 self.transmission_tx.stop_device()
317 314 except:
318 315 return 0
319 return 1
316 return 2
320 317
321 318 def get_status(self):
322 319
@@ -167,6 +167,13 class PedestalConfiguration(Configuration):
167 167 try:
168 168 command = self.device.url() + "stop"
169 169 r = requests.get(command)
170
171 if self.mode == 'table':
172 AX = {'az':'azimuth', 'el':'elevation'}
173 axis = [AX[x.lower().strip()] for x in self.axis.split(',')]
174 list_of_floats = [float(x.strip()) for x in self.angle.split(",")]
175 self.reset_device(axis[0], list_of_floats[0])
176
170 177 if r:
171 178 self.device.status = 4
172 179 self.device.save()
@@ -223,8 +230,6 class PedestalConfiguration(Configuration):
223 230 'top': self.max_value,
224 231 'table': coded_table_ascii
225 232 }
226 self.reset_device(axis[0], list_of_floats[0])
227 time.sleep(15)
228 233
229 234 json_data = json.dumps(payload)
230 235 print(json_data)
@@ -232,6 +237,9 class PedestalConfiguration(Configuration):
232 237 url += base64_table.decode('ascii')
233 238 print(url)
234 239 r = requests.get(url)
240
241 if self.mode == 'table':
242 payload['table'] = list_of_floats
235 243
236 244 if r:
237 245 self.device.status = 3
@@ -249,7 +257,7 class PedestalConfiguration(Configuration):
249 257 self.device.save()
250 258 return False
251 259
252 return True
260 return payload
253 261
254 262 def get_absolute_url_import(self):
255 263 return reverse('url_import_pedestal_conf', args=[str(self.id)])
@@ -214,10 +214,7 class USRPRXConfiguration(Configuration):
214 214 self.device.save()
215 215 return False
216 216
217 return True
217 return payload
218 218
219 219 def get_absolute_url_import(self):
220 return reverse('url_import_usrp_rx_conf', args=[str(self.id)])
221
222
223
220 return reverse('url_import_usrp_rx_conf', args=[str(self.id)]) No newline at end of file
@@ -281,7 +281,7 class USRPTXConfiguration(Configuration):
281 281 self.device.save()
282 282 return False
283 283
284 return True
284 return payload
285 285
286 286 def get_absolute_url_import(self):
287 287 return reverse('url_import_usrp_tx_conf', args=[str(self.id)]) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now