Skip to content

Commit

Permalink
Replace master-slave references by primary-secondary
Browse files Browse the repository at this point in the history
  • Loading branch information
153957 committed Oct 26, 2022
1 parent 09af628 commit df85ec1
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 84 deletions.
2 changes: 1 addition & 1 deletion publicdb/histograms/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',)

Expand Down
21 changes: 9 additions & 12 deletions publicdb/histograms/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions publicdb/inforecords/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions publicdb/raw_data/templates/raw_data/singles_data.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion publicdb/station_layout/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions publicdb/station_layout/templates/station_layout/review.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ <h2>HiSPARC station layout review form</h2>
<thead>
<tr>
<th>
<th colspan='2'>Master
<th colspan='2'>Slave
<th colspan='2'>Primary
<th colspan='2'>Secondary
<tr>
<th>
<th style="color: black;">1
Expand Down
4 changes: 2 additions & 2 deletions publicdb/station_layout/templates/station_layout/submit.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ <h2>HiSPARC station layout submit form</h2>
<thead>
<tr>
<th>
<th colspan='2'>Master
<th colspan='2'>Slave
<th colspan='2'>Primary
<th colspan='2'>Secondary
<tr>
<th>
<th style="color: black;">1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
8 changes: 4 additions & 4 deletions publicdb/status_display/templates/status_display/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ <h3 class="term">HiSPARC electronics</h3>
</p>
</div>

<div id="masterslave">
<h3 class="term">Master and Slave</h3>
<div id="primarysecondary">
<h3 class="term">Primary and Secondary</h3>
<p class="meaning">
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.
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,23 @@ <h3>Detector timing offsets</h3>
</div>
<div id="master">
<div class="sectionTitle">
Master
Primary
<span class="sourceLink">
<a href="{% url 'status:source:electronics' station_number=station.number %}">Source</a>
</span>
</div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.master }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.master_fpga }}</span></div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.primary }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.primary_fpga }}</span></div>
<div class="keyvalue"><span class="key ch1">HV Ch1</span><span class="value">{{ config.mas_ch1_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch2">HV Ch2</span><span class="value">{{ config.mas_ch2_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch1">Ch1 Threshold</span><span class="value">{{ config.mas_ch1_thres_low|mv_to_adc }} ADC {{ config.mas_ch1_thres_high|mv_to_adc }} ADC</span></div>
<div class="keyvalue"><span class="key ch2">Ch2 Threshold</span><span class="value">{{ config.mas_ch2_thres_low|mv_to_adc }} ADC {{ config.mas_ch2_thres_high|mv_to_adc }} ADC</span></div>
</div>
{% if has_slave %}
<div id="slave">
<div class="sectionTitle">Slave</div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.slave }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.slave_fpga }}</span></div>
{% if has_secondary %}
<div id="secondary">
<div class="sectionTitle">Secondary</div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.secondary }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.secondary_fpga }}</span></div>
<div class="keyvalue"><span class="key ch3">HV Ch3</span><span class="value">{{ config.slv_ch1_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch4">HV Ch4</span><span class="value">{{ config.slv_ch2_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch3">Ch3 Threshold</span><span class="value">{{ config.slv_ch1_thres_low|mv_to_adc }} ADC {{ config.slv_ch1_thres_high|mv_to_adc }} ADC</span></div>
Expand All @@ -223,9 +223,9 @@ <h3>Detector timing offsets</h3>
<div class="sectionTitle">Settings</div>
<div class="keyvalue">
<span class="key">Trigger</span>
{% 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 %}
<span class="value good">&#x2713;</span>
{% 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 %}
<span class="value good">&#x2713;</span>
{% else %}
<span class="value bad">&#x2717;</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,19 @@ <h3>Temperature data</h3>
{% block config %}
{% if config %}
<div id="master">
<div class="sectionTitle">Master</div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.master }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.master_fpga }}</span></div>
<div class="sectionTitle">Primary</div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.primary }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.primary_fpga }}</span></div>
<div class="keyvalue"><span class="key ch1">HV Ch1</span><span class="value">{{ config.mas_ch1_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch2">HV Ch2</span><span class="value">{{ config.mas_ch2_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch1">Ch1 Thresholds</span><span class="value">{{ config.mas_ch1_thres_low|mv_to_adc }} ADC {{ config.mas_ch1_thres_high|mv_to_adc }} ADC</span></div>
<div class="keyvalue"><span class="key ch2">Ch2 Thresholds</span><span class="value">{{ config.mas_ch2_thres_low|mv_to_adc }} ADC {{ config.mas_ch2_thres_high|mv_to_adc }} ADC</span></div>
</div>
{% if has_slave %}
<div id="slave">
<div class="sectionTitle">Slave</div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.slave }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.slave_fpga }}</span></div>
{% if has_secondary %}
<div id="secondary">
<div class="sectionTitle">Secondary</div>
<div class="keyvalue"><span class="key">Serial</span><span class="value">{{ config.secondary }}</span></div>
<div class="keyvalue"><span class="key">FPGA</span><span class="value">{{ config.secondary_fpga }}</span></div>
<div class="keyvalue"><span class="key ch3">HV Ch3</span><span class="value">{{ config.slv_ch1_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch4">HV Ch4</span><span class="value">{{ config.slv_ch2_voltage|floatformat:0 }} V</span></div>
<div class="keyvalue"><span class="key ch3">Ch3 Thresholds</span><span class="value">{{ config.slv_ch1_thres_low|mv_to_adc }} ADC {{ config.slv_ch1_thres_high|mv_to_adc }} ADC</span></div>
Expand Down
20 changes: 10 additions & 10 deletions publicdb/status_display/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down
16 changes: 8 additions & 8 deletions tests/data/tsv/singles-s501-20170101.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
24 changes: 11 additions & 13 deletions tests/test_histograms/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit df85ec1

Please sign in to comment.