Kvaser CanKing GUI Extensions SDK - v7.6.1
    Preparing search index...

    Module hooks

    This module includes React hooks for getting/setting data from/to CanKing.

    To be able to use these hooks the CanKingDataProvider component must be present in the component tree above your component. Normally the CanKingDataProvider is added at the root of the component tree.

    Signal and message data — use these when your view needs live or historical CAN/LIN traffic:

    • useMessageData / useSignalData — subscribe to a known, fixed set of frames or signals (for example a gauge or custom widget bound to specific signals). Both automatically persist which frames/signals are subscribed to, buffer data received during startup, and clear their data when a new measurement goes online.
    • useSignalDataEnvelopes — like useSignalData, but returns min/max envelopes over a time window instead of individual samples. Use it to feed a signal plot/graph instead of a table.
    • useScrollModeMeasurementData / useFixedPositionModeMeasurementData — use these instead when your view needs to show all traffic rather than a fixed set of frames: scroll mode for a trace/log style view (latest data, at most 500 frames), fixed position mode for a dashboard showing the latest value per frame id.
    • To let the user pick which messages/signals to subscribe to, prefer the ready-made SelectMessageDialog, SelectSignalDialog and SelectSignalsControl components from @kvaser/canking-api/controls over building a custom picker. Fall back to useMessageDatabases — which lists the message databases (and their signals) available in the current measurement — only if you need a custom picker UI those controls don't support.

    Measurement setup nodes — use these to inspect the sources, data processors and targets configured in the measurement setup:

    Online status — use these to react to the measurement going online/offline:

    • useOnlineStatus — the current online/offline state. Use it to disable controls or clear stale data while offline.
    • useOnlineStatusSync — use this instead of useOnlineStatus when your view needs to run logic exactly once when going online or offline (rather than just reading a flag), and needs to distinguish a freshly-created view from one that's remounting after being hidden.

    Workspace persistence — use these to persist view state so it survives reloads:

    • useProjectDataSlice / useProjectData — persist data to the CanKing project file. Use this for state the user would expect saved with the project, e.g. a selected channel or configuration.
    • useSessionDataSlice / useSessionData — persist data to session data instead. Session data survives the view being hidden/shown again, but is not saved to the project file. Use this for transient UI state that shouldn't pollute the saved project, e.g. the currently selected tab.

    Prefer the *Slice variants (useProjectDataSlice, useSessionDataSlice) when a view stores several independent pieces of data, since each slice is loaded/saved independently under its own key.

    import { useUserSettings } from '@kvaser/canking-api/hooks';
    ...
    const userSettings = useUserSettings();
    MeasurementDataProcessorNodeType
    MeasurementSourceNodeType
    MeasurementTargetNodeType
    IDevicesContext
    IEnvelopeView
    IMeasurementSetupContext
    IMeasurementStatusContext
    IMessageDatabase
    IOnlineStatusContext
    ISignalData
    ISignalDataEnvelope
    ISignalEnvelopePayload
    IUndoObject
    IUndoState
    MeasurementTraceDataOptions
    OnGoingOfflineCallback
    OnGoingOnlineCallback
    useAvailableProtocols
    useCombinedMeasurementTraceData
    useDevices
    useDevicesState
    useFixedPositionModeMeasurementData
    useIsOnline
    useLanguage
    useLocalizedStrings
    useLogMessages
    useMaxDataBytes
    useMeasurementDataProcessorNode
    useMeasurementDataProcessorNodes
    useMeasurementSetup
    useMeasurementSetupState
    useMeasurementSourceNode
    useMeasurementSourceNodes
    useMeasurementStatus
    useMeasurementStatusState
    useMeasurementTargetNode
    useMeasurementTargetNodes
    useMessageData
    useMessageDatabases
    useMessageLogFileFormats
    useNewMeasurementData
    useNodeStatus
    useNumericRadix
    useOnlineStatus
    useOnlineStatusSync
    useOverallStatusLevel
    useProjectData
    useProjectDataSlice
    useRecentProjectFiles
    useRunningPeriodicTransmissions
    useScrollModeMeasurementData
    useSessionData
    useSessionDataSlice
    useSignalData
    useSignalDataEnvelopes
    useSignalLogFileFormats
    useUndo
    useUndoRef
    useUndoSessionDataSlice
    useUserSettings
    useWorkspacePaneWithId