Class DataMonitoring

Tracks and collects device parameter values over time.

Unlike startMonitoring, which returns an observable that does not complete on its own, this class provides explicit control over starting, stopping, and collecting monitoring data. It supports exporting the data in CSV format and provides statistical analysis of the sampling intervals.

Hierarchy

  • DataMonitoring

Constructors

Properties

The Motion Master client used to communicate with the device.

collect: boolean = true

Determines whether incoming monitoring data should be collected.

When true, each emitted value from the monitoring observable is appended to the data array. Set to false to receive data without storing it.

Optional monitoring configuration, such as filters or buffering options.

data: ParameterValueType[][] = []

Stores the collected monitoring data.

Each element of the outer array represents a single monitoring sample, which is an array of parameter values corresponding to ids. Use clear to reset this array before starting a new monitoring session.

An array of device parameter IDs to monitor. Each ID can be a string or a tuple [deviceRef, index, subindex].

monitoringInterval: number

The interval, in microseconds, at which parameter values should be sampled.

stopped: boolean = false

Internal flag indicating whether monitoring has been stopped.

Used by start and stop to control the observable pipeline. When true, the observable returned by start completes on the next emission.

subscription?: Subscription

The internal RxJS subscription used to manage the monitoring stream started by start.

This reference is used by stop to ensure a clean unsubscribe.

Accessors

  • get analysis(): {
        count: number;
        durations: number[];
        filtered: number[];
        filteredCount: number;
        filteredStats: {
            iqr: number;
            max: number;
            mean: number;
            median: number;
            min: number;
            p95: number;
            q1: number;
            q3: number;
            std: number;
        };
        fullStats: {
            iqr: number;
            max: number;
            mean: number;
            median: number;
            min: number;
            p95: number;
            q1: number;
            q3: number;
            std: number;
        };
    }
  • Returns a statistical analysis of the measured timestamp durations.

    The analysis is computed by analyzeTimeDurations, which includes a variety of metrics such as minimum, maximum, mean, median, standard deviation, percentiles, and interquartile range. It also provides filtered statistics based on outlier removal using the IQR method.

    Returns

    An object containing both raw and filtered duration statistics for the monitoring session.

    Returns {
        count: number;
        durations: number[];
        filtered: number[];
        filteredCount: number;
        filteredStats: {
            iqr: number;
            max: number;
            mean: number;
            median: number;
            min: number;
            p95: number;
            q1: number;
            q3: number;
            std: number;
        };
        fullStats: {
            iqr: number;
            max: number;
            mean: number;
            median: number;
            min: number;
            p95: number;
            q1: number;
            q3: number;
            std: number;
        };
    }

    • count: number
    • durations: number[]
    • filtered: number[]
    • filteredCount: number
    • filteredStats: {
          iqr: number;
          max: number;
          mean: number;
          median: number;
          min: number;
          p95: number;
          q1: number;
          q3: number;
          std: number;
      }
      • iqr: number
      • max: number
      • mean: number
      • median: number
      • min: number
      • p95: number
      • q1: number
      • q3: number
      • std: number
    • fullStats: {
          iqr: number;
          max: number;
          mean: number;
          median: number;
          min: number;
          p95: number;
          q1: number;
          q3: number;
          std: number;
      }
      • iqr: number
      • max: number
      • mean: number
      • median: number
      • min: number
      • p95: number
      • q1: number
      • q3: number
      • std: number
  • get csv(): string
  • Converts the collected monitoring data into CSV (Comma-Separated Values) format.

    The first row contains the CSV header generated from header, followed by one row per collected sample in data. Each row represents the parameter values at a given monitoring interval.

    Returns

    A string representing the collected data in CSV format, ready for export or analysis.

    Returns string

  • get durations(): number[]
  • Returns the time differences (in microseconds) between consecutive timestamp values.

    Each duration is computed as:

    durations[i] = timestamps[i] - timestamps[i - 1]

    If fewer than two timestamps are available, an empty array is returned.

    Returns

    An array of durations representing the time between successive timestamp samples.

    Returns number[]

  • get header(): string
  • Generates a CSV header string from the monitored parameter IDs.

    Each parameter ID in ids is converted to a string representation using makeParameterId. String IDs are parsed with splitDeviceParameterId, while tuple IDs [deviceRef, index, subindex] are converted directly.

    Example

    // Possible output: "0x6040:00,0x6060:00,0x6071:00,0x607A:00,0x60FF:00"
    

    Returns

    A comma-separated string representing the header for CSV export.

    Returns string

  • get timestampIndex(): number
  • Finds the zero-based index of the timestamp field in the monitored parameters.

    The timestamp field is identified as object 0x20F0 with subindex 0x00. Parameter IDs in ids may be strings (parsed using splitDeviceParameterId) or tuples in the form [deviceRef, index, subindex].

    Returns

    The index of the timestamp entry in ids, or -1 if no timestamp field exists.

    Returns number

  • get timestamps(): number[]
  • Extracts the timestamp values from the collected monitoring data.

    The timestamp column is determined by timestampIndex, which locates the entry corresponding to object 0x20F0:00 in the monitored parameter list. If no timestamp index is found, an empty array is returned.

    Returns

    An array of numeric timestamps aligned with the collected monitoring samples, or an empty array if no timestamp field is configured.

    Returns number[]

Methods

  • Starts a new monitoring session and returns an observable that emits device parameter values as they arrive.

    This method first calls stop to ensure any existing session is cleanly terminated. It then resets the internal state and, if clear is true, removes all previously collected data.

    The returned observable emits values until stop is called, at which point the internal stopped flag is set, causing the stream to complete on its next emission via takeWhile(). This mechanism ensures that all internal and external subscriptions are cleanly shut down, preventing resource leaks.

    If collect is enabled, each emitted value is also appended to the data array for later retrieval or analysis.

    Returns

    An observable that emits arrays of parameter values until the monitoring is stopped or the source observable completes.

    Parameters

    • clear: boolean = false

      Whether to clear previously collected data in data before starting the monitoring session. Defaults to false.

    Returns Observable<ParameterValueType[]>

  • Stops the active monitoring session and unsubscribes from the source observable.

    This method sets the internal stop flag, causing the observable created in start to complete on its next emission. If a subscription was created during start(), it is explicitly unsubscribed and cleared. This ensures that no monitoring pipeline remains active and prevents resource leaks when creating new DataMonitoring instances.

    Calling this method has no effect if monitoring is not currently active.

    Returns void

Generated using TypeDoc