@@ -745,6 +745,18 class ABSBeam(models.Model): | |||||
745 |
|
745 | |||
746 | return self |
|
746 | return self | |
747 |
|
747 | |||
|
748 | def set_activebeam(self): | |||
|
749 | """ | |||
|
750 | This function change de active beam of ABS Configuration | |||
|
751 | """ | |||
|
752 | conf = self.abs_conf | |||
|
753 | active_beam = {} | |||
|
754 | active_beam['active_beam'] = self.id | |||
|
755 | conf.active_beam = json.dumps(active_beam) | |||
|
756 | conf.save() | |||
|
757 | ||||
|
758 | return | |||
|
759 | ||||
748 |
|
760 | |||
749 |
|
761 | |||
750 | def module_6bits(self, module): |
|
762 | def module_6bits(self, module): |
@@ -469,7 +469,7 | |||||
469 |
|
469 | |||
470 | {% if active_beam.id != beam.id %} |
|
470 | {% if active_beam.id != beam.id %} | |
471 | <div style="vertical-align: top; display:inline-block;"> |
|
471 | <div style="vertical-align: top; display:inline-block;"> | |
472 | <button style="" id="sendbeam" type="button" class="btn btn-default"> |
|
472 | <button style="" id="send_beam{{forloop.counter}}" type="button" class="btn btn-default"> | |
473 | <span class="glyphicon glyphicon-export" aria-hidden="true"></span> |
|
473 | <span class="glyphicon glyphicon-export" aria-hidden="true"></span> | |
474 | Change Beam</button> |
|
474 | Change Beam</button> | |
475 | </div> |
|
475 | </div> | |
@@ -516,6 +516,11 | |||||
516 | <script> |
|
516 | <script> | |
517 | $(document).ready(function() { |
|
517 | $(document).ready(function() { | |
518 |
|
518 | |||
|
519 | {% for beam in beams %} | |||
|
520 | $("#send_beam{{forloop.counter}}").click(function() { | |||
|
521 | document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}"; | |||
|
522 | }); | |||
|
523 | {%endfor%} | |||
519 |
|
524 | |||
520 | }); |
|
525 | }); | |
521 | </script> |
|
526 | </script> |
@@ -8,6 +8,7 urlpatterns = ( | |||||
8 | #url(r'^(?P<id_conf>-?\d+)/read/$', views.dev_conf_read, name='url_read_abs_conf'), |
|
8 | #url(r'^(?P<id_conf>-?\d+)/read/$', views.dev_conf_read, name='url_read_abs_conf'), | |
9 | #url(r'^(?P<id_conf>-?\d+)/import/$', views.dev_conf_import, name='url_import_abs_conf'), |
|
9 | #url(r'^(?P<id_conf>-?\d+)/import/$', views.dev_conf_import, name='url_import_abs_conf'), | |
10 | #url(r'^(?P<id_conf>-?\d+)/export/$', views.dev_conf_export, name='url_export_abs_conf'), |
|
10 | #url(r'^(?P<id_conf>-?\d+)/export/$', views.dev_conf_export, name='url_export_abs_conf'), | |
|
11 | url(r'^(?P<id_conf>-?\d+)/change_beam/(?P<id_beam>-?\d+)/$', views.send_beam, name='url_send_beam'), | |||
11 | url(r'^(?P<id_conf>-?\d+)/plot/$', views.plot_patterns, name='url_plot_abs_patterns'), |
|
12 | url(r'^(?P<id_conf>-?\d+)/plot/$', views.plot_patterns, name='url_plot_abs_patterns'), | |
12 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/$', views.plot_patterns, name='url_plot_abs_patterns'), |
|
13 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/$', views.plot_patterns, name='url_plot_abs_patterns'), | |
13 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/(?P<antenna>[\w\-]+)/pattern.png$', views.plot_pattern, name='url_plot_beam'), |
|
14 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/(?P<antenna>[\w\-]+)/pattern.png$', views.plot_pattern, name='url_plot_beam'), |
@@ -4,6 +4,7 from django.shortcuts import redirect, render, get_object_or_404 | |||||
4 | from django.contrib import messages |
|
4 | from django.contrib import messages | |
5 | from django.conf import settings |
|
5 | from django.conf import settings | |
6 | from django.http import HttpResponse |
|
6 | from django.http import HttpResponse | |
|
7 | from django.core.urlresolvers import reverse | |||
7 |
|
8 | |||
8 | from datetime import datetime |
|
9 | from datetime import datetime | |
9 | from time import sleep |
|
10 | from time import sleep | |
@@ -207,6 +208,25 def abs_conf_edit(request, id_conf): | |||||
207 | return render(request, 'abs_conf_edit.html', kwargs) |
|
208 | return render(request, 'abs_conf_edit.html', kwargs) | |
208 |
|
209 | |||
209 |
|
210 | |||
|
211 | def send_beam(request, id_conf, id_beam): | |||
|
212 | ||||
|
213 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) | |||
|
214 | beam = get_object_or_404(ABSBeam, pk=id_beam) | |||
|
215 | beams_list = ABSBeam.objects.filter(abs_conf=conf) | |||
|
216 | #To set this beam as an Active Beam | |||
|
217 | beam.set_activebeam() | |||
|
218 | #To send beam position to abs-modules | |||
|
219 | i = 0 | |||
|
220 | for b in beams_list: | |||
|
221 | if b.id == int(id_beam): | |||
|
222 | break | |||
|
223 | else: | |||
|
224 | i += 1 | |||
|
225 | beam_pos = i + 1 #Estandarizar | |||
|
226 | print 'Position: ',beam_pos | |||
|
227 | conf.send_beam_num(beam_pos) | |||
|
228 | ||||
|
229 | return redirect('url_abs_conf', conf.id) | |||
210 |
|
230 | |||
211 |
|
231 | |||
212 | def add_beam(request, id_conf): |
|
232 | def add_beam(request, id_conf): |
General Comments 0
You need to be logged in to leave comments.
Login now