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

Merge branch 'master' into L2SS-405-archiving-setup-production

parents fa50d8cb cfd036df
No related branches found
No related tags found
1 merge request!265Resolve L2SS-405 "Archiving setup production"
......@@ -13,7 +13,7 @@
# PyTango imports
from tango.server import attribute, command, Device, DeviceMeta
from tango import AttrWriteType, DevState, DebugIt, Attribute, DeviceProxy, AttrDataFormat
from tango import AttrWriteType, DevState, DebugIt, Attribute, DeviceProxy, AttrDataFormat, DevSource
import time
import math
import numpy
......@@ -83,26 +83,6 @@ class lofar_device(Device, metaclass=DeviceMeta):
return self.get_state() in [DevState.STANDBY, DevState.ON, DevState.ALARM]
def clear_poll_cache(self):
""" Remove all attributes from the poll cache, to remove stale entries
once we know the values can be read. """
# we use proxy.attribute_query_list(), as proxy.get_attribute_list() will throw if we
# call it too soon when starting everything (database, device) from scratch.
attr_names = [config.name for config in self.proxy.attribute_list_query()]
for attr_name in attr_names:
if self.proxy.is_attribute_polled(attr_name):
# save poll period
poll_period = self.proxy.get_attribute_poll_period(attr_name)
try:
# stop polling to remove cache entry
self.proxy.stop_poll_attribute(attr_name)
finally:
# start polling again
self.proxy.poll_attribute(attr_name, poll_period)
@log_exceptions()
def init_device(self):
""" Instantiates the device in the OFF state. """
......@@ -123,6 +103,7 @@ class lofar_device(Device, metaclass=DeviceMeta):
# 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())
self.proxy.set_source(DevSource.DEV)
@log_exceptions()
def delete_device(self):
......@@ -163,8 +144,14 @@ class lofar_device(Device, metaclass=DeviceMeta):
self.configure_for_initialise()
# any values read so far are stale. clear the polling cache.
self.clear_poll_cache()
# WARNING: any values read so far are stale.
# Proxies either need to wait for the next poll round, or
# use proxy.set_source(DevSource.DEV) to avoid the cache
# alltogether.
#
# Actually clearing the polling cache runs into performance
# problems if a lot of attributes are polled, and into race
# conditions with the polling thread itself.
self.set_state(DevState.STANDBY)
self.set_status("Device is in the STANDBY state.")
......
......@@ -92,7 +92,7 @@ class RECV(opcua_device):
doc='Maximum amount of time to wait after turning dithering on or off',
dtype='DevFloat',
mandatory=False,
default_value=10.0
default_value=20.0
)
# ----- Calibration values
......
......@@ -194,12 +194,17 @@ class SDP(opcua_device):
# --------
def _prepare_hardware(self):
# FPGA firmware loading disabled, as it causes SDPTR to crash,
# see https://support.astron.nl/jira/browse/L2SDP-670
"""
# FPGAs need the correct firmware loaded
self.FPGA_boot_image_RW = [1] * self.N_pn
# wait for the firmware to be loaded (ignoring masked out elements)
mask = self.proxy.TR_fpga_mask_RW
self.wait_attribute("FPGA_boot_image_R", lambda attr: ((attr == 1) | ~mask).all(), 10)
"""
pass
# --------
# Commands
......
......@@ -3,7 +3,7 @@
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
""" Beam Device Server for LOFAR2.0
""" TileBeam Device Server for LOFAR2.0
"""
......@@ -28,10 +28,10 @@ logger = logging.getLogger()
__all__ = ["Beam", "main", "BeamTracker"]
__all__ = ["TileBeam", "main", "BeamTracker"]
@device_logging_to_python()
class Beam(lofar_device):
class TileBeam(lofar_device):
# -----------------
# Device Properties
......@@ -320,7 +320,7 @@ class Beam(lofar_device):
# ----------
def main(**kwargs):
"""Main function of the ObservationControl module."""
return entry(Beam, **kwargs)
return entry(TileBeam, **kwargs)
# ----------
# Beam Tracker
......
......@@ -24,12 +24,12 @@ class NumpyEncoder(json.JSONEncoder):
return json.JSONEncoder.default(self, obj)
class TestDeviceBeam(AbstractTestBases.TestDeviceBase):
class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase):
pointing_direction = numpy.array([["J2000","0deg","0deg"]] * 96).flatten()
def setUp(self):
super().setUp("STAT/Beam/1")
super().setUp("STAT/TileBeam/1")
def setup_recv_proxy(self):
# setup RECV
......@@ -146,7 +146,7 @@ class TestDeviceBeam(AbstractTestBases.TestDeviceBase):
numpy.testing.assert_equal(calculated_HBAT_delay_steps[0], expected_HBAT_delay_steps)
numpy.testing.assert_equal(calculated_HBAT_delay_steps[48], expected_HBAT_delay_steps)
def test_beam_tracking(self):
def test_tilebeam_tracking(self):
# setup RECV as well
recv_proxy = self.setup_recv_proxy()
......
......@@ -9,7 +9,7 @@
from tango.test_context import DeviceTestContext
from tangostationcontrol.devices import beam, lofar_device
from tangostationcontrol.devices import tilebeam, lofar_device
import mock
......@@ -22,7 +22,7 @@ class TestBeamDevice(base.TestCase):
# Patch DeviceProxy to allow making the proxies during initialisation
# that we otherwise avoid using
for device in [beam, lofar_device]:
for device in [tilebeam, lofar_device]:
proxy_patcher = mock.patch.object(
device, 'DeviceProxy')
proxy_patcher.start()
......@@ -30,14 +30,14 @@ class TestBeamDevice(base.TestCase):
def test_get_pointing_directions(self):
"""Verify can read pointings attribute and length matches without err"""
with DeviceTestContext(beam.Beam, process=True, timeout=10) as proxy:
with DeviceTestContext(tilebeam.TileBeam, process=True, timeout=10) as proxy:
proxy.initialise()
self.assertEqual(96, len(proxy.read_attribute(
"HBAT_pointing_direction_R").value))
def test_get_pointing_timestamps(self):
"""Verify can read timestamps attribute and length matches without err"""
with DeviceTestContext(beam.Beam, process=True, timeout=10) as proxy:
with DeviceTestContext(tilebeam.TileBeam, process=True, timeout=10) as proxy:
proxy.initialise()
self.assertEqual(96, len(proxy.read_attribute(
"HBAT_pointing_timestamp_R").value))
libhdbpp-python @ 7f316826
Subproject commit 7f3168261290109d64057fd526827bf33089774f
......@@ -78,4 +78,4 @@ commands =
[flake8]
filename = *.py,.stestr.conf,.txt
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,libhdbpp-python
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment