メインコンテンツまでスキップ

History 履歴

Session::read_history(...) これは簡略化されたエントリであり、完全なものは Session::read_history_* / update_history / API にあります delete_history_range。

サブページへの移動
  • 当該範囲内のすべての原点については、以下をご参照ください ReadRaw.
  • 変更履歴についてはこちらをご参照ください ReadModified.
  • 特定の時点における補間については、以下を参照してください ReadAtTime.
  • 集計(平均/最小/最大/ TimeAverage / …)については、こちらをご参照ください ReadProcessed.
  • 履歴(アラーム/条件)については、こちらをご参照ください ReadEvents.
  • 履歴の書き込み(挿入/置換/更新)については、以下をご参照ください HistoryUpdate.
  • 履歴の削除についてはこちらをご参照ください Delete.

5つのモード HistoryRead​

モードAPI説明
Raw 生データread_history区間内のすべての点
Modified 変更履歴ありread_history_modifiedこの範囲には変更履歴が含まれています
AtTime 指定された時点read_history_at_time指定されたタイムスタンプによる補間
Processed 集約read_history_processed集計 (平均 / 最小 / 最大 / ...)
Events イベント履歴read_history_events履歴 (アラーム / 条件)

HistoryUpdate / Delete​

API用途
update_history履歴データの挿入/置換/更新/削除
delete_history_range時間範囲で削除(変更履歴を含む/含まない)

時間の種類​

すべての履歴 API を std::time::SystemTime. で内部変換 FILETIME (1601ベースの 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)?;

一般的な前提​

  • サーバー側はHistorianに対応している必要があります。対応していない場合は、一律に返答します。 BAD_HISTORY_OPERATION_UNSUPPORTED
  • ノードの AccessLevel ビット4(HistoryRead)およびビット8(HistoryWrite)は、セットされている必要がある
  • ノード Historizing Attribute (20) 履歴を記録するかどうかを決定する

Aggregate NodeId 定数​

darra_opcua::history_aggregate モジュールで定義済みの標準集計関数 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 列挙型​

pub enum HistoryUpdateType {
Insert = 1, // 新しい値を挿入します。すでに存在する場合は失敗します。
Replace = 2, // 既存のものを置き換える。存在しない場合は失敗する。
Update = 3, // 「Insert」でも「Replace」でも構いません
Remove = 4, // 時間順に削除(削除 SourceTimestamp 対象は のみで決定)
}

次のステップ​