//****************************************************************************************************** // SerializableTimeSeriesDataPoint.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: // ---------------------------------------------------------------------------------------------------- // 08/21/2009 - Pinal C. Patel // Generated original version of source code. // 09/15/2009 - Stephen C. Wills // Added new header and license agreement. // 11/26/2009 - Pinal C. Patel // Removed Namespace from DataContract serialization. // 12/02/2009 - Pinal C. Patel // Changed the default format of Time to be cross-culture compatible. // 10/11/2010 - Mihir Brahmbhatt // Updated header and license agreement. // 12/14/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.Runtime.Serialization; using System.Xml.Serialization; using GSF.Historian.Files; namespace GSF.Historian.DataServices { /// /// Represents a time-series data-point that can be serialized using , or . /// /// /// This is the output for serialized using : /// /// /// /// ]]> /// /// This is the output for serialized using : /// /// /// 1 /// /// 60.025547 /// Good /// /// ]]> /// /// This is the output for serialized using : /// /// { /// "HistorianID":1, /// "Time":"2009-08-21 14:22:26.971", /// "Value":59.9974136, /// "Quality":29 /// } /// /// /// /// /// /// [XmlType("TimeSeriesDataPoint"), DataContract(Name = "TimeSeriesDataPoint", Namespace = "")] public class SerializableTimeSeriesDataPoint { #region [ Constructors ] /// /// Initializes a new instance of the class. /// public SerializableTimeSeriesDataPoint() { } /// /// Initializes a new instance of the class. /// /// from which is to be initialized. /// is null. public SerializableTimeSeriesDataPoint(IDataPoint dataPoint) { if (dataPoint == null) throw new ArgumentNullException(nameof(dataPoint)); HistorianID = dataPoint.HistorianID; Time = dataPoint.Time.ToString("yyyy-MM-dd HH:mm:ss.fff"); Value = dataPoint.Value; Quality = dataPoint.Quality; } #endregion #region [ Properties ] /// /// Gets or sets the . /// [XmlAttribute, DataMember(Order = 0)] public int HistorianID { get; set; } /// /// Gets or sets the representation of . /// [XmlAttribute, DataMember(Order = 1)] public string Time { get; set; } /// /// Gets or sets the . /// [XmlAttribute, DataMember(Order = 2)] public float Value { get; set; } /// /// Gets or sets the . /// [XmlAttribute, DataMember(Order = 3)] public Quality Quality { get; set; } #endregion #region [ Methods ] /// /// Returns an object for this . /// /// An object. public IDataPoint Deflate() { // TODO: Eliminate the need for this by modifying ArchiveFile to use IDataPoint internally. return new ArchiveDataPoint(HistorianID, TimeTag.Parse(Time), Value, Quality); } #endregion } }