@@ -1,10 +1,10 | |||
|
1 | 1 | REDIS_HOST=radarsys-redis |
|
2 | 2 | REDIS_PORT=6379 |
|
3 | POSTGRES_DB_NAME=radarsys | |
|
4 | 3 | POSTGRES_PORT_5432_TCP_ADDR=radarsys-postgres |
|
5 | 4 | POSTGRES_PORT_5432_TCP_PORT=5432 |
|
6 | POSTGRES_USER=docker | |
|
7 | POSTGRES_PASSWORD=docker | |
|
5 | DB_NAME=radarsys | |
|
6 | DB_USER=docker | |
|
7 | DB_PASSWORD=docker | |
|
8 | 8 | PGDATA=/var/lib/postgresql/data |
|
9 | 9 | LC_ALL=C.UTF-8 |
|
10 | 10 | TZ=America/Lima |
@@ -33,6 +33,7 | |||
|
33 | 33 | </span> |
|
34 | 34 | {% endblock %} |
|
35 | 35 | |
|
36 | {% block content-detail %} | |
|
36 | 37 | <table class="table table-bordered"> |
|
37 | 38 | <tr> |
|
38 | 39 | <th>Status</th> |
@@ -46,6 +47,7 | |||
|
46 | 47 | </tr> |
|
47 | 48 | {% endfor %} |
|
48 | 49 | </table> |
|
50 | {% endblock %} | |
|
49 | 51 | |
|
50 | 52 | {% block extra-content %} |
|
51 | 53 | {% endblock %} |
@@ -36,7 +36,7 from apps.cgs.models import CGSConfiguration | |||
|
36 | 36 | from apps.jars.models import JARSConfiguration, EXPERIMENT_TYPE |
|
37 | 37 | from apps.usrp.models import USRPConfiguration |
|
38 | 38 | from apps.abs.models import ABSConfiguration |
|
39 | from apps.rc.models import RCConfiguration, RCLine, RCLineType | |
|
39 | from apps.rc.models import RCConfiguration, RCLine, RCLineType, RCClock | |
|
40 | 40 | from apps.dds.models import DDSConfiguration |
|
41 | 41 | |
|
42 | 42 | from radarsys.celery import app |
@@ -1368,6 +1368,9 def dev_conf_new(request, id_exp=0, id_dev=0): | |||
|
1368 | 1368 | l.pk) for l in new_lines if l.get_name() == ref_line.get_name()][0] |
|
1369 | 1369 | line.params = json.dumps(line_params) |
|
1370 | 1370 | line.save() |
|
1371 | elif conf.device.device_type.name == 'rc': | |
|
1372 | clk = RCClock(rc_configuration=conf) | |
|
1373 | clk.save() | |
|
1371 | 1374 | |
|
1372 | 1375 | return redirect('url_dev_conf', id_conf=conf.pk) |
|
1373 | 1376 |
@@ -1,5 +1,5 | |||
|
1 | 1 | from django.contrib import admin |
|
2 | from .models import RCConfiguration, RCLine, RCLineType, RCLineCode | |
|
2 | from .models import RCConfiguration, RCLine, RCLineType, RCLineCode, RCClock | |
|
3 | 3 | |
|
4 | 4 | # Register your models here. |
|
5 | 5 | |
@@ -7,3 +7,4 admin.site.register(RCConfiguration) | |||
|
7 | 7 | admin.site.register(RCLine) |
|
8 | 8 | admin.site.register(RCLineType) |
|
9 | 9 | admin.site.register(RCLineCode) |
|
10 | admin.site.register(RCClock) |
@@ -5,7 +5,7 from django import forms | |||
|
5 | 5 | from django.utils.safestring import mark_safe |
|
6 | 6 | from apps.main.models import Device |
|
7 | 7 | from apps.main.forms import add_empty_choice |
|
8 | from .models import RCConfiguration, RCLine, RCLineType, RCLineCode | |
|
8 | from .models import RCConfiguration, RCLine, RCLineType, RCLineCode, RCClock | |
|
9 | 9 | from .widgets import KmUnitWidget, KmUnitHzWidget, KmUnitDcWidget, UnitKmWidget, DefaultWidget, CodesWidget, HiddenWidget, HCheckboxSelectMultiple |
|
10 | 10 | |
|
11 | 11 | def create_choices_from_model(model, conf_id, all_choice=False): |
@@ -78,7 +78,7 class RCConfigurationForm(forms.ModelForm): | |||
|
78 | 78 | |
|
79 | 79 | class Meta: |
|
80 | 80 | model = RCConfiguration |
|
81 | exclude = ('type', 'parameters', 'status', 'total_units', 'mix', 'author', 'hash') | |
|
81 | exclude = ('type', 'parameters', 'status', 'total_units', 'mix', 'author', 'hash', 'clock_in') | |
|
82 | 82 | |
|
83 | 83 | def clean(self): |
|
84 | 84 | form_data = super(RCConfigurationForm, self).clean() |
@@ -382,3 +382,34 class RCLineCodesForm(forms.ModelForm): | |||
|
382 | 382 | class Meta: |
|
383 | 383 | model = RCLineCode |
|
384 | 384 | exclude = ('name',) |
|
385 | ||
|
386 | class RCClockForm(forms.ModelForm): | |
|
387 | ||
|
388 | def __init__(self, *args, **kwargs): | |
|
389 | super(RCClockForm, self).__init__(*args, **kwargs) | |
|
390 | ||
|
391 | instance = getattr(self, 'instance', None) | |
|
392 | ||
|
393 | if instance is not None and instance.mode: | |
|
394 | self.fields['multiplier'].widget.attrs['readonly'] = True | |
|
395 | self.fields['divisor'].widget.attrs['readonly'] = True | |
|
396 | self.fields['reference'].widget.attrs['readonly'] = True | |
|
397 | ||
|
398 | ||
|
399 | class Meta: | |
|
400 | model = RCClock | |
|
401 | exclude = ('rc_configuration',) | |
|
402 | ||
|
403 | def clean(self): | |
|
404 | ||
|
405 | form_data = self.cleaned_data | |
|
406 | ||
|
407 | if form_data['mode'] is True and float(form_data['frequency']) not in (60., 55.): | |
|
408 | self.add_error('frequency', 'Only 60 and 55 are valid values in auto mode') | |
|
409 | elif form_data['mode'] is False: | |
|
410 | if form_data['reference']==0 and not 24<=form_data['multiplier']<=36: | |
|
411 | self.add_error('multiplier', 'For 25MHz, valid values are between 24 and 36') | |
|
412 | elif form_data['reference']==1 and not 60<=form_data['multiplier']<=90: | |
|
413 | self.add_error('multiplier', 'For 10MHz, valid values are between 60 and 90') | |
|
414 | ||
|
415 | return form_data No newline at end of file |
@@ -547,6 +547,20 class RCConfiguration(Configuration): | |||
|
547 | 547 | |
|
548 | 548 | def write_device(self, raw=False): |
|
549 | 549 | |
|
550 | if not raw: | |
|
551 | clock = RCClock.objects.get(rc_configuration=self) | |
|
552 | if clock.mode: | |
|
553 | data = {'default': clock.frequency} | |
|
554 | else: | |
|
555 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} | |
|
556 | payload = self.request('setfreq', 'post', data=json.dumps(data)) | |
|
557 | if payload['command'] <> 'ok': | |
|
558 | self.message = 'RC write: {}'.format(payload['command']) | |
|
559 | else: | |
|
560 | self.message = payload['programming'] | |
|
561 | if payload['programming'] == 'fail': | |
|
562 | self.message = 'RC write: error programming CGS chip' | |
|
563 | ||
|
550 | 564 | values = [] |
|
551 | 565 | for pulse, delay in zip(self.get_pulses(), self.get_delays()): |
|
552 | 566 | while delay>65536: |
@@ -1002,3 +1016,12 class RCLine(models.Model): | |||
|
1002 | 1016 | Y = [(int(ipp*x+before+delay[x%delays]+sync), int(ipp*x+width+before+delay[x%delays]+after+sync)) for x in range(ntx)] |
|
1003 | 1017 | |
|
1004 | 1018 | return Y |
|
1019 | ||
|
1020 | class RCClock(models.Model): | |
|
1021 | ||
|
1022 | rc_configuration = models.ForeignKey(RCConfiguration, on_delete=models.CASCADE) | |
|
1023 | mode = models.BooleanField(default=True, choices=((True, 'Auto'), (False, 'Manual'))) | |
|
1024 | multiplier = models.PositiveIntegerField(default=60) | |
|
1025 | divisor = models.PositiveIntegerField(default=10) | |
|
1026 | reference = models.PositiveSmallIntegerField(default=1, choices=((0, 'Internal (25MHz)'), (1, 'External (10MHz)'))) | |
|
1027 | frequency = models.FloatField(default=60.0) No newline at end of file |
@@ -107,14 +107,55 function updateWindows(label) { | |||
|
107 | 107 | } |
|
108 | 108 | |
|
109 | 109 | } |
|
110 | ||
|
111 | $("#id_clock_in").change(function() { | |
|
112 | $("#id_clock").val(parseFloat($('#id_clock_in').val())/parseFloat($('#id_clock_divider').val())); | |
|
110 | ||
|
111 | function updateClock() { | |
|
112 | if ($("#id_reference").val()==0){ | |
|
113 | var ref = 25; | |
|
114 | }else{ | |
|
115 | var ref = 10; | |
|
116 | } | |
|
117 | $("#id_frequency").val(parseFloat($('#id_multiplier').val())*ref/parseFloat($('#id_divisor').val())); | |
|
118 | $("#id_clock").val(parseFloat($('#id_frequency').val())/parseFloat($('#id_clock_divider').val())); | |
|
119 | updateUnits(); | |
|
120 | } | |
|
121 | ||
|
122 | ||
|
123 | $("#id_frequency").change(function() { | |
|
124 | $("#id_clock").val(parseFloat($('#id_frequency').val())/parseFloat($('#id_clock_divider').val())); | |
|
113 | 125 | updateUnits(); |
|
114 | 126 | }); |
|
115 | 127 | |
|
116 | 128 | $("#id_clock_divider").change(function() { |
|
117 |
$("#id_clock").val(parseFloat($('#id_ |
|
|
129 | $("#id_clock").val(parseFloat($('#id_frequency').val())/parseFloat($('#id_clock_divider').val())); | |
|
118 | 130 | updateUnits(); |
|
119 | 131 | }); |
|
120 | 132 | |
|
133 | $("#id_mode").change(function() { | |
|
134 | if ($("#id_mode").val()=="False"){ | |
|
135 | $('#id_multiplier').removeProp("readonly"); | |
|
136 | $('#id_divisor').removeProp("readonly"); | |
|
137 | $('#id_reference').removeProp("readonly"); | |
|
138 | $('#id_frequency').prop("readonly", true); | |
|
139 | updateClock(); | |
|
140 | }else{ | |
|
141 | $('#id_frequency').removeProp("readonly"); | |
|
142 | $('#id_multiplier').prop("readonly", true); | |
|
143 | $('#id_divisor').prop("readonly", true); | |
|
144 | $('#id_reference').prop("readonly", true); | |
|
145 | $('#id_reference').val(1) | |
|
146 | $('#id_frequency').val(60); | |
|
147 | $("#id_clock").val(parseFloat($('#id_frequency').val())/parseFloat($('#id_clock_divider').val())); | |
|
148 | } | |
|
149 | }); | |
|
150 | ||
|
151 | $("#id_multiplier").change(function() { | |
|
152 | updateClock(); | |
|
153 | }); | |
|
154 | ||
|
155 | $("#id_divisor").change(function() { | |
|
156 | updateClock(); | |
|
157 | }); | |
|
158 | ||
|
159 | $("#id_reference").change(function() { | |
|
160 | updateClock(); | |
|
161 | }); No newline at end of file |
@@ -7,6 +7,40 | |||
|
7 | 7 | <li><a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank"><span class="glyphicon glyphicon-picture" aria-hidden="true"></span> View Pulses </a></li> |
|
8 | 8 | {% endblock %} |
|
9 | 9 | |
|
10 | {% block content-detail %} | |
|
11 | ||
|
12 | <h2>Clock</h2> | |
|
13 | <table class="table table-bordered"> | |
|
14 | <tr> | |
|
15 | <th>Mode</th> | |
|
16 | <td>{{clock.get_mode_display}}</td> | |
|
17 | </tr> | |
|
18 | <tr> | |
|
19 | <th>Reference</th> | |
|
20 | <td>{{clock.get_reference_display}}</td> | |
|
21 | </tr> | |
|
22 | <tr> | |
|
23 | <th>Frequency</th> | |
|
24 | <td>{{clock.frequency}}</td> | |
|
25 | </tr> | |
|
26 | </table> | |
|
27 | <div class="clearfix"></div> | |
|
28 | <h2>RC</h2> | |
|
29 | <table class="table table-bordered"> | |
|
30 | <tr> | |
|
31 | <th>Status</th> | |
|
32 | <td class="text-{{dev_conf.device.status_color}}"><strong>{{dev_conf.device.get_status_display}}</strong></td> | |
|
33 | </tr> | |
|
34 | ||
|
35 | {% for key in dev_conf_keys %} | |
|
36 | <tr> | |
|
37 | <th>{% get_verbose_field_name dev_conf key %}</th> | |
|
38 | <td>{{dev_conf|attr:key}}</td> | |
|
39 | </tr> | |
|
40 | {% endfor %} | |
|
41 | </table> | |
|
42 | {% endblock %} | |
|
43 | ||
|
10 | 44 | {% block extra-content %} |
|
11 | 45 | |
|
12 | 46 | <div class="clearfix"></div> |
@@ -14,9 +14,13 | |||
|
14 | 14 | {% block content %} |
|
15 | 15 | <form class="form" method="post"> |
|
16 | 16 | {% csrf_token %} |
|
17 | <h2>Clock</h2> | |
|
18 | {% bootstrap_form form_clock layout='horizontal' size='medium' %} | |
|
19 | <div style="clear: both;"></div> | |
|
20 | <h2>RC</h2> | |
|
17 | 21 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
18 | 22 | <div style="clear: both;"></div> |
|
19 |
<h2>RC Lines</h2> |
|
|
23 | <h2>RC Lines</h2> | |
|
20 | 24 | <div class="panel-group" id="div_lines" role="tablist" aria-multiselectable="true"> |
|
21 | 25 | {% include "rc_lines.html" %} |
|
22 | 26 | </div> |
@@ -9,8 +9,8 from django.contrib.auth.decorators import login_required | |||
|
9 | 9 | from apps.main.models import Experiment, Device |
|
10 | 10 | from apps.main.views import sidebar |
|
11 | 11 | |
|
12 | from .models import RCConfiguration, RCLine, RCLineType, RCLineCode | |
|
13 | from .forms import RCConfigurationForm, RCLineForm, RCLineViewForm, RCLineEditForm, RCImportForm, RCLineCodesForm | |
|
12 | from .models import RCConfiguration, RCLine, RCLineType, RCLineCode, RCClock | |
|
13 | from .forms import RCConfigurationForm, RCLineForm, RCLineViewForm, RCLineEditForm, RCImportForm, RCLineCodesForm, RCClockForm | |
|
14 | 14 | |
|
15 | 15 | |
|
16 | 16 | def conf(request, conf_id): |
@@ -18,6 +18,7 def conf(request, conf_id): | |||
|
18 | 18 | conf = get_object_or_404(RCConfiguration, pk=conf_id) |
|
19 | 19 | |
|
20 | 20 | lines = RCLine.objects.filter(rc_configuration=conf).order_by('channel') |
|
21 | clk = RCClock.objects.get(rc_configuration=conf) | |
|
21 | 22 | |
|
22 | 23 | for line in lines: |
|
23 | 24 | params = json.loads(line.params) |
@@ -26,9 +27,10 def conf(request, conf_id): | |||
|
26 | 27 | line.subforms = [RCLineViewForm(extra_fields=fields, line=line, subform=True) for fields in params['params']] |
|
27 | 28 | |
|
28 | 29 | kwargs = {} |
|
30 | kwargs['clock'] = clk | |
|
29 | 31 | kwargs['dev_conf'] = conf |
|
30 | 32 | kwargs['rc_lines'] = lines |
|
31 |
kwargs['dev_conf_keys'] = ['ipp_unit', 'ntx', ' |
|
|
33 | kwargs['dev_conf_keys'] = ['ipp_unit', 'ntx', 'clock_divider', 'clock', | |
|
32 | 34 | 'time_before', 'time_after', 'sync', 'sampling_reference', |
|
33 | 35 | 'control_tx', 'control_sw'] |
|
34 | 36 | |
@@ -45,7 +47,7 def conf(request, conf_id): | |||
|
45 | 47 | def conf_edit(request, conf_id): |
|
46 | 48 | |
|
47 | 49 | conf = get_object_or_404(RCConfiguration, pk=conf_id) |
|
48 | ||
|
50 | clock = RCClock.objects.get(rc_configuration=conf) | |
|
49 | 51 | lines = RCLine.objects.filter(rc_configuration=conf).order_by('channel') |
|
50 | 52 | |
|
51 | 53 | for line in lines: |
@@ -60,11 +62,13 def conf_edit(request, conf_id): | |||
|
60 | 62 | if request.method=='GET': |
|
61 | 63 | |
|
62 | 64 | form = RCConfigurationForm(instance=conf) |
|
65 | form_clock = RCClockForm(instance=clock) | |
|
63 | 66 | |
|
64 | 67 | elif request.method=='POST': |
|
65 | 68 | |
|
66 | 69 | line_data = {} |
|
67 | 70 | conf_data = {} |
|
71 | clock_data = {} | |
|
68 | 72 | extras = [] |
|
69 | 73 | |
|
70 | 74 | #classified post fields |
@@ -73,7 +77,10 def conf_edit(request, conf_id): | |||
|
73 | 77 | continue |
|
74 | 78 | |
|
75 | 79 | if label.count('|')==0: |
|
76 | conf_data[label] = value | |
|
80 | if label in ('mode', 'multiplier', 'divisor', 'reference', 'frequency'): | |
|
81 | clock_data[label] = value | |
|
82 | else: | |
|
83 | conf_data[label] = value | |
|
77 | 84 | continue |
|
78 | 85 | |
|
79 | 86 | elif label.split('|')[0]!='-1': |
@@ -91,10 +98,12 def conf_edit(request, conf_id): | |||
|
91 | 98 | line_data[pk] = {name:value} |
|
92 | 99 | |
|
93 | 100 | #update conf |
|
101 | ||
|
102 | form_clock = RCClockForm(clock_data, instance=clock) | |
|
94 | 103 | form = RCConfigurationForm(conf_data, instance=conf) |
|
95 | 104 | |
|
96 | if form.is_valid(): | |
|
97 | ||
|
105 | if form_clock.is_valid() and form.is_valid(): | |
|
106 | form_clock.save() | |
|
98 | 107 | form.save() |
|
99 | 108 | |
|
100 | 109 | #update lines fields |
@@ -127,6 +136,7 def conf_edit(request, conf_id): | |||
|
127 | 136 | kwargs = {} |
|
128 | 137 | kwargs['dev_conf'] = conf |
|
129 | 138 | kwargs['form'] = form |
|
139 | kwargs['form_clock'] = form_clock | |
|
130 | 140 | kwargs['rc_lines'] = lines |
|
131 | 141 | kwargs['edit'] = True |
|
132 | 142 |
@@ -1,5 +1,9 | |||
|
1 |
#!/bin/ |
|
|
2 | echo "Creating database..." | |
|
3 | psql -U postgres -c "CREATE USER $POSTGRES_USER WITH PASSWORD '$POSTGRES_PASSWORD';" | |
|
4 | psql -U postgres -c "CREATE DATABASE $POSTGRES_DB_NAME;" | |
|
5 | psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB_NAME to $POSTGRES_USER;" | |
|
1 | #!/bin/bash | |
|
2 | set -e | |
|
3 | ||
|
4 | echo "Creating database & user" | |
|
5 | psql -v --username "postgres" --dbname "postgres" <<-EOSQL | |
|
6 | CREATE USER $DB_USER WITH PASSWORD '$DB_PASSWORD'; | |
|
7 | CREATE DATABASE $DB_NAME; | |
|
8 | GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER; | |
|
9 | EOSQL |
@@ -91,11 +91,11 DATABASES = { | |||
|
91 | 91 | # } |
|
92 | 92 | 'default': { |
|
93 | 93 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', |
|
94 |
'NAME': os.environ.get(' |
|
|
95 |
'USER': os.environ.get(' |
|
|
96 |
'PASSWORD': os.environ.get(' |
|
|
97 |
'HOST': os.environ.get('POSTGRES_PORT_5432_TCP_ADDR', ' |
|
|
98 | 'PORT': os.environ.get('POSTGRES_PORT_5432_TCP_PORT', ''), | |
|
94 | 'NAME': os.environ.get('DB_NAME', 'radarsys'), | |
|
95 | 'USER': os.environ.get('DB_USER', 'docker'), | |
|
96 | 'PASSWORD': os.environ.get('DB_PASSWORD', 'docker'), | |
|
97 | 'HOST': os.environ.get('POSTGRES_PORT_5432_TCP_ADDR', 'localhost'), | |
|
98 | 'PORT': os.environ.get('POSTGRES_PORT_5432_TCP_PORT', '5400'), | |
|
99 | 99 | } |
|
100 | 100 | } |
|
101 | 101 | |
@@ -104,7 +104,7 DATABASES = { | |||
|
104 | 104 | |
|
105 | 105 | LANGUAGE_CODE = 'en-us' |
|
106 | 106 | |
|
107 |
TIME_ZONE = os.environ.get('TZ', ' |
|
|
107 | TIME_ZONE = os.environ.get('TZ', 'America/Lima') | |
|
108 | 108 | |
|
109 | 109 | USE_I18N = True |
|
110 | 110 | |
@@ -128,7 +128,7 STATICFILES_FINDERS = ( | |||
|
128 | 128 | |
|
129 | 129 | # Celery stuff |
|
130 | 130 | REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1') |
|
131 |
REDIS_PORT = os.environ.get('REDIS_PORT', 63 |
|
|
131 | REDIS_PORT = os.environ.get('REDIS_PORT', 6300) | |
|
132 | 132 | |
|
133 | 133 | BROKER_TRANSPORT = 'redis' |
|
134 | 134 | BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) |
General Comments 0
You need to be logged in to leave comments.
Login now