Commit 7376e7a7 authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

CT-215: Removed forwarded attribute from the Mid CSP.LMC subarray.

Updated TANGO DB configuration.
Updated tests.
parent dd3d57d6
Loading
Loading
Loading
Loading
+0 −75
Original line number Diff line number Diff line
@@ -347,31 +347,6 @@
                                    "-1",
                                    "1"
                                ]
                            },
                            "assignedFspHealthState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_01/fspHealthState"
                                ]
                            }, 
                            "assignedFspState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_01/fspState"
                                ]
                            }, 
                            "assignedReceptors": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_01/receptors"
                                ]
                            }, 
                            "assignedVccHealthState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_01/vccHealthState"
                                ]
                            }, 
                            "assignedVccState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_01/vccState"
                                ]
                            }
                        }, 
                        "properties": {
@@ -510,31 +485,6 @@
                                    "-1",
                                    "1"
                                ]
                            },
                            "assignedFspHealthState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_02/fspHealthState"
                                ]
                            }, 
                            "assignedFspState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_02/fspState"
                                ]
                            }, 
                            "assignedReceptors": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_02/receptors"
                                ]
                            }, 
                            "assignedVccHealthState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_02/vccHealthState"
                                ]
                            }, 
                            "assignedVccState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_02/vccState"
                                ]
                            }
			},
                        "properties": {
@@ -673,31 +623,6 @@
                                    "-1",
                                    "1"
                                ]
                            },
                            "assignedFspHealthState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_03/fspHealthState"
                                ]
                            }, 
                            "assignedFspState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_03/fspState"
                                ]
                            }, 
                            "assignedReceptors": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_03/receptors"
                                ]
                            }, 
                            "assignedVccHealthState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_03/vccHealthState"
                                ]
                            }, 
                            "assignedVccState": {
                                "__root_att": [
                                    "mid_csp_cbf/sub_elt/subarray_03/vccState"
                                ]
                            }
                        }, 
                        "properties": {
+134 −39
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import time
import json
from collections import defaultdict
import logging
import numpy

# PROTECTED REGION END# //MidCspSubarrayBase.standardlibray_import

@@ -88,7 +89,7 @@ class MidCspSubarrayBase(CspSubarray):
            device._assigned_fsp = []
            #device._receptor_to_vcc_map = {}
            #device._receptor_id_list = []
            device._receptors = Receptors(device.CspMaster)
            device._receptors = Receptors(device, self.logger)
            message = "MidCspSubarray Init command completed OK"
            self.logger.info(message)
            return (result_code, message)
@@ -697,43 +698,71 @@ class MidCspSubarrayBase(CspSubarray):
        doc="The progress percentage for the RemoveReceptors command.",
    )

    assignedVccState = attribute(name="assignedVccState",
                                 label="State of the assigned VCC",
                                 forwarded=True
    assignedVccState = attribute(
        dtype=('DevState',),
        max_dim_x=197,
        label="assignedVccState",
        doc="The State of the assigned VCCs.",
    )
    assignedVccHealthState = attribute(name="assignedVccHealthState",
                                       label="HealthState of the assigned VCC",
                                       forwarded=True

    assignedVccHealthState = attribute(
        dtype=('DevUShort',),
        max_dim_x=197,
        label="assignedVccHealthState",
        doc="The health state of the assigned VCCs.",
    )
    assignedFspState = attribute(name="assignedFspState",
                                 label="State of the assigned FSPs",
                                 forwarded=True

    assignedVccObsState = attribute(
        dtype=('DevUShort',),
        max_dim_x=197,
        label="assignedVccObsState",
        doc="The observing state of the assigned VCCs.",
    )
    assignedFspHealthState = attribute(name="assignedFspHealthState",
                                       label="HealthState of the assigned FSPs.",
                                       forwarded=True

    assignedVccAdminMode = attribute(
        dtype=('DevUShort',),
        access=AttrWriteType.READ_WRITE,
        max_dim_x=197,
        label="assignedVccAdminMode",
        doc="The admin mode of the assigned VCCs.",
    )
    assignedReceptors = attribute(name="assignedReceptors",
                                  label="The list of assigned receptor IDs.",
                                  forwarded=True

    assignedFspState = attribute(
        dtype=('DevState',),
        max_dim_x=197,
        label="assignedFSPState",
        doc="The State of the assigned FSPs.",
    )
    # TODO: implement the root attributes on CbfSubarray
    # assignedVccObsState = attribute(name="assignedVccObsState",
    #    label="ObsState of the assigned VCCs",
    #    forwarded=True
    # )
    # assignedFspObsState = attribute(name="assignedFspObsState",
    #    label="ObsState of the assigned FSPs.",
    #    forwarded=True
    # )
    # assignedVccAdminMode = attribute(name="assignedVccAdminMode",
    #    label="AdminMode of the assigned VCCs.",
    #    forwarded=True
    # )
    # assignedFspAdminMode = attribute(name="assignedFspAdminMode",
    #    label="AdminMode of the assigned FSPs.",
    #    forwarded=True
    # )

    assignedFspHealthState = attribute(
        dtype=('DevUShort',),
        max_dim_x=197,
        label="assignedFSPHealthState",
        doc="The health state of the assigned FSPs.",
    )

    assignedFspObsState = attribute(
        dtype=('DevUShort',),
        max_dim_x=197,
        label="assignedFspObsState",
        doc="The observing state of the assigned FSPs.",
    )

    assignedFspAdminMode = attribute(
        dtype=('DevUShort',),
        access=AttrWriteType.READ_WRITE,
        max_dim_x=197,
        label="assignedFspAdminMode",
        doc="The admin mode of the assigned FSPs.",
    )

    assignedReceptors = attribute(
        dtype=('DevULong',),
        max_dim_x=197,
        label="assignedReceptors",
        doc="The list of receptors assigned to the subarray.",
    )

    # ---------------
    # General methods
    # ---------------
@@ -806,7 +835,6 @@ class MidCspSubarrayBase(CspSubarray):
                self.logger.warning(tango_err.args[0].desc)
        '''
        try:
            #assigned_receptors = self._sc_subarray_proxies[self.CbfSubarray].receptors
            assigned_receptors = self._receptors.assigned_to_subarray(self.SubID)
            # NOTE: if receptors attribute is empty, assigned_receptors is an empty numpy array
            # and it will just be skipped by the for loop
@@ -828,6 +856,73 @@ class MidCspSubarrayBase(CspSubarray):
        return self._assigned_vcc
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedVcc_read

    def read_assignedVccState(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedVccState_read) ENABLED START #
        """Return the assignedVccState attribute."""
        return (Tango.DevState.UNKNOWN,)
    def read_assignedVccHealthState(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedVccHealthState_read) ENABLED START #
        """Return the assignedVccHealthState attribute."""
        return (0,)
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedVccHealthState_read

    def read_assignedVccObsState(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedVccObsState_read) ENABLED START #
        """Return the assignedVccObsState attribute."""
        return (0,)
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedVccObsState_read

    def read_assignedVccAdminMode(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedVccAdminMode_read) ENABLED START #
        """Return the assignedVccAdminMode attribute."""
        return (0,)
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedVccAdminMode_read

    def write_assignedVccAdminMode(self, value):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedVccAdminMode_write) ENABLED START #
        """Set the assignedVccAdminMode attribute."""
        pass
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedVccAdminMode_write

    def read_assignedFspState(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedFspState_read) ENABLED START #
        """Return the assignedFspState attribute."""
        return (Tango.DevState.UNKNOWN,)
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedFspState_read

    def read_assignedFspHealthState(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedFspHealthState_read) ENABLED START #
        """Return the assignedFspHealthState attribute."""
        return (0,)
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedFspHealthState_read

    def read_assignedFspObsState(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedFspObsState_read) ENABLED START #
        """Return the assignedFspObsState attribute."""
        return (0,)
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedFspObsState_read

    def read_assignedFspAdminMode(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedFspAdminMode_read) ENABLED START #
        """Return the assignedFspAdminMode attribute."""
        return (0,)
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedFspAdminMode_read

    def write_assignedFspAdminMode(self, value):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedFspAdminMode_write) ENABLED START #
        """Set the assignedFspAdminMode attribute."""
        pass
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedFspAdminMode_write

    def read_assignedReceptors(self):
        # PROTECTED REGION ID(MidCspSubarrayBase.assignedReceptors_read) ENABLED START #
        """Return the assignedReceptors attribute."""
        assigned_receptors = self._receptors.assigned_to_subarray(self.SubID)
        if len(assigned_receptors) == 0:
            return [0]
        return assigned_receptors
        # PROTECTED REGION END #    //  MidCspSubarrayBase.assignedReceptors_read

# ----------
# Run server
# ----------
+15 −14
Original line number Diff line number Diff line
@@ -3,13 +3,15 @@ import logging
import time
from tango import DeviceProxy

LOGGER = logging.getLogger(__name__)
module_logger = logging.getLogger(__name__)
class Receptors:
    """
    Class to handle information about the Mid receptors.
    """
    def __init__(self, csp_master_fqdn):
        self._csp_master_fqdn = csp_master_fqdn
    def __init__(self, device, logger=None):
        self.device = device
        self._csp_master_fqdn = device.CspMaster
        self.logger = logger or module_logger

    def cbf_master_address(self):
        """
@@ -34,7 +36,7 @@ class Receptors:
            proxy.ping()
            return proxy
        except tango.DevFailed as tango_ex:
            LOGGER.error(tango_ex.args[0].desc)
            module_logger.error(tango_ex.args[0].desc)
            tango.Except.re_throw_exception(tango_ex,
                                            "Connection failed",
                                            "Receptors class",
@@ -53,7 +55,7 @@ class Receptors:
                                       for pair in receptor_to_vcc)
            return receptor_to_vcc_map
        except tango.DevFailed as tango_ex:
            LOGGER.error(tango_ex.args[0].desc)
            module_logger.error(tango_ex.args[0].desc)
            tango.Except.re_throw_exception(tango_ex,
                                            "Connection failed",
                                            "Receptors class",
@@ -84,7 +86,7 @@ class Receptors:
            value = proxy.unassignedReceptorIDs
            return value
        except tango.DevFailed as tango_ex:
            LOGGER.error(tango_ex.args[0].desc)
            module_logger.error(tango_ex.args[0].desc)
            tango.Except.re_throw_exception(tango_ex,
                                            "Connection failed",
                                            "Receptors class",
@@ -99,10 +101,10 @@ class Receptors:
        try:
            proxy = self.connect(self._csp_master_fqdn)
            value = proxy.receptorMembership
            LOGGER.debug("receptorMembership:{}".format(value))
            module_logger.debug("receptorMembership:{}".format(value))
            return value
        except tango.DevFailed as tango_ex:
            LOGGER.error(tango_ex.args[0].desc)
            module_logger.error(tango_ex.args[0].desc)
            tango.Except.re_throw_exception(tango_ex,
                                            "Connection failed",
                                            "Receptors class",
@@ -115,16 +117,15 @@ class Receptors:
        assigned_receptors = []
        sub_id = int(_sub_id)
        try:
            proxy = self.connect(self._csp_master_fqdn)
            subarray_addrs = proxy.cspSubarrayAddresses
            self.logger.info(f"CbfSubarray: {self.device.CbfSubarray}")
            proxy = self.connect(self.device.CbfSubarray)
            #receptor_membership = self.subarray_affiliation()
            #assigned_receptors = [receptor_id + 1 for receptor_id, e in enumerate(receptor_membership) if e == int(sub_id)]
            proxy = self.connect(subarray_addrs[sub_id - 1])
            assigned_receptors = proxy.assignedReceptors
            LOGGER.debug(assigned_receptors)
            assigned_receptors = proxy.receptors
            module_logger.debug(assigned_receptors)
            return assigned_receptors
        except tango.DevFailed as tango_ex:
            LOGGER.error(tango_ex.args[0].desc)
            module_logger.error(tango_ex.args[0].desc)
            tango.Except.re_throw_exception(tango_ex,
                                            "Connection failed",
                                            "Receptors class",
+110 −38

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -312,6 +312,7 @@ class TestCspSubarray(TestBase):
        prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.ON, f"CSP Subarray not OFF")
        Poller(4, 0.2).check(prober_subarray_state)

    @pytest.mark.off_resourcing
    def test_OffCommand_after_RESOURCING(self):
        """
        Test that the Off command send the device in OFF-EMPTY
@@ -332,6 +333,7 @@ class TestCspSubarray(TestBase):
        prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY")
        Poller(4, 0.2).check(prober_subarray_obsstate)
        receptors = self.midcsp_subarray01.assignedReceptors
        LOGGER.info(f'type of {type(receptors)}')
        LOGGER.info(f'list of receptors{receptors}')
        assert not receptors.any(), f"CSP Subarray is not empty"

Loading