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
- For a list of all origin points within the range, please refer to ReadHistory (Raw).
- For a record of changes, please refer to ReadHistoryModified.
- For interpolation at a specific point in time, please refer to ReadHistoryAtTime.
- Aggregation (Avg / Min / Max / TimeAverage / ...) Please refer to ReadHistoryProcessed.
- Historical Events (Alarms / Conditions) — Please refer to ReadHistoryEvents.
- For writing history (Insert / Replace / Update / Remove), please refer to UpdateHistory.
- For instructions on deleting history by time period, please refer to DeleteHistoryRange.
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
| Pattern | API | Note |
|---|---|---|
| Raw Data | ReadHistory(...) | All points within the interval |
| Modified (includes revision history) | ReadHistoryModified(...) | The range contains modification records |
| AtTime A specific point in time | ReadHistoryAtTime(...) | Interpolation for a Given Timestamp |
| Processed Aggregation | ReadHistoryProcessed(...) | Aggregation (Avg / Min / Max / ...) |
| Events History | ReadHistoryEvents(...) | Historical Events (Alarms / Conditions) |
HistoryUpdate
| API | Uses |
|---|---|
| UpdateHistory | Insert / Replace / Update / Remove Historical Data |
| DeleteHistoryRange | Delete 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 asBadNotSupported/BadNotReadable/BadCommunicationError. These are raw StatusCodes from the server, surfaced asuint32_t; theStatusenum includes only a subset of common values (includingBadHistoryOperationUnsupported/BadNotReadable/BadCommunicationError, excludingBadNotSupported). For unlisted codes, read the raw value withe.status_code(); do not write enum names likeStatus::BadNotSupported, which fail to compile. - All calls
DeleteHistoryRangeother than result in a throwException; usee.status_code()(uint32_t) ore.status()(Statusenum) to retrieve the status code;DeleteHistoryRangereturns directlyStatusas the return value and does not throw. - Node
AccessLevelAttribute (17) must have historical permissions: Bit 2 (0x04) = HistoryRead, Bit 3 (0x08) = HistoryWrite (same mask as0x01current read /0x02current write). - Node
HistorizingAttribute (20) = Whether the server is currently logging history.