diff --git a/devices/devices/hardware_device.py b/devices/devices/hardware_device.py index 1035f8460e524ecd4db8ed1d8e3d4aba2f014691..6b28fd7ab5acd8bbf4a3742824fde597d5b23d69 100644 --- a/devices/devices/hardware_device.py +++ b/devices/devices/hardware_device.py @@ -56,6 +56,9 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): The user triggers their transitions by the commands reflecting the target state (Initialise(), On(), Fault()). """ + # 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. """ @@ -203,6 +206,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 @@ -211,18 +219,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 ddf834e14bfa9b8a6206ccc072ad4fee204c56ab..e28d402099b71cdcf09f9a7410a271b034e5d689 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 e39663c34767cc6fcbe74e6c2885b4825257a934..221afb245361d4f330aab42b395532624fb4edde 100644 --- a/devices/devices/sdp/sdp.py +++ b/devices/devices/sdp/sdp.py @@ -40,6 +40,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, @@ -63,6 +69,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 3b2f36236a841adb0511b284cbeb4a0fbc6ee296..fe1b353b17737d56f5566da9cc7913e16ff828a6 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 caeeb5d3488369ecaf17208d1b33c2b7e6c76511..af3766738847fbee48cff17d11a5a8901ee169c2 100644 --- a/devices/devices/sdp/xst.py +++ b/devices/devices/sdp/xst.py @@ -75,6 +75,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 # ----------