@@ -0,0 +1,1 | |||
|
1 | {% extends "dev_conf.html" %} No newline at end of file |
@@ -0,0 +1,8 | |||
|
1 | {% extends "dev_conf_edit.html" %} | |
|
2 | {% load bootstrap3 %} | |
|
3 | {% load static %} | |
|
4 | {% load main_tags %} | |
|
5 | ||
|
6 | {% block extra-js%} | |
|
7 | ||
|
8 | {% endblock %} No newline at end of file |
@@ -10,11 +10,14 class JARSConfigurationForm(forms.ModelForm): | |||
|
10 | 10 | if instance and instance.pk: |
|
11 | 11 | devices = Device.objects.filter(device_type__name='jars') |
|
12 | 12 | |
|
13 | self.fields['experiment'].widget.attrs['readonly'] = True | |
|
14 |
self.fields['experiment'].widget. |
|
|
13 | if instance.experiment: | |
|
14 | self.fields['experiment'].widget.attrs['disabled'] = 'disabled' | |
|
15 | ||
|
16 | #self.fields['experiment'].widget.attrs['readonly'] = True | |
|
17 | #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)] | |
|
15 | 18 | |
|
16 | 19 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
17 | 20 | |
|
18 | 21 | class Meta: |
|
19 | 22 | model = JARSConfiguration |
|
20 | exclude = ('parameters', 'status') | |
|
23 | exclude = ('type', 'parameters', 'status') |
@@ -1,9 +1,26 | |||
|
1 | 1 | from django.db import models |
|
2 | 2 | from apps.main.models import Configuration |
|
3 | from django.core.validators import MinValueValidator, MaxValueValidator | |
|
3 | 4 | # Create your models here. |
|
4 | 5 | |
|
6 | ANSWER = ( | |
|
7 | (False, 'NO'), | |
|
8 | (True, 'YES'), | |
|
9 | ) | |
|
10 | ||
|
5 | 11 | class JARSConfiguration(Configuration): |
|
6 | 12 | |
|
13 | ADC_RESOLUTION = 8 | |
|
14 | PCI_DIO_BUSWIDTH = 32 | |
|
15 | ||
|
16 | cards_number = models.PositiveIntegerField(verbose_name='Number of Cards',validators=[MaxValueValidator(4)], default = 1) | |
|
17 | channels_number = models.PositiveIntegerField(verbose_name='Number of Channels',validators=[MinValueValidator(1), MaxValueValidator(8)], default = 1) | |
|
18 | rd_directory = models.CharField(verbose_name='Raw Data Directory', max_length=40, default='', blank=True, null=True) | |
|
19 | raw_data_blocks = models.PositiveIntegerField(verbose_name='Raw Data Blocks',validators=[MaxValueValidator(5000)], default=120) | |
|
20 | acq_profiles = models.PositiveIntegerField(verbose_name='Acquired Profiles',validators=[MaxValueValidator(5000)], default=400) | |
|
21 | profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block',validators=[MaxValueValidator(5000)], default=400) | |
|
22 | create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True) | |
|
23 | include_expname = models.BooleanField(verbose_name='Include Experiment Name in Directory', default=True) | |
|
7 | 24 | |
|
8 | 25 | class Meta: |
|
9 | 26 | db_table = 'jars_configurations' |
@@ -1,11 +1,6 | |||
|
1 | 1 | from django.conf.urls import url |
|
2 | 2 | |
|
3 | 3 | urlpatterns = ( |
|
4 |
|
|
|
5 |
url(r'^(?P<id_conf>-?\d+)/$', 'apps. |
|
|
6 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.main.views.dev_conf_edit', name='url_edit_jars_conf'), | |
|
7 | url(r'^(?P<id_conf>-?\d+)/write/$', 'apps.main.views.dev_conf_write', name='url_write_jars_conf'), | |
|
8 | url(r'^(?P<id_conf>-?\d+)/read/$', 'apps.main.views.dev_conf_read', name='url_read_jars_conf'), | |
|
9 | url(r'^(?P<id_conf>-?\d+)/import/$', 'apps.main.views.dev_conf_import', name='url_import_jars_conf'), | |
|
10 | url(r'^(?P<id_conf>-?\d+)/export/$', 'apps.main.views.dev_conf_export', name='url_export_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'), | |
|
11 | 6 | ) |
@@ -1,5 +1,6 | |||
|
1 | 1 | from django.shortcuts import render_to_response |
|
2 | 2 | from django.template import RequestContext |
|
3 | from django.shortcuts import redirect, render, get_object_or_404 | |
|
3 | 4 | |
|
4 | 5 | from apps.main.models import Device |
|
5 | 6 | from apps.main.views import sidebar |
@@ -8,28 +9,59 from .models import JARSConfiguration | |||
|
8 | 9 | from .forms import JARSConfigurationForm |
|
9 | 10 | # Create your views here. |
|
10 | 11 | |
|
11 |
def jars_conf |
|
|
12 | def jars_conf(request, id_conf): | |
|
12 | 13 | |
|
13 | if id: | |
|
14 | conf = JARSConfiguration.objects.get(pk=id) | |
|
15 | devices = Device.objects.filter(configuration__experiment=conf.experiment) | |
|
16 | devices = devices.values('configuration__id', 'device_type__name') | |
|
17 | for device in devices: | |
|
18 | if device['device_type__name']=='jars': | |
|
19 | device['active'] = 'active' | |
|
20 | # form = JARSConfigurationForm(instance=conf) | |
|
21 | # else: | |
|
22 | # form = JARSConfigurationForm() | |
|
14 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) | |
|
23 | 15 | |
|
24 | kwargs = { | |
|
25 | 'dev_conf': conf | |
|
26 |
|
|
|
16 | ip=conf.device.ip_address | |
|
17 | port=conf.device.port_address | |
|
18 | ||
|
19 | kwargs = {} | |
|
20 | ||
|
21 | kwargs['status'] = conf.device.get_status_display() | |
|
22 | ||
|
23 | ||
|
24 | kwargs['dev_conf'] = conf | |
|
25 | kwargs['dev_conf_keys'] = ['experiment', 'device', | |
|
26 | 'cards_number', 'channels_number', | |
|
27 | 'rd_directory', 'create_directory', | |
|
28 | 'include_expname', 'raw_data_blocks', | |
|
29 | 'acq_profiles', 'profiles_block'] | |
|
30 | ||
|
31 | kwargs['title'] = 'JARS Configuration' | |
|
32 | kwargs['suptitle'] = 'Details' | |
|
33 | ||
|
34 | kwargs['button'] = 'Edit Configuration' | |
|
35 | ||
|
36 | kwargs['no_play'] = True | |
|
27 | 37 | |
|
28 | 38 | ###### SIDEBAR ###### |
|
29 | kwargs.update(sidebar(conf)) | |
|
39 | kwargs.update(sidebar(conf=conf)) | |
|
40 | ||
|
41 | return render(request, 'jars_conf.html', kwargs) | |
|
42 | ||
|
43 | def jars_conf_edit(request, id_conf): | |
|
44 | ||
|
45 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) | |
|
46 | ||
|
47 | if request.method=='GET': | |
|
48 | form = JARSConfigurationForm(instance=conf) | |
|
49 | ||
|
50 | if request.method=='POST': | |
|
51 | form = JARSConfigurationForm(request.POST, instance=conf) | |
|
30 | 52 | |
|
31 | return render_to_response('jars.html', kwargs, context_instance=RequestContext(request)) | |
|
53 | if form.is_valid(): | |
|
54 | conf = form.save(commit=False) | |
|
32 | 55 | |
|
56 | return redirect('url_jars_conf', id_conf=conf.id) | |
|
33 | 57 | |
|
58 | ##ERRORS | |
|
34 | 59 | |
|
60 | kwargs = {} | |
|
61 | kwargs['id_dev'] = conf.id | |
|
62 | kwargs['form'] = form | |
|
63 | kwargs['title'] = 'Device Configuration' | |
|
64 | kwargs['suptitle'] = 'Edit' | |
|
65 | kwargs['button'] = 'Save' | |
|
35 | 66 | |
|
67 | return render(request, 'jars_conf_edit.html', kwargs) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now