UNPKG

@kvaser/canking-api

Version:

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

191 lines (190 loc) 9.21 kB
import { CanFrameFlag, DataProcessorNodeProperties, FrameDefinition, PeriodicTransmissionSettings, SourceNodeProperties, TargetNodeProperties, ILogFileFormat, WriteFrame } from '../models'; /** * 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; /** * 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<void>; /** * 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<number>; /** * Starts a measurement. */ export declare const startMeasurement: () => Promise<void>; /** * Stops any running measurement. */ export declare const stopMeasurement: () => Promise<void>; /** * Adds a new source node to the current measurement setup. * @param sourceNode - The new source node. */ export declare const addSource: (sourceNode: SourceNodeProperties) => Promise<void>; /** * Updates a source node in the current measurement setup. * @param sourceNode - The updated source node. */ export declare const updateSource: (sourceNode: SourceNodeProperties) => Promise<void>; /** * 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<void>; /** * 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<void>; /** * Updates a data processor node in the current measurement setup. * @param dataProcessorNode - The updated data processor node. */ export declare const updateDataProcessor: (dataProcessorNode: DataProcessorNodeProperties) => Promise<void>; /** * 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<void>; /** * Adds a new target node to the current measurement setup. * @param targetNode - The new target node. */ export declare const addTarget: (targetNode: TargetNodeProperties) => Promise<void>; /** * Updates a target node in the current measurement setup. * @param targetNode - The updated target node. */ export declare const updateTarget: (targetNode: TargetNodeProperties) => Promise<void>; /** * 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<void>; /** * 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<void>; /** * 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<void>; /** * Enables the specified node. * @param id - Identifier of the node to be enabled. */ export declare const enableNode: (id: string) => Promise<void>; /** * Disables the specified node. * @param id - Identifier of the node to be disabled. */ export declare const disableNode: (id: string) => Promise<void>; /** * 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<void>; /** * 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<void>; /** * 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<void>; /** * 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<void>; /** * 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<void>; /** * 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<string>; /** * 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<void>; /** * Stops a running periodic transmission. * @param periodicTransmissionId - Identifier of the periodic transmission to be stopped. */ export declare const stopPeriodicTransmission: (periodicTransmissionId: string) => Promise<void>; /** * Starts a new log replay. * @param logReplayId - Identifier of the log replay to be started. */ export declare const startLogReplay: (logReplayId: string) => Promise<void>; /** * Stops running a log replay. * @param logReplayId - Identifier of the log replay to be stopped. */ export declare const stopLogReplay: (logReplayId: string) => Promise<void>; /** * 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<ILogFileFormat[]>; /** * 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<ILogFileFormat[]>; /** * 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<FrameDefinition[]>;