import { CanFrameFlag, DataProcessorNodeProperties, FrameDefinition, PeriodicTransmissionSettings, SourceNodeProperties, TargetNodeProperties, LogFileFormatInfo, WriteFrame, Frame, FixedPosFrameIdentifier } from '../models'; import { OpenDialogSyncOptions } from 'electron'; import { type ExtensionDialogOptions, type ExtensionDialogResult } from './extensionDialogUtils'; export { type ExtensionDialogOptions, type ExtensionDialogResult, type ExtensionDialogFailureReason, } from './extensionDialogUtils'; /** * A logger that can be used for logging messages to CanKing's log window and log file. */ export interface ILogger { trace(message: string): void; debug(message: string): void; info(message: string): void; warn(message: string): void; error(message: unknown, error?: unknown): void; critical(message: string): void; } /** * Creates a new logger that can be used for logging messages to CanKing's log window and log file. * @param categoryName - The category name used by the returned logger, typically the extension name. * @returns A new logger. */ export declare const getLogger: (categoryName: string) => ILogger; /** * The entitlement state for a licensed extension, as decided by the CanKing host application. * @internal */ export interface Entitlement { /** True if a valid license currently grants use of the extension's product. */ granted: boolean; /** * Re-validation deadline as an ISO 8601 timestamp. Only set when granted; the host re-validates * the entitlement automatically, so extensions normally do not need to act on this value. */ expires?: string; /** * Machine-readable denial reason, e.g. 'no-license', 'expired', 'unsigned', 'product-mismatch', * 'service-unavailable' or 'unsupported-host'. Only set when not granted. */ reason?: string; } /** * Requests an entitlement for the extension's product. Extensions that are verified or licensed * must call this once at startup, before using other API functions: until an entitlement is * granted, the host rejects their API calls. Free extensions never need to call this. * @param productEan - The product EAN of the extension, as assigned by Kvaser. * @param version - The version of the extension, as specified in the extension's package.json. * @param distributionTier - The distribution tier of the extension, "Verified" or "Licensed". * @returns The resulting entitlement state. * @internal */ export declare const acquireEntitlement: (productEan: string, version: string, distributionTier: "Verified" | "Licensed") => Promise; /** * Subscribes to entitlement changes for this extension, raised by the host when its entitlement * is revoked or renewed (for example when a license is deactivated or expires). Use this to * switch the extension into a "license required" state instead of failing on the next API call. * @param listener - Callback invoked with the new entitlement state. * @returns A function that removes the listener when called. * @internal */ export declare const onEntitlementChanged: (listener: (entitlement: Entitlement) => void) => (() => void); /** * Displays a file open dialog to browse after and selecting files. * Reads the selected files as text files and returns their contents. * @param options - The dialog options. * @returns The text contents of all selected file paths. */ export declare const openTextFileOpenDialog: (options: OpenDialogSyncOptions) => Promise; /** * Displays a file open dialog to browse after and selecting files. * Reads the selected files as binary files and returns their contents. * @param options - The dialog options. * @returns The binary contents of all selected file paths. */ export declare const openBinaryFileOpenDialog: (options: OpenDialogSyncOptions) => Promise; /** * Displays a message box with an OK button for the user. * @param message - The message to display. * @param title - The dialog title. */ export declare const showMessageBox: (message: string, title: string) => Promise; /** * Displays a question box for the user. * @param message - The message/question to display. * @param title - The dialog title. * @param buttons - Captions of the buttons that should be present, defaults to ['Yes', 'No']. * @param defaultId - Index of the button in the buttons array which will be selected by default when the message box opens. * @param cancelId - The index of the button to be used to cancel the dialog, via the `Esc` key. By default this is assigned * to the first button with "cancel" or "no" as the label. If no such labeled buttons exist and this option * is not set, `0` will be used as the return value. * @returns The index of the button that was clicked. */ export declare const showQuestionBox: (message: string, title: string, buttons?: string[], defaultId?: number, cancelId?: number) => Promise; /** * Opens one of this extension's dialog routes in a separate CanKing window. * * The dialog is rendered from the same bundle as the WorkspaceView, at the route * `/dialog/{dialogId}`, but in its own window so it is not limited to the size of the extension's * pane. The extension supplies only a dialog id — CanKing resolves the calling extension from the * window's origin, so a dialog can never point at anything but its own extension. * * Pass the WorkspaceView's `id` so the dialog can share state with the pane through the * `useProjectDataSlice` hook. Note that session data slices are loaded once when a view mounts and * are not pushed between windows, so use project data slices for state that both the pane and the * dialog need to see change. * * @typeParam TResult - Type of the value the dialog passes to `closeExtensionDialog`. * @typeParam TArgs - Type of the arguments handed to the dialog. * @param dialogId - Identifies the dialog, matching a key in the extension's dialog registry. Must * consist only of letters, digits, `-` and `_`. * @param id - The unique id of the WorkspaceView opening the dialog. * @param args - Optional arguments for the dialog to read with `getExtensionDialogArgs`. Must be * JSON-serializable. * @param options - Optional window options. * @returns The outcome of the dialog. Check `completed` before reading `result` — a dialog that was * never opened, for example on a CanKing version that predates this API, reports * `completed: false` with a `reason`. */ export declare const openExtensionDialog: (dialogId: string, id: number, args?: TArgs, options?: ExtensionDialogOptions) => Promise>; /** * Closes the extension dialog this code is running in, returning a result to whoever opened it. * * Only callable from inside a dialog window; CanKing identifies the window from the caller, so a * dialog cannot close another extension's window. Closing the window by any other means resolves * the opener with no result. * * @typeParam TResult - Type of the result value. Must be JSON-serializable. * @param result - The value to resolve the opener's `openExtensionDialog` promise with. */ export declare const closeExtensionDialog: (result?: TResult) => Promise; /** * Reads the arguments passed to this dialog by `openExtensionDialog`. * * The arguments are held by CanKing rather than placed on the dialog's URL, and are only handed to * the window they were meant for. * * @typeParam TArgs - Type of the arguments. * @returns The arguments, or undefined if none were supplied or this is not an extension dialog. */ export declare const getExtensionDialogArgs: () => Promise; /** * Starts a measurement. */ export declare const startMeasurement: () => Promise; /** * Stops any running measurement. */ export declare const stopMeasurement: () => Promise; /** * Adds a new source node to the current measurement setup. * @param sourceNode - The new source node. */ export declare const addSource: (sourceNode: SourceNodeProperties) => Promise; /** * Updates a source node in the current measurement setup. * @param sourceNode - The updated source node. */ export declare const updateSource: (sourceNode: SourceNodeProperties) => Promise; /** * Deletes a source node from the current measurement setup. * @param sourceId - Identifier of the source node to delete. */ export declare const deleteSource: (sourceId: string) => Promise; /** * Adds a new data processor node to the current measurement setup. * @param dataProcessorNode - The new data processor node. * @param previousNode - Identifier of the pervious node in the measurement setup. * @param nextNode - Identifier of the next node in the measurement setup. */ export declare const addDataProcessor: (dataProcessorNode: DataProcessorNodeProperties, previousNode?: string, nextNode?: string) => Promise; /** * Updates a data processor node in the current measurement setup. * @param dataProcessorNode - The updated data processor node. */ export declare const updateDataProcessor: (dataProcessorNode: DataProcessorNodeProperties) => Promise; /** * Deletes a data processor node from the current measurement setup. * @param dataProcessorId - Identifier of the data processor node to delete. */ export declare const deleteDataProcessor: (dataProcessorId: string) => Promise; /** * Adds a new target node to the current measurement setup. * @param targetNode - The new target node. */ export declare const addTarget: (targetNode: TargetNodeProperties) => Promise; /** * Updates a target node in the current measurement setup. * @param targetNode - The updated target node. */ export declare const updateTarget: (targetNode: TargetNodeProperties) => Promise; /** * Deletes a target node from the current measurement setup. * @param targetId - Identifier of the target node to delete. */ export declare const deleteTarget: (targetId: string) => Promise; /** * Adds a connection between the specified start node and the specified end node. * @param startId - Identifier of the new connection's start node. * @param endId - Identifier of the new connection's end node. */ export declare const connectNodes: (startId: string, endId: string) => Promise; /** * Removes a connection between the specified start node and the specified end node. * @param startId - Identifier of the connection's start node. * @param endId - Identifier of the connection's end node. */ export declare const disconnectNodes: (startId: string, endId: string) => Promise; /** * Enables the specified node. * @param id - Identifier of the node to be enabled. */ export declare const enableNode: (id: string) => Promise; /** * Disables the specified node. * @param id - Identifier of the node to be disabled. */ export declare const disableNode: (id: string) => Promise; /** * Sends out a frame on the specified out channel. * @param channelId - Identifier of the out channel to be used when sending out the message. * @param frame - Definition of the frame to be sent out. */ export declare const sendMessage: (channelId: string, frame: WriteFrame) => Promise; /** * Sends out a CAN message on the specified out channel. * @param channelId - Identifier of the out channel to be used when sending out the message, must be a CAN channel. * @param canId - The CAN identifier. * @param data - The message data. * @param flags - Any extra {@link CanFrameFlag} values to control how the message is sent out. */ export declare const sendCanMessage: (channelId: string, canId: number, data: number[], ...flags: CanFrameFlag[]) => Promise; /** * Updates a LIN slave channel's message buffer. * @param channelId - Identifier of the out channel to be used when updating the message. * @param frame - Definition of the frame to be sent out. */ export declare const updateLinMessage: (channelId: string, frame: WriteFrame) => Promise; /** * Clears a LIN slave channel's message buffer. * @param channelId - Identifier of the out channel to be used when clearing the message. * @param frameId - Identifier of the message to be cleared. */ export declare const clearLinMessage: (channelId: string, frameId: number) => Promise; /** * Writes a LIN request message (a LIN message header) to the LIN bus. A slave in the system is then expected to fill in the header * with data. Note: This call is only available in master mode. * @param channelId - Identifier of the out channel to be used when sending the message. * @param frameId - Identifier of the message to be requested. */ export declare const requestLinMessage: (channelId: string, frameId: number) => Promise; /** * Starts a new periodic transmission. * @param settings - The periodic transmission settings. * @returns A promise that resolves with the identifier of the new periodic transmission. */ export declare const startPeriodicTransmission: (settings: PeriodicTransmissionSettings) => Promise; /** * Updates a periodic transmission. * @param settings - The new periodic transmission settings. * @param periodicTransmissionId - Identifier of the periodic transmission. */ export declare const updatePeriodicTransmission: (settings: PeriodicTransmissionSettings, periodicTransmissionId: string) => Promise; /** * Stops a running periodic transmission. * @param periodicTransmissionId - Identifier of the periodic transmission to be stopped. */ export declare const stopPeriodicTransmission: (periodicTransmissionId: string) => Promise; /** * Starts a new log replay. * @param logReplayId - Identifier of the log replay to be started. */ export declare const startLogReplay: (logReplayId: string) => Promise; /** * Stops running a log replay. * @param logReplayId - Identifier of the log replay to be stopped. */ export declare const stopLogReplay: (logReplayId: string) => Promise; /** * Gets all available message log file formats. * @returns A promise that resolves with a collection of all available message log file formats. */ export declare const getMessageLogFileFormats: () => Promise; /** * Gets all available signal log file formats. * @returns A promise that resolves with a collection of all available signal log file formats. */ export declare const getSignalLogFileFormats: () => Promise; /** * Gets all available frame definitions. * @param nodeIdentifier - An optional node identifier. If specified then all frame definitions available for the * specified node will be returned; otherwise all available frame definitions will be returned. * @returns A promise that resolves with a collection of all available frame definitions. */ export declare const getFrameDefinitions: (nodeIdentifier?: string) => Promise; /** * Gets message data (frames) before a specific timestamp. * @param timestampUs - The timestamp (in microseconds since start of measurement) before which frames should be retrieved. * @param maxCount - The maximum number of frames to retrieve. * @param identifiers - An optional collection of frame identifiers to filter the results. If not specified, frames * for all identifiers will be retrieved. * @returns A promise that resolves with a collection of frames. */ export declare const getMessageDataBeforeTimestamp: (timestampUs: number, maxCount: number, identifiers?: FixedPosFrameIdentifier[]) => Promise; /** * Gets timestamp of the first frame in the current measurement. * @returns A promise that resolves with the first timestamp (in microseconds since start of measurement). */ export declare const getFirstTimestamp: () => Promise; /** * Gets timestamp of the latest frame in the current measurement. * @returns A promise that resolves with the latest timestamp (in microseconds since start of measurement). */ export declare const getLatestTimestamp: () => Promise; /** * Gets timestamps of the first and latest frames in the current measurement. * @returns A promise that resolves with an object containing the first and latest timestamps * (in microseconds since start of measurement). */ export declare const getFirstAndLatestTimestamp: () => Promise<{ firstTimestamp: number; latestTimestamp: number; }>; /** * Invokes an ad-hoc command on the extension. * @param extensionNodeId - Identifier (or name) of the extension node that will execute the command. * @param commandId - Identifier of the command to execute. * @param commandArgs - The command arguments. * @returns A promise that resolves with an object containing the success payload, or the error message on failure, along with whether it succeeded. */ export declare const runExtensionCommand: (extensionNodeId: string, commandId: string, commandArgs: string) => Promise<{ success: boolean; value: string; }>;