Device Monitoring Studio - Monitor, log and analyze data coming through PC ports and connections
Download Device Monitoring Studio Hide this button

Visualizer Host

Accessing Fields of a Bound Packet

function get(obj: object, path: string, forceReference?: boolean): any;

A first argument to a processPacket method is a reference to an object that represents a bound packet to a custom view script. For performance reasons, parsed fields are not directly accessible to the script. Instead, it must call a get function, passing it the bound packet object, a full path to the required field and an optional boolean argument, which, being set to true, forces the evaluation of the ref() function for the result.

Advanced Formatting

function format(fmtString: string, ...values: any[]) : string;

format function takes a format string and a list of arguments to substitute in a format string and returns a resulting string.

Visualizer Host

Visualizer Host is an object accessible to a custom view script via a global variable nvis. It implements the following interface:

interface IVisualizerHost {
    // Enable or disable line numbers and optionally set scheme for line numbers
    enableLineNumbers(state: boolean, scheme?: number): void;

    // Add new block, optionally set background color
    addBlock(color?: number): void;

    // Add text. '\n' character is used to separate lines
    addText(text: string, scheme?: number): void;

    // Low-level add text
    addTextRaw(...args: (string | number | boolean)[]): void;

    // Add a line break
    addNewLine(): void;

    // Add a dump
    addDump(scheme: number, obj: object): void;

    // Add a formatted table
    addTable(nameScheme: number, valueScheme: number, ...rows: any[]): void;

    // Format packet time
    formatTime(entryTime: number, prevEntryTime: number): string;

    // Get multi-source device name
    getDeviceName(ordinal: number): string;

    // Visualize bound field
    visualize(obj: object): string;


    // Control flow: set variable
    setVariable(varName: string, varValue: number): void;
    // Control flow: if
    ifEq(varName: string, varValue: number): void;

    // Control flow: if not
    ifNotEq(varName: string, varValue: number): void;

    // Control flow: end if
    ifEnd(): void;

    // Control flow: else
    ifElse(): void;
}
enableLineNumbers
This method switches the built-in displaying of line numbers for a custom view. This is the only method of the IVisualizerHost interface that is allowed to be called outside of the execution of processPacket method.
addBlock
Add a new block to the visualizer. A block is a collection of lines. Block may have a separate background color, which may be directly passed to this method. If omitted, a color is set automatically. By default, the Custom View uses interlacing when displaying subsequent blocks.
addText
Add a text to the visualizer. A text may contain one or more lines, separated by the '\n' character. A second optional argument specifies the visual scheme (as an ordinal in visual scheme array) to be used to display the text. If omitted, the current scheme is used.
addTextRaw
A more efficient version of the previous method. It accepts any number of arguments. Each argument must be a string, a number or a boolean. If an argument is a string, it is added to the visualizer. Note that the string is not scanned for new line characters. A number changes the current visual scheme to a given one. A special value of -1 reverts the most recent visual scheme change. A boolean value (no matter whether it is true or false) adds a newline.
addNewLine
Add a new line to the visualizer.
addDump
Add a dump to visualizer. The first argument indicates a visual scheme to use and the second argument must be a reference to a bound packet field you want to display. It is recommended to use monospace font, otherwise the dump will look unaligned.
addTable
Add a formatted table to the visualizer. The first argument is a visual scheme index to use for a field name and the second argument is a visual scheme to use for a field value. Other arguments must come in pairs. The first element of a pair is a field name (a string), while the second element is a field value. If you want to use the special visualization algorithms (also used by Structure View and Text Exporter components), like automatic parsing of enumeration values and automatic array visualization, make sure you pass a reference to a field. For simple cases, use plain field values.
formatTime
Standard packet time formatting routine. Pass it the current packet's time and previous packet's time to get a formatted packet time string.
getDeviceName
May be used in multi-source session to obtain a name of a source device by its index.
visualize
Invokes standard visualization mechanism for a passed field reference and returns a resulting string.
setVariable
Assigns a value for a given variable. As mentioned before, the order of packets in calls to processPacket is not guaranteed, preventing the custom view script of maintaining any inter-packet state. To overcome this limitation, a custom view script may have any number of named variables, access to which is synchronized. That means, that variable set during processing of packet N is guaranteed to have the same value during processing of packet N+1.
ifEq
Checks if the variable equals the given value. If the condition is false, all subsequent visualizer commands are ignored until ifElse or ifEnd method is invoked.
ifNotEq
Checks if the variable not equals the given value. If the condition is false, all subsequent visualizer commands are ignored until ifElse or ifEnd method is invoked.
ifEnd
Marks the end of a current if block.
ifElse
Reverts the result of the previous condition for subsequent commands, until the ifEnd method is invoked.