Represents a record in the StateFile that contains the state information associated to a HistorianID.
Inheritance: ISupportBinaryImage, IComparable
Example #1
0
        /// <summary>
        /// Compares the current <see cref="StateRecord"/> object to <paramref name="obj"/>.
        /// </summary>
        /// <param name="obj">Object against which the current <see cref="StateRecord"/> object is to be compared.</param>
        /// <returns>
        /// Negative value if the current <see cref="StateRecord"/> object is less than <paramref name="obj"/>,
        /// Zero if the current <see cref="StateRecord"/> object is equal to <paramref name="obj"/>,
        /// Positive value if the current <see cref="StateRecord"/> object is greater than <paramref name="obj"/>.
        /// </returns>
        public virtual int CompareTo(object obj)
        {
            StateRecord other = obj as StateRecord;

            if (other == null)
            {
                return(1);
            }
            else
            {
                return(m_historianID.CompareTo(other.HistorianID));
            }
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StateRecordSummary"/> class.
 /// </summary>
 /// <param name="record">A <see cref="StateRecord"/> object.</param>
 public StateRecordSummary(StateRecord record)
 {
     HistorianID = record.HistorianID;
     CurrentData = record.CurrentData;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StateRecordSummary"/> class.
 /// </summary>
 /// <param name="record">A <see cref="StateRecord"/> object.</param>
 public StateRecordSummary(StateRecord record)
 {
     HistorianID = record.HistorianID;
     CurrentData = record.CurrentData;
 }
Example #4
0
 /// <summary>
 /// Raises the <see cref="ProcessAlarmNotification"/> event.
 /// </summary>
 /// <param name="pointState"><see cref="StateRecord"/> to send to <see cref="ProcessAlarmNotification"/> event.</param>
 protected virtual void OnProcessAlarmNotification(StateRecord pointState)
 {
     if ((object)ProcessAlarmNotification != null)
         ProcessAlarmNotification(this, new EventArgs<StateRecord>(pointState));
 }
Example #5
0
        private SerializableTimeSeriesData ReadCurrentTimeSeriesData(string fromID, string toID)
        {
            try
            {
                // Abort if services is not enabled.
                if (!Enabled)
                    return null;

                // Ensure that data archive is available.
                if (Archive == null)
                    throw new ArgumentNullException("Archive");

                // Read current time-series data from the archive.
                byte[] buffer = null;
                StateRecord state = null;
                SerializableTimeSeriesData data = new SerializableTimeSeriesData();
                List<SerializableTimeSeriesDataPoint> points = new List<SerializableTimeSeriesDataPoint>();
                for (int id = int.Parse(fromID); id <= int.Parse(toID); id++)
                {
                    buffer = Archive.ReadStateData(id);
                    if ((object)buffer == null)
                    {
                        // ID is invalid.
                        continue;
                    }
                    else
                    {
                        // Add to resultset.
                        state = new StateRecord(id, buffer, 0, buffer.Length);
                        points.Add(new SerializableTimeSeriesDataPoint(state.CurrentData));
                    }
                }
                data.TimeSeriesDataPoints = points.ToArray();

                return data;
            }
            catch (Exception ex)
            {
                // Notify about the encountered processing exception.
                OnServiceProcessException(ex);
                throw;
            }
        }
        private StateRecord ReadStateDataRecord(int historianID)
        {
            StateRecord record = new StateRecord(historianID);

            // TODO: Just doing this to get latest value until API supports this
            IEnumerable<IDataPoint> dataPoints;
            Ticks stopTime = DateTime.UtcNow.Ticks;
            Ticks startTime = stopTime - Ticks.PerSecond * 2;

            dataPoints = ReadDataStream(m_clientDatabase.Read((ulong)(long)startTime, (ulong)(long)stopTime, new[] { (ulong)historianID }));

            StateRecordDataPoint dataPoint = new StateRecordDataPoint(dataPoints.Last());

            record.CurrentData = dataPoint;
            record.PreviousData = dataPoint;
            record.ArchivedData = dataPoint;

            return record;
        }