Skip to content
Snippets Groups Projects
Commit ea940bc6 authored by Jan David Mol's avatar Jan David Mol
Browse files

Merge branch 'L2SS-370-ordered-defaults' into 'master'

L2SS-370: Set some default properties first

Closes L2SS-370

See merge request !115
parents c9aa3feb e322ab9b
Branches
No related tags found
1 merge request!115L2SS-370: Set some default properties first
...@@ -56,6 +56,9 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): ...@@ -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()). 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 @classmethod
def attr_list(cls): def attr_list(cls):
""" Return a list of all the attribute_wrapper members of this class. """ """ Return a list of all the attribute_wrapper members of this class. """
...@@ -203,6 +206,11 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): ...@@ -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. 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. 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 # we cannot write directly to our attribute, as that would not
...@@ -211,11 +219,18 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): ...@@ -211,11 +219,18 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas):
# obtain a proxy to myself, to write values # obtain a proxy to myself, to write values
proxy = DeviceProxy(self.get_name()) proxy = DeviceProxy(self.get_name())
# for all my members # collect all attributes for which defaults are provided
for name in dir(self): attributes_with_defaults = [name for name in dir(self)
attr = getattr(self, name) # collect all attribute members
# check if it's an attribute, and there is a default value available if isinstance(getattr(self, name), Attribute)
if isinstance(attr, Attribute) and hasattr(self, f"{name}_default"): # 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: try:
default_value = getattr(self, f"{name}_default") default_value = getattr(self, f"{name}_default")
......
...@@ -40,6 +40,24 @@ class RECV(opcua_device): ...@@ -40,6 +40,24 @@ class RECV(opcua_device):
# Device Properties # 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 # Attributes
# ---------- # ----------
......
...@@ -40,6 +40,12 @@ class SDP(opcua_device): ...@@ -40,6 +40,12 @@ class SDP(opcua_device):
# Device Properties # Device Properties
# ----------------- # -----------------
TR_fpga_mask_RW_default = device_property(
dtype='DevVarBooleanArray',
mandatory=False,
default_value=[True] * 16
)
FPGA_processing_enable_RW_default = device_property( FPGA_processing_enable_RW_default = device_property(
dtype='DevVarBooleanArray', dtype='DevVarBooleanArray',
mandatory=False, mandatory=False,
...@@ -63,6 +69,11 @@ class SDP(opcua_device): ...@@ -63,6 +69,11 @@ class SDP(opcua_device):
default_value=[[8192] * 12 * 512] * 16 default_value=[[8192] * 12 * 512] * 16
) )
first_default_settings = [
# set the masks first, as those filter any subsequent settings
'TR_fpga_mask_RW'
]
# ---------- # ----------
# Attributes # Attributes
# ---------- # ----------
......
...@@ -57,12 +57,29 @@ class SST(Statistics): ...@@ -57,12 +57,29 @@ class SST(Statistics):
mandatory=True 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( FPGA_sst_offload_weighted_subbands_RW_default = device_property(
dtype='DevVarBooleanArray', dtype='DevVarBooleanArray',
mandatory=False, mandatory=False,
default_value=[True] * 16 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 # Attributes
# ---------- # ----------
......
...@@ -75,6 +75,23 @@ class XST(Statistics): ...@@ -75,6 +75,23 @@ class XST(Statistics):
default_value=[[0,102,0,0,0,0,0,0]] * 16 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 # Attributes
# ---------- # ----------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment