From e5cd4efa960ec00e2d8052d78b9cea7ff35cb997 Mon Sep 17 00:00:00 2001 From: stedif <stefano.difrischia@inaf.it> Date: Tue, 19 Sep 2023 15:23:34 +0200 Subject: [PATCH] L2SS-1173: create ec2 device --- CDB/LOFAR_ConfigDb.json | 10 ++++ CDB/stations/common.json | 10 ++++ docker-compose/device-ec2.yml | 50 ++++++++++++++++++ .../startup/01-devices.py | 2 + .../lofar2-fast-policy.json | 2 + .../lofar2-policy.json | 3 ++ .../lofar2-slow-policy.json | 2 + sbin/run_integration_test.sh | 2 +- .../docs/source/devices/ec2.rst | 6 +++ tangostationcontrol/docs/source/index.rst | 1 + .../default/devices/test_device_ec.py | 4 +- .../default/devices/test_device_ec2.py | 11 ++++ tangostationcontrol/setup.cfg | 1 + .../tangostationcontrol/devices/README.md | 4 +- .../tangostationcontrol/devices/docker.py | 8 +++ .../tangostationcontrol/devices/ec2.py | 51 +++++++++++++++++++ 16 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 docker-compose/device-ec2.yml create mode 100644 tangostationcontrol/docs/source/devices/ec2.rst create mode 100644 tangostationcontrol/integration_test/default/devices/test_device_ec2.py create mode 100644 tangostationcontrol/tangostationcontrol/devices/ec2.py diff --git a/CDB/LOFAR_ConfigDb.json b/CDB/LOFAR_ConfigDb.json index 97de683bb..ebd099ad6 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 45768cf24..11cd0e715 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 000000000..1667a72e1 --- /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 36179e8ce..235b9a389 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 ef26b8bd9..bb64cdcb6 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 d6a867b7c..39e40c1de 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 f05afaf8f..db7a0e857 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 afed289d5..681375997 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 000000000..f2a148e5f --- /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 8fe720c9f..a489419d3 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 eda721a20..04f286f9c 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 000000000..12b875048 --- /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 11f69814c..d56fe47f7 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 ae4e123be..ba4549b17 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 4778b61aa..bf6a162df 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 000000000..70b3a9797 --- /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) -- GitLab