//******************************************************************************************************
// SeriesInstance.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:
// ----------------------------------------------------------------------------------------------------
// 05/04/2012 - Stephen C. Wills, Grid Protection Alliance
// Generated original version of source code.
// 12/17/2012 - Starlynn Danyelle Gilliam
// Modified Header.
//
//******************************************************************************************************
using System;
using System.Collections.Generic;
using GSF.PQDIF.Physical;
namespace GSF.PQDIF.Logical
{
///
/// Represents an instance of a series in a PQDIF file. A series
/// instance resides in a and is
/// defined by a .
///
public class SeriesInstance : IEquatable
{
#region [ Members ]
// Fields
private readonly CollectionElement m_physicalStructure;
private readonly ChannelInstance m_channel;
private readonly SeriesDefinition m_definition;
#endregion
#region [ Constructors ]
///
/// Creates a new instance of the class.
///
/// The physical structure of the series instance.
/// The channel instance that this series instance resides in.
/// The series definition that defines this series instance.
public SeriesInstance(CollectionElement physicalStructure, ChannelInstance channel, SeriesDefinition definition)
{
m_physicalStructure = physicalStructure;
m_channel = channel;
m_definition = definition;
}
#endregion
#region [ Properties ]
///
/// Gets the physical structure of the series instance.
///
public CollectionElement PhysicalStructure
{
get
{
return m_physicalStructure;
}
}
///
/// Gets the channel instance in which the series instance resides.
///
public ChannelInstance Channel
{
get
{
return m_channel;
}
}
///
/// Gets the series definition that defines the series.
///
public SeriesDefinition Definition
{
get
{
return m_definition;
}
}
///
/// Gets the value by which to scale the values in
/// order to restore the original data values.
///
public ScalarElement SeriesScale
{
get
{
return m_physicalStructure.GetScalarByTag(SeriesScaleTag)
?? SeriesShareSeries?.SeriesScale;
}
set
{
value.TagOfElement = SeriesScaleTag;
m_physicalStructure.RemoveElementsByTag(SeriesScaleTag);
m_physicalStructure.AddElement(value);
}
}
///
/// Gets the value added to the values in order
/// to restore the original data values.
///
public ScalarElement SeriesOffset
{
get
{
return m_physicalStructure.GetScalarByTag(SeriesOffsetTag)
?? SeriesShareSeries?.SeriesOffset;
}
set
{
value.TagOfElement = SeriesOffsetTag;
m_physicalStructure.RemoveElementsByTag(SeriesOffsetTag);
m_physicalStructure.AddElement(value);
}
}
///
/// Gets the values contained in this series instance.
///
public VectorElement SeriesValues
{
get
{
SeriesInstance seriesShareSeries = SeriesShareSeries;
return ((object)seriesShareSeries != null)
? seriesShareSeries.SeriesValues
: m_physicalStructure.GetVectorByTag(SeriesValuesTag);
}
set
{
value.TagOfElement = SeriesValuesTag;
m_physicalStructure.RemoveElementsByTag(SeriesValuesTag);
m_physicalStructure.AddElement(value);
}
}
///
/// Gets the original data values, after expanding
/// sequences and scale and offset modifications.
///
public IList