@@ -1,95 +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 |
|
|
|
22 |
|
|
|
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) | |
|
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) | |
|
25 | filter_2 = models.PositiveIntegerField(verbose_name='Filter 2',validators=[MinValueValidator(1), MaxValueValidator(20)], default = 10) | |
|
23 | 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) | |
|
24 | 28 | |
|
25 | 29 | class Meta: |
|
26 | 30 | db_table = 'jars_filters' |
|
27 | 31 | #ordering = ['channel'] |
|
28 | 32 | |
|
29 | 33 | |
|
30 | 34 | class JARSConfiguration(Configuration): |
|
31 | 35 | |
|
32 | 36 | ADC_RESOLUTION = 8 |
|
33 | 37 | PCI_DIO_BUSWIDTH = 32 |
|
34 | 38 | HEADER_VERSION = 1103 |
|
35 | 39 | BEGIN_ON_START = True |
|
36 | 40 | REFRESH_RATE = 1 |
|
37 | 41 | |
|
38 | 42 | rc = models.ForeignKey(RCConfiguration, on_delete=models.CASCADE, null=True) |
|
39 | 43 | exp_type = models.PositiveIntegerField(verbose_name='Experiment Type', choices=EXPERIMENT_TYPE, default=0) |
|
40 | 44 | cards_number = models.PositiveIntegerField(verbose_name='Number of Cards', validators=[MinValueValidator(1), MaxValueValidator(4)], default = 1) |
|
41 | 45 | channels_number = models.PositiveIntegerField(verbose_name='Number of Channels', validators=[MinValueValidator(1), MaxValueValidator(8)], default = 5) |
|
42 | 46 | channels = models.CharField(verbose_name='Channels', max_length=15, default = '1,2,3,4,5') |
|
43 | 47 | rd_directory = models.CharField(verbose_name='Raw Data Directory', max_length=40, default='', blank=True, null=True) |
|
44 | 48 | raw_data_blocks = models.PositiveIntegerField(verbose_name='Raw Data Blocks', validators=[MaxValueValidator(5000)], default=120) |
|
45 | 49 | data_type = models.PositiveIntegerField(verbose_name='Data Type', choices=DATA_TYPE, default=0) |
|
46 | 50 | acq_profiles = models.PositiveIntegerField(verbose_name='Acquired Profiles', validators=[MaxValueValidator(5000)], default=400) |
|
47 | 51 | profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400) |
|
48 | 52 | fftpoints = models.PositiveIntegerField(verbose_name='FFT Points',default=16) |
|
49 | 53 | incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default=30) |
|
50 | 54 | filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True, blank=True) |
|
51 | 55 | spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], default=1) |
|
52 | 56 | spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0, 0],') |
|
53 | 57 | create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True) |
|
54 | 58 | include_expname = models.BooleanField(verbose_name='Experiment Name in Directory', default=True) |
|
55 | 59 | acq_link = models.BooleanField(verbose_name='Acquisition Link', default=True) |
|
56 | 60 | view_raw_data = models.BooleanField(verbose_name='View Raw Data', default=True) |
|
57 | 61 | save_ch_dc = models.BooleanField(verbose_name='Save Channels DC', default=True) |
|
58 | 62 | |
|
59 | 63 | class Meta: |
|
60 | 64 | db_table = 'jars_configurations' |
|
61 | 65 | |
|
62 | 66 | def parms_to_dict(self): |
|
63 | 67 | |
|
64 | 68 | parameters = {} |
|
65 | 69 | |
|
66 | 70 | parameters['name'] = self.name |
|
67 | 71 | parameters['rc'] = self.rc.name |
|
68 | 72 | parameters['exp_type'] = self.exp_type |
|
69 | 73 | parameters['cards_number'] = self.cards_number |
|
70 | 74 | parameters['channels_number'] = self.channels_number |
|
71 | 75 | parameters['channels'] = self.channels |
|
72 | 76 | parameters['rd_directory'] = self.rd_directory |
|
73 | 77 | parameters['raw_data_blocks'] = self.raw_data_blocks |
|
74 | 78 | parameters['data_type'] = self.data_type |
|
75 | 79 | parameters['acq_profiles'] = self.acq_profiles |
|
76 | 80 | parameters['profiles_block'] = self.profiles_block |
|
77 | 81 | parameters['filter'] = self.filter.name |
|
78 | 82 | parameters['create_directory'] = bool(self.create_directory) |
|
79 | 83 | parameters['include_expname'] = bool(self.include_expname) |
|
80 | 84 | parameters['acq_link'] = bool(self.acq_link) |
|
81 | 85 | parameters['view_raw_data'] = bool(self.view_raw_data) |
|
82 | 86 | |
|
83 | 87 | return parameters |
|
84 | 88 | |
|
85 | 89 | def dict_to_parms(self, parameters): |
|
86 | 90 | return |
|
87 | 91 | |
|
88 | 92 | def status_device(self): |
|
89 | 93 | return |
|
90 | 94 | |
|
91 | 95 | def read_device(self): |
|
92 | 96 | return |
|
93 | 97 | |
|
94 | 98 | def write_device(self): |
|
95 | 99 | return No newline at end of file |
@@ -1,8 +1,22 | |||
|
1 | 1 | {% extends "dev_conf_edit.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 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" id="bt_add_line">See Filter</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> | |
|
16 | </div> | |
|
17 | </form> | |
|
18 | {% endblock %} | |
|
19 | ||
|
6 | 20 | {% block extra-js%} |
|
7 | 21 | <script src="{% static 'js/jars.js' %}"></script> |
|
8 | 22 | {% endblock %} No newline at end of file |
@@ -1,67 +1,67 | |||
|
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 | 4 | |
|
5 | 5 | from apps.main.models import Device |
|
6 | 6 | from apps.main.views import sidebar |
|
7 | 7 | |
|
8 | 8 | from .models import JARSConfiguration |
|
9 | 9 | from .forms import JARSConfigurationForm |
|
10 | 10 | # Create your views here. |
|
11 | 11 | |
|
12 | 12 | def jars_conf(request, id_conf): |
|
13 | 13 | |
|
14 | 14 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) |
|
15 | 15 | |
|
16 | 16 | ip=conf.device.ip_address |
|
17 | 17 | port=conf.device.port_address |
|
18 | 18 | |
|
19 | 19 | kwargs = {} |
|
20 | 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 | 'acq_profiles', 'profiles_block'] | |
|
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 | 61 | kwargs['id_dev'] = conf.id |
|
62 | 62 | kwargs['form'] = form |
|
63 | 63 | kwargs['title'] = 'Device Configuration' |
|
64 | 64 | kwargs['suptitle'] = 'Edit' |
|
65 | 65 | kwargs['button'] = 'Save' |
|
66 | 66 | |
|
67 | 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