diff --git a/bin/update_submodules.sh b/bin/update_submodules.sh new file mode 100755 index 0000000000000000000000000000000000000000..9dcb9745849c01bbf61b9ffae92c5c7cc21a5a8f --- /dev/null +++ b/bin/update_submodules.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git submodule update --init diff --git a/bootstrap/etc/lofar20rc.sh b/bootstrap/etc/lofar20rc.sh index e3bc4ac1e71c43a92a5b7f2ee8f05339b92edeaf..9a9dd658b56f5d30bb1ff8c5de692bd8fe2164de 100755 --- a/bootstrap/etc/lofar20rc.sh +++ b/bootstrap/etc/lofar20rc.sh @@ -12,6 +12,10 @@ ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE})) export LOFAR20_DIR=${1:-$(realpath ${ABSOLUTE_PATH}/../..)} +if [ ! -f "${LOFAR20_DIR}/.git/hooks/post-checkout" ]; then + alias git="cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-checkout; cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-merge; unalias git; git" +fi + # This needs to be modified for a development environment. # In case you run multiple Docker networks on the same host in parallel, you need to specify a unique # network name for each of them. diff --git a/devices/devices/hardware_device.py b/devices/devices/hardware_device.py index 7b5c1ef8a2324bbb033479418f47f404aed5a550..09bcfca2d9acae016d01ebce2448b88469115029 100644 --- a/devices/devices/hardware_device.py +++ b/devices/devices/hardware_device.py @@ -60,6 +60,9 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): version_R = attribute(dtype=str, access=AttrWriteType.READ, fget=lambda self: get_version()) + # list of property names too be set first by set_defaults + first_default_settings = [] + @classmethod def attr_list(cls): """ Return a list of all the attribute_wrapper members of this class. """ @@ -207,6 +210,11 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): A hardware point XXX is set to the value of the object member named XXX_default, if it exists. XXX_default can be f.e. a constant, or a device_property. + + The points are set in the following order: + 1) The python class property 'first_default_settings' is read, as an array of strings denoting property names. Each property + is set in that order. + 2) Any remaining default properties are set. """ # we cannot write directly to our attribute, as that would not @@ -215,18 +223,25 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): # obtain a proxy to myself, to write values proxy = DeviceProxy(self.get_name()) - # for all my members - for name in dir(self): - attr = getattr(self, name) - # check if it's an attribute, and there is a default value available - if isinstance(attr, Attribute) and hasattr(self, f"{name}_default"): - try: - default_value = getattr(self, f"{name}_default") - - # set the attribute to the configured default - self.debug_stream(f"Setting attribute {name} to {default_value}") - proxy.write_attribute(name, default_value) - except Exception as e: - # log which attribute we're addressing - raise Exception(f"Cannot assign default to attribute {name}") from e + # collect all attributes for which defaults are provided + attributes_with_defaults = [name for name in dir(self) + # collect all attribute members + if isinstance(getattr(self, name), Attribute) + # with a default set + and hasattr(self, f"{name}_default")] + + # determine the order: first do the ones mentioned in default_settings_order + attributes_to_set = self.first_default_settings + [name for name in attributes_with_defaults if name not in self.first_default_settings] + + # set them all + for name in attributes_to_set: + try: + default_value = getattr(self, f"{name}_default") + + # set the attribute to the configured default + self.debug_stream(f"Setting attribute {name} to {default_value}") + proxy.write_attribute(name, default_value) + except Exception as e: + # log which attribute we're addressing + raise Exception(f"Cannot assign default to attribute {name}") from e diff --git a/devices/devices/recv.py b/devices/devices/recv.py index b841250a3f875a5e6b659eb750b0aca4b57b82bb..c589f7b9d260aa319bf9db13e2369a7288c846bf 100644 --- a/devices/devices/recv.py +++ b/devices/devices/recv.py @@ -40,6 +40,24 @@ class RECV(opcua_device): # Device Properties # ----------------- + Ant_mask_RW_default = device_property( + dtype='DevVarBooleanArray', + mandatory=False, + default_value=[[True] * 3] * 32 + ) + + RCU_mask_RW_default = device_property( + dtype='DevVarBooleanArray', + mandatory=False, + default_value=[True] * 32 + ) + + first_default_settings = [ + # set the masks first, as those filter any subsequent settings + 'Ant_mask_RW', + 'RCU_mask_RW' + ] + # ---------- # Attributes # ---------- diff --git a/devices/devices/sdp/sdp.py b/devices/devices/sdp/sdp.py index af7242389fd3e97adc96f59abdd21974a23db992..693fab3a9b912a3e8e3e30d58dc237be6149df56 100644 --- a/devices/devices/sdp/sdp.py +++ b/devices/devices/sdp/sdp.py @@ -39,6 +39,12 @@ class SDP(opcua_device): # Device Properties # ----------------- + TR_fpga_mask_RW_default = device_property( + dtype='DevVarBooleanArray', + mandatory=False, + default_value=[True] * 16 + ) + FPGA_processing_enable_RW_default = device_property( dtype='DevVarBooleanArray', mandatory=False, @@ -62,6 +68,11 @@ class SDP(opcua_device): default_value=[[8192] * 12 * 512] * 16 ) + first_default_settings = [ + # set the masks first, as those filter any subsequent settings + 'TR_fpga_mask_RW' + ] + # ---------- # Attributes # ---------- diff --git a/devices/devices/sdp/sst.py b/devices/devices/sdp/sst.py index 85d4f043de15ca074b03f754584fec655576f119..277714ab0b7ada6882a5ec1086690b3c29fb2382 100644 --- a/devices/devices/sdp/sst.py +++ b/devices/devices/sdp/sst.py @@ -57,12 +57,29 @@ class SST(Statistics): mandatory=True ) + FPGA_sst_offload_enable_RW_default = device_property( + dtype='DevVarBooleanArray', + mandatory=False, + default_value=[True] * 16 + ) + FPGA_sst_offload_weighted_subbands_RW_default = device_property( dtype='DevVarBooleanArray', mandatory=False, default_value=[True] * 16 ) + first_default_settings = [ + 'FPGA_sst_offload_hdr_eth_destination_mac_RW', + 'FPGA_sst_offload_hdr_ip_destination_address_RW', + 'FPGA_sst_offload_hdr_udp_destination_port_RW', + + 'FPGA_sst_offload_weighted_subbands_RW', + + # enable only after the offloading is configured correctly + 'FPGA_sst_offload_enable_RW' + ] + # ---------- # Attributes # ---------- diff --git a/devices/devices/sdp/xst.py b/devices/devices/sdp/xst.py index d4fdc99142275b9736983668996ba6659a4eedf5..928637ce5e548dcc2c418a2874dcaed9abd662b4 100644 --- a/devices/devices/sdp/xst.py +++ b/devices/devices/sdp/xst.py @@ -72,6 +72,23 @@ class XST(Statistics): default_value=[[0,102,0,0,0,0,0,0]] * 16 ) + FPGA_xst_offload_enable_RW_default = device_property( + dtype='DevVarBooleanArray', + mandatory=False, + default_value=[True] * 16 + ) + + first_default_settings = [ + 'FPGA_xst_offload_hdr_eth_destination_mac_RW', + 'FPGA_xst_offload_hdr_ip_destination_address_RW', + 'FPGA_xst_offload_hdr_udp_destination_port_RW', + + 'FPGA_xst_subband_select_RW', + + # enable only after the offloading is configured correctly + 'FPGA_xst_offload_enable_RW' + ] + # ---------- # Attributes # ----------