@@ -0,0 +1,55 | |||
|
1 | {% extends "base.html" %} | |
|
2 | {% load bootstrap3 %} | |
|
3 | {% load static %} | |
|
4 | {% load main_tags %} | |
|
5 | ||
|
6 | {% block search-active %}active{% endblock %} | |
|
7 | ||
|
8 | {% block content-title %}{{title}}{% endblock %} | |
|
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |
|
10 | ||
|
11 | {% block content %} | |
|
12 | ||
|
13 | {% block menu-actions %} | |
|
14 | ||
|
15 | {% endblock %} | |
|
16 | ||
|
17 | <table class="table table-bordered"> | |
|
18 | ||
|
19 | {% for key in dev_conf_keys %} | |
|
20 | <tr> | |
|
21 | <th>{% get_verbose_field_name dev_conf key %}</th> | |
|
22 | <td>{{dev_conf|attr:key}}</td> | |
|
23 | </tr> | |
|
24 | {% endfor %} | |
|
25 | </table> | |
|
26 | {% if button %} | |
|
27 | <div class="pull-right"> | |
|
28 | <button type="button" class="btn btn-primary" id="back_button">{% if cancel %}{{cancel}}{% else %}Back{% endif %}</button> | |
|
29 | <button type="button" id="edit_button" class="btn btn-primary">{{edit_button}}</button> | |
|
30 | <button type="button" id="add_button" class="btn btn-primary">{{add_button}}</button> | |
|
31 | </div> | |
|
32 | {% endif %} | |
|
33 | ||
|
34 | {% block extra-content %} | |
|
35 | {% endblock %} | |
|
36 | ||
|
37 | {% endblock %} | |
|
38 | ||
|
39 | {% block sidebar%} | |
|
40 | {% include "sidebar_devices.html" %} | |
|
41 | {% endblock %} | |
|
42 | ||
|
43 | {% block extra-js%} | |
|
44 | <script type="text/javascript"> | |
|
45 | ||
|
46 | $("#edit_button").click(function() { | |
|
47 | document.location = "{% url 'url_edit_jars_filter' conf.id filter.id%}"; | |
|
48 | }); | |
|
49 | ||
|
50 | $("#back_button").click(function() { | |
|
51 | document.location = "{% url 'url_edit_jars_conf' conf.id%}"; | |
|
52 | }); | |
|
53 | ||
|
54 | </script> | |
|
55 | {% endblock %} No newline at end of file |
@@ -0,0 +1,17 | |||
|
1 | {% extends "dev_conf_edit.html" %} | |
|
2 | {% load bootstrap3 %} | |
|
3 | {% load static %} | |
|
4 | {% load main_tags %} | |
|
5 | ||
|
6 | {% block content %} | |
|
7 | <form class="form" method="post"> | |
|
8 | {% csrf_token %} | |
|
9 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
|
10 | <div style="clear: both;"></div> | |
|
11 | <br> | |
|
12 | <div class="pull-right"> | |
|
13 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button> | |
|
14 | <button type="submit" class="btn btn-primary">{{button}}</button> | |
|
15 | </div> | |
|
16 | </form> | |
|
17 | {% endblock %} No newline at end of file |
@@ -1,31 +1,41 | |||
|
1 | 1 | from django import forms |
|
2 | 2 | from apps.main.models import Device, Experiment |
|
3 | from .models import JARSConfiguration | |
|
3 | from .models import JARSConfiguration, JARSfilter | |
|
4 | 4 | from .widgets import SpectralWidget |
|
5 | 5 | |
|
6 | 6 | class JARSConfigurationForm(forms.ModelForm): |
|
7 | 7 | def __init__(self, *args, **kwargs): |
|
8 | 8 | super(JARSConfigurationForm, self).__init__(*args, **kwargs) |
|
9 | 9 | instance = getattr(self, 'instance', None) |
|
10 | 10 | |
|
11 | 11 | if instance and instance.pk: |
|
12 | 12 | devices = Device.objects.filter(device_type__name='jars') |
|
13 | 13 | |
|
14 | 14 | if instance.experiment: |
|
15 | 15 | experiments = Experiment.objects.filter(pk=instance.experiment.id) |
|
16 | 16 | self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments] |
|
17 | 17 | |
|
18 | 18 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
19 | 19 | #self.fields['spectral'].widget = SpectralWidget() |
|
20 | 20 | self.fields['spectral'].widget = SpectralWidget() |
|
21 | 21 | #-------------JARS Configuration needs an Experiment----------------- |
|
22 | 22 | def clean(self): |
|
23 | 23 | cleaned_data = super(JARSConfigurationForm, self).clean() |
|
24 | 24 | experiment = cleaned_data.get('experiment') |
|
25 | 25 | if experiment == None: |
|
26 | 26 | msg = "Error: Jars Configuration needs an Experiment" |
|
27 | 27 | self.add_error('experiment', msg) |
|
28 | 28 | |
|
29 | 29 | class Meta: |
|
30 | 30 | model = JARSConfiguration |
|
31 | 31 | exclude = ('type', 'parameters', 'status') |
|
32 | ||
|
33 | ||
|
34 | class JARSfilterForm(forms.ModelForm): | |
|
35 | def __init__(self, *args, **kwargs): | |
|
36 | super(JARSfilterForm, self).__init__(*args, **kwargs) | |
|
37 | instance = getattr(self, 'instance', None) | |
|
38 | ||
|
39 | class Meta: | |
|
40 | model = JARSfilter | |
|
41 | exclude = ('type', 'parameters', 'status') No newline at end of file |
@@ -1,99 +1,99 | |||
|
1 | 1 | from django.db import models |
|
2 | 2 | from apps.main.models import Configuration |
|
3 | 3 | from django.core.validators import MinValueValidator, MaxValueValidator |
|
4 | 4 | |
|
5 | 5 | from apps.rc.models import RCConfiguration |
|
6 | 6 | # Create your models here. |
|
7 | 7 | |
|
8 | 8 | EXPERIMENT_TYPE = ( |
|
9 | 9 | (0, 'RAW_DATA'), |
|
10 | 10 | (1, 'PDATA'), |
|
11 | 11 | ) |
|
12 | 12 | |
|
13 | 13 | DATA_TYPE = ( |
|
14 | 14 | (0, 'SHORT'), |
|
15 | 15 | (1, 'FLOAT'), |
|
16 | 16 | ) |
|
17 | 17 | |
|
18 | 18 | class JARSfilter(models.Model): |
|
19 | 19 | |
|
20 | 20 | name = models.CharField(max_length=60, unique=True, default='') |
|
21 | 21 | clock = models.FloatField(verbose_name='Clock Input (MHz)',validators=[MinValueValidator(5), MaxValueValidator(75)], null=True, default=60) |
|
22 | 22 | mult = models.PositiveIntegerField(verbose_name='Multiplier',validators=[MinValueValidator(1), MaxValueValidator(20)], default=5) |
|
23 | 23 | fch = models.DecimalField(verbose_name='Frequency (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, null=True, default=49.9200) |
|
24 | 24 | filter_fir = models.PositiveIntegerField(verbose_name='FIR Filter',validators=[MinValueValidator(1), MaxValueValidator(20)], default = 6) |
|
25 | 25 | filter_2 = models.PositiveIntegerField(verbose_name='Filter 2',validators=[MinValueValidator(1), MaxValueValidator(20)], default = 10) |
|
26 | 26 | filter_5 = models.PositiveIntegerField(verbose_name='Filter 5',validators=[MinValueValidator(1), MaxValueValidator(20)], default = 1) |
|
27 | 27 | speed = models.PositiveIntegerField(verbose_name='Speed',validators=[MinValueValidator(0), MaxValueValidator(100000)], default = 0) |
|
28 | 28 | |
|
29 | 29 | class Meta: |
|
30 | 30 | db_table = 'jars_filters' |
|
31 | 31 | #ordering = ['channel'] |
|
32 | 32 | |
|
33 | 33 | |
|
34 | 34 | class JARSConfiguration(Configuration): |
|
35 | 35 | |
|
36 | 36 | ADC_RESOLUTION = 8 |
|
37 | 37 | PCI_DIO_BUSWIDTH = 32 |
|
38 | 38 | HEADER_VERSION = 1103 |
|
39 | 39 | BEGIN_ON_START = True |
|
40 | 40 | REFRESH_RATE = 1 |
|
41 | 41 | |
|
42 | 42 | rc = models.ForeignKey(RCConfiguration, on_delete=models.CASCADE, null=True) |
|
43 | 43 | exp_type = models.PositiveIntegerField(verbose_name='Experiment Type', choices=EXPERIMENT_TYPE, default=0) |
|
44 | 44 | cards_number = models.PositiveIntegerField(verbose_name='Number of Cards', validators=[MinValueValidator(1), MaxValueValidator(4)], default = 1) |
|
45 | 45 | channels_number = models.PositiveIntegerField(verbose_name='Number of Channels', validators=[MinValueValidator(1), MaxValueValidator(8)], default = 5) |
|
46 | 46 | channels = models.CharField(verbose_name='Channels', max_length=15, default = '1,2,3,4,5') |
|
47 | 47 | rd_directory = models.CharField(verbose_name='Raw Data Directory', max_length=40, default='', blank=True, null=True) |
|
48 | 48 | raw_data_blocks = models.PositiveIntegerField(verbose_name='Raw Data Blocks', validators=[MaxValueValidator(5000)], default=120) |
|
49 | 49 | data_type = models.PositiveIntegerField(verbose_name='Data Type', choices=DATA_TYPE, default=0) |
|
50 | 50 | acq_profiles = models.PositiveIntegerField(verbose_name='Acquired Profiles', validators=[MaxValueValidator(5000)], default=400) |
|
51 | 51 | profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400) |
|
52 | 52 | fftpoints = models.PositiveIntegerField(verbose_name='FFT Points',default=16) |
|
53 | 53 | incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default=30) |
|
54 |
filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True |
|
|
54 | filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True) | |
|
55 | 55 | spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], default=1) |
|
56 | 56 | spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0, 0],') |
|
57 | 57 | create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True) |
|
58 | 58 | include_expname = models.BooleanField(verbose_name='Experiment Name in Directory', default=True) |
|
59 | 59 | acq_link = models.BooleanField(verbose_name='Acquisition Link', default=True) |
|
60 | 60 | view_raw_data = models.BooleanField(verbose_name='View Raw Data', default=True) |
|
61 | 61 | save_ch_dc = models.BooleanField(verbose_name='Save Channels DC', default=True) |
|
62 | 62 | |
|
63 | 63 | class Meta: |
|
64 | 64 | db_table = 'jars_configurations' |
|
65 | 65 | |
|
66 | 66 | def parms_to_dict(self): |
|
67 | 67 | |
|
68 | 68 | parameters = {} |
|
69 | 69 | |
|
70 | 70 | parameters['name'] = self.name |
|
71 | 71 | parameters['rc'] = self.rc.name |
|
72 | 72 | parameters['exp_type'] = self.exp_type |
|
73 | 73 | parameters['cards_number'] = self.cards_number |
|
74 | 74 | parameters['channels_number'] = self.channels_number |
|
75 | 75 | parameters['channels'] = self.channels |
|
76 | 76 | parameters['rd_directory'] = self.rd_directory |
|
77 | 77 | parameters['raw_data_blocks'] = self.raw_data_blocks |
|
78 | 78 | parameters['data_type'] = self.data_type |
|
79 | 79 | parameters['acq_profiles'] = self.acq_profiles |
|
80 | 80 | parameters['profiles_block'] = self.profiles_block |
|
81 | 81 | parameters['filter'] = self.filter.name |
|
82 | 82 | parameters['create_directory'] = bool(self.create_directory) |
|
83 | 83 | parameters['include_expname'] = bool(self.include_expname) |
|
84 | 84 | parameters['acq_link'] = bool(self.acq_link) |
|
85 | 85 | parameters['view_raw_data'] = bool(self.view_raw_data) |
|
86 | 86 | |
|
87 | 87 | return parameters |
|
88 | 88 | |
|
89 | 89 | def dict_to_parms(self, parameters): |
|
90 | 90 | return |
|
91 | 91 | |
|
92 | 92 | def status_device(self): |
|
93 | 93 | return |
|
94 | 94 | |
|
95 | 95 | def read_device(self): |
|
96 | 96 | return |
|
97 | 97 | |
|
98 | 98 | def write_device(self): |
|
99 | 99 | return No newline at end of file |
@@ -1,22 +1,28 | |||
|
1 | 1 | {% extends "dev_conf_edit.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 | 6 | {% block content %} |
|
7 | 7 | <form class="form" method="post"> |
|
8 | 8 | {% csrf_token %} |
|
9 | 9 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
10 | 10 | <div style="clear: both;"></div> |
|
11 | 11 | <br> |
|
12 | 12 | <div class="pull-right"> |
|
13 |
<button type="button" class="btn btn-primary" id="bt_ |
|
|
13 | <button type="button" class="btn btn-primary" id="bt_view_filter">View Filter</button> | |
|
14 | 14 | <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button> |
|
15 | 15 | <button type="submit" class="btn btn-primary">{{button}}</button> |
|
16 | 16 | </div> |
|
17 | 17 | </form> |
|
18 | 18 | {% endblock %} |
|
19 | 19 | |
|
20 | 20 | {% block extra-js%} |
|
21 | 21 | <script src="{% static 'js/jars.js' %}"></script> |
|
22 | ||
|
23 | <script type="text/javascript"> | |
|
24 | $("#bt_view_filter").click(function() { | |
|
25 | document.location = "{% url 'url_jars_filter' id_dev filter_id%}"; | |
|
26 | }); | |
|
27 | </script> | |
|
22 | 28 | {% endblock %} No newline at end of file |
@@ -1,6 +1,8 | |||
|
1 | 1 | from django.conf.urls import url |
|
2 | 2 | |
|
3 | 3 | urlpatterns = ( |
|
4 | 4 | url(r'^(?P<id_conf>-?\d+)/$', 'apps.jars.views.jars_conf', name='url_jars_conf'), |
|
5 | 5 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.jars.views.jars_conf_edit', name='url_edit_jars_conf'), |
|
6 | url(r'^(?P<conf_id>-?\d+)/view_filter/(?P<filter_id>-?\d+)/$', 'apps.jars.views.view_filter', name='url_jars_filter'), | |
|
7 | url(r'^(?P<conf_id>-?\d+)/view_filter/(?P<filter_id>-?\d+)/edit$', 'apps.jars.views.edit_filter', name='url_edit_jars_filter'), | |
|
6 | 8 | ) |
@@ -1,67 +1,119 | |||
|
1 | 1 | from django.shortcuts import render_to_response |
|
2 | 2 | from django.template import RequestContext |
|
3 | 3 | from django.shortcuts import redirect, render, get_object_or_404 |
|
4 | from django.contrib import messages | |
|
4 | 5 | |
|
5 | 6 | from apps.main.models import Device |
|
6 | 7 | from apps.main.views import sidebar |
|
7 | 8 | |
|
8 | from .models import JARSConfiguration | |
|
9 | from .forms import JARSConfigurationForm | |
|
9 | from .models import JARSConfiguration, JARSfilter | |
|
10 | from .forms import JARSConfigurationForm, JARSfilterForm | |
|
10 | 11 | # Create your views here. |
|
11 | 12 | |
|
12 | 13 | def jars_conf(request, id_conf): |
|
13 | 14 | |
|
14 | 15 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) |
|
15 | 16 | |
|
16 | 17 | ip=conf.device.ip_address |
|
17 | 18 | port=conf.device.port_address |
|
18 | 19 | |
|
19 | 20 | kwargs = {} |
|
20 | ||
|
21 | 21 | kwargs['status'] = conf.device.get_status_display() |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | kwargs['dev_conf'] = conf |
|
25 | 25 | kwargs['dev_conf_keys'] = ['experiment', 'device', |
|
26 | 26 | 'cards_number', 'channels_number', |
|
27 | 27 | 'rd_directory', 'create_directory', |
|
28 | 28 | 'include_expname', 'raw_data_blocks', |
|
29 | 29 | 'acq_profiles', 'profiles_block', 'filter'] |
|
30 | 30 | |
|
31 | 31 | kwargs['title'] = 'JARS Configuration' |
|
32 | 32 | kwargs['suptitle'] = 'Details' |
|
33 | 33 | |
|
34 | 34 | kwargs['button'] = 'Edit Configuration' |
|
35 | 35 | |
|
36 | 36 | kwargs['no_play'] = True |
|
37 | 37 | |
|
38 | 38 | ###### SIDEBAR ###### |
|
39 | 39 | kwargs.update(sidebar(conf=conf)) |
|
40 | 40 | |
|
41 | 41 | return render(request, 'jars_conf.html', kwargs) |
|
42 | 42 | |
|
43 | 43 | def jars_conf_edit(request, id_conf): |
|
44 | 44 | |
|
45 | 45 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) |
|
46 | 46 | |
|
47 | 47 | if request.method=='GET': |
|
48 | 48 | form = JARSConfigurationForm(instance=conf) |
|
49 | 49 | |
|
50 | 50 | if request.method=='POST': |
|
51 | 51 | form = JARSConfigurationForm(request.POST, instance=conf) |
|
52 | 52 | |
|
53 | 53 | if form.is_valid(): |
|
54 | 54 | conf = form.save(commit=False) |
|
55 | 55 | conf.save() |
|
56 | 56 | return redirect('url_jars_conf', id_conf=conf.id) |
|
57 | 57 | |
|
58 | 58 | ##ERRORS |
|
59 | 59 | |
|
60 | 60 | kwargs = {} |
|
61 | ||
|
62 | kwargs['filter_id'] = conf.filter.id | |
|
61 | 63 | kwargs['id_dev'] = conf.id |
|
62 | 64 | kwargs['form'] = form |
|
63 | 65 | kwargs['title'] = 'Device Configuration' |
|
64 | 66 | kwargs['suptitle'] = 'Edit' |
|
65 | 67 | kwargs['button'] = 'Save' |
|
66 | 68 | |
|
67 | 69 | return render(request, 'jars_conf_edit.html', kwargs) |
|
70 | ||
|
71 | def view_filter(request, conf_id, filter_id): | |
|
72 | ||
|
73 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |
|
74 | filter = get_object_or_404(JARSfilter, pk=filter_id) | |
|
75 | ||
|
76 | kwargs = {} | |
|
77 | kwargs['conf'] = conf | |
|
78 | kwargs['filter'] = filter | |
|
79 | kwargs['dev_conf'] = filter | |
|
80 | kwargs['dev_conf_keys'] = ['name', 'clock', | |
|
81 | 'mult', 'fch', | |
|
82 | 'filter_fir', 'filter_2', | |
|
83 | 'filter_5', 'speed'] | |
|
84 | ||
|
85 | kwargs['title'] = 'Filter View' | |
|
86 | kwargs['suptitle'] = 'Details' | |
|
87 | kwargs['button'] = 'SI' | |
|
88 | kwargs['edit_button'] = 'Edit Filter' | |
|
89 | kwargs['add_button'] = 'Add Filter' | |
|
90 | ||
|
91 | return render(request, 'jars_filter.html', kwargs) | |
|
92 | ||
|
93 | def edit_filter(request, conf_id, filter_id): | |
|
94 | ||
|
95 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |
|
96 | ||
|
97 | if filter_id: | |
|
98 | filter = get_object_or_404(JARSfilter, pk=filter_id) | |
|
99 | ||
|
100 | if request.method=='GET': | |
|
101 | form = JARSfilterForm(instance=filter) | |
|
102 | ||
|
103 | if request.method=='POST': | |
|
104 | #form = JARSfilterForm(request.POST) | |
|
105 | form = JARSfilterForm(request.POST, instance=filter) | |
|
106 | if form.is_valid(): | |
|
107 | form.save() | |
|
108 | messages.success(request, 'JARS Filter successfully updated') | |
|
109 | return redirect('url_jars_filter', conf.id, filter.id) | |
|
110 | ||
|
111 | kwargs = {} | |
|
112 | kwargs['form'] = form | |
|
113 | kwargs['title'] = conf.name | |
|
114 | kwargs['suptitle'] = 'Edit Filter' | |
|
115 | kwargs['button'] = 'Save' | |
|
116 | # kwargs['previous'] = conf.get_absolute_url_edit() | |
|
117 | kwargs['dev_conf'] = conf | |
|
118 | ||
|
119 | return render(request, 'jars_filter_edit.html', kwargs) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now