@kvaser/canking-api
Version:
CanKing API to communicate with the CanKing service using Node.js.
278 lines (277 loc) • 13.7 kB
TypeScript
/**
* This module includes UI controls for editing CAN identifiers.
*
* To be able to use these controls 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.
*
* @packageDocumentation
*/
import { JSX } from 'react';
import { PeriodicTransmissionSettings, SignalDefinition, WriteFrame } from '../models';
/** Possible CAN identifier types, standard (11-bits) or extended (29-bits). */
export type canIdentifierType = 'standard' | 'extended';
/** Possible CAN identifier generator types. */
export type canIdentifierGeneratorType = 'constant' | 'random' | 'scan';
/**
* Properties of the CanIdentifierControl React component.
*/
interface CanIdentifierControlProps {
/** The current CAN identifier. */
canIdentifier: string;
/** The current CAN identifier type, 'extended or 'standard'. */
canIdentifierType: canIdentifierType;
/** The source identifier of the selected message or signal. */
selectedSourceId?: string;
/**
* Callback that will be called when the CAN identifier has changed.
* @param identifier - The new CAN identifier.
* @param idType - The new CAN identifier type.
* @param sourceId - The source identifier of the selected message. Could be undefined if no (any) source is selected.
*/
onCanIdentifierChange: (identifier: string, idType: canIdentifierType, sourceId: string | undefined) => void;
/**
* Callback that will be called when the settings have changed after selecting a signal.
* If this property is set, then the onCanIdentifierChange callback will not be called.
* @param identifier - The new CAN identifier.
* @param idType - The new CAN identifier type.
* @param signal - The new signal or undefined if no signal is selected.
* @param sourceId - The source identifier of the selected signal. Could be undefined if no (any) source is selected.
*/
onSignalChange?: (identifier: string, idType: canIdentifierType, signal: SignalDefinition | undefined, sourceId: string | undefined) => void;
/**
* Callback that will be called when the errors state has changed.
* @param errors - The new errors state.
*/
onErrorsChange?: (errors: boolean) => void;
/** Set to true to disable this control. */
disabled?: boolean;
/**
* Name of a parent dialog, if any, that is used as the parent for the select message and select signal dialogs.
* Leave undefined if there is no parent dialog.
*/
parentDialogTitle?: string;
/** Set to true if the select message and select signal dialogs should be full screen dialogs. */
fullScreen?: boolean;
/**
* Identifier of the node that will be used to filter messages and signals in the select dialogs.
* Leave undefined if no filtering should be done.
*/
nodeIdentifier?: string;
/**
* The source identifier that will be used to filter messages in the select dialog.
* Leave undefined if no filtering should be done.
*/
sourceIdFilter?: string;
/** Set to true if the select message button should be disabled. */
disableSelectMessageButton?: boolean;
/** Set to true if the select signal button should be disabled. */
disableSelectSignalButton?: boolean;
/** Set to true if this control shouldn't be encapsulated inside a SectionControl. */
hideSection?: boolean;
/** Set to true if the select message button should be hidden. */
hideSelectMessageButton?: boolean;
/** Set to true if the select signal button should be visible. If set to true, then the select message button will be hidden. */
showSelectSignalButton?: boolean;
/** Set to true if the SectionControl should be collapsible, ignored if hideSectionControl is true. */
collapsible?: boolean;
/** Current collapse state of the SectionControl. */
collapsed?: boolean;
/**
* Callback that will be called when collapse state has changed.
* @param value - The new collapse state.
*/
collapsedChange?: (value: boolean) => void;
/** Set to true if the source field should be shown. Default is false. */
showSource?: boolean;
}
/**
* Creates an UI control for editing a CAN identifier.
* @param props - Component properties.
* @returns The CanIdentifierControl React component.
*/
declare function CanIdentifierControl({ canIdentifier, canIdentifierType, selectedSourceId, onCanIdentifierChange, onErrorsChange, onSignalChange, disabled, parentDialogTitle, fullScreen, nodeIdentifier, sourceIdFilter, disableSelectMessageButton, disableSelectSignalButton, hideSection, hideSelectMessageButton, showSelectSignalButton, collapsible, collapsed, collapsedChange, showSource, }: CanIdentifierControlProps): JSX.Element;
/**
* Properties of the CanIdentifierFrameControl React component.
*/
interface CanIdentifierFrameControlProps {
/** The frame object that holds the CAN identifier. */
frame: WriteFrame;
/**
* Callback that will be called when the frame is updated after the CAN identifier has changed.
* @param value - The new frame object.
*/
onFrameChange: (value: WriteFrame) => void;
/**
* Callback that will be called when the errors state has changed.
* @param errors - The new errors state.
*/
onErrorsChange?: (errors: boolean) => void;
/**
* Name of a parent dialog, if any, that is used as the parent for the select message and select signal dialogs.
* Leave undefined if there is no parent dialog.
*/
parentDialogTitle?: string;
/** Set to true if the select message and select signal dialogs should be full screen dialogs. */
fullScreen?: boolean;
/**
* Identifier of the node that will be used to filter messages and signals in the select dialogs.
* Leave undefined if no filtering should be done.
*/
nodeIdentifier?: string;
/**
* The source identifier that will be used to filter messages in the select dialog.
* Leave undefined if no filtering should be done.
*/
sourceIdFilter?: string;
/** Set to true if the select message button should be disabled. */
disableSelectMessageButton?: boolean;
/** Set to true if this control shouldn't be encapsulated inside a SectionControl. */
hideSection?: boolean;
/** Set to true if the select message button should be hidden. */
hideSelectMessageButton?: boolean;
/** Set to true if the SectionControl should be collapsible. */
collapsible?: boolean;
/** Current collapse state of the SectionControl. */
collapsed?: boolean;
/**
* Callback that will be called when collapse state has changed.
* @param value - The new collapse state.
*/
collapsedChange?: (value: boolean) => void;
}
/**
* Creates an UI control for editing a CAN identifier using a Frame as source.
* @param props - Component properties.
* @returns The CanIdentifierFrameControl React component.
*/
declare function CanIdentifierFrameControl({ frame, onFrameChange, onErrorsChange, parentDialogTitle, fullScreen, nodeIdentifier, sourceIdFilter, disableSelectMessageButton, hideSection, hideSelectMessageButton, collapsible, collapsed, collapsedChange, }: CanIdentifierFrameControlProps): JSX.Element;
/**
* Properties of the CanIdentifierGeneratorControl React component.
*/
interface CanIdentifierGeneratorControlProps {
/** The CAN identifier. */
canIdentifier: string;
/**
* The generator type: 'constant' | 'random' | 'scan'
* 'constant': The CAN identifier set to canIdentifier will be used for all generated messages.
* 'random': A random CAN identifier between minCanIdentifier and maxCanIdentifier will be used.
* 'scan': A CAN identifier will be picked from minCanIdentifier to maxCanIdentifier.
*/
identifierGeneratorType: canIdentifierGeneratorType;
/** The min CAN identifier that will be used if identifierGeneratorType is 'random' or 'scan'. */
minCanIdentifier: string;
/** The max CAN identifier that will be used if identifierGeneratorType is 'random' or 'scan'. */
maxCanIdentifier: string;
/** The CAN identifier type that will be used, 'extended' or 'standard'. */
canIdentifierType: canIdentifierType;
/**
* Callback that will be called when the CAN identifier(s) has changed.
* @param newCanIdentifier - The new constant CAN identifier.
* @param newIdentifierGeneratorType - The new generator type.
* @param newMinCanIdentifier - The new min CAN identifier.
* @param newMaxCanIdentifier - The new max CAN identifier.
*/
onChange: (newCanIdentifier: string, newIdentifierGeneratorType: canIdentifierGeneratorType, newMinCanIdentifier: string, newMaxCanIdentifier: string, newIdentifierType: canIdentifierType) => void;
/**
* Callback that will be called when the errors state has changed.
* @param errors - The new errors state.
*/
onErrorsChange?: (errors: boolean) => void;
/** Set to true to disable this control. */
disabled?: boolean;
/** Set to true if the SectionControl should be collapsible. */
collapsible?: boolean;
/** Current collapse state of the SectionControl. */
collapsed?: boolean;
/**
* Callback that will be called when collapse state has changed.
* @param value - The new collapse state.
*/
collapsedChange?: (value: boolean) => void;
/**
* Callback for specifying if the signal values table should be visible.
*/
showSignalValuesTable: (value: boolean) => void;
/**
* Name of a parent dialog, if any, that is used as the parent for the select message dialog.
* Leave undefined if there is no parent dialog.
*/
parentDialogTitle?: string;
/** Set to true if the select message dialog should be a full screen dialog. */
fullScreen?: boolean;
/**
* Identifier of the node that will be used to filter messages in the select dialog.
* Leave undefined if no filtering should be done.
*/
nodeIdentifier?: string;
/**
* The source identifier that will be used to filter messages in the select dialog.
* Leave undefined if no filtering should be done.
*/
sourceIdFilter?: string;
}
/**
* Creates an UI control for editing CAN identifier(s) used by a message generator.
* @param props - Component properties.
* @returns The CanIdentifierGeneratorControl React component.
*/
declare function CanIdentifierGeneratorControl({ canIdentifier, identifierGeneratorType, minCanIdentifier, maxCanIdentifier, canIdentifierType, onChange, onErrorsChange, disabled, collapsible, collapsed, collapsedChange, showSignalValuesTable, parentDialogTitle, fullScreen, nodeIdentifier, sourceIdFilter, }: CanIdentifierGeneratorControlProps): JSX.Element;
/**
* Properties of the CanIdentifierGeneratorSettingsControl React component.
*/
interface CanIdentifierGeneratorSettingsControlProps {
/** The settings object that holds the CAN identifier(s) generator settings. */
settings: PeriodicTransmissionSettings;
/**
* Callback that will be called when the settings are updated after the CAN identifiers have changed.
* @param value - The new settings object.
*/
onSettingsChange: (value: PeriodicTransmissionSettings) => void;
/**
* Callback that will be called when the errors state has changed.
* @param errors - The new errors state.
*/
onErrorsChange?: (errors: boolean) => void;
/** Set to true to disable this control. */
disabled?: boolean;
/** Set to true if the SectionControl should be collapsible. */
collapsible?: boolean;
/** Current collapse state of the SectionControl. */
collapsed?: boolean;
/**
* Callback that will be called when collapse state has changed.
* @param value - The new collapse state.
*/
collapsedChange?: (value: boolean) => void;
/**
* Callback for specifying if the signal values table should be visible.
*/
showSignalValuesTable: (value: boolean) => void;
/**
* Name of a parent dialog, if any, that is used as the parent for the select message dialog.
* Leave undefined if there is no parent dialog.
*/
parentDialogTitle?: string;
/** Set to true if the select message dialog should be a full screen dialog. */
fullScreen?: boolean;
/**
* Identifier of the node that will be used to filter messages in the select dialog.
* Leave undefined if no filtering should be done.
*/
nodeIdentifier?: string;
/**
* The source identifier that will be used to filter messages in the select dialog.
* Leave undefined if no filtering should be done.
*/
sourceIdFilter?: string;
}
/**
* Creates an UI control for editing CAN identifier(s) used by a message generator
* using a PeriodicTransmissionSettings as source.
* @param props - Component properties.
* @returns The CanIdentifierGeneratorSettingsControl React component.
*/
declare function CanIdentifierGeneratorSettingsControl({ settings, onSettingsChange, onErrorsChange, disabled, collapsible, collapsed, collapsedChange, showSignalValuesTable, parentDialogTitle, fullScreen, nodeIdentifier, sourceIdFilter, }: CanIdentifierGeneratorSettingsControlProps): JSX.Element;
export default CanIdentifierControl;
export { type CanIdentifierControlProps, CanIdentifierControl, type CanIdentifierFrameControlProps, CanIdentifierFrameControl, type CanIdentifierGeneratorControlProps, CanIdentifierGeneratorControl, type CanIdentifierGeneratorSettingsControlProps, CanIdentifierGeneratorSettingsControl, };