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