1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,5 | |||||
|
1 | import time | |||
|
2 | ||||
|
3 | while True: | |||
|
4 | print("Adquiriendo") | |||
|
5 | time.sleep(3) No newline at end of file |
@@ -0,0 +1,5 | |||||
|
1 | import time | |||
|
2 | ||||
|
3 | while True: | |||
|
4 | print("Transmitiendo") | |||
|
5 | time.sleep(3) No newline at end of file |
@@ -24,10 +24,10 class GeneratorConfigurationForm(forms.ModelForm): | |||||
24 | if instance and instance.pk: |
|
24 | if instance and instance.pk: | |
25 |
|
25 | |||
26 | devices = Device.objects.filter(device_type__name='generator') |
|
26 | devices = Device.objects.filter(device_type__name='generator') | |
27 | if instance.experiment: |
|
27 | #if instance.experiment: | |
28 | self.fields['experiment'].widget.attrs['read_only'] = True |
|
28 | #self.fields['experiment'].widget.attrs['read_only'] = True | |
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] |
|
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
30 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
30 | #self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |
31 |
|
31 | |||
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): |
|
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |
33 | self.fields['experiment'].widget.attrs['readonly'] = True |
|
33 | self.fields['experiment'].widget.attrs['readonly'] = True |
@@ -79,6 +79,23 class ExperimentForm(forms.ModelForm): | |||||
79 | class Meta: |
|
79 | class Meta: | |
80 | model = Experiment |
|
80 | model = Experiment | |
81 | exclude = ['task', 'status', 'author', 'hash'] |
|
81 | exclude = ['task', 'status', 'author', 'hash'] | |
|
82 | ||||
|
83 | class ExperimentEditionForm(forms.ModelForm): | |||
|
84 | ||||
|
85 | def __init__(self, *args, **kwargs): | |||
|
86 | super(ExperimentEditionForm, self).__init__(*args, **kwargs) | |||
|
87 | #self.fields['start_time'].widget = TimepickerWidget(self.fields['start_time'].widget.attrs) | |||
|
88 | #self.fields['end_time'].widget = TimepickerWidget(self.fields['end_time'].widget.attrs) | |||
|
89 | ||||
|
90 | def save(self, *args, **kwargs): | |||
|
91 | exp = super(ExperimentEditionForm, self).save(*args, **kwargs) | |||
|
92 | exp.name = exp.name.replace(' ', '') | |||
|
93 | exp.save() | |||
|
94 | return exp | |||
|
95 | ||||
|
96 | class Meta: | |||
|
97 | model = Experiment | |||
|
98 | exclude = ['pedestal', 'generator', 'task', 'status', 'author', 'hash'] | |||
82 |
|
99 | |||
83 | class LocationForm(forms.ModelForm): |
|
100 | class LocationForm(forms.ModelForm): | |
84 | class Meta: |
|
101 | class Meta: | |
@@ -111,7 +128,7 class DownloadFileForm(forms.Form): | |||||
111 | format = forms.ChoiceField(choices= ((0, 'json'),) ) |
|
128 | format = forms.ChoiceField(choices= ((0, 'json'),) ) | |
112 |
|
129 | |||
113 | def __init__(self, device_type, *args, **kwargs): |
|
130 | def __init__(self, device_type, *args, **kwargs): | |
114 |
|
131 | |||
115 | super(DownloadFileForm, self).__init__(*args, **kwargs) |
|
132 | super(DownloadFileForm, self).__init__(*args, **kwargs) | |
116 |
|
133 | |||
117 | self.fields['format'].choices = FILE_FORMAT |
|
134 | self.fields['format'].choices = FILE_FORMAT |
@@ -152,7 +152,7 class Device(models.Model): | |||||
152 | if self.status == 0: |
|
152 | if self.status == 0: | |
153 | color = "danger" |
|
153 | color = "danger" | |
154 | elif self.status == 1: |
|
154 | elif self.status == 1: | |
155 |
color = " |
|
155 | color = "primary" | |
156 | elif self.status == 2: |
|
156 | elif self.status == 2: | |
157 | color = "info" |
|
157 | color = "info" | |
158 | elif self.status == 3: |
|
158 | elif self.status == 3: | |
@@ -328,7 +328,7 class RunningExperiment(models.Model): | |||||
328 | status = models.PositiveSmallIntegerField(default=0, choices=RADAR_STATES) |
|
328 | status = models.PositiveSmallIntegerField(default=0, choices=RADAR_STATES) | |
329 |
|
329 | |||
330 |
|
330 | |||
331 |
class Experiment( |
|
331 | class Experiment(PolymorphicModel): | |
332 |
|
332 | |||
333 | template = models.BooleanField(default=False) |
|
333 | template = models.BooleanField(default=False) | |
334 | name = models.CharField(max_length=40, default='', unique=True) |
|
334 | name = models.CharField(max_length=40, default='', unique=True) | |
@@ -336,10 +336,13 class Experiment(models.Model): | |||||
336 | #freq = models.FloatField(verbose_name='Operating Freq. (MHz)', validators=[MinValueValidator(1), MaxValueValidator(10000)], default=49.9200) |
|
336 | #freq = models.FloatField(verbose_name='Operating Freq. (MHz)', validators=[MinValueValidator(1), MaxValueValidator(10000)], default=49.9200) | |
337 | #start_time = models.TimeField(default='00:00:00') |
|
337 | #start_time = models.TimeField(default='00:00:00') | |
338 | #end_time = models.TimeField(default='23:59:59') |
|
338 | #end_time = models.TimeField(default='23:59:59') | |
339 |
pedestal = models.ForeignKey('pedestal.PedestalConfiguration', null=False, blank=False, on_delete=models. |
|
339 | pedestal = models.ForeignKey('pedestal.PedestalConfiguration', null=False, blank=False, on_delete=models.PROTECT, default=None, related_name = "pedestal_conf") | |
|
340 | generator = models.ForeignKey('Device', null=False, blank=False, on_delete=models.PROTECT, default=None, limit_choices_to={'device_type__name': 'generator'}, related_name = "generator_conf") | |||
|
341 | reception_rx = models.ForeignKey('usrp_rx.USRPRXConfiguration', null=False, blank=False, on_delete=models.PROTECT, default=None, related_name = "usrp_rx_CONF") | |||
|
342 | transmission_tx = models.ForeignKey('usrp_tx.USRPTXConfiguration', null=False, blank=False, on_delete=models.PROTECT, default=None, related_name = "usrp_tx") | |||
340 | task = models.CharField(max_length=36, default='', blank=True, null=True) |
|
343 | task = models.CharField(max_length=36, default='', blank=True, null=True) | |
341 | status = models.PositiveSmallIntegerField(default=4, choices=EXP_STATES) |
|
344 | status = models.PositiveSmallIntegerField(default=4, choices=EXP_STATES) | |
342 | author = models.ForeignKey(User, null=True, blank=True,on_delete=models.CASCADE) |
|
345 | author = models.ForeignKey(User, null=True, blank=True, on_delete=models.CASCADE) | |
343 | hash = models.CharField(default='', max_length=64, null=True, blank=True) |
|
346 | hash = models.CharField(default='', max_length=64, null=True, blank=True) | |
344 |
|
347 | |||
345 | class Meta: |
|
348 | class Meta: | |
@@ -394,21 +397,33 class Experiment(models.Model): | |||||
394 | ''' |
|
397 | ''' | |
395 | Configure and start experiments's devices |
|
398 | Configure and start experiments's devices | |
396 | ''' |
|
399 | ''' | |
397 |
|
400 | #confs = [] | ||
398 | confs = [] |
|
401 | #allconfs = Configuration.objects.filter(experiment=self, type = 0).order_by('-device__device_type__sequence') | |
399 | allconfs = Configuration.objects.filter(experiment=self, type = 0).order_by('-device__device_type__sequence') |
|
402 | #confs = allconfs | |
400 | confs = allconfs |
|
403 | experiment = get_object_or_404(Experiment, pk=self.id) | |
|
404 | id_p = experiment.pedestal_id | |||
|
405 | id_rx = experiment.reception_rx_id | |||
|
406 | id_tx = experiment.transmission_tx_id | |||
|
407 | generator_periode = 1 /experiment.transmission_tx.frequency | |||
|
408 | generator_delay = experiment.transmission_tx.delay_1 | |||
|
409 | generator_width = int((experiment.transmission_tx.ipp * 2 / 300000) * 1000000) * experiment.transmission_tx.pulse_1 / 100 | |||
|
410 | print(generator_width) | |||
|
411 | generator_selector = 1 | |||
401 |
|
412 | |||
402 | try: |
|
413 | try: | |
403 | for conf in confs: |
|
414 | print("Hola") | |
404 | conf.stop_device() |
|
415 | #Configuration.objects.get(id = id_rx).start_device() | |
405 | print("OK") |
|
416 | #Configuration.objects.get(id = id_p).start_device() | |
406 | #conf.write_device() |
|
417 | #Configuration.objects.get(id = id_tx).start_device() | |
407 |
|
|
418 | # for conf in confs: | |
408 |
conf.devic |
|
419 | # conf.stop_device() | |
409 |
|
|
420 | # print("OK") | |
410 |
|
|
421 | # #conf.write_device() | |
411 | time.sleep(1) |
|
422 | # conf.device.conf_active = conf.pk | |
|
423 | # conf.device.save() | |||
|
424 | # conf.start_device() | |||
|
425 | # print("OK") | |||
|
426 | # time.sleep(1) | |||
412 | except: |
|
427 | except: | |
413 | return 0 |
|
428 | return 0 | |
414 | return 2 |
|
429 | return 2 | |
@@ -420,10 +435,18 class Experiment(models.Model): | |||||
420 | PEDESTAL, PULSE GENERATOR & USRP's |
|
435 | PEDESTAL, PULSE GENERATOR & USRP's | |
421 | ''' |
|
436 | ''' | |
422 |
|
437 | |||
423 | confs = Configuration.objects.filter(experiment=self, type = 0).order_by('device__device_type__sequence') |
|
438 | #confs = Configuration.objects.filter(experiment=self, type = 0).order_by('device__device_type__sequence') | |
|
439 | experiment = get_object_or_404(Experiment, pk=self.id) | |||
|
440 | id_p = experiment.pedestal_id | |||
|
441 | id_rx = experiment.reception_rx_id | |||
|
442 | id_tx = experiment.transmission_tx_id | |||
|
443 | ||||
424 | try: |
|
444 | try: | |
425 | for conf in confs: |
|
445 | Configuration.objects.get(id = id_rx).stop_device() | |
426 |
|
|
446 | Configuration.objects.get(id = id_p).stop_device() | |
|
447 | Configuration.objects.get(id = id_tx).stop_device() | |||
|
448 | # for conf in confs: | |||
|
449 | # conf.stop_device() | |||
427 | except: |
|
450 | except: | |
428 | return 0 |
|
451 | return 0 | |
429 | return 1 |
|
452 | return 1 | |
@@ -537,7 +560,6 class Configuration(PolymorphicModel): | |||||
537 | # name = models.CharField(verbose_name="Configuration Name", max_length=40, default='') |
|
560 | # name = models.CharField(verbose_name="Configuration Name", max_length=40, default='') | |
538 | device = models.ForeignKey('Device', verbose_name='Device', null=True, on_delete=models.CASCADE) |
|
561 | device = models.ForeignKey('Device', verbose_name='Device', null=True, on_delete=models.CASCADE) | |
539 | label = models.CharField(verbose_name="Label", max_length=40, default='', blank=False, null=False) |
|
562 | label = models.CharField(verbose_name="Label", max_length=40, default='', blank=False, null=False) | |
540 | experiment = models.ForeignKey('Experiment', verbose_name='Experiment', null=True, blank=True, on_delete=models.CASCADE) |
|
|||
541 | type = models.PositiveSmallIntegerField(default=0, choices=CONF_TYPES) |
|
563 | type = models.PositiveSmallIntegerField(default=0, choices=CONF_TYPES) | |
542 | created_date = models.DateTimeField(auto_now_add=True) |
|
564 | created_date = models.DateTimeField(auto_now_add=True) | |
543 | programmed_date = models.DateTimeField(auto_now=True) |
|
565 | programmed_date = models.DateTimeField(auto_now=True) | |
@@ -577,7 +599,7 class Configuration(PolymorphicModel): | |||||
577 |
|
599 | |||
578 | ignored = ('type', 'polymorphic_ctype', 'configuration_ptr', |
|
600 | ignored = ('type', 'polymorphic_ctype', 'configuration_ptr', | |
579 | 'created_date', 'programmed_date', 'template', 'device', |
|
601 | 'created_date', 'programmed_date', 'template', 'device', | |
580 | 'experiment') |
|
602 | 'experiment', 'author') | |
581 |
|
603 | |||
582 | for field in self._meta.fields: |
|
604 | for field in self._meta.fields: | |
583 | if field.name in ignored: |
|
605 | if field.name in ignored: | |
@@ -653,6 +675,7 class Configuration(PolymorphicModel): | |||||
653 | content_type = 'application/json' |
|
675 | content_type = 'application/json' | |
654 | filename = '%s_%s.json' %(self.device.device_type.name, self.name) |
|
676 | filename = '%s_%s.json' %(self.device.device_type.name, self.name) | |
655 | content = json.dumps(self.parms_to_dict(), indent=2) |
|
677 | content = json.dumps(self.parms_to_dict(), indent=2) | |
|
678 | print(content) | |||
656 |
|
679 | |||
657 | fields = {'content_type':content_type, |
|
680 | fields = {'content_type':content_type, | |
658 | 'filename':filename, |
|
681 | 'filename':filename, | |
@@ -674,31 +697,31 class Configuration(PolymorphicModel): | |||||
674 |
|
697 | |||
675 | def status_device(self): |
|
698 | def status_device(self): | |
676 |
|
699 | |||
677 |
self.message = 'Function not |
|
700 | self.message = 'Function not supported' | |
678 | return False |
|
701 | return False | |
679 |
|
702 | |||
680 |
|
703 | |||
681 | def stop_device(self): |
|
704 | def stop_device(self): | |
682 |
|
705 | |||
683 |
self.message = 'Function not |
|
706 | self.message = 'Function not supported' | |
684 | return False |
|
707 | return False | |
685 |
|
708 | |||
686 |
|
709 | |||
687 | def start_device(self): |
|
710 | def start_device(self): | |
688 |
|
711 | |||
689 |
self.message = 'Function not |
|
712 | self.message = 'Function not supported' | |
690 | return False |
|
713 | return False | |
691 |
|
714 | |||
692 |
|
715 | |||
693 | def write_device(self): |
|
716 | def write_device(self): | |
694 |
|
717 | |||
695 |
self.message = 'Function not |
|
718 | self.message = 'Function not supported' | |
696 | return False |
|
719 | return False | |
697 |
|
720 | |||
698 |
|
721 | |||
699 | def read_device(self): |
|
722 | def read_device(self): | |
700 |
|
723 | |||
701 |
self.message = 'Function not |
|
724 | self.message = 'Function not supported' | |
702 | return False |
|
725 | return False | |
703 |
|
726 | |||
704 |
|
727 |
@@ -77,6 +77,7 | |||||
77 |
|
77 | |||
78 | <div class="page-header"> |
|
78 | <div class="page-header"> | |
79 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> |
|
79 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> | |
|
80 | <br> | |||
80 | </div> |
|
81 | </div> | |
81 | {% block messages %} |
|
82 | {% block messages %} | |
82 | {% if messages %} |
|
83 | {% if messages %} |
@@ -19,6 +19,20 | |||||
19 | {% endblock %} |
|
19 | {% endblock %} | |
20 | {% else %} |
|
20 | {% else %} | |
21 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
21 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
|
22 | {% if form_pedestal %} | |||
|
23 | <br> | |||
|
24 | <h1>Pedestal</h1> | |||
|
25 | <br> | |||
|
26 | {% bootstrap_form form_pedestal layout='horizontal' size='medium' %} | |||
|
27 | <br> | |||
|
28 | <h1>RX</h1> | |||
|
29 | <br> | |||
|
30 | {% bootstrap_form form_rx layout='horizontal' size='medium' %} | |||
|
31 | <br> | |||
|
32 | <h1>TX</h1> | |||
|
33 | <br> | |||
|
34 | {% bootstrap_form form_tx layout='horizontal' size='medium' %} | |||
|
35 | {% endif %} | |||
22 | {% endif %} |
|
36 | {% endif %} | |
23 |
|
37 | |||
24 | <div style="clear: both;"></div> |
|
38 | <div style="clear: both;"></div> |
@@ -7,6 +7,7 | |||||
7 | {% endblock %} |
|
7 | {% endblock %} | |
8 |
|
8 | |||
9 | {% block extra-js%} |
|
9 | {% block extra-js%} | |
|
10 | ||||
10 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> |
|
11 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |
11 | <script type="text/javascript"> |
|
12 | <script type="text/javascript"> | |
12 |
|
13 |
@@ -20,14 +20,14 try: | |||||
20 | except ImportError: |
|
20 | except ImportError: | |
21 | from urllib import urlencode |
|
21 | from urllib import urlencode | |
22 |
|
22 | |||
23 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm |
|
23 | from .forms import CampaignForm, ExperimentForm, ExperimentEditionForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm | |
24 | from .forms import OperationSearchForm, FilterForm, ChangeIpForm |
|
24 | from .forms import OperationSearchForm, FilterForm, ChangeIpForm | |
25 |
|
25 | |||
26 | from apps.pedestal.forms import PedestalConfigurationForm |
|
26 | from apps.pedestal.forms import PedestalConfigurationForm, PedestalEditionForm | |
27 | from apps.pedestal_dev.forms import PedestalDevConfigurationForm |
|
27 | from apps.pedestal_dev.forms import PedestalDevConfigurationForm | |
28 | from apps.generator.forms import GeneratorConfigurationForm |
|
28 | from apps.generator.forms import GeneratorConfigurationForm | |
29 | from apps.usrp_rx.forms import USRPRXConfigurationForm |
|
29 | from apps.usrp_rx.forms import USRPRXConfigurationForm, USRPRXEditionForm | |
30 | from apps.usrp_tx.forms import USRPTXConfigurationForm |
|
30 | from apps.usrp_tx.forms import USRPTXConfigurationForm, USRPTXEditionForm | |
31 | from .utils import Params |
|
31 | from .utils import Params | |
32 |
|
32 | |||
33 | from .models import Campaign, Experiment, Device, Configuration, Location, RunningExperiment, DEV_STATES |
|
33 | from .models import Campaign, Experiment, Device, Configuration, Location, RunningExperiment, DEV_STATES | |
@@ -259,7 +259,7 def device_new(request): | |||||
259 |
|
259 | |||
260 | @login_required |
|
260 | @login_required | |
261 | def device_edit(request, id_dev): |
|
261 | def device_edit(request, id_dev): | |
262 |
|
262 | |||
263 | device = get_object_or_404(Device, pk=id_dev) |
|
263 | device = get_object_or_404(Device, pk=id_dev) | |
264 |
|
264 | |||
265 | if request.method == 'GET': |
|
265 | if request.method == 'GET': | |
@@ -576,7 +576,7 def experiments(request): | |||||
576 |
|
576 | |||
577 | form = FilterForm(initial=request.GET, extra_fields=fields) |
|
577 | form = FilterForm(initial=request.GET, extra_fields=fields) | |
578 |
|
578 | |||
579 | kwargs['keys'] = ['name', 'radar_system', 'actions'] |
|
579 | kwargs['keys'] = ['name', 'radar_system', 'pedestal', 'generator', 'reception_rx', 'transmission_tx', 'actions'] | |
580 | kwargs['title'] = 'Experiment' |
|
580 | kwargs['title'] = 'Experiment' | |
581 | kwargs['suptitle'] = 'List' |
|
581 | kwargs['suptitle'] = 'List' | |
582 | kwargs['no_sidebar'] = True |
|
582 | kwargs['no_sidebar'] = True | |
@@ -593,13 +593,12 def experiments(request): | |||||
593 | def experiment(request, id_exp): |
|
593 | def experiment(request, id_exp): | |
594 |
|
594 | |||
595 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
595 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
596 |
|
||||
597 | configurations = Configuration.objects.filter( |
|
|||
598 | experiment=experiment, type=0) |
|
|||
599 |
|
596 | |||
|
597 | #experiment = Experiment.objects.select_related('pedestal').get(pk=id_exp) | |||
|
598 | configurations = PedestalConfiguration.objects.filter(id = experiment.pedestal_id) | |||
600 | kwargs = {} |
|
599 | kwargs = {} | |
601 |
|
600 | |||
602 | kwargs['experiment_keys'] = ['template', 'radar_system', 'name'] |
|
601 | kwargs['experiment_keys'] = ['template', 'radar_system', 'name', 'pedestal', 'generator', 'reception_rx', 'transmission_tx'] | |
603 | kwargs['experiment'] = experiment |
|
602 | kwargs['experiment'] = experiment | |
604 | kwargs['configuration_keys'] = ['name', 'device__ip_address', |
|
603 | kwargs['configuration_keys'] = ['name', 'device__ip_address', | |
605 | 'device__port_address', 'device__status'] |
|
604 | 'device__port_address', 'device__status'] | |
@@ -608,7 +607,7 def experiment(request, id_exp): | |||||
608 | kwargs['suptitle'] = 'Details' |
|
607 | kwargs['suptitle'] = 'Details' | |
609 | kwargs['button'] = 'Add Configuration' |
|
608 | kwargs['button'] = 'Add Configuration' | |
610 | kwargs['menu_experiments'] = 'active' |
|
609 | kwargs['menu_experiments'] = 'active' | |
611 |
|
610 | #print(kwargs) | ||
612 | ###### SIDEBAR ###### |
|
611 | ###### SIDEBAR ###### | |
613 | kwargs.update(sidebar(experiment=experiment)) |
|
612 | kwargs.update(sidebar(experiment=experiment)) | |
614 |
|
613 | |||
@@ -617,7 +616,7 def experiment(request, id_exp): | |||||
617 |
|
616 | |||
618 | @login_required |
|
617 | @login_required | |
619 | def experiment_new(request, id_camp=None): |
|
618 | def experiment_new(request, id_camp=None): | |
620 |
|
619 | |||
621 | if not is_developer(request.user): |
|
620 | if not is_developer(request.user): | |
622 | messages.error( |
|
621 | messages.error( | |
623 | request, 'Developer required, to create new Experiments') |
|
622 | request, 'Developer required, to create new Experiments') | |
@@ -672,19 +671,39 def experiment_new(request, id_camp=None): | |||||
672 | def experiment_edit(request, id_exp): |
|
671 | def experiment_edit(request, id_exp): | |
673 |
|
672 | |||
674 | experiment = get_object_or_404(Experiment, pk=id_exp) |
|
673 | experiment = get_object_or_404(Experiment, pk=id_exp) | |
|
674 | id_p = experiment.pedestal_id | |||
|
675 | id_rx = experiment.reception_rx_id | |||
|
676 | id_tx = experiment.transmission_tx_id | |||
|
677 | #print(id_p) | |||
|
678 | #configurations = get_object_or_404(PedestalConfiguration, id = id_p) | |||
|
679 | conf_pedestal = PedestalConfiguration.objects.get(id = id_p) | |||
|
680 | conf_rx = USRPRXConfiguration.objects.get(id = id_rx) | |||
|
681 | conf_tx = USRPTXConfiguration.objects.get(id = id_tx) | |||
675 |
|
682 | |||
676 | if request.method == 'GET': |
|
683 | if request.method == 'GET': | |
677 | form = ExperimentForm(instance=experiment) |
|
684 | form = ExperimentEditionForm(instance=experiment) | |
|
685 | form_pedestal = PedestalEditionForm(instance=conf_pedestal) | |||
|
686 | form_rx = USRPRXEditionForm(instance=conf_rx) | |||
|
687 | form_tx = USRPTXEditionForm(instance=conf_tx) | |||
678 |
|
688 | |||
679 | if request.method == 'POST': |
|
689 | if request.method == 'POST': | |
680 | form = ExperimentForm(request.POST, instance=experiment) |
|
690 | form = ExperimentEditionForm(request.POST, instance=experiment) | |
|
691 | form_pedestal = PedestalEditionForm(request.POST, instance=conf_pedestal) | |||
|
692 | form_rx = USRPRXEditionForm(request.POST, instance=conf_rx) | |||
|
693 | form_tx = USRPTXEditionForm(request.POST, instance=conf_tx) | |||
681 |
|
694 | |||
682 | if form.is_valid(): |
|
695 | if form.is_valid(): | |
683 | experiment = form.save() |
|
696 | experiment = form.save() | |
|
697 | form_pedestal.save() | |||
|
698 | form_rx.save() | |||
|
699 | form_tx.save() | |||
684 | return redirect('url_experiment', id_exp=experiment.id) |
|
700 | return redirect('url_experiment', id_exp=experiment.id) | |
685 |
|
701 | |||
686 | kwargs = {} |
|
702 | kwargs = {} | |
687 | kwargs['form'] = form |
|
703 | kwargs['form'] = form | |
|
704 | kwargs['form_pedestal'] = form_pedestal | |||
|
705 | kwargs['form_rx'] = form_rx | |||
|
706 | kwargs['form_tx'] = form_tx | |||
688 | kwargs['title'] = 'Experiment' |
|
707 | kwargs['title'] = 'Experiment' | |
689 | kwargs['suptitle'] = 'Edit' |
|
708 | kwargs['suptitle'] = 'Edit' | |
690 | kwargs['button'] = 'Update' |
|
709 | kwargs['button'] = 'Update' | |
@@ -700,8 +719,8 def experiment_delete(request, id_exp): | |||||
700 |
|
719 | |||
701 | if request.method == 'POST': |
|
720 | if request.method == 'POST': | |
702 | if is_developer(request.user): |
|
721 | if is_developer(request.user): | |
703 | for conf in Configuration.objects.filter(experiment=experiment): |
|
722 | #for conf in Configuration.objects.filter(experiment=experiment): | |
704 | conf.delete() |
|
723 | #conf.delete() | |
705 | experiment.delete() |
|
724 | experiment.delete() | |
706 | return redirect('url_experiments') |
|
725 | return redirect('url_experiments') | |
707 |
|
726 | |||
@@ -770,7 +789,7 def experiment_import(request, id_exp): | |||||
770 | def experiment_start(request, id_exp): |
|
789 | def experiment_start(request, id_exp): | |
771 |
|
790 | |||
772 | exp = get_object_or_404(Experiment, pk=id_exp) |
|
791 | exp = get_object_or_404(Experiment, pk=id_exp) | |
773 |
|
792 | exp.status = 0 | ||
774 | if exp.status == 2: |
|
793 | if exp.status == 2: | |
775 | messages.warning(request, 'Experiment {} already runnnig'.format(exp)) |
|
794 | messages.warning(request, 'Experiment {} already runnnig'.format(exp)) | |
776 | else: |
|
795 | else: | |
@@ -1266,7 +1285,7 def dev_confs(request): | |||||
1266 | if request.user.is_authenticated: |
|
1285 | if request.user.is_authenticated: | |
1267 | fields.append('my configurations') |
|
1286 | fields.append('my configurations') | |
1268 | form = FilterForm(initial=request.GET, extra_fields=fields) |
|
1287 | form = FilterForm(initial=request.GET, extra_fields=fields) | |
1269 |
kwargs['keys'] = ['name', 'device', |
|
1288 | kwargs['keys'] = ['name', 'device', | |
1270 | 'type', 'programmed_date', 'actions'] |
|
1289 | 'type', 'programmed_date', 'actions'] | |
1271 | kwargs['title'] = 'Configuration' |
|
1290 | kwargs['title'] = 'Configuration' | |
1272 | kwargs['suptitle'] = 'List' |
|
1291 | kwargs['suptitle'] = 'List' | |
@@ -1363,7 +1382,7 def dev_conf_new(request, id_exp=0, id_dev=0): | |||||
1363 |
|
1382 | |||
1364 | @login_required |
|
1383 | @login_required | |
1365 | def dev_conf_edit(request, id_conf): |
|
1384 | def dev_conf_edit(request, id_conf): | |
1366 |
|
1385 | |||
1367 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
1386 | conf = get_object_or_404(Configuration, pk=id_conf) | |
1368 |
|
1387 | |||
1369 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
1388 | DevConfForm = CONF_FORMS[conf.device.device_type.name] | |
@@ -1597,6 +1616,7 def dev_conf_export(request, id_conf): | |||||
1597 | if file_form.is_valid(): |
|
1616 | if file_form.is_valid(): | |
1598 | fields = conf.export_to_file( |
|
1617 | fields = conf.export_to_file( | |
1599 | format=file_form.cleaned_data['format']) |
|
1618 | format=file_form.cleaned_data['format']) | |
|
1619 | ||||
1600 | if not fields['content']: |
|
1620 | if not fields['content']: | |
1601 | messages.error(request, conf.message) |
|
1621 | messages.error(request, conf.message) | |
1602 | return redirect(conf.get_absolute_url_export()) |
|
1622 | return redirect(conf.get_absolute_url_export()) | |
@@ -1621,12 +1641,15 def dev_conf_export(request, id_conf): | |||||
1621 |
|
1641 | |||
1622 | @login_required |
|
1642 | @login_required | |
1623 | def dev_conf_delete(request, id_conf): |
|
1643 | def dev_conf_delete(request, id_conf): | |
1624 |
|
1644 | print("Está aquí") | ||
1625 | conf = get_object_or_404(Configuration, pk=id_conf) |
|
1645 | conf = get_object_or_404(Configuration, pk=id_conf) | |
1626 |
|
1646 | |||
1627 | if request.method == 'POST': |
|
1647 | if request.method == 'POST': | |
1628 | if is_developer(request.user): |
|
1648 | if is_developer(request.user): | |
1629 |
|
|
1649 | try: | |
|
1650 | conf.delete() | |||
|
1651 | except Exception as e: | |||
|
1652 | messages.error(request, "The device configuration is protected") | |||
1630 | return redirect('url_dev_confs') |
|
1653 | return redirect('url_dev_confs') | |
1631 |
|
1654 | |||
1632 | messages.error(request, 'Not enough permission to delete this object') |
|
1655 | messages.error(request, 'Not enough permission to delete this object') | |
@@ -1650,8 +1673,8 def sidebar(**kwargs): | |||||
1650 | conf = kwargs.get('conf', None) |
|
1673 | conf = kwargs.get('conf', None) | |
1651 | experiment = kwargs.get('experiment', None) |
|
1674 | experiment = kwargs.get('experiment', None) | |
1652 |
|
1675 | |||
1653 | if not experiment: |
|
1676 | #if not experiment: | |
1654 |
|
|
1677 | #experiment = conf.experiment | |
1655 |
|
1678 | |||
1656 | if experiment: |
|
1679 | if experiment: | |
1657 | side_data['experiment'] = experiment |
|
1680 | side_data['experiment'] = experiment | |
@@ -1661,10 +1684,9 def sidebar(**kwargs): | |||||
1661 | experiments = campaign[0].experiments.all().order_by('name') |
|
1684 | experiments = campaign[0].experiments.all().order_by('name') | |
1662 | else: |
|
1685 | else: | |
1663 | experiments = [experiment] |
|
1686 | experiments = [experiment] | |
1664 | configurations = experiment.configuration_set.filter(type=0) |
|
1687 | #configurations = experiment.configuration_set.filter(type=0) | |
1665 | side_data['side_experiments'] = experiments |
|
1688 | side_data['side_experiments'] = experiments | |
1666 | side_data['side_configurations'] = configurations.order_by( |
|
1689 | #side_data['side_configurations'] = configurations.order_by('device__device_type__name') | |
1667 | 'device__device_type__name') |
|
|||
1668 |
|
1690 | |||
1669 | return side_data |
|
1691 | return side_data | |
1670 |
|
1692 |
@@ -24,17 +24,17 class PedestalConfigurationForm(forms.ModelForm): | |||||
24 | if instance and instance.pk: |
|
24 | if instance and instance.pk: | |
25 |
|
25 | |||
26 | devices = Device.objects.filter(device_type__name='pedestal') |
|
26 | devices = Device.objects.filter(device_type__name='pedestal') | |
27 | if instance.experiment: |
|
27 | #if instance.experiment: | |
28 | self.fields['experiment'].widget.attrs['read_only'] = True |
|
28 | #self.fields['experiment'].widget.attrs['read_only'] = True | |
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] |
|
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
30 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
30 | #self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |
31 |
|
31 | |||
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): |
|
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |
33 | self.fields['experiment'].widget.attrs['readonly'] = True |
|
33 | self.fields['experiment'].widget.attrs['readonly'] = True | |
34 |
|
34 | |||
35 | class Meta: |
|
35 | class Meta: | |
36 | model = PedestalConfiguration |
|
36 | model = PedestalConfiguration | |
37 | exclude = ('type', 'parameters', 'status', 'total_units', 'author', 'hash') |
|
37 | exclude = ('template', 'type', 'parameters', 'status', 'total_units', 'author', 'hash') | |
38 |
|
38 | |||
39 | def clean(self): |
|
39 | def clean(self): | |
40 | form_data = super(PedestalConfigurationForm, self).clean() |
|
40 | form_data = super(PedestalConfigurationForm, self).clean() | |
@@ -45,6 +45,37 class PedestalConfigurationForm(forms.ModelForm): | |||||
45 | conf.save() |
|
45 | conf.save() | |
46 | return conf |
|
46 | return conf | |
47 |
|
47 | |||
|
48 | class PedestalEditionForm(forms.ModelForm): | |||
|
49 | ||||
|
50 | def __init__(self, *args, **kwargs): | |||
|
51 | super(PedestalEditionForm, self).__init__(*args, **kwargs) | |||
|
52 | ||||
|
53 | instance = getattr(self, 'instance', None) | |||
|
54 | ||||
|
55 | if instance and instance.pk: | |||
|
56 | ||||
|
57 | devices = Device.objects.filter(device_type__name='pedestal') | |||
|
58 | #if instance.experiment: | |||
|
59 | #self.fields['experiment'].widget.attrs['read_only'] = True | |||
|
60 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |||
|
61 | #self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |||
|
62 | ||||
|
63 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |||
|
64 | self.fields['experiment'].widget.attrs['readonly'] = True | |||
|
65 | ||||
|
66 | class Meta: | |||
|
67 | model = PedestalConfiguration | |||
|
68 | exclude = ('device', 'label', 'template', 'type', 'parameters', 'status', 'total_units', 'author', 'hash') | |||
|
69 | ||||
|
70 | def clean(self): | |||
|
71 | form_data = super(PedestalEditionForm, self).clean() | |||
|
72 | return form_data | |||
|
73 | ||||
|
74 | def save(self, *args, **kwargs): | |||
|
75 | conf = super(PedestalEditionForm, self).save(*args, **kwargs) | |||
|
76 | conf.save() | |||
|
77 | return conf | |||
|
78 | ||||
48 | class ExtFileField(forms.FileField): |
|
79 | class ExtFileField(forms.FileField): | |
49 | """ |
|
80 | """ | |
50 | Same as forms.FileField, but you can specify a file extension whitelist. |
|
81 | Same as forms.FileField, but you can specify a file extension whitelist. |
@@ -13,15 +13,15 from django.core.validators import MinValueValidator, MaxValueValidator | |||||
13 | from apps.main.models import Configuration |
|
13 | from apps.main.models import Configuration | |
14 |
|
14 | |||
15 | AXIS_VALUE = ( |
|
15 | AXIS_VALUE = ( | |
16 |
(' |
|
16 | ('azimuth', 'PPI'), | |
17 |
(' |
|
17 | ('elevation', 'RHI') | |
18 | ) |
|
18 | ) | |
19 |
|
19 | |||
20 | class PedestalConfiguration(Configuration): |
|
20 | class PedestalConfiguration(Configuration): | |
21 |
|
21 | |||
22 | axis = models.CharField( |
|
22 | axis = models.CharField( | |
23 | verbose_name='Axis', |
|
23 | verbose_name='Axis', | |
24 |
max_length= |
|
24 | max_length=10, | |
25 | choices=AXIS_VALUE, |
|
25 | choices=AXIS_VALUE, | |
26 | null=False, |
|
26 | null=False, | |
27 | blank=False |
|
27 | blank=False | |
@@ -133,9 +133,9 class PedestalConfiguration(Configuration): | |||||
133 | try: |
|
133 | try: | |
134 | pedestal = PedestalConfiguration.objects.get(pk=self) |
|
134 | pedestal = PedestalConfiguration.objects.get(pk=self) | |
135 | print(pedestal) |
|
135 | print(pedestal) | |
136 | pedestal_axis = pedestal.get_axis_display() |
|
136 | #pedestal_axis = pedestal.get_axis_display() | |
137 | print(pedestal) |
|
137 | print(pedestal) | |
138 | print(pedestal_axis) |
|
138 | #print(pedestal_axis) | |
139 | table = pedestal.table |
|
139 | table = pedestal.table | |
140 | print(table) |
|
140 | print(table) | |
141 | li = list(table.split(",")) |
|
141 | li = list(table.split(",")) | |
@@ -155,13 +155,13 class PedestalConfiguration(Configuration): | |||||
155 | coded_table = base64.standard_b64encode(bytes(byte_table)) |
|
155 | coded_table = base64.standard_b64encode(bytes(byte_table)) | |
156 | coded_table_ascii = coded_table.decode('ascii') |
|
156 | coded_table_ascii = coded_table.decode('ascii') | |
157 | print(coded_table_ascii) |
|
157 | print(coded_table_ascii) | |
158 |
data = {'axis': pedestal |
|
158 | data = {'axis': pedestal.axis, 'speed': pedestal.speed, 'table': coded_table_ascii} | |
159 | print(data) |
|
159 | print(data) | |
160 | json_data = json.dumps(data) |
|
160 | json_data = json.dumps(data) | |
161 | print(json_data) |
|
161 | print(json_data) | |
162 | first_position = table[0] |
|
162 | first_position = table[0] | |
163 |
|
163 | |||
164 |
if pedestal.axis==' |
|
164 | if pedestal.axis=='PPI': | |
165 | json_az = json.dumps({"axis": 'azimuth', "position": 0.0}) |
|
165 | json_az = json.dumps({"axis": 'azimuth', "position": 0.0}) | |
166 | json_el = json.dumps({"axis": 'elevation', "position": first_position}) |
|
166 | json_el = json.dumps({"axis": 'elevation', "position": first_position}) | |
167 | else: |
|
167 | else: |
@@ -14,7 +14,6 | |||||
14 | {% block content %} |
|
14 | {% block content %} | |
15 | <form class="form" method="post"> |
|
15 | <form class="form" method="post"> | |
16 | {% csrf_token %} |
|
16 | {% csrf_token %} | |
17 | <h2>Pedestal</h2> |
|
|||
18 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
17 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
19 | <div style="clear: both;"></div> |
|
18 | <div style="clear: both;"></div> | |
20 | <br> |
|
19 | <br> |
@@ -35,7 +35,7 def conf(request, conf_id): | |||||
35 |
|
35 | |||
36 | @login_required |
|
36 | @login_required | |
37 | def conf_edit(request, conf_id): |
|
37 | def conf_edit(request, conf_id): | |
38 |
|
38 | |||
39 | conf = get_object_or_404(PedestalConfiguration, pk=conf_id) |
|
39 | conf = get_object_or_404(PedestalConfiguration, pk=conf_id) | |
40 | print(conf) |
|
40 | print(conf) | |
41 | #print("fin de carga de params") |
|
41 | #print("fin de carga de params") |
@@ -24,10 +24,10 class USRPRXConfigurationForm(forms.ModelForm): | |||||
24 | if instance and instance.pk: |
|
24 | if instance and instance.pk: | |
25 |
|
25 | |||
26 | devices = Device.objects.filter(device_type__name='usrp_rx') |
|
26 | devices = Device.objects.filter(device_type__name='usrp_rx') | |
27 | if instance.experiment: |
|
27 | #if instance.experiment: | |
28 | self.fields['experiment'].widget.attrs['read_only'] = True |
|
28 | #self.fields['experiment'].widget.attrs['read_only'] = True | |
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] |
|
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
30 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
30 | #self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |
31 |
|
31 | |||
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): |
|
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |
33 | self.fields['experiment'].widget.attrs['readonly'] = True |
|
33 | self.fields['experiment'].widget.attrs['readonly'] = True | |
@@ -45,6 +45,37 class USRPRXConfigurationForm(forms.ModelForm): | |||||
45 | conf.save() |
|
45 | conf.save() | |
46 | return conf |
|
46 | return conf | |
47 |
|
47 | |||
|
48 | class USRPRXEditionForm(forms.ModelForm): | |||
|
49 | ||||
|
50 | def __init__(self, *args, **kwargs): | |||
|
51 | super(USRPRXEditionForm, self).__init__(*args, **kwargs) | |||
|
52 | ||||
|
53 | instance = getattr(self, 'instance', None) | |||
|
54 | ||||
|
55 | if instance and instance.pk: | |||
|
56 | ||||
|
57 | devices = Device.objects.filter(device_type__name='usrp_rx') | |||
|
58 | #if instance.experiment: | |||
|
59 | #self.fields['experiment'].widget.attrs['read_only'] = True | |||
|
60 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |||
|
61 | #self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |||
|
62 | ||||
|
63 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |||
|
64 | self.fields['experiment'].widget.attrs['readonly'] = True | |||
|
65 | ||||
|
66 | class Meta: | |||
|
67 | model = USRPRXConfiguration | |||
|
68 | exclude = ('template', 'device', 'label', 'ip_address', 'daughterboard', 'antenna', 'type', 'parameters', 'status', 'total_units', 'author', 'hash') | |||
|
69 | ||||
|
70 | def clean(self): | |||
|
71 | form_data = super(USRPRXEditionForm, self).clean() | |||
|
72 | return form_data | |||
|
73 | ||||
|
74 | def save(self, *args, **kwargs): | |||
|
75 | conf = super(USRPRXEditionForm, self).save(*args, **kwargs) | |||
|
76 | conf.save() | |||
|
77 | return conf | |||
|
78 | ||||
48 | class ExtFileField(forms.FileField): |
|
79 | class ExtFileField(forms.FileField): | |
49 | """ |
|
80 | """ | |
50 | Same as forms.FileField, but you can specify a file extension whitelist. |
|
81 | Same as forms.FileField, but you can specify a file extension whitelist. |
@@ -162,7 +162,7 class USRPRXConfiguration(Configuration): | |||||
162 | def stop_device(self): |
|
162 | def stop_device(self): | |
163 |
|
163 | |||
164 | try: |
|
164 | try: | |
165 | command = self.device.url() + "stop" |
|
165 | command = self.device.url() + "stoprx" | |
166 | r = requests.get(command) |
|
166 | r = requests.get(command) | |
167 | if r: |
|
167 | if r: | |
168 | self.device.status = 4 |
|
168 | self.device.status = 4 |
@@ -24,10 +24,10 class USRPTXConfigurationForm(forms.ModelForm): | |||||
24 | if instance and instance.pk: |
|
24 | if instance and instance.pk: | |
25 |
|
25 | |||
26 | devices = Device.objects.filter(device_type__name='usrp_tx') |
|
26 | devices = Device.objects.filter(device_type__name='usrp_tx') | |
27 | if instance.experiment: |
|
27 | #if instance.experiment: | |
28 | self.fields['experiment'].widget.attrs['read_only'] = True |
|
28 | #self.fields['experiment'].widget.attrs['read_only'] = True | |
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] |
|
29 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
30 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
30 | #self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |
31 |
|
31 | |||
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): |
|
32 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |
33 | self.fields['experiment'].widget.attrs['readonly'] = True |
|
33 | self.fields['experiment'].widget.attrs['readonly'] = True | |
@@ -45,6 +45,37 class USRPTXConfigurationForm(forms.ModelForm): | |||||
45 | conf.save() |
|
45 | conf.save() | |
46 | return conf |
|
46 | return conf | |
47 |
|
47 | |||
|
48 | class USRPTXEditionForm(forms.ModelForm): | |||
|
49 | ||||
|
50 | def __init__(self, *args, **kwargs): | |||
|
51 | super(USRPTXEditionForm, self).__init__(*args, **kwargs) | |||
|
52 | ||||
|
53 | instance = getattr(self, 'instance', None) | |||
|
54 | ||||
|
55 | if instance and instance.pk: | |||
|
56 | ||||
|
57 | devices = Device.objects.filter(device_type__name='usrp_tx') | |||
|
58 | #if instance.experiment: | |||
|
59 | #self.fields['experiment'].widget.attrs['read_only'] = True | |||
|
60 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |||
|
61 | #self.fields['device'].widget.choices = [(device.id, device) for device in devices] | |||
|
62 | ||||
|
63 | if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'): | |||
|
64 | self.fields['experiment'].widget.attrs['readonly'] = True | |||
|
65 | ||||
|
66 | class Meta: | |||
|
67 | model = USRPTXConfiguration | |||
|
68 | exclude = ('template', 'device', 'label', 'ip_address', 'daughterboard', 'antenna', 'type', 'parameters', 'status', 'total_units', 'author', 'hash') | |||
|
69 | ||||
|
70 | def clean(self): | |||
|
71 | form_data = super(USRPTXEditionForm, self).clean() | |||
|
72 | return form_data | |||
|
73 | ||||
|
74 | def save(self, *args, **kwargs): | |||
|
75 | conf = super(USRPTXEditionForm, self).save(*args, **kwargs) | |||
|
76 | conf.save() | |||
|
77 | return conf | |||
|
78 | ||||
48 | class ExtFileField(forms.FileField): |
|
79 | class ExtFileField(forms.FileField): | |
49 | """ |
|
80 | """ | |
50 | Same as forms.FileField, but you can specify a file extension whitelist. |
|
81 | Same as forms.FileField, but you can specify a file extension whitelist. |
@@ -130,6 +130,7 class USRPTXConfiguration(Configuration): | |||||
130 |
|
130 | |||
131 | pulse_2 = models.FloatField( |
|
131 | pulse_2 = models.FloatField( | |
132 | verbose_name='Width (Pulse 2)', |
|
132 | verbose_name='Width (Pulse 2)', | |
|
133 | default=1, | |||
133 | blank=True, |
|
134 | blank=True, | |
134 | null=True, |
|
135 | null=True, | |
135 | help_text='Introduce the value in %' |
|
136 | help_text='Introduce the value in %' | |
@@ -228,7 +229,7 class USRPTXConfiguration(Configuration): | |||||
228 | def stop_device(self): |
|
229 | def stop_device(self): | |
229 |
|
230 | |||
230 | try: |
|
231 | try: | |
231 | command = self.device.url() + "stop" |
|
232 | command = self.device.url() + "stoptx" | |
232 | r = requests.get(command) |
|
233 | r = requests.get(command) | |
233 | if r: |
|
234 | if r: | |
234 | self.device.status = 4 |
|
235 | self.device.status = 4 |
@@ -117,7 +117,7 def import_file(request, conf_id): | |||||
117 | try: |
|
117 | try: | |
118 | data = conf.import_from_file(request.FILES['file_name']) |
|
118 | data = conf.import_from_file(request.FILES['file_name']) | |
119 | conf.dict_to_parms(data) |
|
119 | conf.dict_to_parms(data) | |
120 | conf.update_pulses() |
|
120 | #conf.update_pulses() | |
121 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) |
|
121 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) | |
122 | return redirect(conf.get_absolute_url_edit()) |
|
122 | return redirect(conf.get_absolute_url_edit()) | |
123 |
|
123 |
@@ -39,14 +39,20 def usrprx_start(): | |||||
39 | time_source = request_data['time_source'] |
|
39 | time_source = request_data['time_source'] | |
40 | clock_rate = request_data['clock_rate'] |
|
40 | clock_rate = request_data['clock_rate'] | |
41 |
|
41 | |||
42 | command_usrp_rx = subprocess.Popen(["python2.7", "/home/developer/HaystackOP/thor.py", "-m", ip_address, "-d", daughterboard, |
|
42 | #command_usrp_rx = subprocess.Popen(["python2.7", "/home/developer/HaystackOP/thor.py", "-m", ip_address, "-d", daughterboard, | |
43 | "-c ch0,ch1", "-y", antenna, "-r", str(sample_rate) + "e6", "-f", str(frequency) + "e6", |
|
43 | # "-c ch0,ch1", "-y", antenna, "-r", str(sample_rate) + "e6", "-f", str(frequency) + "e6", | |
44 | "-datadir", datadir, "--clock_source", clock_source, "--time_source", time_source, |
|
44 | # "-datadir", datadir, "--clock_source", clock_source, "--time_source", time_source, | |
45 | "--clock_rate", str(clock_rate) + "e6"], stdout=subprocess.PIPE) |
|
45 | # "--clock_rate", str(clock_rate) + "e6"], stdout=subprocess.PIPE) | |
46 | command_usrp_rx_out = command_usrp_rx.communicate()[0] |
|
46 | command_usrp_rx = subprocess.Popen(["python", "thor.py"], stdout=subprocess.PIPE) | |
47 | print(command_usrp_rx_out) |
|
47 | #command_usrp_rx_out = command_usrp_rx.communicate()[0] | |
|
48 | #print(command_usrp_rx_out) | |||
48 |
|
49 | |||
49 | return "USRP Rx configured" |
|
50 | return "USRP Rx configured" | |
|
51 | ||||
|
52 | @app.route('/stoprx/', methods=['GET']) | |||
|
53 | def usrprx_stop(): | |||
|
54 | #stop_usrp_rx = subprocess.Popen(["pkill", "-f", "thor.py"], stdout=subprocess.PIPE) | |||
|
55 | return 'USRP stopped' | |||
50 |
|
56 | |||
51 | @app.route('/usrptx/', methods=['POST']) |
|
57 | @app.route('/usrptx/', methods=['POST']) | |
52 | def usrptx_start(): |
|
58 | def usrptx_start(): | |
@@ -172,15 +178,17 def usrptx_start(): | |||||
172 | print(name) |
|
178 | print(name) | |
173 | cod.tofile(name) |
|
179 | cod.tofile(name) | |
174 |
|
180 | |||
175 | command_usrp_tx = subprocess.Popen(["python", "tx.py", "-m", ip_address, "-d", daughterboard, "-y", antenna, "-f", str(frequency) + "e6", |
|
181 | #command_usrp_tx = subprocess.Popen(["python", "tx.py", "-m", ip_address, "-d", daughterboard, "-y", antenna, "-f", str(frequency) + "e6", | |
176 | "-r", str(sample_rate) + "e6", "code.bin"], stdout=subprocess.PIPE) |
|
182 | # "-r", str(sample_rate) + "e6", "code.bin"], stdout=subprocess.PIPE) | |
177 | command_usrp_tx_out = command_usrp_tx.communicate()[0] |
|
183 | command_usrp_tx = subprocess.Popen(["python", "tx.py"], stdout=subprocess.PIPE) | |
178 | print(command_usrp_tx_out) |
|
184 | #command_usrp_tx_out = command_usrp_tx.communicate()[1] | |
|
185 | #print(command_usrp_tx_out) | |||
179 |
|
186 | |||
180 | return "USRP Tx configured" |
|
187 | return "USRP Tx configured" | |
181 |
|
188 | |||
182 | @app.route('/stop/', methods=['GET']) |
|
189 | @app.route('/stoptx/', methods=['GET']) | |
183 | def usrp_stop(): |
|
190 | def usrptx_stop(): | |
|
191 | #stop_usrp_tx = subprocess.Popen(["pkill", "-f", "tx.py"], stdout=subprocess.PIPE) | |||
184 | return 'USRP stopped' |
|
192 | return 'USRP stopped' | |
185 |
|
193 | |||
186 | if __name__ =='__main__': |
|
194 | if __name__ =='__main__': |
General Comments 0
You need to be logged in to leave comments.
Login now