From 7109f83d8a19289d04078589a370e9825e8fbc0c Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Tue, 18 May 2021 16:42:51 +0200
Subject: [PATCH] L2SS-176: Add version monitoring point to our devices

---
 devices/APSCTL.py | 6 +++++-
 devices/PCC.py    | 6 +++++-
 devices/SDP.py    | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/devices/APSCTL.py b/devices/APSCTL.py
index f1ea50f30..24da18c8b 100644
--- a/devices/APSCTL.py
+++ b/devices/APSCTL.py
@@ -13,7 +13,7 @@
 
 # PyTango imports
 from tango.server import run
-from tango.server import device_property
+from tango.server import device_property, attribute
 from tango import AttrWriteType
 # Additional import
 
@@ -22,6 +22,7 @@ from util.attribute_wrapper import attribute_wrapper
 from util.hardware_device import hardware_device
 
 from util.lofar_logging import device_logging_to_python, log_exceptions
+from util.lofar_git import get_version
 
 import numpy
 
@@ -64,6 +65,9 @@ class APSCTL(hardware_device):
     # ----------
     # Attributes
     # ----------
+
+    version = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version())
+
     N_unb = 2
     N_fpga = 4
     N_ddr = 2
diff --git a/devices/PCC.py b/devices/PCC.py
index ff0ed0914..847d54d49 100644
--- a/devices/PCC.py
+++ b/devices/PCC.py
@@ -14,7 +14,7 @@
 # PyTango imports
 from tango import DebugIt
 from tango.server import run, command
-from tango.server import device_property
+from tango.server import device_property, attribute
 from tango import AttrWriteType
 import numpy
 # Additional import
@@ -25,6 +25,7 @@ from clients.opcua_connection import OPCUAConnection
 from util.attribute_wrapper import attribute_wrapper
 from util.hardware_device import hardware_device
 from util.lofar_logging import device_logging_to_python, log_exceptions
+from util.lofar_git import get_version
 
 __all__ = ["PCC", "main"]
 
@@ -69,6 +70,9 @@ class PCC(hardware_device):
     # ----------
     # Attributes
     # ----------
+
+    version = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version())
+
     RCU_mask_RW = attribute_wrapper(comms_annotation=["2:PCC", "2:RCU_mask_RW"], datatype=numpy.bool_, dims=(32,), access=AttrWriteType.READ_WRITE)
     Ant_mask_RW = attribute_wrapper(comms_annotation=["2:PCC", "2:Ant_mask_RW"], datatype=numpy.bool_, dims=(3, 32), access=AttrWriteType.READ_WRITE)
     RCU_attenuator_R = attribute_wrapper(comms_annotation=["2:PCC", "2:RCU_attenuator_R"], datatype=numpy.int64, dims=(3, 32))
diff --git a/devices/SDP.py b/devices/SDP.py
index f3fbdcaba..2d9ce7b1a 100644
--- a/devices/SDP.py
+++ b/devices/SDP.py
@@ -13,7 +13,7 @@
 
 # PyTango imports
 from tango.server import run
-from tango.server import device_property
+from tango.server import device_property, attribute
 from tango import AttrWriteType
 # Additional import
 
@@ -22,6 +22,7 @@ from util.attribute_wrapper import attribute_wrapper
 from util.hardware_device import hardware_device
 
 from util.lofar_logging import device_logging_to_python, log_exceptions
+from util.lofar_git import get_version
 
 import numpy
 
@@ -64,6 +65,9 @@ class SDP(hardware_device):
     # ----------
     # Attributes
     # ----------
+
+    version = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version())
+
     # SDP will switch from fpga_mask_RW to tr_fpga_mask_RW, offer both for now as its a critical flag
     tr_fpga_mask_RW = attribute_wrapper(comms_annotation=["2:tr_fpga_mask_RW"], datatype=numpy.bool_, dims=(16,), access=AttrWriteType.READ_WRITE)
     fpga_mask_RW = attribute_wrapper(comms_annotation=["2:fpga_mask_RW"], datatype=numpy.bool_, dims=(16,), access=AttrWriteType.READ_WRITE)
-- 
GitLab