Skip to content
Snippets Groups Projects
Commit 08cb499e authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

Merge branch 'master' into L2SS-542-add-timescaledb-views

parents 34563af9 407b3f82
No related branches found
No related tags found
1 merge request!240Resolve L2SS-542 "Add timescaledb views"
{
"servers": {
"RECV": {
"STAT": {
"RECV": {
"STAT/RECV/1": {
"properties": {
"HBAT_reference_itrf": [
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786",
"3826577.066", "461022.948", "5064892.786"
],
"HBAT_antenna_itrf_offsets": [
"-1.847", "-1.180", " 1.493",
"-1.581", " 0.003", " 1.186",
"-1.315", " 1.185", " 0.880",
"-1.049", " 2.367", " 0.573",
"-0.882", "-1.575", " 0.804",
"-0.616", "-0.393", " 0.498",
"-0.350", " 0.789", " 0.191",
"-0.083", " 1.971", "-0.116",
" 0.083", "-1.971", " 0.116",
" 0.350", "-0.789", "-0.191",
" 0.616", " 0.393", "-0.498",
" 0.882", " 1.575", "-0.804",
" 1.049", "-2.367", "-0.573",
" 1.315", "-1.185", "-0.880",
" 1.581", "-0.003", "-1.186",
" 1.847", " 1.180", "-1.493"
]
}
}
}
}
}
}
}
...@@ -29,6 +29,7 @@ sleep 60 ...@@ -29,6 +29,7 @@ sleep 60
# Do not remove `bash`, otherwise statement ignored by gitlab ci shell! # Do not remove `bash`, otherwise statement ignored by gitlab ci shell!
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/LOFAR_ConfigDb.json bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/LOFAR_ConfigDb.json
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/stations/simulators_ConfigDb.json bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/stations/simulators_ConfigDb.json
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/stations/dummy_positions_ConfigDb.json
#bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/integration_ConfigDb.json #bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/integration_ConfigDb.json
cd "$LOFAR20_DIR/docker-compose" || exit 1 cd "$LOFAR20_DIR/docker-compose" || exit 1
......
...@@ -66,10 +66,14 @@ class Beam(lofar_device): ...@@ -66,10 +66,14 @@ class Beam(lofar_device):
self.recv_proxy = DeviceProxy("STAT/RECV/1") self.recv_proxy = DeviceProxy("STAT/RECV/1")
# Retrieve positions from RECV device # Retrieve positions from RECV device
self.HBAT_reference_itrf = self.recv_proxy.get_hbat_reference_itrf().reshape(96,3) HBAT_reference_itrf = self.recv_proxy.HBAT_reference_itrf_R
self.HBAT_antenna_itrf = self.recv_proxy.get_hbat_antenna_itrf().reshape(96,16,3) HBAT_antenna_itrf_offsets = self.recv_proxy.HBAT_antenna_itrf_offsets_R
# Retrieve signal delays from RECV device
self.HBAT_signal_input_delays = self.recv_proxy.get_hbat_signal_input_delays().reshape(96,32) # a delay calculator for each tile
self.HBAT_delay_calculators = [delay_calculator(reference_itrf) for reference_itrf in HBAT_reference_itrf]
# absolute positions of each antenna element
self.HBAT_antenna_positions = [reference_itrf + HBAT_antenna_itrf_offsets for reference_itrf in HBAT_reference_itrf]
# -------- # --------
# internal functions # internal functions
...@@ -85,11 +89,11 @@ class Beam(lofar_device): ...@@ -85,11 +89,11 @@ class Beam(lofar_device):
for tile in range(96): for tile in range(96):
# initialise delay calculator # initialise delay calculator
d = delay_calculator(self.HBAT_reference_itrf[tile]) d = self.HBAT_delay_calculators[tile]
d.set_measure_time(timestamp) d.set_measure_time(timestamp)
# calculate the delays based on the set reference position, the set time and now the set direction and antenna positions # calculate the delays based on the set reference position, the set time and now the set direction and antenna positions
delays[tile] = d.convert(pointing_direction[tile], self.HBAT_antenna_itrf[tile]) delays[tile] = d.convert(pointing_direction[tile], self.HBAT_antenna_positions[tile])
return delays return delays
......
...@@ -93,15 +93,6 @@ class lofar_device(Device, metaclass=DeviceMeta): ...@@ -93,15 +93,6 @@ class lofar_device(Device, metaclass=DeviceMeta):
# trigger a write_{name} call. See https://www.tango-controls.org/community/forum/c/development/c/accessing-own-deviceproxy-class/?page=1#post-2021 # trigger a write_{name} call. See https://www.tango-controls.org/community/forum/c/development/c/accessing-own-deviceproxy-class/?page=1#post-2021
self.proxy = DeviceProxy(self.get_name()) self.proxy = DeviceProxy(self.get_name())
# register a proxy to ourselves, to interact with
# our attributes and commands as a client would.
#
# this is required to get/set attributes.
#
# we cannot write directly to our attribute, as that would not
# trigger a write_{name} call. See https://www.tango-controls.org/community/forum/c/development/c/accessing-own-deviceproxy-class/?page=1#post-2021
self.proxy = DeviceProxy(self.get_name())
@log_exceptions() @log_exceptions()
def delete_device(self): def delete_device(self):
"""Hook to delete resources allocated in init_device. """Hook to delete resources allocated in init_device.
......
...@@ -65,14 +65,12 @@ class RECV(opcua_device): ...@@ -65,14 +65,12 @@ class RECV(opcua_device):
HBAT_reference_itrf = device_property( HBAT_reference_itrf = device_property(
dtype='DevVarFloatArray', dtype='DevVarFloatArray',
mandatory=False, mandatory=False
default_value = numpy.tile(numpy.array([3826577.066, 461022.948, 5064892.786]),(96,1)) # CS002LBA, in ITRF2005 timestamp 2012.5
) )
HBAT_antenna_itrf = device_property( HBAT_antenna_itrf_offsets = device_property(
dtype='DevVarFloatArray', dtype='DevVarFloatArray',
mandatory=False, mandatory=False
default_value = numpy.tile(numpy.array([3826923.546, 460915.441, 5064643.489]),(96,16,1)) # CS001LBA, in ITRF2005 timestamp 2012.5
) )
HBAT_signal_input_delays = device_property( HBAT_signal_input_delays = device_property(
...@@ -149,6 +147,14 @@ class RECV(opcua_device): ...@@ -149,6 +147,14 @@ class RECV(opcua_device):
RECVTR_monitor_rate_RW = attribute_wrapper(comms_annotation=["RECVTR_monitor_rate_RW" ],datatype=numpy.int64 , access=AttrWriteType.READ_WRITE) RECVTR_monitor_rate_RW = attribute_wrapper(comms_annotation=["RECVTR_monitor_rate_RW" ],datatype=numpy.int64 , access=AttrWriteType.READ_WRITE)
RECVTR_translator_busy_R = attribute_wrapper(comms_annotation=["RECVTR_translator_busy_R" ],datatype=numpy.bool_ ) RECVTR_translator_busy_R = attribute_wrapper(comms_annotation=["RECVTR_translator_busy_R" ],datatype=numpy.bool_ )
HBAT_antenna_itrf_offsets_R = attribute(access=AttrWriteType.READ,
dtype=((numpy.float,),), max_dim_x=3, max_dim_y=16,
fget=lambda self: numpy.array(self.HBAT_antenna_itrf_offsets).reshape(16,3))
HBAT_reference_itrf_R = attribute(access=AttrWriteType.READ,
dtype=((numpy.float,),), max_dim_x=3, max_dim_y=96,
fget=lambda self: numpy.array(self.HBAT_reference_itrf).reshape(96,3))
# -------- # --------
# overloaded functions # overloaded functions
# -------- # --------
...@@ -180,37 +186,8 @@ class RECV(opcua_device): ...@@ -180,37 +186,8 @@ class RECV(opcua_device):
# -------- # --------
# Commands # Commands
# -------- # --------
@command(dtype_out=DevVarFloatArray)
@DebugIt()
@only_in_states([DevState.ON])
def get_hbat_bf_delay_step_delays(self):
""" Return the property HBAT_bf_delay_step_delays """
return self.HBAT_bf_delay_step_delays
@command(dtype_out=DevVarFloatArray)
@DebugIt()
@only_in_states([DevState.ON])
def get_hbat_reference_itrf(self):
""" Return the property HBAT_reference_itrf (96x3) into a flatten array """
return self.HBAT_reference_itrf.flatten()
@command(dtype_out=DevVarFloatArray)
@DebugIt()
@only_in_states([DevState.ON])
def get_hbat_antenna_itrf(self):
""" Return the property HBAT_antenna_itrf (96x16x3) into a flatten array """
return self.HBAT_antenna_itrf.flatten()
@command(dtype_out=DevVarFloatArray)
@DebugIt()
@only_in_states([DevState.ON])
def get_hbat_signal_input_delays(self):
""" Return the property HBAT_signal_input_delays (96x32) into a flatten array """
return self.HBAT_signal_input_delays.flatten()
@command(dtype_in=DevVarFloatArray, dtype_out=DevVarFloatArray) @command(dtype_in=DevVarFloatArray, dtype_out=DevVarFloatArray)
@DebugIt()
@only_in_states([DevState.ON])
def calculate_HBAT_bf_delay_steps(self, delays: numpy.ndarray): def calculate_HBAT_bf_delay_steps(self, delays: numpy.ndarray):
""" converts a signal path delay (in seconds) to an analog beam weight """ """ converts a signal path delay (in seconds) to an analog beam weight """
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
# See LICENSE.txt for more info. # See LICENSE.txt for more info.
from tango.test_context import DeviceTestContext from tango.test_context import DeviceTestContext
from tango import DeviceProxy, DevState
from tangostationcontrol.devices import recv, lofar_device from tangostationcontrol.devices import recv, lofar_device
...@@ -19,7 +18,8 @@ from tangostationcontrol.test import base ...@@ -19,7 +18,8 @@ from tangostationcontrol.test import base
class TestRecvDevice(base.TestCase): class TestRecvDevice(base.TestCase):
recv_properties = {'OPC_Server_Name': 'ltspi.astron.nl', 'OPC_Server_Port': 4840, 'OPC_Time_Out': 5.0} # some dummy values for mandatory properties
recv_properties = {'OPC_Server_Name': 'example.com', 'OPC_Server_Port': 4840, 'OPC_Time_Out': 5.0}
def setUp(self): def setUp(self):
super(TestRecvDevice, self).setUp() super(TestRecvDevice, self).setUp()
...@@ -32,42 +32,10 @@ class TestRecvDevice(base.TestCase): ...@@ -32,42 +32,10 @@ class TestRecvDevice(base.TestCase):
proxy_patcher.start() proxy_patcher.start()
self.addCleanup(proxy_patcher.stop) self.addCleanup(proxy_patcher.stop)
def init_device(self, proxy:DeviceProxy):
proxy.off()
proxy.initialise()
self.assertEqual(DevState.STANDBY, proxy.state())
proxy.set_defaults()
proxy.on()
self.assertEqual(DevState.ON, proxy.state())
def test_get_hbat_bf_delay_step_delays(self):
"""Verify can read delay step attribute and length matches without err"""
with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True, timeout=10) as proxy:
self.init_device(proxy)
self.assertEqual(32, len(proxy.get_hbat_bf_delay_step_delays()))
def test_get_hbat_reference_itrf(self):
"""Verify can read hbat reference itrf attribute and length matches without err"""
with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True, timeout=10) as proxy:
self.init_device(proxy)
self.assertEqual(288, len(proxy.get_hbat_reference_itrf())) # 96x3=288
def test_get_hbat_antenna_itrf(self):
"""Verify can read hbat antenna itrf attribute and length matches without err"""
with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True, timeout=10) as proxy:
self.init_device(proxy)
self.assertEqual(4608, len(proxy.get_hbat_antenna_itrf())) # 96x16X3=4608
def test_get_hbat_signal_input_delays(self):
"""Verify can read signal input delay attribute and length matches without err"""
with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True, timeout=10) as proxy:
self.init_device(proxy)
self.assertEqual(3072, len(proxy.get_hbat_signal_input_delays())) # 96x32=3072
def test_calculate_HBAT_bf_delay_steps(self): def test_calculate_HBAT_bf_delay_steps(self):
"""Verify HBAT beamforming calculations are correctly executed""" """Verify HBAT beamforming calculations are correctly executed"""
with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True, timeout=10) as proxy: with DeviceTestContext(recv.RECV, properties=self.recv_properties, process=True) as proxy:
self.init_device(proxy)
delays = numpy.random.rand(96,16).flatten() delays = numpy.random.rand(96,16).flatten()
HBAT_bf_delay_steps = proxy.calculate_HBAT_bf_delay_steps(delays) HBAT_bf_delay_steps = proxy.calculate_HBAT_bf_delay_steps(delays)
self.assertEqual(3072, len(HBAT_bf_delay_steps)) # 96x32=3072 self.assertEqual(3072, len(HBAT_bf_delay_steps)) # 96x32=3072
...@@ -7,6 +7,7 @@ bandit>=1.6.0 # Apache-2.0 ...@@ -7,6 +7,7 @@ bandit>=1.6.0 # Apache-2.0
coverage>=5.2.0 # Apache-2.0 coverage>=5.2.0 # Apache-2.0
doc8>=0.8.0 # Apache-2.0 doc8>=0.8.0 # Apache-2.0
flake8>=3.8.0 # MIT flake8>=3.8.0 # MIT
flake8-bugbear>=22.1.11 # MIT
flake8-breakpoint>=1.1.0 # MIT flake8-breakpoint>=1.1.0 # MIT
flake8-debugger>=4.0.0 #MIT flake8-debugger>=4.0.0 #MIT
flake8-mock>=0.3 #GPL flake8-mock>=0.3 #GPL
......
...@@ -76,5 +76,5 @@ commands = ...@@ -76,5 +76,5 @@ commands =
[flake8] [flake8]
filename = *.py,.stestr.conf,.txt filename = *.py,.stestr.conf,.txt
select = W292,B601,B602,T100,M001,F401 select = W292,B601,B602,T100,M001,F401,B001,B002,B003,B004,B005,B006,B007,B008,B009,B010,B011,B012,B013,B014.B015,B016,B017,B018
exclude=.tox,.egg-info exclude=.tox,.egg-info
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment