Class Alarm


  • public abstract class Alarm
    extends Object
    Alarm information. Represents the severity and name of the highest alarm associated with the channel.
    Author:
    carcassi
    • Constructor Detail

      • Alarm

        public Alarm()
    • Method Detail

      • getSeverity

        public abstract AlarmSeverity getSeverity()
        Returns the alarm severity, which describes the quality of the value returned. Never null.
        Returns:
        the alarm severity
      • getStatus

        public abstract AlarmStatus getStatus()
        Returns the alarm status, which returns the source of the alarm. Never null.
        Returns:
        the alarm status
      • getName

        public abstract String getName()
        Returns a brief text representation of the highest currently active alarm. Never null.
        Returns:
        the alarm status
      • equals

        public final boolean equals​(Object obj)
        Tests whether the give object is and Alarm with the same name and severity.
        Overrides:
        equals in class Object
        Parameters:
        obj - another alarm
        Returns:
        true if equal
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • of

        public static Alarm of​(AlarmSeverity severity,
                               AlarmStatus status,
                               String name)
        New alarm with the given severity and status.
        Parameters:
        severity - the alarm severity
        status - the alarm status
        name - the alarm name
        Returns:
        the new alarm
      • none

        public static Alarm none()
        No alarm. To be used whenever there is no alarm associated with the value.

        To test for no alarm, one should always check the severity, and not equality to this specific alarm: depending on the data source the status may be different and contain extra information.

        Returns:
        severity NONE and status "None"
      • hihi

        public static Alarm hihi()
        Alarm condition for when a value is above the high alarm threshold.
        Returns:
        the HIHI alarm
      • high

        public static Alarm high()
        Alarm condition for when a value is above the high warning threshold.
        Returns:
        the HIGH alarm
      • low

        public static Alarm low()
        Alarm condition for when a value is below the low warning threshold.
        Returns:
        the LOW alarm
      • lolo

        public static Alarm lolo()
        Alarm condition for when a value is below the low alarm threshold.
        Returns:
        the LOLO alarm
      • noValue

        public static Alarm noValue()
        Alarm condition for when a value is not present. To be used as the alarm associated to a null value.
        Returns:
        severity INVALID and status "No Value"
      • disconnected

        public static Alarm disconnected()
        Alarm condition for when a channel is disconnected. To be used as the alarm associated with a broken connection.
        Returns:
        severity UNDEFINED and status "Disconnected"
      • highestAlarmOf

        public static Alarm highestAlarmOf​(List<?> values,
                                           boolean ignoreNull)
        Returns the value with highest severity. null values can either be ignored or treated as disconnected/missing value (noValue()).
        Parameters:
        values - a list of values
        ignoreNull - true to simply skip null values
        Returns:
        the value with highest alarm; can't be null
      • alarmOf

        public static Alarm alarmOf​(Object value)
        Null and non-VType safe utility to extract alarm information.
        • If the value is has an alarm, the associated alarm is returned.
        • If the value is does not have an alarm, none() is returned.
        • If the value is null, noValue() is returned.
        Parameters:
        value - the value
        Returns:
        the alarm information for the value
      • alarmOf

        public static Alarm alarmOf​(Object value,
                                    boolean connected)
        Null and non-VType safe utility to extract alarm information for a connection.
        • If the value is has an alarm, the associated alarm is returned.
        • If the value is does not have an alarm, none() is returned.
        • If the value is null and connected is true, noValue() is returned.
        • If the value is null and disconnected is true, disconnected() is returned.
        Parameters:
        value - a value
        connected - the connection status
        Returns:
        the alarm information