//******************************************************************************************************
// SerializableAlarm.cs - Gbtc
//
// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 02/09/2012 - Stephen C. Wills
// Generated original version of source code.
// 12/13/2012 - Starlynn Danyelle Gilliam
// Modified Header.
//
//******************************************************************************************************
using System;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using GSF.TimeSeries;
namespace DataQualityMonitoring.Services
{
///
/// Represents a serializable that can be serialized using , or .
///
[XmlType("Alarm"), DataContract(Name = "Alarm", Namespace = "")]
public class SerializableAlarm
{
#region [ Constructors ]
///
/// Creates a new instance of the class.
///
public SerializableAlarm()
{
Description = string.Empty;
}
///
/// Creates a new instance of the class.
///
/// from which is to be initialized.
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);
}
#endregion
#region [ Properties ]
///
/// Gets or sets the identification number of the alarm.
///
[XmlAttribute, DataMember(Order = 0)]
public int ID { get; set; }
///
/// Gets or sets the tag name of the alarm.
///
[XmlAttribute, DataMember(Order = 1)]
public string TagName { get; set; }
///
/// Gets or sets the severity of the alarm.
///
[XmlAttribute, DataMember(Order = 2)]
public int Severity { get; set; }
///
/// Gets or sets the state of the alarm (raised or cleared).
///
[XmlAttribute, DataMember(Order = 3)]
public AlarmState State { get; set; }
///
/// Gets or sets the identification number of the
/// signal whose value is monitored by the alarm.
///
[XmlAttribute, DataMember(Order = 4)]
public string SignalID { get; set; }
///
/// Gets or sets the time at which the alarm was raised.
///
[XmlAttribute, DataMember(Order = 5)]
public string TimeRaised { get; set; }
///
/// Gets or sets the value of the signal
/// at the time that the alarm was raised.
///
[XmlAttribute, DataMember(Order = 6)]
public double ValueAtTimeRaised { get; set; }
///
/// Gets or sets the description of the alarm.
///
[XmlAttribute, DataMember(Order = 7)]
public string Description { get; set; }
///
/// Gets or sets the operation to be performed
/// when testing values from the incoming signal.
///
[XmlAttribute, DataMember(Order = 8)]
public int Operation { get; set; }
///
/// Gets or sets the value to be compared against
/// the signal to determine whether to raise the
/// alarm.
///
[XmlAttribute, DataMember(Order = 9)]
public double SetPoint { get; set; }
///
/// Gets or sets a tolerance window around the
/// to use when comparing
/// against the value of the signal.
///
[XmlAttribute, DataMember(Order = 10)]
public double Tolerance { get; set; }
///
/// Gets or sets the amount of time that the
/// signal must be exhibiting alarming behavior
/// before the alarm is raised.
///
[XmlAttribute, DataMember(Order = 11)]
public double Delay { get; set; }
///
/// Gets or sets the hysteresis used when clearing alarms.
///
[XmlAttribute, DataMember(Order = 12)]
public double Hysteresis { get; set; }
#endregion
}
}