import { DataType, EndianType } from '../shared/DataTypes'; /** * Creates a DBC instance that allows for parsing/loading of an existing DBC file * or write data to a new DBC file. * * If loading data from an existing file, simply call: * const dbc = new Dbc(); * dbc.load(fileContent) * * By default, when a new Dbc() instance is created, the encapsulated data will be empty. * If you are wanting to create fresh data you can call createMessage or createSignal to * create messages and signals, respectively. * Calls to createMessage and createSignal do not by default add the messages to the data, * you will need to make subsequent calls to addMessage or addSignal to add the data * to the class. * */ declare class Dbc { data: DbcData; errors: Map; constructor(); /** * Adds a version number to dbc data */ set version(version: string); /** * Adds a short description for the DBC data */ set description(description: string); createNode(name: string, options?: { description?: string; attributes?: Attributes; }): Node; /** * * Creates a Message instance that can later be added using addMessage() * or using the attached method .add() * * Ex. * let msg = dbc.createMessage('MessageName',100,8); * msg.add(); or dbc.addMessage(msg); * * @param name Name of CAN message * @param id ID of CAN message * @param dlc Data Length Code (data length) of CAN message * @param options Optional attributes that can be used when creating a message: signals, attributes, signalGroups, * sendingNode, and description * @returns Message */ createMessage(name: string, id: number, dlc: number, options?: AdditionalMessageOptions): Message; /** * * Adds/appends message to existing message list * * @param message Message object to be added */ addMessage(message: Message | Message[]): void; /** * Removes an existing message from the DBC data * @param messageName Name of the message to remove */ removeMessage(messageName: string): void; /** * Creates a signal based on characteristics such as start bit and length * @param name Name of the signal * @param startBit Bit position of where the signal is to start in the Message bitfield * @param length Length of the signal * @param options Additional options, such as signed, endian, etc. */ createSignal(name: string, startBit: number, length: number, options?: AdditionalSignalOptions): Signal; /** * Removes a signal from an existing message * @param signalName Name of the signal * @param messageName Name of the message containing the signal */ removeSignal(signalName: string, messageName: string): void; /** * * Adds a Signal object to a specified Message * * @param messageName Name of the message the signal will be added to * @param signal Signal object to be added to the specified message */ addSignal(messageName: string, signal: Signal | Signal[]): void; /** * * Returns a message with the corresponding CAN ID. If message does not exist * a MessageDoesNotExist error will be thrown. * * @param id The CAN ID of the message wanting to be found * @returns Message * @throws MessageDoesNotExist */ getMessageById(id: number): Message; /** * * Finds a specific message within the DBC file data by name * * @param name string * @returns Message * @error MessageDoesNotExist */ getMessageByName(name: string): Message | undefined; /** * * Returns a signal object located in a specific CAN message by name * * @param name string * @param messageName string * @returns Signal * @error SignalDoesNotExist */ getSignalByName(name: string, messageName: string): Signal; /** * Convenience method that will create an Attribute object that can be appended to DBC data * @param name Name to be assigned to the attribute * @param type Attribute type: FLOAT, HEX, ENUM, INT, STRING * @param props Required properties of the attribute based on the type provided * @param options Additional attribute options that can be added */ createAttribute(name: string, type: AttributeDataType, props?: RequiredAttributeProps, options?: AdditionalAttributeObjects): Attribute; /** * Adds an existing attribute to the DBC data based on the supplied type * @param attribute Attribute * @param options node, id, signalName, or evName */ addAttribute(attribute: Attribute, options?: { node?: string; id?: number; signalName?: string; evName?: string; }): void; /** * Returns an environmental variable by name * @param name Name of environmental variable * @throws Error if environmental variable does not exist in database */ getEnvironmentalVariable(name: string): EnvironmentVariable; /** * Returns a node if it exists in the database * @param name Name of the node (string) * @throws Error if node does not exist */ getNode(name: string): Node; /** * Returns the mapped name in the database based on the supplied CAN ID * @param id Message ID (number) * @throws Error if no message with the corresponding ID exists */ messageIdToName(id: number): string; /** * * Loads a DBC file, as opposed to the default method 'load', which is * a non-blocking/async call whose promise must be caught for the return data to be used. * * @param fileContent Full file path to the dbc file, including extension * @param throwOnError * @returns DbcData Data contained in the dbc file */ load(fileContent: string, throwOnError?: boolean): DbcData; /** * * Writes the encapsulated data of a Dbc class instance to a dbc file */ write(): string; /** * * Transforms the internal DBC data from class instance into a JSON object/string * * @param options Additional formatting options, such as pretty print. * @returns JSON representation of loaded DBC data */ toJson(options?: { pretty?: boolean; preserveFormat?: boolean; }): string; initDbcDataObj(): DbcData; } export default Dbc; export declare type Signals = Map; export declare type AdditionalSignalOptions = { signed?: boolean; endian?: EndianType; min?: number; max?: number; factor?: number; offset?: number; isFloat?: boolean; unit?: string; description?: string; multiplex?: string; multiplexer?: boolean; receivingNodes?: string[]; valueTable?: ValueTable; attributes?: Attributes; }; export declare type Signal = { name: string; multiplex: string | null; multiplexer: boolean; startBit: number; length: number; endian: EndianType; signed: boolean; factor: number; offset: number; min: number; max: number; unit: string; receivingNodes: string[]; description: string | null; valueTable: ValueTable | null; attributes: Attributes; dataType: DataType | undefined; add: (messageName: string) => Signal; updateDescription: (content: string) => Signal; addAttribute: (attrName: string, messageId: number, type: AttributeDataType, attrProps?: RequiredAttributeProps, attrOptions?: AdditionalAttributeObjects) => Signal; isMultiplex: () => boolean; }; export declare type SignalGroups = Map; export declare type SignalGroup = { name: string; id: number; groupId: number; signals: string[]; }; export declare type MultiplexSignals = Map; export declare type MultiplexSignal = { signal: Signal; children: Map; }; export declare type AdditionalMessageOptions = { signals?: Signals; baseSignals?: Signals; multiplexSignals?: MultiplexSignals; attributes?: Attributes; signalGroups?: SignalGroups; sendingNode?: string; description?: string; }; export declare type Message = { name: string; id: number; dlc: number; sendingNode: string | null; signals: Map; baseSignals: Map; multiplexSignals: Map; description: string | null; attributes: Attributes; signalGroups: SignalGroups; add: () => Message; addSignal: (name: string, startBit: number, length: number, options?: AdditionalSignalOptions) => Message; updateDescription: (content: string) => Message; updateNode: (node: string) => Message; addAttribute: (attrName: string, type: AttributeDataType, attrProps?: RequiredAttributeProps, attrOptions?: AdditionalAttributeObjects) => Message; }; export declare type SignalMultiplexValue = { id: number; name: string; switchName: string; value_ranges: string[][]; }; export declare type EnvType = 'Integer' | 'Float' | 'String'; export declare type AccessType = 'Unrestricted' | 'Read' | 'Write' | 'ReadWrite'; export declare type EnvironmentVariable = { name: string; type: EnvType; min: number; max: number; initialValue: number; evId: number; accessType: AccessType; accessNode: string; attributes: Attributes; valueTable: ValueTable | null; description: string | null; dataBytesLength: number | null; unit: string; }; export declare type Node = { name: string; description: string | null; attributes: Attributes; add: () => Node; updateDescription: (content: string) => Node; addAttribute: (attrName: string, type: AttributeDataType, attrProps?: RequiredAttributeProps, attrOptions?: AdditionalAttributeObjects) => Node; }; export declare type TxMessages = string[]; export declare type CanId = number; export declare type NetworkBridges = Map; export declare type DbcData = { version: string | null; messages: Map; description: string | null; busSpeed: number | null; nodes: Map; valueTables: Map | null; attributes: Attributes; newSymbols: string[]; environmentVariables: Map; networkBridges: NetworkBridges; }; export declare type ValueTable = Map; export declare type RequiredAttributeProps = { type?: AttributeType; min?: number; max?: number; enumMembers?: string[]; }; export declare type AdditionalAttributeObjects = { value?: string; defaultValue?: string; }; export declare type Attributes = Map; export declare type AttributeType = 'Global' | 'Message' | 'Signal' | 'Node' | 'EnvironmentVariable'; export declare type AttributeDataType = 'FLOAT' | 'STRING' | 'ENUM' | 'INT' | 'HEX'; export declare type Attribute = { name: string; type: AttributeType; dataType: AttributeDataType; value: string | null; defaultValue: string | null; options: string[] | null; min: number | null; max: number | null; };