@kvaser/canking-api
Version:
CanKing API to communicate with the CanKing service using Node.js.
171 lines (170 loc) • 6.38 kB
TypeScript
/**
* This module includes types to be used in communication with CanKing.
* @packageDocumentation
*/
import { StringsMap } from '../controls';
import { MeasurementSetup } from '../protos/measurement_settings';
import Long from 'long';
import DataBuffer, { DataBufferView, IReadOnlyDataBuffer as ReadOnlyDataBuffer } from './DataBuffer';
import electronApiFake, { createElectronApiFake } from './ElectronAPIFake';
import Point from './Point';
import deep_equal from './deep_equal';
import { jsonReplacer, jsonReviver } from './json_utilities';
import { FixedPosFrameIdentifier, Frame } from '../protos/frame_params';
export * from '../protos/google/protobuf/empty';
export * from '../protos/app_params';
export * from '../protos/device_params';
export * from '../protos/frame_params';
export * from '../protos/measurement_params';
export * from '../protos/measurement_settings';
export * from '../protos/signal_params';
export * from '../protos/status_params';
/**
* Compares two FixedPosFrameIdentifier objects for equality.
* @remarks
* The first FixedPosFrameIdentifier 'a' is considered the reference. If it has optional properties
* (mux, tx, sourceId) defined, they must match in 'b' for the identifiers to be considered equal.
* If these properties are undefined in 'a', they are ignored in the comparison.
* @param a - The first FixedPosFrameIdentifier to compare.
* @param b - The second FixedPosFrameIdentifier to compare.
* @returns True if the FixedPosFrameIdentifier objects are equal, false otherwise.
* @internal
*/
export declare const compareFixedPosFrameIdentifiers: (a: FixedPosFrameIdentifier, b: FixedPosFrameIdentifier) => boolean;
/**
* Calculates a unique subscription key for a given frame identifier.
* @param frameId - The frame identifier.
* @returns The subscription key.
* @internal
*/
export declare const calculateSubscriptionKey: (frameId: FixedPosFrameIdentifier) => string;
/**
* Calculates a unique subscription key for a given frame.
* @param frame - The frame to calculate the subscription key for.
* @param ignoreSource - Whether to ignore the source identifier when calculating the key.
* @param ignoreDirection - Whether to ignore the transmission direction when calculating the key.
* @param ignoreMux - Whether to ignore the mux value when calculating the key.
* @param ignoreBRS - Whether to ignore the BRS flag when calculating the key.
* @returns The subscription key.
* @internal
*/
export declare const calculateSubscriptionKeyFromFrame: (frame: Frame, ignoreSource?: boolean, ignoreDirection?: boolean, ignoreMux?: boolean, ignoreBRS?: boolean) => string;
/**
* Converts a decimal number to a hexadecimal string.
* @param d - The number to convert.
* @param padding - Number of hexadecimal digits in the returned value, the result will be padded with zeroes.
* @param prefix - True if a 0x prefix should be added.
* @returns The hexadecimal formatted value.
*/
declare const decimalToHex: (d: number, padding?: number, prefix?: boolean) => string;
/**
* Converts a decimal number to a fixed length string.
* @param d - The number to convert.
* @param padding - Number of digits in the returned value, the result will be padded with zeroes.
* @returns The fixed length formatted value.
*/
declare const decimalToFixed: (d: number, padding?: number) => string;
/**
* Converts a Long value to a number.
* @param value - The Long value to convert.
* @returns The value as a number.
*/
declare const longToNumber: (value: Long) => number;
export { deep_equal, jsonReplacer, jsonReviver, Point, decimalToHex, decimalToFixed, longToNumber, DataBuffer, DataBufferView, electronApiFake, createElectronApiFake, };
export type IReadOnlyDataBuffer<T> = ReadOnlyDataBuffer<T>;
export type themes = 'light' | 'dark';
/**
* Interface describing the contents of the settings file.
*/
export interface IUserSettings {
version: string;
theme: themes;
language: string;
strings: StringsMap;
showToolsPanel: boolean;
useHexNumericBase: boolean;
maxDataBytes: number;
defaultProjectFolder: string;
defaultLogFilesFolder: string;
defaultCANDatabasesFolder: string;
defaultLINDatabasesFolder: string;
currentProjectFile: string;
currentProjectFileName: string;
recentProjectFiles: string[];
closeAppServiceAction: 'prompt' | 'clear' | 'keep';
}
/**
* Default user setting values.
*/
export declare const defaultUserSettings: IUserSettings;
/**
* Data stored by a Workspace.
* @internal
*/
export interface IWorkspaceData {
id: number;
title: string;
workspacePaneId: number;
}
/**
* Data stored by a Workspace view.
*/
export interface IWorkspaceComponentPaneData {
componentId: string;
componentPropSlices: {
[key: string]: string;
};
}
/**
* Data stored by a Workspace view container.
*/
export interface IWorkspaceContainerPaneData {
vertical: boolean;
paneDataIds: number[];
paneRatios: number[];
}
/**
* Data stored by a Workspace pane.
*/
export interface IWorkspacePaneData {
id: number;
componentData?: IWorkspaceComponentPaneData;
containerData?: IWorkspaceContainerPaneData;
}
/**
* Data stored by the CanKing project.
* @internal
*/
export interface IProject {
version: number;
measurementSetup: MeasurementSetup;
workspaces: IWorkspaceData[];
workspacePanes: IWorkspacePaneData[];
}
/**
* A serializable version of the Frame type, which can be used in IPC (Inter-Process Communication).
*/
export type SerializableFrame = Frame & {
timeUsParts: {
low: number;
high: number;
unsigned: boolean;
};
deltaTimeUsParts: {
low: number;
high: number;
unsigned: boolean;
} | undefined;
};
/**
* Converts a Frame object into a SerializableFrame object for IPC.
* @param frame - The Frame object to be serialized.
* @returns A SerializableFrame object that can be sent through IPC.
*/
export declare function serializeFrame(frame: Frame): SerializableFrame;
/**
* Converts a SerializableFrame object back into a Frame object after receiving it through IPC.
* @param serializableFrame - The SerializableFrame object to be deserialized.
* @returns A Frame object reconstructed from the SerializableFrame.
*/
export declare function deserializeFrame(serializableFrame: SerializableFrame): Frame;