diff --git a/CDB/LOFAR_ConfigDb.json b/CDB/LOFAR_ConfigDb.json index 97de683bb7ebd6bc26b9e357812aaddd11b3d344..ebd099ad6345b5ae34796de54f1e74ecb9175275 100644 --- a/CDB/LOFAR_ConfigDb.json +++ b/CDB/LOFAR_ConfigDb.json @@ -96,6 +96,16 @@ } } }, + "EC2": { + "STAT": { + "EC2": { + "STAT/EC2/1": { + "properties": { + } + } + } + } + }, "ObservationControl": { "STAT": { "ObservationControl": { diff --git a/CDB/stations/common.json b/CDB/stations/common.json index 45768cf244203c86e94ca786550ae669aaf30e96..11cd0e71547640e887c679d30cad6fcc858c6190 100644 --- a/CDB/stations/common.json +++ b/CDB/stations/common.json @@ -85,6 +85,16 @@ } } }, + "EC2": { + "STAT": { + "EC2": { + "STAT/EC2/1": { + "properties": { + } + } + } + } + }, "ObservationControl": { "STAT": { "ObservationControl": { diff --git a/docker-compose/device-ec2.yml b/docker-compose/device-ec2.yml new file mode 100644 index 0000000000000000000000000000000000000000..1667a72e122dc81c4ee8451d8f3668c4fcde5514 --- /dev/null +++ b/docker-compose/device-ec2.yml @@ -0,0 +1,50 @@ +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 +# +# Requires: +# - lofar-device-base.yml +# +version: '2.1' + +volumes: + iers-data: { } + +services: + device-ec2: + image: ${LOCAL_DOCKER_REGISTRY_HOST}/${LOCAL_DOCKER_REGISTRY_USER}/lofar-device-base:${TAG} + hostname: device-ec2 + container_name: device-ec2 + logging: + driver: "json-file" + options: + max-size: "100m" + max-file: "10" + networks: + - control + ports: + - "5730:5730" # unique port for this DS + - "5830:5830" # ZeroMQ event port + - "5930:5930" # ZeroMQ heartbeat port + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: + - ..:/opt/lofar/tango:rw + environment: + - TANGO_HOST=${TANGO_HOST} + - TANGO_ZMQ_EVENT_PORT=5830 + - TANGO_ZMQ_HEARTBEAT_PORT=5930 + healthcheck: + test: l2ss-health dserver/ec2/STAT + interval: 1m + timeout: 30s + retries: 3 + start_period: 30s + working_dir: /opt/lofar/tango + entrypoint: + - bin/start-ds.sh + # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA + # can't know about our Docker port forwarding + - l2ss-ec2 ec2 STAT -v -ORBendPoint giop:tcp:device-ec2:5730 -ORBendPointPublish giop:tcp:${HOSTNAME}:5730 + restart: on-failure + stop_signal: SIGINT # request a graceful shutdown of Tango + stop_grace_period: 2s diff --git a/docker-compose/jupyter-lab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py b/docker-compose/jupyter-lab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py index 36179e8ceabf679aa860da7575a8d6b8e86efd07..235b9a389328d86107b183d900cb70828a206669 100644 --- a/docker-compose/jupyter-lab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py +++ b/docker-compose/jupyter-lab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py @@ -73,6 +73,7 @@ stationmanager = OptionalDeviceProxy("STAT/StationManager/1") boot = OptionalDeviceProxy("STAT/Boot/1") ccd = OptionalDeviceProxy("STAT/CCD/1") ec = OptionalDeviceProxy("STAT/EC/1") +ec2 = OptionalDeviceProxy("STAT/EC2/1") pcon = OptionalDeviceProxy("STAT/PCON/1") psoc = OptionalDeviceProxy("STAT/PSOC/1") docker = OptionalDeviceProxy("STAT/Docker/1") @@ -86,6 +87,7 @@ devices = ( boot, ccd, ec, + ec2, pcon, psoc, docker, diff --git a/docker-compose/tango-prometheus-exporter/lofar2-fast-policy.json b/docker-compose/tango-prometheus-exporter/lofar2-fast-policy.json index ef26b8bd9d15492b7fd2add30d659f7408e42e4a..bb64cdcb694519ecbd0a60b3ea2a13c55e9291fe 100644 --- a/docker-compose/tango-prometheus-exporter/lofar2-fast-policy.json +++ b/docker-compose/tango-prometheus-exporter/lofar2-fast-policy.json @@ -12,6 +12,8 @@ }, "stat/ec/1": { }, + "stat/ec2/1": { + }, "stat/configuration/1": { }, "stat/apspu/*": { diff --git a/docker-compose/tango-prometheus-exporter/lofar2-policy.json b/docker-compose/tango-prometheus-exporter/lofar2-policy.json index d6a867b7cf268556e73c0c0ac662fb73c6771df8..39e40c1de92932884a5b9a080b63e71cd988c710 100644 --- a/docker-compose/tango-prometheus-exporter/lofar2-policy.json +++ b/docker-compose/tango-prometheus-exporter/lofar2-policy.json @@ -36,6 +36,9 @@ "stat/ec/1": { "include": ["*_RW"] }, + "stat/ec2/1": { + "include": ["*_RW"] + }, "stat/configuration/1": { }, "stat/apspu/*": { diff --git a/docker-compose/tango-prometheus-exporter/lofar2-slow-policy.json b/docker-compose/tango-prometheus-exporter/lofar2-slow-policy.json index f05afaf8f253767f63bcd6c8154b64b0c51e1aaf..db7a0e85785ff32ee4cea0709a6f31c4fc675aaf 100644 --- a/docker-compose/tango-prometheus-exporter/lofar2-slow-policy.json +++ b/docker-compose/tango-prometheus-exporter/lofar2-slow-policy.json @@ -20,6 +20,8 @@ }, "stat/ec/1": { }, + "stat/ec2/1": { + }, "stat/configuration/1": { }, "stat/apspu/*": { diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh index afed289d534538656b245244f157379b5157e151..68137599725b09f6132ec7f89a7af4beb1393e79 100755 --- a/sbin/run_integration_test.sh +++ b/sbin/run_integration_test.sh @@ -98,7 +98,7 @@ echo '/usr/local/bin/wait-for-it.sh ${TANGO_HOST} --strict --timeout=300 -- true # Devices list is used to explitly word split when supplied to commands, must # disable shellcheck SC2086 for each case. -DEVICES=(device-station-manager device-boot device-aps device-apsct device-ccd device-ec device-apspu device-sdpfirmware device-sdp device-recvh device-recvl device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-pcon device-antennafield device-temperature-manager device-observation-control device-configuration device-calibration) +DEVICES=(device-station-manager device-boot device-aps device-apsct device-ccd device-ec device-ec2 device-apspu device-sdpfirmware device-sdp device-recvh device-recvl device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-pcon device-antennafield device-temperature-manager device-observation-control device-configuration device-calibration) SIMULATORS=(sdptr-sim recvh-sim recvl-sim unb2-sim apsct-sim apspu-sim ccd-sim ec-sim) diff --git a/tangostationcontrol/docs/source/devices/ec2.rst b/tangostationcontrol/docs/source/devices/ec2.rst new file mode 100644 index 0000000000000000000000000000000000000000..f2a148e5f3da99c056ee1ffdc272ded39c71748d --- /dev/null +++ b/tangostationcontrol/docs/source/devices/ec2.rst @@ -0,0 +1,6 @@ +.. _ec2: + +EC2 +-------------------- + +The ``ec2 == DeviceProxy("STAT/EC2/1")`` device controls the Environmental Control (EC) - 2.0 version. diff --git a/tangostationcontrol/docs/source/index.rst b/tangostationcontrol/docs/source/index.rst index 8fe720c9ff899d84cd9f035b5dce0259cdb4ed3d..a489419d33f1b398621d0cb7862c6fd51456a2ab 100644 --- a/tangostationcontrol/docs/source/index.rst +++ b/tangostationcontrol/docs/source/index.rst @@ -33,6 +33,7 @@ Even without having access to any LOFAR2.0 hardware, you can install the full st devices/psoc devices/ccd devices/ec + devices/ec2 devices/configuration devices/temperature-manager devices/configure diff --git a/tangostationcontrol/integration_test/default/devices/test_device_ec.py b/tangostationcontrol/integration_test/default/devices/test_device_ec.py index eda721a203902a07fbbe5ec6f26d071b352cfaa0..04f286f9c37b4ebb71bdc53ce8e75778f430f3e3 100644 --- a/tangostationcontrol/integration_test/default/devices/test_device_ec.py +++ b/tangostationcontrol/integration_test/default/devices/test_device_ec.py @@ -4,6 +4,8 @@ from integration_test.default.devices.base import AbstractTestBases -class TestDevicePCON(AbstractTestBases.TestDeviceBase): +class TestDeviceEC(AbstractTestBases.TestDeviceBase): + """Integration test class for device EC""" + def setUp(self): super().setUp("STAT/EC/1") diff --git a/tangostationcontrol/integration_test/default/devices/test_device_ec2.py b/tangostationcontrol/integration_test/default/devices/test_device_ec2.py new file mode 100644 index 0000000000000000000000000000000000000000..12b8750482a3c39a7e643db681470dd4b5d67be3 --- /dev/null +++ b/tangostationcontrol/integration_test/default/devices/test_device_ec2.py @@ -0,0 +1,11 @@ +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 + +from integration_test.default.devices.base import AbstractTestBases + + +class TestDeviceEC2(AbstractTestBases.TestDeviceBase): + """Integration test class for device EC 2.0""" + + def setUp(self): + super().setUp("STAT/EC2/1") diff --git a/tangostationcontrol/setup.cfg b/tangostationcontrol/setup.cfg index 11f69814ceb864875cb806b9c2866c967febb782..d56fe47f72a25893866b5fcd8c19c1e1e976917d 100644 --- a/tangostationcontrol/setup.cfg +++ b/tangostationcontrol/setup.cfg @@ -36,6 +36,7 @@ console_scripts = l2ss-apspu = tangostationcontrol.devices.apspu:main l2ss-ccd = tangostationcontrol.devices.ccd:main l2ss-ec = tangostationcontrol.devices.ec:main + l2ss-ec2 = tangostationcontrol.devices.ec2:main l2ss-psoc = tangostationcontrol.devices.psoc:main l2ss-pcon = tangostationcontrol.devices.pcon:main l2ss-tilebeam = tangostationcontrol.devices.tilebeam:main diff --git a/tangostationcontrol/tangostationcontrol/devices/README.md b/tangostationcontrol/tangostationcontrol/devices/README.md index ae4e123bec1c7331945d25c91cd9f3bd31c58831..ba4549b17b3d762384d6100ef9905a96e4373028 100644 --- a/tangostationcontrol/tangostationcontrol/devices/README.md +++ b/tangostationcontrol/tangostationcontrol/devices/README.md @@ -7,11 +7,11 @@ This directory contains the sources for our custom Tango devices. If a new device is added, it will (likely) need to be referenced in several places. Adjust or add the following files (referenced from the repository root), following the pattern shown by the devices already there: - Adjust `CDB/LOFAR_ConfigDb.json` to create the device in the Tango device database, -- Add the device hierarchies in `CDB/hierarchies` to define the power, control and clock configuration, +- Add the device hierarchies in CDB files (f.e. `CDB/stations/common.json` or `CDB/stations/cs001.json`) to define the power, control and clock configuration in a certain station, - Adjust `docker-compose/jupyter-lab/ipython-profiles/stationcontrol-jupyter/startup/01-devices.py` to make an alias for it available in Jupyter-Lab, - Adjust `tangostationcontrol/tangostationcontrol/devices/boot.py` to add the device to the station initialisation sequence, - Adjust `tangostationcontrol/tangostationcontrol/devices/docker.py` to have the device container available as R and RW attributes, -- Add to `docker-compose/` to create a YaML file to start the device in a docker container. NOTE: it needs a unique 57xx port assigned (current _unused_ port value: 5730), a unique 58xx port for ZMQ events, and a unique 59xx port for ZMQ heartbeat +- Add to `docker-compose/` to create a YaML file to start the device in a docker container. NOTE: it needs a unique 57xx port assigned (current _unused_ port value: 5731), a unique 58xx port for ZMQ events, and a unique 59xx port for ZMQ heartbeat - Adjust `tangostationcontrol/setup.cfg` to add an entry point for the device in the package installation, - Add to `tangostationcontrol/tangostationcontrol/integration_test/default/devices/` to add an integration test, - Adjust `sbin/run_integration_test.sh` to have the device started when running the integration tests, diff --git a/tangostationcontrol/tangostationcontrol/devices/docker.py b/tangostationcontrol/tangostationcontrol/devices/docker.py index 4778b61aa86a1cdb5ab17448651767428d5ee5f3..bf6a162dfe92d59059163434ff3d8f9723585a7a 100644 --- a/tangostationcontrol/tangostationcontrol/devices/docker.py +++ b/tangostationcontrol/tangostationcontrol/devices/docker.py @@ -77,6 +77,14 @@ class Docker(LOFARDevice): datatype=bool, access=AttrWriteType.READ_WRITE, ) + device_ec2_R = AttributeWrapper( + comms_annotation={"container": "device-ec2"}, datatype=bool + ) + device_ec2_RW = AttributeWrapper( + comms_annotation={"container": "device-ec2"}, + datatype=bool, + access=AttrWriteType.READ_WRITE, + ) # device_docker_RW is not available, as we cannot start our own container` device_temperature_manager_R = AttributeWrapper( comms_annotation={"container": "device-temperature-manager"}, datatype=bool diff --git a/tangostationcontrol/tangostationcontrol/devices/ec2.py b/tangostationcontrol/tangostationcontrol/devices/ec2.py new file mode 100644 index 0000000000000000000000000000000000000000..70b3a979762635af4961db4ff8d279ce5898ce54 --- /dev/null +++ b/tangostationcontrol/tangostationcontrol/devices/ec2.py @@ -0,0 +1,51 @@ +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 + +""" EC (Environmental Control) 2.0 Device Server for LOFAR2.0 + +""" +import logging + +# PyTango imports +from tangostationcontrol.common.entrypoint import entry +from tangostationcontrol.common.lofar_logging import device_logging_to_python +from tangostationcontrol.devices.base_device_classes.opcua_device import OPCUADevice + +# Additional import + +logger = logging.getLogger() + +__all__ = ["EC2", "main"] + + +@device_logging_to_python() +class EC2(OPCUADevice): + """EC Device Server 2.0 for LOFAR2.0""" + + # ----------------- + # Device Properties + # ----------------- + + # ---------- + # Attributes + # ---------- + + # ---------- + # Summarising Attributes + # ---------- + + # -------- + # overloaded functions + # -------- + + # -------- + # Commands + # -------- + + +# ---------- +# Run server +# ---------- +def main(**kwargs): + """Main function of the EnvironmentalControl 2.0 module.""" + return entry(EC2, **kwargs)