跳到主要内容

History 历史

ua.read_history(...) 是简化入口, 完整 API 直接挂在 OpcUaSession 上, 命名 read_history_* / update_history / delete_history_*.

子页跳转

5 种 HistoryRead 模式

模式API说明
Raw 原始数据read_history区间内全部点
Modified 含修改记录read_history_modified区间内含修改记录
AtTime 指定时间点read_history_at_time给定时间戳的内插值
Processed 聚合read_history_processed聚合 (Avg / Min / Max / ...)
Events 事件历史read_history_events历史事件 (报警 / 条件)

HistoryUpdate

API用途
update_historyInsert / Replace / Update / Remove 历史数据
delete_history_range按时间段删除历史

时间戳约定

所有 API 入参 / 返回的 datetime 都是 UTC:

import datetime as dt

start = dt.datetime.now(dt.timezone.utc) - dt.timedelta(hours=1)
end = dt.datetime.now(dt.timezone.utc)

不要传本地时间 (dt.datetime.now() 默认本地, 没 tzinfo). SDK 内部 datetime → FILETIME 转换会强制按 UTC 处理 naive datetime.

通用前提

  • 服务端必须支持 Historian, 否则统一返回 BadHistoryOperationUnsupported
  • 节点的 AccessLevel bit 4 (HistoryRead) / bit 8 (HistoryWrite) 必须置位
  • 节点 Historizing Attribute (20) 决定是否在记录历史

下一步