History 历史
Session 提供历史读 5 模式 + 历史写 / 删. 时间一律用 FileTime (UTC 100ns since 1601-01-01), 与 Windows DateTime.ToFileTimeUtc() 一致.
子页跳转
- 区间内全部原始点请参考 ReadHistory (Raw).
- 含修改记录请参考 ReadHistoryModified.
- 指定时间点的内插值请参考 ReadHistoryAtTime.
- 聚合 (Avg / Min / Max / TimeAverage / ...) 请参考 ReadHistoryProcessed.
- 历史事件 (报警 / 条件) 请参考 ReadHistoryEvents.
- 写历史 (Insert / Replace / Update / Remove) 请参考 UpdateHistory.
- 按时间段删除历史请参考 DeleteHistoryRange.
FileTime 常量
constexpr int64_t WIN_EPOCH_OFFSET = 116444736000000000LL; // 1601 → 1970 间隔
// 当前时刻的 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 小时前
int64_t one_hour_ago = now_ft - 3600LL * 10000000LL;
5 种 HistoryRead 模式
| 模式 | API | 说明 |
|---|---|---|
| Raw 原始数据 | ReadHistory(...) | 区间内全部点 |
| Modified 含修改记录 | ReadHistoryModified(...) | 区间内含修改记录 |
| AtTime 指定时间点 | ReadHistoryAtTime(...) | 给定时间戳的内插值 |
| Processed 聚合 | ReadHistoryProcessed(...) | 聚合 (Avg / Min / Max / ...) |
| Events 事件历史 | ReadHistoryEvents(...) | 历史事件 (报警 / 条件) |
HistoryUpdate
| API | 用途 |
|---|---|
UpdateHistory | Insert / Replace / Update / Remove 历史数据 |
DeleteHistoryRange | 按时间段删除 |
通用前提
- 服务端必须支持 Historian, 否则统一返回
Status::BadHistoryOperationUnsupported - 节点的 AccessLevel bit 4 (HistoryRead) / bit 8 (HistoryWrite) 必须置位
- 节点
HistorizingAttribute (20) 决定是否在记录历史