UNPKG

@kvaser/canking-api

Version:

CanKing API to communicate with the CanKing service using Node.js.

110 lines (109 loc) 4.68 kB
import Long from 'long'; import { Frame, FixedPosFrameIdentifier } from '../models'; /** * Interface for signal data. */ export interface ISignalData { /** The qualified name of the signal. */ qualifiedName: string; /** The source identifier of the signal. */ sourceId?: string; /** The name of the signal. */ name: string; /** The unit of the signal. */ unit: string; /** The timestamp of the signal data in microseconds. */ timeUs: Long; /** The double value of the signal. */ doubleValue: number; /** Optional string value of the signal. */ stringValue?: string; } /** * Initialization state for signal data hook. * @internal */ export declare enum SignalDataInitState { /** Not yet initialized */ PENDING = "pending", /** Frame keys loaded, waiting for historical data */ FRAME_KEYS_READY = "frameKeysReady", /** Historical data loaded, waiting for frame keys */ HISTORICAL_DATA_READY = "historicalDataReady", /** Fully initialized and ready to process data */ READY = "ready" } /** * Interface for signal data envelope. * Each envelope contains arrays of time, min, and max values for a signal. * All arrays are aligned by index. */ export interface ISignalDataEnvelope { /** The qualified name of the signal. */ qualifiedName: string; /** The source identifier of the signal. */ sourceId?: string; /** The timestamps of the signal data in microseconds. */ timeUs: number[]; /** The minimum values of the signal data. */ min: number[]; /** The maximum values of the signal data. */ max: number[]; } /** * Interface for envelope view parameters. */ export interface IEnvelopeView { /** The start time of the view in microseconds. */ startTimeUs?: number; /** The end time of the view in microseconds. */ endTimeUs?: number; /** The time window of the view in microseconds. If start and end is not set then this defines the window. */ windowUs?: number; /** The width of the view in pixels. */ width?: number; /** Optional counter to force update the envelopes. Change it to trigger a refresh even if other parameters have not changed. */ forceUpdateCounter?: number; } /** * A hook for extracting message data from the measurement context. * * @remarks * This hook buffers incoming frame data during initialization (before historical data is ready) * and merges it with historical data once available. This ensures no data is lost during the startup phase. * * @param id - The unique id of the view. This is passed to the view component as the `id` prop. * @param subscriptionName - The subscription name for the data. Must be unique per view. * @param identifiers - The fixed position frame identifiers to get data for. To avoid unnecessary re-renders, make sure to memoize this object. * @returns The measurement data for the specified identifiers. If an empty array is returned, then all previously received data is invalid and should be discarded. */ export declare const useMessageData: (id: number, subscriptionName: string, identifiers: FixedPosFrameIdentifier[]) => Frame[]; /** * A hook for extracting signal data from the measurement context. * * @remarks * This hook buffers incoming frame data during initialization (before frame keys and historical data are ready) * and merges it with historical data once available. * * @param id - The unique id of the view. * @param subscriptionName - The subscription name for the data. Must be unique per view. * @param subscribedSignals - The signals to extract data for. To avoid unnecessary re-renders, memoize this object. * @returns The extracted signal data. If an empty array is returned, all previously received data is invalid and should be discarded. */ export declare const useSignalData: (id: number, subscriptionName: string, subscribedSignals: { qualifiedName: string; sourceId?: string; }[]) => ISignalData[]; /** * A hook for extracting signal data envelopes to be used for graphical visualization. * * @param id - The unique id of the view. * @param subscriptionName - The subscription name for the data. Must be unique per view. * @param subscribedSignals - The subscribed signals with their qualified names and optional source identifiers. * @param view - Optional view parameters to define the time range and width for the envelopes. * @returns The extracted signal data envelopes. */ export declare const useSignalDataEnvelopes: (id: number, subscriptionName: string, subscribedSignals: { qualifiedName: string; sourceId?: string; }[], view: IEnvelopeView) => ISignalDataEnvelope[];