Represents an alarm that tests the values of an incoming signal to determine the state of alarm.
Example #1
0
 /// <summary>
 /// Creates a new instance of the <see cref="SerializableAlarm"/> class.
 /// </summary>
 /// <param name="sourceAlarm"><see cref="Alarm"/> from which <see cref="SerializableAlarm"/> is to be initialized.</param>
 public SerializableAlarm(Alarm sourceAlarm)
 {
     ID = sourceAlarm.ID;
     TagName = sourceAlarm.TagName;
     Severity = (int)sourceAlarm.Severity;
     State = sourceAlarm.State;
     SignalID = sourceAlarm.SignalID.ToString();
     TimeRaised = ((DateTime)sourceAlarm.Cause.Timestamp).ToString("MM/dd/yyyy HH:mm:ss");
     ValueAtTimeRaised = sourceAlarm.Cause.AdjustedValue;
     Description = sourceAlarm.Description;
     Operation = (int)sourceAlarm.Operation;
     SetPoint = sourceAlarm.SetPoint ?? default(double);
     Tolerance = sourceAlarm.Tolerance ?? default(double);
     Delay = sourceAlarm.Delay ?? default(double);
     Hysteresis = sourceAlarm.Hysteresis ?? default(double);
 }
Example #2
0
        // Writes an entry to the alarm log when the alarm state changes.
        private void LogStateChange(Guid signalID, Alarm oldState, Alarm newState, DateTime timestamp, double value)
        {
            int? oldStateID;
            int? newStateID;

            if (m_useAlarmLog)
            {
                oldStateID = ((object)oldState != null) ? oldState.ID : (int?)null;
                newStateID = ((object)newState != null) ? newState.ID : (int?)null;

                StateChange stateChange = new StateChange()
                {
                    SignalID = signalID,
                    OldStateID = oldStateID,
                    NewStateID = newStateID,
                    Timestamp = timestamp,
                    Value = value
                };

                m_stateChanges.Enqueue(new StateChange[] { stateChange });
                m_alarmLogOperation.RunOnceAsync();
            }
        }
Example #3
0
        // Creates an alarm event from the given alarm and measurement.
        private IMeasurement CreateAlarmEvent(Ticks timestamp, Alarm alarm)
        {
            IMeasurement alarmEvent = new Measurement()
            {
                Timestamp = timestamp,
                Value = (int)alarm.State
            };

            if ((object)alarm.AssociatedMeasurementID != null)
            {
                Guid alarmEventID = alarm.AssociatedMeasurementID.GetValueOrDefault();
                alarmEvent.Key = MeasurementKey.LookUpBySignalID(alarmEventID);
            }

            return alarmEvent;
        }
Example #4
0
 // Returns true if a change to the alarm's configuration also changed the alarm's behavior.
 private bool BehaviorChanged(Alarm existingAlarm, Alarm definedAlarm)
 {
     return (object)definedAlarm == null ||
            (existingAlarm.SignalID != definedAlarm.SignalID) ||
            (existingAlarm.AssociatedMeasurementID != definedAlarm.AssociatedMeasurementID) ||
            (existingAlarm.Operation != definedAlarm.Operation) ||
            (existingAlarm.SetPoint != definedAlarm.SetPoint) ||
            (existingAlarm.Tolerance != definedAlarm.Tolerance) ||
            (existingAlarm.Delay != definedAlarm.Delay) ||
            (existingAlarm.Hysteresis != definedAlarm.Hysteresis);
 }
Example #5
0
 /// <summary>
 /// Increments the counter for the given alarm.
 /// </summary>
 /// <param name="alarm">The alarm that was raised.</param>
 public void IncrementCounter(Alarm alarm)
 {
     m_countBySeverity.AddOrUpdate((int)alarm.Severity, severity => 1L, (severity, count) => count + 1L);
 }