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