Skip to main content

History

Session Provides 5 modes for reading history + writing/deleting history. All times are expressed in FileTime (UTC 100ns since 1601-01-01), consistent DateTime.ToFileTimeUtc() with Windows.

Subpage Redirect

FileTime Constants​

constexpr int64_t WIN_EPOCH_OFFSET = 116444736000000000LL;  // 1601 → 1970 interval

// At this moment, FileTime
auto now_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
int64_t now_ft = WIN_EPOCH_OFFSET + now_ns / 100;

// 1 hour ago
int64_t one_hour_ago = now_ft - 3600LL * 10000000LL;

5 Modes HistoryRead​

PatternAPINote
Raw DataReadHistory(...)All points within the interval
Modified (includes revision history)ReadHistoryModified(...)The range contains modification records
AtTime A specific point in timeReadHistoryAtTime(...)Interpolation for a Given Timestamp
Processed AggregationReadHistoryProcessed(...)Aggregation (Avg / Min / Max / ...)
Events HistoryReadHistoryEvents(...)Historical Events (Alarms / Conditions)

HistoryUpdate​

APIUses
UpdateHistoryInsert / Replace / Update / Remove Historical Data
DeleteHistoryRangeDelete by Time Period

General Prerequisites​

  • The server must support Historian. If it does not, the server returns BadHistoryOperationUnsupported; it may also return status codes such as BadNotSupported / BadNotReadable / BadCommunicationError. These are raw StatusCodes from the server, surfaced as uint32_t; the Status enum includes only a subset of common values (including BadHistoryOperationUnsupported / BadNotReadable / BadCommunicationError, excluding BadNotSupported). For unlisted codes, read the raw value with e.status_code(); do not write enum names like Status::BadNotSupported, which fail to compile.
  • All calls DeleteHistoryRange other than result in a throw Exception; use e.status_code() (uint32_t) or e.status() (Status enum) to retrieve the status code; DeleteHistoryRange returns directly Status as the return value and does not throw.
  • Node AccessLevel Attribute (17) must have historical permissions: Bit 2 (0x04) = HistoryRead, Bit 3 (0x08) = HistoryWrite (same mask as 0x01 current read / 0x02 current write).
  • Node Historizing Attribute (20) = Whether the server is currently logging history.

Next Step​