From df85ec111172d5b86dd13436ca8814618020f2db Mon Sep 17 00:00:00 2001 From: Arne de Laat Date: Wed, 26 Oct 2022 16:48:00 -0600 Subject: [PATCH] Replace master-slave references by primary-secondary --- publicdb/histograms/admin.py | 2 +- publicdb/histograms/models.py | 21 +++++++--------- publicdb/inforecords/models.py | 4 ++-- .../templates/raw_data/singles_data.tsv | 16 ++++++------- publicdb/station_layout/forms.py | 2 +- .../templates/station_layout/review.html | 4 ++-- .../templates/station_layout/submit.html | 4 ++-- .../templates/source/electronics_config.tsv | 6 ++--- .../templates/status_display/help.html | 8 +++---- .../status_display/station_config.html | 20 ++++++++-------- .../status_display/station_data.html | 16 ++++++------- publicdb/status_display/views.py | 20 ++++++++-------- tests/data/tsv/singles-s501-20170101.tsv | 16 ++++++------- tests/test_histograms/test_models.py | 24 +++++++++---------- 14 files changed, 79 insertions(+), 84 deletions(-) diff --git a/publicdb/histograms/admin.py b/publicdb/histograms/admin.py index 661e14586..d62512136 100644 --- a/publicdb/histograms/admin.py +++ b/publicdb/histograms/admin.py @@ -162,7 +162,7 @@ def set_config_flag(self, request, qs): @admin.register(models.Configuration) class ConfigurationAdmin(admin.ModelAdmin): - list_display = ('station', 'master', 'slave', 'timestamp') + list_display = ('station', 'primary', 'secondary', 'timestamp') list_filter = ('timestamp', 'summary__station__number') raw_id_fields = ('summary',) diff --git a/publicdb/histograms/models.py b/publicdb/histograms/models.py index 553ea1dcf..e6bf7189d 100644 --- a/publicdb/histograms/models.py +++ b/publicdb/histograms/models.py @@ -1,6 +1,7 @@ import datetime import re +from django.contrib import admin from django.contrib.postgres.fields import ArrayField from django.core.exceptions import ValidationError from django.db import models @@ -201,26 +202,22 @@ def station(self): station.admin_order_field = 'summary__station__number' - def _master(self): + @property + @admin.display(ordering='mas_version') + def primary(self): return self.extract_hardware_serial(self.mas_version) - _master.admin_order_field = 'mas_version' - - master = property(_master) - - def _slave(self): + @property + @admin.display(ordering='slv_version') + def secondary(self): return self.extract_hardware_serial(self.slv_version) - _slave.admin_order_field = 'slv_version' - - slave = property(_slave) - @property - def master_fpga(self): + def primary_fpga(self): return self.extract_fpga_version(self.mas_version) @property - def slave_fpga(self): + def secondary_fpga(self): return self.extract_fpga_version(self.slv_version) def extract_hardware_serial(self, electronics_version): diff --git a/publicdb/inforecords/models.py b/publicdb/inforecords/models.py index 60c871597..9e726755f 100644 --- a/publicdb/inforecords/models.py +++ b/publicdb/inforecords/models.py @@ -244,7 +244,7 @@ def delete(self, *args, **kwargs): reload_datastore() def number_of_detectors(self): - """Get number of detectors, based on presence of Slave electronics + """Get number of detectors, based on presence of Secondary electronics Returns 4 if no config is present to be on the safe side. @@ -257,7 +257,7 @@ def number_of_detectors(self): except Configuration.DoesNotExist: n_detectors = 4 else: - if config.slave == -1: + if config.secondary == -1: n_detectors = 2 else: n_detectors = 4 diff --git a/publicdb/raw_data/templates/raw_data/singles_data.tsv b/publicdb/raw_data/templates/raw_data/singles_data.tsv index 4a249a970..a584621d5 100644 --- a/publicdb/raw_data/templates/raw_data/singles_data.tsv +++ b/publicdb/raw_data/templates/raw_data/singles_data.tsv @@ -12,14 +12,14 @@ # date: time of event [GPS calendar date] # time: time of event [GPS time of day] # timestamp: time of event [UNIX timestamp] -# mas_ch1_low singles rate master channel 1 above low threshold -# mas_ch1_high singles rate master channel 1 above high threshold -# mas_ch2_low singles rate master channel 2 above low threshold -# mas_ch2_high singles rate master channel 2 above high threshold -# slv_ch1_low singles rate slave channel 1 above low threshold -# slv_ch1_high singles rate slave channel 1 above high threshold -# slv_ch2_low singles rate slave channel 2 above low threshold -# slv_ch2_high singles rate slave channel 2 above high threshold +# mas_ch1_low singles rate primary channel 1 above low threshold +# mas_ch1_high singles rate primary channel 1 above high threshold +# mas_ch2_low singles rate primary channel 2 above low threshold +# mas_ch2_high singles rate primary channel 2 above high threshold +# slv_ch1_low singles rate secondary channel 1 above low threshold +# slv_ch1_high singles rate secondary channel 1 above high threshold +# slv_ch2_low singles rate secondary channel 2 above low threshold +# slv_ch2_high singles rate secondary channel 2 above high threshold # Values of -1 or -999 indicate a problem in that measurement or # the absence of that sensor. # diff --git a/publicdb/station_layout/forms.py b/publicdb/station_layout/forms.py index 921d02155..ee6d471d6 100644 --- a/publicdb/station_layout/forms.py +++ b/publicdb/station_layout/forms.py @@ -33,7 +33,7 @@ class StationLayoutQuarantineForm(forms.Form): detector_2_height = height_field() detector_2_beta = beta_field() - # Optional slave detectors + # Optional secondary detectors detector_3_radius = radius_field(required=False) detector_3_alpha = alpha_field(required=False) detector_3_height = height_field(required=False) diff --git a/publicdb/station_layout/templates/station_layout/review.html b/publicdb/station_layout/templates/station_layout/review.html index 901473ec8..91b6370bc 100644 --- a/publicdb/station_layout/templates/station_layout/review.html +++ b/publicdb/station_layout/templates/station_layout/review.html @@ -30,8 +30,8 @@

HiSPARC station layout review form

- Master - Slave + Primary + Secondary 1 diff --git a/publicdb/station_layout/templates/station_layout/submit.html b/publicdb/station_layout/templates/station_layout/submit.html index d7895af7c..25272a7f6 100644 --- a/publicdb/station_layout/templates/station_layout/submit.html +++ b/publicdb/station_layout/templates/station_layout/submit.html @@ -54,8 +54,8 @@

HiSPARC station layout submit form

- Master - Slave + Primary + Secondary 1 diff --git a/publicdb/status_display/templates/source/electronics_config.tsv b/publicdb/status_display/templates/source/electronics_config.tsv index 9c84e9ded..3d96a9c3d 100644 --- a/publicdb/status_display/templates/source/electronics_config.tsv +++ b/publicdb/status_display/templates/source/electronics_config.tsv @@ -8,10 +8,10 @@ # This data contains the following columns: # # timestamp: time of configuration in seconds after 1970-1-1 [UNIX timestamp] -# hardware serial (2x): hardware serial number for Master and Slave -# FPGA version (2x): FPGA firmware version for Master and Slave +# hardware serial (2x): hardware serial number for Primary and Secondary +# FPGA version (2x): FPGA firmware version for Primary and Secondary # # -# timestamp master_serial slave_serial master_fpga slave_fpga +# timestamp primary_serial secondary_serial primary_fpga secondary_fpga {% for row in data %}{% ifchanged row|slice:"1:" %}{{ row.0|date:"U" }}{% for value in row|slice:"1:" %} {{ value }}{% endfor %} {% endifchanged %}{% endfor %} diff --git a/publicdb/status_display/templates/status_display/help.html b/publicdb/status_display/templates/status_display/help.html index 67f15b9ff..6c8d38a2a 100644 --- a/publicdb/status_display/templates/status_display/help.html +++ b/publicdb/status_display/templates/status_display/help.html @@ -124,12 +124,12 @@

HiSPARC electronics

-
-

Master and Slave

+
+

Primary and Secondary

- All stations have HiSPARC Master electronics that reads out + All stations have HiSPARC Primary electronics that reads out 2 detectors. Stations that have 4 detectors also have - HiSPARC Slave electronics, linked to the Master, to read out + HiSPARC Secondary electronics, linked to the Primary, to read out the other two detectors.

diff --git a/publicdb/status_display/templates/status_display/station_config.html b/publicdb/status_display/templates/status_display/station_config.html index 5625ab913..a43d0a3a1 100644 --- a/publicdb/status_display/templates/status_display/station_config.html +++ b/publicdb/status_display/templates/status_display/station_config.html @@ -196,23 +196,23 @@

Detector timing offsets

- Master + Primary Source
-
Serial{{ config.master }}
-
FPGA{{ config.master_fpga }}
+
Serial{{ config.primary }}
+
FPGA{{ config.primary_fpga }}
HV Ch1{{ config.mas_ch1_voltage|floatformat:0 }} V
HV Ch2{{ config.mas_ch2_voltage|floatformat:0 }} V
Ch1 Threshold{{ config.mas_ch1_thres_low|mv_to_adc }} ADC {{ config.mas_ch1_thres_high|mv_to_adc }} ADC
Ch2 Threshold{{ config.mas_ch2_thres_low|mv_to_adc }} ADC {{ config.mas_ch2_thres_high|mv_to_adc }} ADC
- {% if has_slave %} -
-
Slave
-
Serial{{ config.slave }}
-
FPGA{{ config.slave_fpga }}
+ {% if has_secondary %} +
+
Secondary
+
Serial{{ config.secondary }}
+
FPGA{{ config.secondary_fpga }}
HV Ch3{{ config.slv_ch1_voltage|floatformat:0 }} V
HV Ch4{{ config.slv_ch2_voltage|floatformat:0 }} V
Ch3 Threshold{{ config.slv_ch1_thres_low|mv_to_adc }} ADC {{ config.slv_ch1_thres_high|mv_to_adc }} ADC
@@ -223,9 +223,9 @@

Detector timing offsets

Settings
Trigger - {% if has_slave and config.trig_low_signals == 3 and config.trig_high_signals == 2 and config.trig_and_or and config.trig_external == 0 %} + {% if has_secondary and config.trig_low_signals == 3 and config.trig_high_signals == 2 and config.trig_and_or and config.trig_external == 0 %} - {% elif not has_slave and config.trig_low_signals == 2 and config.trig_high_signals == 0 and not config.trig_and_or and config.trig_external == 0 %} + {% elif not has_secondary and config.trig_low_signals == 2 and config.trig_high_signals == 0 and not config.trig_and_or and config.trig_external == 0 %} {% else %} diff --git a/publicdb/status_display/templates/status_display/station_data.html b/publicdb/status_display/templates/status_display/station_data.html index d59afc270..e05eeb808 100644 --- a/publicdb/status_display/templates/status_display/station_data.html +++ b/publicdb/status_display/templates/status_display/station_data.html @@ -335,19 +335,19 @@

Temperature data

{% block config %} {% if config %}
-
Master
-
Serial{{ config.master }}
-
FPGA{{ config.master_fpga }}
+
Primary
+
Serial{{ config.primary }}
+
FPGA{{ config.primary_fpga }}
HV Ch1{{ config.mas_ch1_voltage|floatformat:0 }} V
HV Ch2{{ config.mas_ch2_voltage|floatformat:0 }} V
Ch1 Thresholds{{ config.mas_ch1_thres_low|mv_to_adc }} ADC {{ config.mas_ch1_thres_high|mv_to_adc }} ADC
Ch2 Thresholds{{ config.mas_ch2_thres_low|mv_to_adc }} ADC {{ config.mas_ch2_thres_high|mv_to_adc }} ADC
- {% if has_slave %} -
-
Slave
-
Serial{{ config.slave }}
-
FPGA{{ config.slave_fpga }}
+ {% if has_secondary %} +
+
Secondary
+
Serial{{ config.secondary }}
+
FPGA{{ config.secondary_fpga }}
HV Ch3{{ config.slv_ch1_voltage|floatformat:0 }} V
HV Ch4{{ config.slv_ch2_voltage|floatformat:0 }} V
Ch3 Thresholds{{ config.slv_ch1_thres_low|mv_to_adc }} ADC {{ config.slv_ch1_thres_high|mv_to_adc }} ADC
diff --git a/publicdb/status_display/views.py b/publicdb/status_display/views.py index ec751043e..4e9118f93 100644 --- a/publicdb/status_display/views.py +++ b/publicdb/status_display/views.py @@ -404,13 +404,13 @@ def get_context_data(self, **kwargs): try: summary = Summary.objects.with_config().filter(station=station, date__lte=date).latest() config = Configuration.objects.filter(summary=summary).latest() - if config.slave == -1: - has_slave = False + if config.secondary == -1: + has_secondary = False else: - has_slave = True + has_secondary = True except (Summary.DoesNotExist, Configuration.DoesNotExist): config = None - has_slave = False + has_secondary = False location = station.latest_location(date=date) @@ -441,7 +441,7 @@ def get_context_data(self, **kwargs): 'tomorrow': date + datetime.timedelta(days=1), 'config': config, 'location': location, - 'has_slave': has_slave, + 'has_secondary': has_secondary, 'plots': plots, 'thismonth': thismonth, 'month_list': month_list, @@ -578,10 +578,10 @@ def station_config(request, station_number): has_data = station_has_data(station) config = configs[-1] - if config.slave == -1: - has_slave = False + if config.secondary == -1: + has_secondary = False else: - has_slave = True + has_secondary = True gpslocations = get_gpslocations(configs) @@ -611,7 +611,7 @@ def station_config(request, station_number): 'altitudegraph': altitudegraph, 'gpstrack': gpstrack, 'layout': layout, - 'has_slave': has_slave, + 'has_secondary': has_secondary, 'has_data': has_data, 'has_config': True, 'coincidences_found': True, @@ -1008,7 +1008,7 @@ def get_config_source(station_number, type): if type == 'electronics': data = [ - (config.timestamp, config.master, config.slave, config.master_fpga, config.slave_fpga) for config in configs + (config.timestamp, config.primary, config.secondary, config.primary_fpga, config.secondary_fpga) for config in configs ] else: data = list(configs.values_list(*fields)) diff --git a/tests/data/tsv/singles-s501-20170101.tsv b/tests/data/tsv/singles-s501-20170101.tsv index 98e94aefd..4dc7ee4b8 100644 --- a/tests/data/tsv/singles-s501-20170101.tsv +++ b/tests/data/tsv/singles-s501-20170101.tsv @@ -12,14 +12,14 @@ # date: time of event [GPS calendar date] # time: time of event [GPS time of day] # timestamp: time of event [UNIX timestamp] -# mas_ch1_low singles rate master channel 1 above low threshold -# mas_ch1_high singles rate master channel 1 above high threshold -# mas_ch2_low singles rate master channel 2 above low threshold -# mas_ch2_high singles rate master channel 2 above high threshold -# slv_ch1_low singles rate slave channel 1 above low threshold -# slv_ch1_high singles rate slave channel 1 above high threshold -# slv_ch2_low singles rate slave channel 2 above low threshold -# slv_ch2_high singles rate slave channel 2 above high threshold +# mas_ch1_low singles rate primary channel 1 above low threshold +# mas_ch1_high singles rate primary channel 1 above high threshold +# mas_ch2_low singles rate primary channel 2 above low threshold +# mas_ch2_high singles rate primary channel 2 above high threshold +# slv_ch1_low singles rate secondary channel 1 above low threshold +# slv_ch1_high singles rate secondary channel 1 above high threshold +# slv_ch2_low singles rate secondary channel 2 above low threshold +# slv_ch2_high singles rate secondary channel 2 above high threshold # Values of -1 or -999 indicate a problem in that measurement or # the absence of that sensor. # diff --git a/tests/test_histograms/test_models.py b/tests/test_histograms/test_models.py index 243c1a993..3c74dc7d1 100644 --- a/tests/test_histograms/test_models.py +++ b/tests/test_histograms/test_models.py @@ -93,23 +93,21 @@ def test_str(self): def test_station(self): self.assertEqual(9, self.configuration.station()) - def test_master(self): + def test_primary(self): master_version = int(self.configuration.mas_version.split(' ')[1]) - self.assertEqual(master_version, self.configuration.master) - self.assertEqual(self.configuration._master(), self.configuration.master) + self.assertEqual(primary_version, self.configuration.primary) - def test_slave(self): - slave_version = int(self.configuration.slv_version.split(' ')[1]) - self.assertEqual(slave_version, self.configuration.slave) - self.assertEqual(self.configuration._slave(), self.configuration.slave) + def test_secondary(self): + secondary_version = int(self.configuration.slv_version.split(' ')[1]) + self.assertEqual(secondary_version, self.configuration.secondary) - def test_master_fpga(self): - master_fpga_version = int(self.configuration.mas_version.split(' ')[3]) - self.assertEqual(master_fpga_version, self.configuration.master_fpga) + def test_primary_fpga(self): + primary_fpga_version = int(self.configuration.mas_version.split(' ')[3]) + self.assertEqual(primary_fpga_version, self.configuration.primary_fpga) - def test_slave_fpga(self): - slave_fpga_version = int(self.configuration.slv_version.split(' ')[3]) - self.assertEqual(slave_fpga_version, self.configuration.slave_fpga) + def test_secondary_fpga(self): + secondary_fpga_version = int(self.configuration.slv_version.split(' ')[3]) + self.assertEqual(secondary_fpga_version, self.configuration.secondary_fpga) def test_extract_hardware_serial(self): self.assertEqual(123, self.configuration.extract_hardware_serial('Foo 123 Bar 456'))