/// <summary> /// Initializes a new instance of the <see cref="StateRecord"/> class. /// </summary> /// <param name="historianID">Historian identifier of <see cref="StateRecord"/>.</param> public StateRecord(int historianID) { m_historianID = historianID; m_archivedData = new StateRecordDataPoint(m_historianID); m_previousData = new StateRecordDataPoint(m_historianID); m_currentData = new StateRecordDataPoint(m_historianID); m_activeDataBlockIndex = -1; m_activeDataBlockSlot = 1; }
/// <summary> /// Initializes <see cref="StateRecordSummary"/> from the specified <paramref name="buffer"/>. /// </summary> /// <param name="buffer">Binary image to be used for initializing <see cref="StateRecordSummary"/>.</param> /// <param name="startIndex">0-based starting index of initialization data in the <paramref name="buffer"/>.</param> /// <param name="length">Valid number of bytes in <paramref name="buffer"/> from <paramref name="startIndex"/>.</param> /// <returns>Number of bytes used from the <paramref name="buffer"/> for initializing <see cref="StateRecordSummary"/>.</returns> public int ParseBinaryImage(byte[] buffer, int startIndex, int length) { if (length >= FixedLength) { // Binary image has sufficient data. HistorianID = LittleEndian.ToInt32(buffer, startIndex); CurrentData = new StateRecordDataPoint(HistorianID, buffer, startIndex + 4, length - 4); return(FixedLength); } else { // Binary image does not have sufficient data. return(0); } }
/// <summary> /// Initializes <see cref="StateRecordSummary"/> from the specified <paramref name="buffer"/>. /// </summary> /// <param name="buffer">Binary image to be used for initializing <see cref="StateRecordSummary"/>.</param> /// <param name="startIndex">0-based starting index of initialization data in the <paramref name="buffer"/>.</param> /// <param name="length">Valid number of bytes in <paramref name="buffer"/> from <paramref name="startIndex"/>.</param> /// <returns>Number of bytes used from the <paramref name="buffer"/> for initializing <see cref="StateRecordSummary"/>.</returns> public int ParseBinaryImage(byte[] buffer, int startIndex, int length) { if (length >= FixedLength) { // Binary image has sufficient data. HistorianID = LittleEndian.ToInt32(buffer, startIndex); CurrentData = new StateRecordDataPoint(HistorianID, buffer, startIndex + 4, length - 4); return FixedLength; } else { // Binary image does not have sufficient data. return 0; } }
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; }