外观
finWatcherExt 扩展参考
原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34794078209/FIN+5.3.1+finWatcherExt 中文整理基于 FIN 5.3.1
导读: FIN观察者扩展
以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。
目录(导读)
- classes
- docs
- Overview
- Slot Details
- checkMsg
- ext
- initMsg
- make
- onFreqChange
- onStart
- onStop
- receive
- stopped
- cur
- finResetBoolStats
- finResetStatsStartTime
- finWatcherCallbackOn
概述(中译)
FinWatcher 扩展实现了一个监视机制,用于检测设备上的变化,同时也用于收集历史化布尔点的统计数据。
检测到的每个更改都会创建一个包含以下内容的临时记录:
- 一个指向已更改记录的 finWatcherChangedRef 引用
- 表示更改类型的标记标签,finWatcherAdded、finWatcherChanged、finWatcherRemoved
- 如果检测到记录结构的更改,并标记为 finWatcherChanged,则必须存在 finWatcherChanges
FinWatcher 会在每次检测到变化时调用一个用 finWatcherCallback 标记的函数 (func)。可以有多个回调函数在一次检测过程中执行。回调函数必须有两个参数,"self" 指向当前回调函数记录的 ID,"timestamp"(数字类型)表示检测到的最后一次变化的时间戳。函数将负责选择如何处理检测到的变化,并可以使用 timestamp 参数仅处理较新的变化。在 finWatcherCallback 函数中添加 finWatcherCallbackOn 标签,会指示 FinWatcher 仅评估回调函数中匹配 finWatcherCallbackOn 标签内 Axon 表达式的变化。比当前时间减去 2 倍 finWatcherFreq 更早的变化记录将被标记为垃圾。
布尔点的统计收集器收集有关一个点处于真状态的频率以及在一段时间内持续多长时间的数据。每个启用历史记录的布尔点将为这两个值分别添加两个额外的标签,称为“runStarts”和“runTime”。初始周期由该点历史记录的开始日期时间确定,然后随着统计的运行,周期的开始时间为上一次收集器的结束日期时间。statsResetTs 标签可以覆盖收集器使用的时间跨度的开始时间。
const class FinBoolStats : Actor
构造函数
字段
方法
插槽详情
API 正文(英文)
checkMsg
const static Obj checkMsg := "_check_"
ext
const Ext ext
initMsg
const static Obj initMsg := "_init_"
make
new make(Ext ext)
onFreqChange
Void onFreqChange()
onStart
Void onStart()
onStop
Void onStop()
receive
virtual override Obj? receive(Obj? msg)
stopped
const AtomicBool stopped := AtomicBool.<ctor>(false)
FinWatcher
const class FinWatcher : Actor
Constructors
| make |
Fields
| checkMsg | |
| ext | |
| initMsg | |
| stopped |
Methods
| onFreqChange | |
| onStart | |
| onStop | |
| receive |
Slot Details
checkMsg
const static Obj checkMsg := "_check_"
ext
const Ext ext
initMsg
const static Obj initMsg := "_init_"
make
new make(Ext ext)
onFreqChange
Void onFreqChange()
onStart
Void onStart()
onStop
Void onStop()
receive
virtual override Obj? receive(Obj? msg)
stopped
const AtomicBool stopped := AtomicBool.<ctor>(false)
FinWatcherExt
@ExtMeta { name="finWatcher"; depends=["his"] } @FinExtMeta { licFeature="finstack"; pngIcon=`fan://finWatcherExt/res/img/icon24.png` } const class FinWatcherExt : FinExt
Methods
| cur | |
| onFreqChange | |
| onStart | |
| onStop |
Slot Details
cur
static FinWatcherExt? cur(Bool checked := true)
onFreqChange
Void onFreqChange(Dict event)
onStart
virtual override Void onStart()
onStop
virtual override Void onStop()
FinWatcherLib
const class FinWatcherLib : Obj
Methods
| finResetBoolStats | Resets runtime statistics for bool points |
| finResetStatsStartTime | Resets the start time from when boolean statistics are collected. |
| finWatcherCallbackOn | Based on the filter expression, returns a grid with all the changes that match the filter expression. |
Slot Details
finResetBoolStats
@Axon static Void finResetBoolStats(Dict ops := Etc.makeDict(["runStarts","runTime"]))
Resets runtime statistics for bool points
By default this will reset both runStarts and runTime.
Users can reset only one of them by setting the tag parameter like:
finResetBoolStats({runTime}) or finResetBoolStats({runStarts})
finResetStatsStartTime
@Axon static Void finResetStatsStartTime(Obj? points := null, DateTime? ts := null)
Resets the start time from when boolean statistics are collected. there are 2 optional parameters:
- point can be a point or list of points which need to be reseted, if null then all the bools stats point
- time stamp, the datetime of the new stats collecting start, if null it is the current datetime
finWatcherCallbackOn
@Axon static Grid finWatcherCallbackOn(Str filter, Grid chagedRefs := Etc.makeEmptyGrid())
Based on the filter expression, returns a grid with all the changes that match the filter expression.