Skip to main content

History

Session::read_history(...) This is a simplified entry; the full version is at API Session::read_history_* / update_history / delete_history_range.

Subpage Redirect
  • For a list of all origin points within the range, please refer to ReadRaw.
  • For a record of changes, please refer to ReadModified.
  • For interpolation at a specific point in time, please refer to ReadAtTime.
  • Aggregation (Average / Min / Max / TimeAverage / ...) Please refer to ReadProcessed.
  • Historical Events (Alarms / Conditions) — Please refer to ReadEvents.
  • For writing history (Insert / Replace / Update), please refer to HistoryUpdate.
  • For instructions on deleting history, please refer to Delete.

5 Modes HistoryRead​

PatternAPINote
Raw Dataread_historyAll points within the interval
Modified (includes revision history)read_history_modifiedThe range contains modification records
AtTime A specific point in timeread_history_at_timeInterpolation for a Given Timestamp
Processed Aggregationread_history_processedAggregation (Average / Min / Max / ...)
Events Historyread_history_eventsHistorical Events (Alarms / Conditions)

HistoryUpdate / Delete​

APIUses
update_historyInsert / Replace / Update / Remove Historical Data
delete_history_rangeDelete by Time Range (Including / Excluding Modification Records)

Time Type​

All history converted internally using API std::time::SystemTime. ( FILETIME 1601-based ticks 100ns ):

use std::time::{Duration, SystemTime};

let now = SystemTime::now();
let one_hour_ago = now - Duration::from_secs(3600);

let dvs = s.read_history("ns=2;s=Temperature", one_hour_ago, now, 1000)?;

General Prerequisites​

  • The server must support Historian; otherwise, a uniform response will be returned. BAD_HISTORY_OPERATION_UNSUPPORTED
  • Bit AccessLevel 4 (HistoryRead) / bit 8 (HistoryWrite) of the node must be set
  • Node Historizing Attribute (20) Determines whether to log history

Aggregate NodeId Constants​

darra_opcua::history_aggregate Module-defined standard aggregation functions NodeId:

use darra_opcua::history_aggregate;

history_aggregate::AVERAGE; // i=2342
history_aggregate::MINIMUM; // i=2346
history_aggregate::MAXIMUM; // i=2347
history_aggregate::COUNT; // i=2352
history_aggregate::TOTAL; // i=2348
history_aggregate::TIME_AVERAGE; // i=11285
history_aggregate::RANGE; // i=2353
history_aggregate::DELTA; // i=11286
history_aggregate::STANDARD_DEVIATION_SAMPLE; // i=11427

HistoryUpdateType Enumeration​

pub enum HistoryUpdateType {
Insert = 1, // Insert a new value; if it already exists, the operation fails.
Replace = 2, // Replace if it already exists; otherwise, the operation fails.
Update = 3, // "Insert" or "Replace"—either is fine.
Remove = 4, // Delete by Date (Use this option only to SourceTimestamp decide which items to delete)
}

Next Step​