@@ -2,8 +2,7 | |||
|
2 | 2 | |
|
3 | 3 | The Integrated Radar System (SIR) is a web application that allows the configuration of the radar devices as required by the experiment, |
|
4 | 4 | This app allows the creation of Campaigns, Experiment and Device Configurations. |
|
5 | For the python3.0 update please check the requeriments vrsion for each package. It depends on the python 3.7 or 3.8 version. | |
|
6 | Special attention with the bokeh version. | |
|
5 | For the python3.0 update please check the requeriments vrsion for each package. It depends on the python 3.7 or 3.8 version. Special attention with the bokeh version. | |
|
7 | 6 | For more information visit: http://jro-dev.igp.gob.pe:3000/projects/sistema-integrado-de-radar/wiki |
|
8 | 7 | |
|
9 | 8 | ## Installation |
@@ -21,7 +21,7 from .forms import ABSConfigurationForm, ABSBeamEditForm, ABSBeamAddForm, ABSImp | |||
|
21 | 21 | |
|
22 | 22 | from .utils.overJroShow import overJroShow |
|
23 | 23 | #from .utils.OverJRO import OverJRO |
|
24 |
# |
|
|
24 | #Create your views here. | |
|
25 | 25 | import json, ast |
|
26 | 26 | |
|
27 | 27 | |
@@ -307,13 +307,13 def add_beam(request, id_conf): | |||
|
307 | 307 | beam_data = get_values_from_form(request.POST) |
|
308 | 308 | |
|
309 | 309 | new_beam = ABSBeam( |
|
310 | name = beam_data['name'], | |
|
311 | antenna = json.dumps(beam_data['antenna']), | |
|
310 | name = beam_data['name'], | |
|
311 | antenna = json.dumps(beam_data['antenna']), | |
|
312 | 312 | abs_conf = conf, |
|
313 | tx = json.dumps(beam_data['tx']), | |
|
314 | rx = json.dumps(beam_data['rx']), | |
|
315 | ues = json.dumps(beam_data['ues']), | |
|
316 | only_rx = json.dumps(beam_data['only_rx']) | |
|
313 | tx = json.dumps(beam_data['tx']), | |
|
314 | rx = json.dumps(beam_data['rx']), | |
|
315 | ues = json.dumps(beam_data['ues']), | |
|
316 | only_rx = json.dumps(beam_data['only_rx']) | |
|
317 | 317 | ) |
|
318 | 318 | new_beam.save() |
|
319 | 319 | messages.success(request, 'Beam: "%s" has been added.' % new_beam.name) |
@@ -323,17 +323,16 def add_beam(request, id_conf): | |||
|
323 | 323 | ###### SIDEBAR ###### |
|
324 | 324 | kwargs = {} |
|
325 | 325 | |
|
326 | #kwargs['dev_conf'] = conf.device | |
|
327 | #kwargs['id_dev'] = conf.device | |
|
328 | kwargs['id_conf'] = conf.id | |
|
329 |
kwargs['f |
|
|
330 | kwargs['title'] = 'ABS Beams' | |
|
331 |
kwargs[' |
|
|
332 |
kwargs[' |
|
|
326 | #kwargs['dev_conf'] = conf.device | |
|
327 | #kwargs['id_dev'] = conf.device | |
|
328 | #kwargs['previous'] = conf.get_absolute_url_edit() | |
|
329 | kwargs['id_conf'] = conf.id | |
|
330 | kwargs['form'] = form | |
|
331 | kwargs['title'] = 'ABS Beams' | |
|
332 | kwargs['suptitle'] = 'Add Beam' | |
|
333 | kwargs['button'] = 'Add' | |
|
333 | 334 | kwargs['no_sidebar'] = True |
|
334 | ||
|
335 | #kwargs['previous'] = conf.get_absolute_url_edit() | |
|
336 | kwargs['edit'] = True | |
|
335 | kwargs['edit'] = True | |
|
337 | 336 | |
|
338 | 337 | return render(request, 'abs_add_beam.html', kwargs) |
|
339 | 338 |
@@ -10,7 +10,7 def create_choices_from_model(model, filter_id=None): | |||
|
10 | 10 | |
|
11 | 11 | #instance = globals()[model] |
|
12 | 12 | choices = model.objects.all().values_list('pk', 'name') |
|
13 | choices = add_empty_choice(choices) | |
|
13 | choices = add_empty_choice(choices,label="New Choice") | |
|
14 | 14 | return choices |
|
15 | 15 | |
|
16 | 16 | class JARSConfigurationForm(forms.ModelForm): |
@@ -37,7 +37,7 class JARSFilterForm(forms.ModelForm): | |||
|
37 | 37 | |
|
38 | 38 | if 'initial' in kwargs: |
|
39 | 39 | self.fields['filter_template'] = forms.ChoiceField( |
|
40 | choices=create_choices_from_model(JARSFilter), | |
|
40 | choices = create_choices_from_model(JARSFilter), | |
|
41 | 41 | initial = kwargs['initial']['id'] |
|
42 | 42 | ) |
|
43 | 43 | # self.fields['name'].initial = kwargs['initial']['id'] |
@@ -65,6 +65,15 class JARSFilterForm(forms.ModelForm): | |||
|
65 | 65 | model = JARSFilter |
|
66 | 66 | exclude = ('name', ) |
|
67 | 67 | |
|
68 | class JARSFilterFormNew(forms.ModelForm): | |
|
69 | def __init__(self, *args, **kwargs): | |
|
70 | super(JARSFilterFormNew, self).__init__(*args, **kwargs) | |
|
71 | ||
|
72 | self.fields['f_decimal'].widget.attrs['readonly'] = True | |
|
73 | ||
|
74 | class Meta: | |
|
75 | model = JARSFilter | |
|
76 | exclude = () | |
|
68 | 77 | |
|
69 | 78 | class ExtFileField(forms.FileField): |
|
70 | 79 | """ |
@@ -32,32 +32,32 FILTER = '{"id":1, "clock": 60, "multiplier": 5, "frequency": 49.92, "f_decimal" | |||
|
32 | 32 | |
|
33 | 33 | class JARSFilter(models.Model): |
|
34 | 34 | |
|
35 | JARS_NBITS = 32 | |
|
35 | JARS_NBITS = 32 | |
|
36 | 36 | |
|
37 | name = models.CharField(verbose_name='Name', max_length=60, unique=True, default='') | |
|
38 | clock = models.FloatField(verbose_name='Clock In (MHz)', validators=[ | |
|
37 | name = models.CharField(verbose_name='Name', max_length=60, unique=True, default='') | |
|
38 | clock = models.FloatField(verbose_name='Clock In (MHz)', validators=[ | |
|
39 | 39 | MinValueValidator(5), MaxValueValidator(75)], null=True, default=60) |
|
40 | multiplier = models.PositiveIntegerField(verbose_name='Multiplier', validators=[ | |
|
40 | multiplier = models.PositiveIntegerField(verbose_name='Multiplier', validators=[ | |
|
41 | 41 | MinValueValidator(1), MaxValueValidator(20)], default=5) |
|
42 | frequency = models.FloatField(verbose_name='Frequency (MHz)', validators=[ | |
|
42 | frequency = models.FloatField(verbose_name='Frequency (MHz)', validators=[ | |
|
43 | 43 | MaxValueValidator(150)], null=True, default=49.9200) |
|
44 | f_decimal = models.BigIntegerField(verbose_name='Frequency (Decimal)', validators=[ | |
|
44 | f_decimal = models.BigIntegerField(verbose_name='Frequency (Decimal)', validators=[ | |
|
45 | 45 | MinValueValidator(-9223372036854775808), MaxValueValidator(2**JARS_NBITS-1)], null=True, default=721554505) |
|
46 | cic_2 = models.PositiveIntegerField(verbose_name='CIC2', validators=[ | |
|
46 | cic_2 = models.PositiveIntegerField(verbose_name='CIC2', validators=[ | |
|
47 | 47 | MinValueValidator(2), MaxValueValidator(100)], default=10) |
|
48 | 48 | scale_cic_2 = models.PositiveIntegerField(verbose_name='Scale CIC2', validators=[ |
|
49 | 49 | MinValueValidator(0), MaxValueValidator(6)], default=1) |
|
50 | cic_5 = models.PositiveIntegerField(verbose_name='CIC5', validators=[ | |
|
50 | cic_5 = models.PositiveIntegerField(verbose_name='CIC5', validators=[ | |
|
51 | 51 | MinValueValidator(1), MaxValueValidator(100)], default=1) |
|
52 | 52 | scale_cic_5 = models.PositiveIntegerField(verbose_name='Scale CIC5', validators=[ |
|
53 | 53 | MinValueValidator(0), MaxValueValidator(20)], default=5) |
|
54 | fir = models.PositiveIntegerField(verbose_name='FIR', validators=[ | |
|
54 | fir = models.PositiveIntegerField(verbose_name='FIR', validators=[ | |
|
55 | 55 | MinValueValidator(1), MaxValueValidator(100)], default=6) |
|
56 | scale_fir = models.PositiveIntegerField(verbose_name='Scale FIR', validators=[ | |
|
56 | scale_fir = models.PositiveIntegerField(verbose_name='Scale FIR', validators=[ | |
|
57 | 57 | MinValueValidator(0), MaxValueValidator(7)], default=3) |
|
58 | 58 | number_taps = models.PositiveIntegerField(verbose_name='Number of taps', validators=[ |
|
59 | 59 | MinValueValidator(1), MaxValueValidator(256)], default=4) |
|
60 | taps = models.CharField(verbose_name='Taps', max_length=1600, default='0') | |
|
60 | taps = models.CharField(verbose_name='Taps', max_length=1600, default='0') | |
|
61 | 61 | |
|
62 | 62 | class Meta: |
|
63 | 63 | db_table = 'jars_filters' |
@@ -67,7 +67,7 class JARSFilter(models.Model): | |||
|
67 | 67 | |
|
68 | 68 | def jsonify(self): |
|
69 | 69 | |
|
70 | data = {} | |
|
70 | data = {} | |
|
71 | 71 | ignored = () |
|
72 | 72 | |
|
73 | 73 | for field in self._meta.fields: |
@@ -81,82 +81,97 class JARSFilter(models.Model): | |||
|
81 | 81 | |
|
82 | 82 | parameters = {} |
|
83 | 83 | |
|
84 | parameters['name'] = self.name | |
|
85 | parameters['clock'] = float(self.clock) | |
|
84 | parameters['name'] = self.name | |
|
85 | parameters['clock'] = float(self.clock) | |
|
86 | 86 | parameters['multiplier'] = int(self.multiplier) |
|
87 | parameters['frequency'] = float(self.frequency) | |
|
88 | parameters['f_decimal'] = int(self.frequency) | |
|
89 | parameters['fir'] = int(self.fir) | |
|
90 | parameters['cic_2'] = int(self.cic_2) | |
|
91 | parameters['cic_5'] = int(self.cic_5) | |
|
87 | parameters['frequency'] = float(self.frequency) | |
|
88 | parameters['f_decimal'] = int(self.frequency) | |
|
89 | parameters['fir'] = int(self.fir) | |
|
90 | parameters['cic_2'] = int(self.cic_2) | |
|
91 | parameters['cic_5'] = int(self.cic_5) | |
|
92 | 92 | |
|
93 | 93 | return parameters |
|
94 | 94 | |
|
95 | 95 | def dict_to_parms(self, parameters): |
|
96 | 96 | |
|
97 | self.name = parameters['name'] | |
|
98 | self.clock = parameters['clock'] | |
|
97 | self.name = parameters['name'] | |
|
98 | self.clock = parameters['clock'] | |
|
99 | 99 | self.multiplier = parameters['multiplier'] |
|
100 | self.frequency = parameters['frequency'] | |
|
101 | self.f_decimal = parameters['f_decimal'] | |
|
102 | self.fir = parameters['fir'] | |
|
103 | self.cic_2 = parameters['cic_2'] | |
|
104 | self.cic_5 = parameters['cic_5'] | |
|
105 | ||
|
100 | self.frequency = parameters['frequency'] | |
|
101 | self.f_decimal = parameters['f_decimal'] | |
|
102 | self.fir = parameters['fir'] | |
|
103 | self.cic_2 = parameters['cic_2'] | |
|
104 | self.cic_5 = parameters['cic_5'] | |
|
105 | ||
|
106 | def dict_to_parms_new(self, parameters): | |
|
107 | ||
|
108 | self.name = parameters['name'] | |
|
109 | self.clock = parameters['clock'] | |
|
110 | self.multiplier = parameters['multiplier'] | |
|
111 | self.frequency = parameters['frequency'] | |
|
112 | self.f_decimal = parameters['f_decimal'] | |
|
113 | self.fir = parameters['fir'] | |
|
114 | self.cic_2 = parameters['cic_2'] | |
|
115 | self.cic_5 = parameters['cic_5'] | |
|
116 | self.scale_fir = parameters['scale_fir'] | |
|
117 | self.scale_cic_2 = parameters['scale_cic_2'] | |
|
118 | self.scale_cic_5 = parameters['scale_cic_5'] | |
|
119 | self.number_taps = parameters['number_taps'] | |
|
120 | self.taps = parameters['taps'] | |
|
106 | 121 | |
|
107 | 122 | class JARSConfiguration(Configuration): |
|
108 | 123 | |
|
109 | ADC_RESOLUTION = 8 | |
|
124 | ADC_RESOLUTION = 8 | |
|
110 | 125 | PCI_DIO_BUSWIDTH = 32 |
|
111 | HEADER_VERSION = 1103 | |
|
112 | BEGIN_ON_START = True | |
|
113 | REFRESH_RATE = 1 | |
|
126 | HEADER_VERSION = 1103 | |
|
127 | BEGIN_ON_START = True | |
|
128 | REFRESH_RATE = 1 | |
|
114 | 129 | |
|
115 | exp_type = models.PositiveIntegerField( | |
|
130 | exp_type = models.PositiveIntegerField( | |
|
116 | 131 | verbose_name='Experiment Type', choices=EXPERIMENT_TYPE, default=0) |
|
117 | cards_number = models.PositiveIntegerField(verbose_name='Number of Cards', validators=[ | |
|
132 | cards_number = models.PositiveIntegerField(verbose_name='Number of Cards', validators=[ | |
|
118 | 133 | MinValueValidator(1), MaxValueValidator(4)], default=1) |
|
119 | channels_number = models.PositiveIntegerField(verbose_name='Number of Channels', validators=[ | |
|
134 | channels_number = models.PositiveIntegerField(verbose_name='Number of Channels', validators=[ | |
|
120 | 135 | MinValueValidator(1), MaxValueValidator(8)], default=5) |
|
121 | channels = models.CharField( | |
|
136 | channels = models.CharField( | |
|
122 | 137 | verbose_name='Channels', max_length=15, default='1,2,3,4,5') |
|
123 | data_type = models.PositiveIntegerField( | |
|
138 | data_type = models.PositiveIntegerField( | |
|
124 | 139 | verbose_name='Data Type', choices=DATA_TYPE, default=0) |
|
125 | raw_data_blocks = models.PositiveIntegerField( | |
|
140 | raw_data_blocks = models.PositiveIntegerField( | |
|
126 | 141 | verbose_name='Raw Data Blocks', validators=[MaxValueValidator(5000)], default=60) |
|
127 | profiles_block = models.PositiveIntegerField( | |
|
142 | profiles_block = models.PositiveIntegerField( | |
|
128 | 143 | verbose_name='Profiles Per Block', default=400) |
|
129 | acq_profiles = models.PositiveIntegerField( | |
|
144 | acq_profiles = models.PositiveIntegerField( | |
|
130 | 145 | verbose_name='Acquired Profiles', default=400) |
|
131 | ftp_interval = models.PositiveIntegerField( | |
|
146 | ftp_interval = models.PositiveIntegerField( | |
|
132 | 147 | verbose_name='FTP Interval', default=60) |
|
133 | fftpoints = models.PositiveIntegerField( | |
|
148 | fftpoints = models.PositiveIntegerField( | |
|
134 | 149 | verbose_name='FFT Points', default=16) |
|
135 | cohe_integr_str = models.PositiveIntegerField( | |
|
150 | cohe_integr_str = models.PositiveIntegerField( | |
|
136 | 151 | verbose_name='Coh. Int. Stride', validators=[MinValueValidator(1)], default=30) |
|
137 | cohe_integr = models.PositiveIntegerField( | |
|
152 | cohe_integr = models.PositiveIntegerField( | |
|
138 | 153 | verbose_name='Coherent Integrations', validators=[MinValueValidator(1)], default=30) |
|
139 | incohe_integr = models.PositiveIntegerField( | |
|
154 | incohe_integr = models.PositiveIntegerField( | |
|
140 | 155 | verbose_name='Incoherent Integrations', validators=[MinValueValidator(1)], default=30) |
|
141 | decode_data = models.PositiveIntegerField( | |
|
156 | decode_data = models.PositiveIntegerField( | |
|
142 | 157 | verbose_name='Decode Data', choices=DECODE_TYPE, default=0) |
|
143 | post_coh_int = models.BooleanField( | |
|
158 | post_coh_int = models.BooleanField( | |
|
144 | 159 | verbose_name='Post Coherent Integration', default=False) |
|
145 | spectral_number = models.PositiveIntegerField( | |
|
160 | spectral_number = models.PositiveIntegerField( | |
|
146 | 161 | verbose_name='# Spectral Combinations', validators=[MinValueValidator(1)], default=1) |
|
147 | spectral = models.CharField( | |
|
162 | spectral = models.CharField( | |
|
148 | 163 | verbose_name='Combinations', max_length=5000, default='[0, 0],') |
|
149 | 164 | create_directory = models.BooleanField( |
|
150 | 165 | verbose_name='Create Directory Per Day', default=True) |
|
151 | include_expname = models.BooleanField( | |
|
166 | include_expname = models.BooleanField( | |
|
152 | 167 | verbose_name='Experiment Name in Directory', default=False) |
|
153 | 168 | #view_raw_data = models.BooleanField(verbose_name='View Raw Data', default=True) |
|
154 | save_ch_dc = models.BooleanField( | |
|
169 | save_ch_dc = models.BooleanField( | |
|
155 | 170 | verbose_name='Save Channels DC', default=True) |
|
156 | save_data = models.BooleanField(verbose_name='Save Data', default=True) | |
|
157 | filter_parms = models.CharField( | |
|
171 | save_data = models.BooleanField(verbose_name='Save Data', default=True) | |
|
172 | filter_parms = models.CharField( | |
|
158 | 173 | max_length=10000, default=FILTER) |
|
159 | filter = models.ForeignKey( | |
|
174 | filter = models.ForeignKey( | |
|
160 | 175 | 'JARSFilter', verbose_name='Filter', null=True, blank=True, on_delete=models.CASCADE) |
|
161 | 176 | |
|
162 | 177 | class Meta: |
@@ -164,11 +179,11 class JARSConfiguration(Configuration): | |||
|
164 | 179 | |
|
165 | 180 | def filter_resolution(self): |
|
166 | 181 | filter_parms = json.loads(self.filter_parms) |
|
167 | clock = float(filter_parms['clock']) | |
|
168 | cic_2 = filter_parms['cic_2'] | |
|
169 | cic_5 = filter_parms['cic_5'] | |
|
170 | fir = filter_parms['fir'] | |
|
171 | resolution = round((clock/(cic_2*cic_5*fir)), 2) | |
|
182 | clock = float(filter_parms['clock']) | |
|
183 | cic_2 = filter_parms['cic_2'] | |
|
184 | cic_5 = filter_parms['cic_5'] | |
|
185 | fir = filter_parms['fir'] | |
|
186 | resolution = round((clock/(cic_2*cic_5*fir)), 2) | |
|
172 | 187 | return resolution |
|
173 | 188 | |
|
174 | 189 | def dict_to_parms(self, params, id=None): |
@@ -183,31 +198,31 class JARSConfiguration(Configuration): | |||
|
183 | 198 | self.exp_type = data['exp_type'] |
|
184 | 199 | #----PDATA---- |
|
185 | 200 | if self.exp_type == 1: |
|
186 | self.incohe_integr = data['incohe_integr'] | |
|
201 | self.incohe_integr = data['incohe_integr'] | |
|
187 | 202 | self.spectral_number = data['spectral_number'] |
|
188 | self.spectral = data['spectral'] | |
|
189 | self.fftpoints = data['fftpoints'] | |
|
190 | self.save_ch_dc = data['save_ch_dc'] | |
|
203 | self.spectral = data['spectral'] | |
|
204 | self.fftpoints = data['fftpoints'] | |
|
205 | self.save_ch_dc = data['save_ch_dc'] | |
|
191 | 206 | else: |
|
192 | 207 | self.raw_data_blocks = data['raw_data_blocks'] |
|
193 | 208 | #----PDATA---- |
|
194 | self.cards_number = data['cards_number'] | |
|
209 | self.cards_number = data['cards_number'] | |
|
195 | 210 | self.channels_number = data['channels_number'] |
|
196 | self.channels = data['channels'] | |
|
197 | self.data_type = data['data_type'] | |
|
198 | self.profiles_block = data['profiles_block'] | |
|
199 | self.acq_profiles = data['acq_profiles'] | |
|
200 | self.ftp_interval = data['ftp_interval'] | |
|
211 | self.channels = data['channels'] | |
|
212 | self.data_type = data['data_type'] | |
|
213 | self.profiles_block = data['profiles_block'] | |
|
214 | self.acq_profiles = data['acq_profiles'] | |
|
215 | self.ftp_interval = data['ftp_interval'] | |
|
201 | 216 | self.cohe_integr_str = data['cohe_integr_str'] |
|
202 | self.cohe_integr = data['cohe_integr'] | |
|
217 | self.cohe_integr = data['cohe_integr'] | |
|
203 | 218 | #----DECODE---- |
|
204 | self.decode_data = data['decode_data'] | |
|
219 | self.decode_data = data['decode_data'] | |
|
205 | 220 | self.post_coh_int = data['post_coh_int'] |
|
206 | 221 | #----DECODE---- |
|
207 | 222 | self.create_directory = data['create_directory'] |
|
208 | self.include_expname = data['include_expname'] | |
|
209 | self.save_data = data['save_data'] | |
|
210 | self.filter_parms = json.dumps(data['filter_parms']) | |
|
223 | self.include_expname = data['include_expname'] | |
|
224 | self.save_data = data['save_data'] | |
|
225 | self.filter_parms = json.dumps(data['filter_parms']) | |
|
211 | 226 | |
|
212 | 227 | self.save() |
|
213 | 228 | |
@@ -305,7 +320,7 class JARSConfiguration(Configuration): | |||
|
305 | 320 | return False |
|
306 | 321 | |
|
307 | 322 | data = self.experiment.parms_to_dict() |
|
308 | ||
|
323 | #print(data) | |
|
309 | 324 | for key in data['configurations']['allIds']: |
|
310 | 325 | if data['configurations']['byId'][key]['device_type'] in ('dds', 'cgs'): |
|
311 | 326 | data['configurations']['allIds'].remove(key) |
@@ -1,5 +1,5 | |||
|
1 | 1 | {% extends "base.html" %} |
|
2 |
{% load bootstrap |
|
|
2 | {% load bootstrap4 %} | |
|
3 | 3 | {% block mainactive %}active{% endblock %} |
|
4 | 4 | |
|
5 | 5 | {% block content-title %}Acquisition System{% endblock %} |
@@ -1,6 +1,6 | |||
|
1 | 1 | {% extends "dev_conf.html" %} |
|
2 | 2 | {% load static %} |
|
3 |
{% load bootstrap |
|
|
3 | {% load bootstrap4 %} | |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 | 6 | {% block extra-menu-actions %} |
@@ -1,5 +1,5 | |||
|
1 | 1 | {% extends "dev_conf_edit.html" %} |
|
2 |
{% load bootstrap |
|
|
2 | {% load bootstrap4 %} | |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
@@ -33,7 +33,10 | |||
|
33 | 33 | }); |
|
34 | 34 | |
|
35 | 35 | $("#id_filter_template").change(function () { |
|
36 | document.location = "{% url 'url_change_jars_filter' id_dev %}" + $("#id_filter_template").val(); | |
|
36 | if($("#id_filter_template").val()!=0) | |
|
37 | document.location = "{% url 'url_change_jars_filter' id_dev %}" + $("#id_filter_template").val(); | |
|
38 | else | |
|
39 | document.location = "{% url 'url_new_jars_filter' id_dev %}" | |
|
37 | 40 | }); |
|
38 | 41 | |
|
39 | 42 | </script> |
@@ -7,6 +7,7 urlpatterns = ( | |||
|
7 | 7 | path('<int:id_conf>/edit/', views.jars_conf_edit, name='url_edit_jars_conf'), |
|
8 | 8 | path('<int:conf_id>/change_filter/', views.change_filter, name='url_change_jars_filter'), |
|
9 | 9 | path('<int:conf_id>/change_filter/<int:filter_id>/', views.change_filter, name='url_change_jars_filter'), |
|
10 | path('<int:conf_id>/new_filter/', views.new_filter, name='url_new_jars_filter'), | |
|
10 | 11 | path('<int:conf_id>/import/', views.import_file, name='url_import_jars_conf'), |
|
11 | 12 | path('<int:conf_id>/read/', views.read_conf, name='url_read_jars_conf'), |
|
12 | 13 | path('<int:conf_id>/get_log/', views.get_log, name='url_get_jars_log'), |
@@ -8,7 +8,7 from apps.main.models import Device | |||
|
8 | 8 | from apps.main.views import sidebar |
|
9 | 9 | |
|
10 | 10 | from .models import JARSConfiguration, JARSFilter |
|
11 | from .forms import JARSConfigurationForm, JARSFilterForm, JARSImportForm | |
|
11 | from .forms import JARSConfigurationForm, JARSFilterForm, JARSImportForm,JARSFilterFormNew | |
|
12 | 12 | |
|
13 | 13 | import json |
|
14 | 14 | # Create your views here. |
@@ -20,19 +20,19 def jars_conf(request, id_conf): | |||
|
20 | 20 | filter_parms = json.loads(conf.filter_parms) |
|
21 | 21 | |
|
22 | 22 | kwargs = {} |
|
23 | kwargs['filter'] = filter_parms | |
|
24 | kwargs['filter_obj'] = JARSFilter.objects.get(pk=1) | |
|
23 | kwargs['filter'] = filter_parms | |
|
24 | kwargs['filter_obj'] = JARSFilter.objects.get(pk=1) | |
|
25 | 25 | kwargs['filter_keys'] = ['clock', 'multiplier', 'frequency', 'f_decimal', |
|
26 | 26 | 'cic_2', 'scale_cic_2', 'cic_5', 'scale_cic_5', 'fir', |
|
27 | 27 | 'scale_fir', 'number_taps', 'taps'] |
|
28 | 28 | |
|
29 | filter_resolution = conf.filter_resolution() | |
|
30 | kwargs['resolution'] = '{} (MHz)'.format(filter_resolution) | |
|
29 | filter_resolution = conf.filter_resolution() | |
|
30 | kwargs['resolution'] = '{} (MHz)'.format(filter_resolution) | |
|
31 | 31 | if filter_resolution < 1: |
|
32 | 32 | kwargs['resolution'] = '{} (kHz)'.format(filter_resolution*1000) |
|
33 | 33 | |
|
34 | kwargs['status'] = conf.device.get_status_display() | |
|
35 | kwargs['dev_conf'] = conf | |
|
34 | kwargs['status'] = conf.device.get_status_display() | |
|
35 | kwargs['dev_conf'] = conf | |
|
36 | 36 | kwargs['dev_conf_keys'] = ['cards_number', 'channels_number', 'channels', |
|
37 | 37 | 'ftp_interval', 'data_type','acq_profiles', |
|
38 | 38 | 'profiles_block', 'raw_data_blocks', 'ftp_interval', |
@@ -59,39 +59,38 def jars_conf(request, id_conf): | |||
|
59 | 59 | |
|
60 | 60 | def jars_conf_edit(request, id_conf): |
|
61 | 61 | |
|
62 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) | |
|
63 | ||
|
62 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) | |
|
64 | 63 | filter_parms = json.loads(conf.filter_parms) |
|
65 | 64 | |
|
66 | 65 | if request.method=='GET': |
|
67 | form = JARSConfigurationForm(instance=conf) | |
|
66 | form = JARSConfigurationForm(instance=conf) | |
|
68 | 67 | filter_form = JARSFilterForm(initial=filter_parms) |
|
69 | 68 | |
|
70 | 69 | if request.method=='POST': |
|
71 | form = JARSConfigurationForm(request.POST, instance=conf) | |
|
70 | form = JARSConfigurationForm(request.POST, instance=conf) | |
|
72 | 71 | filter_form = JARSFilterForm(request.POST) |
|
73 | 72 | |
|
74 | 73 | if filter_form.is_valid(): |
|
75 | jars_filter = filter_form.cleaned_data | |
|
74 | jars_filter = filter_form.cleaned_data | |
|
76 | 75 | jars_filter['id'] = request.POST['filter_template'] |
|
77 | 76 | else: |
|
78 | 77 | messages.error(request, filter_form.errors) |
|
79 | 78 | |
|
80 | 79 | if form.is_valid(): |
|
81 | conf = form.save(commit=False) | |
|
80 | conf = form.save(commit=False) | |
|
82 | 81 | conf.filter_parms = json.dumps(jars_filter) |
|
83 | 82 | conf.save() |
|
84 | 83 | return redirect('url_jars_conf', id_conf=conf.id) |
|
85 | 84 | |
|
86 | 85 | kwargs = {} |
|
87 | 86 | |
|
88 | kwargs['id_dev'] = conf.id | |
|
89 | kwargs['form'] = form | |
|
87 | kwargs['id_dev'] = conf.id | |
|
88 | kwargs['form'] = form | |
|
90 | 89 | kwargs['filter_form'] = filter_form |
|
91 | 90 | kwargs['filter_name'] = JARSFilter.objects.get(pk=filter_parms['id']).name |
|
92 | kwargs['title'] = 'Device Configuration' | |
|
93 | kwargs['suptitle'] = 'Edit' | |
|
94 | kwargs['button'] = 'Save' | |
|
91 | kwargs['title'] = 'Device Configuration' | |
|
92 | kwargs['suptitle'] = 'Edit' | |
|
93 | kwargs['button'] = 'Save' | |
|
95 | 94 | |
|
96 | 95 | return render(request, 'jars_conf_edit.html', kwargs) |
|
97 | 96 | |
@@ -114,10 +113,10 def import_file(request, conf_id): | |||
|
114 | 113 | form = JARSImportForm() |
|
115 | 114 | |
|
116 | 115 | kwargs = {} |
|
117 | kwargs['form'] = form | |
|
118 | kwargs['title'] = 'JARS Configuration' | |
|
116 | kwargs['form'] = form | |
|
117 | kwargs['title'] = 'JARS Configuration' | |
|
119 | 118 | kwargs['suptitle'] = 'Import file' |
|
120 | kwargs['button'] = 'Upload' | |
|
119 | kwargs['button'] = 'Upload' | |
|
121 | 120 | kwargs['previous'] = conf.get_absolute_url() |
|
122 | 121 | |
|
123 | 122 | return render(request, 'jars_import.html', kwargs) |
@@ -148,22 +147,50 def read_conf(request, conf_id): | |||
|
148 | 147 | messages.error(request, "Parameters could not be saved") |
|
149 | 148 | |
|
150 | 149 | kwargs = {} |
|
151 | kwargs['id_dev'] = conf.id | |
|
150 | kwargs['id_dev'] = conf.id | |
|
152 | 151 | kwargs['filter_id'] = conf.filter.id |
|
153 | kwargs['form'] = form | |
|
154 | kwargs['title'] = 'Device Configuration' | |
|
155 | kwargs['suptitle'] = 'Parameters read from device' | |
|
156 | kwargs['button'] = 'Save' | |
|
152 | kwargs['form'] = form | |
|
153 | kwargs['title'] = 'Device Configuration' | |
|
154 | kwargs['suptitle'] = 'Parameters read from device' | |
|
155 | kwargs['button'] = 'Save' | |
|
157 | 156 | |
|
158 | 157 | ###### SIDEBAR ###### |
|
159 | 158 | kwargs.update(sidebar(conf=conf)) |
|
160 | 159 | |
|
161 | 160 | return render(request, 'jars_conf_edit.html', kwargs) |
|
162 | 161 | |
|
162 | def new_filter(request, conf_id): | |
|
163 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |
|
164 | form = JARSFilterFormNew() | |
|
165 | ||
|
166 | if request.method=='POST': | |
|
167 | filter_form = JARSFilterFormNew(request.POST) | |
|
168 | ||
|
169 | if filter_form.is_valid(): | |
|
170 | jars_filter = filter_form.cleaned_data | |
|
171 | jars_filter['id'] = request.POST['name'] | |
|
172 | else: | |
|
173 | messages.error(request, filter_form.errors) | |
|
174 | ||
|
175 | #print(json.dumps(jars_filter)) | |
|
176 | jars_filter_obj = JARSFilter() | |
|
177 | jars_filter_obj.dict_to_parms_new(request.POST) | |
|
178 | jars_filter_obj.save() | |
|
179 | return redirect('url_edit_jars_conf', id_conf=conf.id) | |
|
180 | ||
|
181 | kwargs = {} | |
|
182 | kwargs['id_dev'] = conf.id | |
|
183 | kwargs['form'] = form | |
|
184 | kwargs['title'] = 'New JARS Filter' | |
|
185 | kwargs['suptitle'] = 'Parameters' | |
|
186 | kwargs['button'] = 'Save' | |
|
187 | ||
|
188 | return render(request, 'jars_new_filter.html', kwargs) | |
|
189 | ||
|
163 | 190 | def change_filter(request, conf_id, filter_id): |
|
164 | 191 | |
|
165 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |
|
166 | filter = get_object_or_404(JARSFilter, pk=filter_id) | |
|
192 | conf = get_object_or_404(JARSConfiguration, pk=conf_id) | |
|
193 | filter = get_object_or_404(JARSFilter, pk=filter_id) | |
|
167 | 194 | conf.filter_parms = json.dumps(filter.jsonify()) |
|
168 | 195 | conf.save() |
|
169 | 196 | |
@@ -184,7 +211,7 def get_log(request, conf_id): | |||
|
184 | 211 | messages.error(request, message) |
|
185 | 212 | return redirect('url_jars_conf', id_conf=conf.id) |
|
186 | 213 | except Exception as e: |
|
187 | message = 'Restarting Report.txt has been downloaded successfully.' | |
|
214 | message = 'Restarting Report.txt has been downloaded successfully.'+e | |
|
188 | 215 | |
|
189 | 216 | content = response |
|
190 | 217 | filename = 'Log_%s_%s.txt' %(conf.experiment.name, conf.experiment.id) |
@@ -10,8 +10,8 from django.utils.html import conditional_escape | |||
|
10 | 10 | |
|
11 | 11 | class SpectralWidget(forms.widgets.TextInput): |
|
12 | 12 | |
|
13 |
def render(self, |
|
|
14 | ||
|
13 | def render(self, name, value, attrs=None, renderer=None): | |
|
14 | label = name | |
|
15 | 15 | readonly = 'readonly' if attrs.get('readonly', False) else '' |
|
16 | 16 | name = attrs.get('name', label) |
|
17 | 17 | if value == None: |
@@ -638,6 +638,14 class Configuration(PolymorphicModel): | |||
|
638 | 638 | data['phaseA'] = dds_data.phase_to_binary(data['phaseA_degrees']) |
|
639 | 639 | data['phaseB'] = dds_data.phase_to_binary(data['phaseB_degrees']) |
|
640 | 640 | |
|
641 | elif self.device.device_type.name == 'dds_rest': | |
|
642 | data['frequencyA_Mhz'] = float(data['frequencyA_Mhz']) | |
|
643 | data['frequencyB_Mhz'] = float(data['frequencyB_Mhz']) | |
|
644 | data['phaseA'] = dds_data.phase_to_binary(data['phaseA_degrees']) | |
|
645 | data['phaseB'] = dds_data.phase_to_binary(data['phaseB_degrees']) | |
|
646 | data['delta_frequency_Mhz'] = float(data['delta_frequency_Mhz'] or 0.00) | |
|
647 | data['update_clock_Mhz'] = float(data['update_clock_Mhz'] or 0.00) | |
|
648 | data['ramp_rate_clock_Mhz'] = float(data['ramp_rate_clock_Mhz'] or 0.0) | |
|
641 | 649 | return data |
|
642 | 650 | |
|
643 | 651 | def clone(self, **kwargs): |
@@ -258,8 +258,6 class DefaultWidget(forms.widgets.TextInput): | |||
|
258 | 258 | else: |
|
259 | 259 | return mark_safe(html+script) |
|
260 | 260 | |
|
261 | ||
|
262 | ||
|
263 | 261 | return mark_safe(html) |
|
264 | 262 | |
|
265 | 263 |
@@ -132,11 +132,11 REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1') | |||
|
132 | 132 | REDIS_PORT = os.environ.get('REDIS_PORT', 6300) |
|
133 | 133 | |
|
134 | 134 | BROKER_TRANSPORT = 'redis' |
|
135 | BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) | |
|
135 | BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) | |
|
136 | 136 | |
|
137 | CELERY_RESULT_BACKEND = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) | |
|
138 | CELERY_BROKER_TRANSPORT = BROKER_URL | |
|
139 | CELERY_ACCEPT_CONTENT = ['application/json'] | |
|
140 | CELERY_TASK_SERIALIZER = 'json' | |
|
137 | CELERY_RESULT_BACKEND = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) | |
|
138 | CELERY_BROKER_TRANSPORT = BROKER_URL | |
|
139 | CELERY_ACCEPT_CONTENT = ['application/json'] | |
|
140 | CELERY_TASK_SERIALIZER = 'json' | |
|
141 | 141 | CELERY_RESULT_SERIALIZER = 'json' |
|
142 | CELERY_ENABLE_UTC = False | |
|
142 | CELERY_ENABLE_UTC = False |
General Comments 0
You need to be logged in to leave comments.
Login now