-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference: Event Detection
Inherits from:
handle
det = EventDetector() det = EventDetector('MinDuration', 2, 'OnEventStart', @myCallback)
Call shape: events = det.detect(tag, threshold) % 2-arg Tag overload
Reads (X, Y) from tag.getXY() and derives threshold metadata from the Threshold handle; forwards to the private detect_ body. Dispatch is entry-level on isa(arg, 'Tag') — the ABSTRACT BASE — matching the FastSense.addTag precedent (Pitfall 1: NO subclass isa anywhere in this file).
obj = EventDetector(varargin)| Property | Default | Description |
|---|---|---|
| MinDuration | numeric: minimum event duration (default 0) | |
| OnEventStart | function handle: callback f(event) on new event | |
| MaxCallsPerEvent | numeric: max callback invocations per event (default 1) |
DETECT Find events from threshold violations. events = det.detect(tag, threshold)
Inherits from:
handle
Tracks last-processed index per sensor and carries over open events.
obj = IncrementalEventDetector(varargin)| Property | Default | Description |
|---|---|---|
| MinDuration | 0 |
|
| MaxCallsPerEvent | 1 |
|
| OnEventStart | [] |
|
| EscalateSeverity | true |
PROCESS Legacy entry point -- no longer functional. The Sensor/Threshold/StateChannel pipeline this method relied on was deleted in Phase 1011. LiveEventPipeline now uses MonitorTag.appendData() for incremental detection (Phase 1007 MONITOR-08). This stub remains so that callers get a clear error rather than a missing-method crash.
Inherits from:
handle
e = Event(startTime, endTime, sensorName, thresholdLabel, thresholdValue, direction) e.setStats(peakValue, numPoints, minVal, maxVal, meanVal, rmsVal, stdVal)
obj = Event(startTime, endTime, sensorName, thresholdLabel, thresholdValue, direction)| Property | Default | Description |
|---|---|---|
| TagKeys | {} |
cell of char: tag keys bound to this event (EVENT-01) |
| Severity | 1 |
numeric: 1=ok/info, 2=warn, 3=alarm (EVENT-04) |
| Category | '' |
char: alarm|maintenance|process_change|manual_annotation (EVENT-05) |
| Id | '' |
char: unique id assigned by EventStore.append (EVENT-02) |
| IsOpen | false |
logical: true while event is still open (EndTime = NaN) — Phase 1012 |
| Notes | '' |
char: free-form user annotation edited via details popup — Phase 1012 |
| DIRECTIONS | {'upper', 'lower'} |
SETSTATS Set event statistics.
CLOSE Close an open event in place; update EndTime, Duration, and optional running stats. ev.close(endTime, finalStats) mutates the SetAccess=private fields EndTime and Duration and optionally populates stats from a struct with fields {PeakValue, NumPoints, MinValue, MaxValue, MeanValue, RmsValue, StdValue}. Toggles IsOpen false. Called by EventStore.closeEvent.
ESCALATETOP Escalate event to a higher severity threshold.
Inherits from:
handle
cfg = EventConfig() cfg.MinDuration = 2; cfg.addSensor(sensor); events = cfg.runDetection();
obj = EventConfig()| Property | Default | Description |
|---|---|---|
| Sensors | cell array of Sensor objects | |
| SensorData | struct array: name, t, y (for viewer click-to-plot) | |
| MinDuration | numeric: debounce (default 0) | |
| MaxCallsPerEvent | numeric: callback limit (default 1) | |
| OnEventStart | function handle: callback | |
| ThresholdColors | containers.Map: label -> [R G B] | |
| AutoOpenViewer | logical: auto-open EventViewer after detection | |
| EscalateSeverity | logical: escalate events to higher thresholds (default true) | |
| EventFile | char: path to .mat file for auto-saving events (empty = disabled) | |
| MaxBackups | numeric: number of backup files to keep (default 5, 0 = no backups) |
ADDSENSOR Legacy entry point -- no longer functional. The Sensor.resolve() pipeline was deleted in Phase 1011. Use MonitorTag + EventStore for event detection.
SETCOLOR Set color for a threshold label.
BUILDDETECTOR Create a configured EventDetector.
RUNDETECTION Detect events across all configured sensors.
Inherits from:
handle
obj = EventStore(filePath, varargin)| Property | Default | Description |
|---|---|---|
| FilePath | '' |
|
| MaxBackups | 5 |
|
| PipelineConfig | struct() |
|
| SensorData | [] |
struct array: name, t, y (for EventViewer click-to-plot) |
| ThresholdColors | struct() |
serialized threshold colors struct |
| Timestamp | [] |
datetime: when events were saved |
CLOSEEVENT Close an open event in place. es.closeEvent(eventId, endTime, finalStats) locates an open Event by Id, delegates to ev.close(endTime, finalStats) for the in-place mutation, and returns. finalStats may be [] (empty) to skip stats update. Does NOT call save() — consumers decide when to persist (Pitfall 2).
GETEVENTSFORTAG Return events bound to tagKey via EventBinding + carrier fallback. Primary path: uses EventBinding.getEventsForTag for events with non-empty Id (Phase 1010 EVENT-01/EVENT-03). Fallback path: carrier-field matching (SensorName/ThresholdLabel) for events without Id (backward compat, Pitfall 4).
Inherits from:
handle
viewer = EventViewer(events) viewer = EventViewer(events, sensorData) viewer = EventViewer(events, sensorData, thresholdColors) viewer.update(newEvents)
obj = EventViewer(events, sensorData, thresholdColors)| Property | Default | Description |
|---|---|---|
| Events | Event array | |
| SensorData | struct array: name, t, y (for click-to-plot) | |
| ThresholdColors | containers.Map: label -> [R G B] | |
| hFigure | figure handle | |
| BarPositions | Nx4 matrix: [x, y, w, h] cached from drawTimeline | |
| BarRects | rectangle handles for hover detection | |
| BarEvents | Event objects corresponding to BarRects |
UPDATE Refresh the viewer with new events.
GETSENSORNAMES Get unique sensor names from events.
GETTHRESHOLDLABELS Get unique threshold labels from events.
REFRESHFROMFILE Reload events from the source .mat file.
STARTAUTOREFRESH Start polling the source file at given interval. obj.startAutoRefresh(5) % refresh every 5 seconds
STOPAUTOREFRESH Stop the auto-refresh timer.
FROMFILE Open EventViewer from a saved .mat event store file. viewer = EventViewer.fromFile('events.mat')
Inherits from:
handle
Uses MonitorTargets — containers.Map of key -> MonitorTag; processed via MonitorTag.appendData (Phase 1007 MONITOR-08 streaming tail extension).
Ordering invariant (Pitfall Y) — enforced by processMonitorTag_: monitor.Parent.updateData(newX, newY) <- called FIRST monitor.appendData(newX, newY) <- THEN The reverse order causes cache incoherence: MonitorTag.appendData's cold path recomputes against a stale parent grid. See the docstring at libs/SensorThreshold/MonitorTag.m lines 330-334 for the contract.
obj = LiveEventPipeline(monitors, dataSourceMap, varargin)| Property | Default | Description |
|---|---|---|
| MonitorTargets | containers.Map: key -> MonitorTag | |
| DataSourceMap | DataSourceMap | |
| EventStore | EventStore | |
| NotificationService | NotificationService | |
| Interval | 15 |
seconds |
| Status | 'stopped' |
|
| MinDuration | 0 |
|
| EscalateSeverity | true |
|
| MaxCallsPerEvent | 1 |
|
| OnEventStart | [] |
Inherits from:
handle
obj = NotificationService(varargin)| Property | Default | Description |
|---|---|---|
| Rules | [] |
|
| DefaultRule | [] |
|
| Enabled | true |
|
| DryRun | false |
|
| SnapshotDir | '' |
|
| SnapshotRetention | 7 |
days |
| SmtpServer | '' |
|
| SmtpPort | 25 |
|
| SmtpUser | '' |
|
| SmtpPassword | '' |
|
| FromAddress | 'fastsense@noreply.com' |
|
| NotificationCount | 0 |
Inherits from:
handle
obj = NotificationRule(varargin)| Property | Default | Description |
|---|---|---|
| SensorKey | '' |
|
| ThresholdLabel | '' |
|
| Recipients | {{}} |
|
| Subject | 'Event: {sensor} - {threshold}' |
|
| Message | '{sensor} exceeded {threshold} ({direction}) at {startTime}. Peak: {peak}' |
|
| IncludeSnapshot | true |
|
| ContextHours | 2 |
|
| SnapshotPadding | 0.1 |
|
| SnapshotSize | [800, 400] |
Returns match score: 3=sensor+threshold, 2=sensor, 1=default, 0=no match
Inherits from:
handle
Subclasses must implement fetchNew() which returns a struct: .X — 1xN datenum timestamps .Y — 1xN (or MxN) values .stateX — 1xK datenum state timestamps (empty if none) .stateY — 1xK state values (empty if none) .changed — logical, true if new data since last call
Inherits from:
DataSource
obj = MatFileDataSource(filePath, varargin)| Property | Default | Description |
|---|---|---|
| FilePath | '' |
|
| XVar | 'X' |
|
| YVar | 'Y' |
|
| StateXVar | '' |
|
| StateYVar | '' |
Inherits from:
handle
obj = DataSourceMap()EventBinding stores (eventId, tagKey) pairs using two persistent containers.Map indexes (forward: eventId -> {tagKeys}, reverse: tagKey -> {eventIds}) for O(1) lookup in both directions.
This is the single-write-side for Event-Tag binding (EVENT-02). Only EventBinding.attach mutates the registry. Convenience wrappers on Event/Tag/EventStore delegate to this class.
ATTACH Bind an event to a tag (idempotent). EventBinding.attach(eventId, tagKey) adds the (eventId, tagKey) pair to both forward and reverse indexes. Silent on duplicate.
GETTAGKEYSFOREVENT Return cell of tagKey strings bound to eventId.
GETEVENTSFORTAG Return Event array bound to tagKey via reverse index. Uses the reverse index for O(1) lookup of eventIds, then filters the eventStore's events by matching Id.
CLEAR Reset all bindings in both forward and reverse indexes.
Inherits from:
DataSource
obj = MockDataSource(varargin)| Property | Default | Description |
|---|---|---|
| BaseValue | 100 |
|
| NoiseStd | 1 |
|
| DriftRate | 0 |
drift per second |
| SampleInterval | 3 |
seconds between points |
| BacklogDays | 3 |
days of history on first fetch |
| ViolationProbability | 0.005 |
chance per point of starting violation |
| ViolationAmplitude | 20 |
how far signal ramps beyond base |
| ViolationDuration | 60 |
seconds per violation episode |
| StateValues | {{}} |
cell of char, e.g. {'idle','running'} |
| StateChangeProbability | 0.001 |
chance per point of state transition |
| Seed | [] |
optional RNG seed |
| PipelineInterval | 15 |
seconds per fetch cycle |
FastPlot Wiki
API Reference
Guides
Use Cases
Internals
Resources