//****************************************************************************************************** // SubscriptionInfo.cs - Gbtc // // Copyright © 2010, 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 Eclipse Public License -v 1.0 (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/eclipse-1.0.php // // 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: // ---------------------------------------------------------------------------------------------------- // 04/25/2012 - Stephen C. Wills // Generated original version of source code. // //****************************************************************************************************** using System; namespace GSF.TimeSeries.Transport { /// /// Configuration object for data subscriptions. /// public abstract class SubscriptionInfo { #region [ Members ] // Fields private string m_filterExpression; private bool m_useCompactMeasurementFormat; private bool m_useMillisecondResolution; private bool m_udpDataChannel; private int m_dataChannelLocalPort; private double m_lagTime; private double m_leadTime; private bool m_useLocalClockAsRealTime; private string m_startTime; private string m_stopTime; private string m_constraintParameters; private int m_processingInterval; private string m_waitHandleNames; private int m_waitHandleTimeout; private string m_extraConnectionStringParameters; #endregion #region [ Constructors ] /// /// Creates a new instance of the class. /// public SubscriptionInfo() { m_useCompactMeasurementFormat = true; m_dataChannelLocalPort = 9500; m_lagTime = 10.0; m_leadTime = 5.0; m_processingInterval = -1; } #endregion #region [ Properties ] /// /// Gets or sets the filter expression used to define which /// measurements are being requested by the subscriber. /// public virtual string FilterExpression { get { return m_filterExpression; } set { m_filterExpression = value; } } /// /// Gets or sets the flag that determines whether to use the /// compact measurement format or the full measurement format /// for transmitting measurements to the subscriber. /// public virtual bool UseCompactMeasurementFormat { get { return m_useCompactMeasurementFormat; } set { m_useCompactMeasurementFormat = value; } } /// /// Gets or sets the flag that determines whether the subscriber /// is requesting its data over a separate UDP data channel. /// public virtual bool UdpDataChannel { get { return m_udpDataChannel; } set { m_udpDataChannel = value; } } /// /// Gets or sets the port number that the UDP data channel binds to. /// This value is only used when the subscriber requests a separate /// UDP data channel. /// public virtual int DataChannelLocalPort { get { return m_dataChannelLocalPort; } set { m_dataChannelLocalPort = value; } } /// /// Gets or sets the allowed past time deviation /// tolerance in seconds (can be subsecond). /// public virtual double LagTime { get { return m_lagTime; } set { m_lagTime = value; } } /// /// Gets or sets the allowed future time deviation /// tolerance, in seconds (can be subsecond). /// public virtual double LeadTime { get { return m_leadTime; } set { m_leadTime = value; } } /// /// Gets or sets the flag that determines whether the server's /// local clock is used as real-time. If false, the timestamps /// of the measurements will be used as real-time. /// public virtual bool UseLocalClockAsRealTime { get { return m_useLocalClockAsRealTime; } set { m_useLocalClockAsRealTime = value; } } /// /// Gets or sets the flag that determines whether measurement timestamps use /// millisecond resolution. If false, they will use resolution. /// /// /// This flag determines the size of the timestamps transmitted as part of /// the compact measurement format when the server is using base time offsets. /// public virtual bool UseMillisecondResolution { get { return m_useMillisecondResolution; } set { m_useMillisecondResolution = value; } } /// /// Gets or sets the start time of the requested /// temporal session for streaming historic data. /// /// /// /// When the or temporal processing contraints are defined (i.e., not null), this /// specifies the start and stop time over which the subscriber session will process data. Passing in null for the /// and specifies the the subscriber session will process data in standard, i.e., real-time, operation. /// /// /// /// Both the and parameters can be specified in one of the /// following formats: /// /// /// Time Format /// Format Description /// /// /// 12-30-2000 23:59:59.033 /// Absolute date and time. /// /// /// * /// Evaluates to . /// /// /// *-20s /// Evaluates to 20 seconds before . /// /// /// *-10m /// Evaluates to 10 minutes before . /// /// /// *-1h /// Evaluates to 1 hour before . /// /// /// *-1d /// Evaluates to 1 day before . /// /// /// /// public virtual string StartTime { get { return m_startTime; } set { m_startTime = value; } } /// /// Gets or sets the stop time of the requested /// temporal session for streaming historic data. /// /// /// /// When the or temporal processing contraints are defined (i.e., not null), this /// specifies the start and stop time over which the subscriber session will process data. Passing in null for the /// and specifies the the subscriber session will process data in standard, i.e., real-time, operation. /// /// /// /// Both the and parameters can be specified in one of the /// following formats: /// /// /// Time Format /// Format Description /// /// /// 12-30-2000 23:59:59.033 /// Absolute date and time. /// /// /// * /// Evaluates to . /// /// /// *-20s /// Evaluates to 20 seconds before . /// /// /// *-10m /// Evaluates to 10 minutes before . /// /// /// *-1h /// Evaluates to 1 hour before . /// /// /// *-1d /// Evaluates to 1 day before . /// /// /// /// public virtual string StopTime { get { return m_stopTime; } set { m_stopTime = value; } } /// /// Gets or sets the aditional constraint parameters /// supplied to temporal adapters in a temporal session. /// public virtual string ConstraintParameters { get { return m_constraintParameters; } set { m_constraintParameters = value; } } /// /// Gets or sets the processing interval requested by the subscriber. /// A value of -1 indicates the default processing interval. /// A value of 0 indicates data will be processed as fast as /// possible. /// /// /// With the exception of the values of -1 and 0, the value specifies the desired historical playback data /// processing interval in milliseconds. This is basically a delay, or timer interval, overwhich to process data. Setting this value to -1 means /// to use the default processing interval while setting the value to 0 means to process data as fast as possible. /// public virtual int ProcessingInterval { get { return m_processingInterval; } set { m_processingInterval = value; } } /// /// Gets or sets the wait handle names used to deterministically /// wait for data to become available on the server side. /// public virtual string WaitHandleNames { get { return m_waitHandleNames; } set { m_waitHandleNames = value; } } /// /// Gets or sets the amount of time to wait on the wait handles /// identified by the before the /// operation times out. /// public virtual int WaitHandleTimeout { get { return m_waitHandleTimeout; } set { m_waitHandleTimeout = value; } } /// /// Gets or sets the additional connection string parameters to /// be applied to the connection string sent to the publisher /// during subscription. /// public virtual string ExtraConnectionStringParameters { get { return m_extraConnectionStringParameters; } set { m_extraConnectionStringParameters = value; } } #endregion #region [ Methods ] /// /// Creates a shallow copy of this /// object. /// /// The copy of this object. public virtual SubscriptionInfo Copy() { return (SubscriptionInfo)MemberwiseClone(); } #endregion } /// /// Configuration object for synchronized data subscriptions. /// public sealed class SynchronizedSubscriptionInfo : SubscriptionInfo { #region [ Members ] // Fields private bool m_remotelySynchronized; private int m_framesPerSecond; private DownsamplingMethod m_downsamplingMethod; private bool m_allowPreemptivePublishing; private bool m_allowSortsByArrival; private bool m_ignoreBadTimestamps; private long m_timeResolution; #endregion #region [ Constructors ] /// /// Creates a new instance of the class. /// /// Flag that determines whether the subscription defined by this object is remotely synchronized or locally synchronized. /// Frame rate of the subscription in frames per second. public SynchronizedSubscriptionInfo(bool remotelySynchronized, int framesPerSecond) { m_remotelySynchronized = remotelySynchronized; m_framesPerSecond = framesPerSecond; m_downsamplingMethod = DownsamplingMethod.LastReceived; m_allowPreemptivePublishing = true; m_allowSortsByArrival = true; m_timeResolution = Ticks.PerMillisecond; } #endregion #region [ Properties ] /// /// Gets or sets the flag that determines whether this subscription /// is remotely synchronized or locally synchronized. /// public bool RemotelySynchronized { get { return m_remotelySynchronized; } set { m_remotelySynchronized = value; } } /// /// Gets or sets the frame rate of the subscription in frames per second. /// public int FramesPerSecond { get { return m_framesPerSecond; } set { m_framesPerSecond = value; } } /// /// Gets or sets the downsampling method used when the frame rate of /// the subscription is lower than the frame rate of the measurement's /// source. /// public DownsamplingMethod DownsamplingMethod { get { return m_downsamplingMethod; } set { m_downsamplingMethod = value; } } /// /// Gets or sets the flag that determines whether frames should be published /// as soon as the data is available. If false, frames will be published /// when their timestamp expires (realTime > timestamp + lagTime). /// public bool AllowPreemptivePublishing { get { return m_allowPreemptivePublishing; } set { m_allowPreemptivePublishing = value; } } /// /// Gets or sets the flag that determines whether to allow measurement /// sorting based on the measurement's time of arrival, if its timestamp /// is unreasonable. /// public bool AllowSortsByArrival { get { return m_allowSortsByArrival; } set { m_allowSortsByArrival = value; } } /// /// Gets or sets the flag that determines whether to /// ignore bad timestamps when sorting measurements. /// public bool IgnoreBadTimestamps { get { return m_ignoreBadTimestamps; } set { m_ignoreBadTimestamps = value; } } /// /// Gets or sets the maximum time resolution, in ticks, to use when sorting measurements by timestamps into their proper destination frame. /// /// /// /// /// Desired maximum resolution /// Value to assign /// /// /// Seconds /// . /// /// /// Milliseconds /// . /// /// /// Microseconds /// . /// /// /// 100-Nanoseconds /// 0 /// /// /// Assigning values less than zero will be set to zero since minimum possible concentrator resolution is one tick (100-nanoseconds). Assigning /// values values greater than . will be set to . /// since maximum possible concentrator resolution is one second (i.e., 1 frame per second). /// public long TimeResolution { get { return m_timeResolution; } set { m_timeResolution = value; } } #endregion } /// /// Configuration object for unsynchronized data subscriptions. /// public sealed class UnsynchronizedSubscriptionInfo : SubscriptionInfo { #region [ Members ] // Fields private bool m_throttled; private double m_publishInterval; private bool m_includeTime; #endregion #region [ Constructors ] /// /// Creates a new instance of the class. /// /// The flag that determines whether to request that the subscription be throttled. public UnsynchronizedSubscriptionInfo(bool throttled) { m_throttled = throttled; m_publishInterval = -1; m_includeTime = true; } #endregion #region [ Properties ] /// /// Gets or sets the flag that determines whether /// to request that the subscription be throttled. /// public bool Throttled { get { return m_throttled; } set { m_throttled = value; } } /// /// Gets or sets the interval at which data should be /// published when using a throttled subscription. /// public double PublishInterval { get { return m_publishInterval; } set { m_publishInterval = value; } } /// /// Gets or sets the flag that determines whether timestamps are /// included in the data sent from the publisher. This value is /// ignored if the data is remotely synchronized. /// public bool IncludeTime { get { return m_includeTime; } set { m_includeTime = value; } } #endregion } }