General information request - vissimRequest()

The vissimRequest() function provides a general, extensible request mechanism for obtaining information from Embed.

EXPORT32 long vissimRequest(long req, arg2, arg3);

The first argument (long req) is a message code describing the action for Embed to take. The message codes that pertain to writing a custom block are as follows:

Message

Description

VR_CG_GET_TIMER_FUNC

Returns name of main interrupt function.

VR_CG_REWRITE_LOCAL_VAR_STR

Reserved.

VR_CHECK_PORT_NAME_SYNTAX

Reserved.

VR_CLEAR_BLOCK

Clears red error state on block. Uses currently executing block if block handle in arg1 is null.
arg1:   Block handle (opt.)

VR_CLEAR_BLOCK_ERR

Clears red error state on block. Uses currently executing block if block handle in arg1 is null.
arg1:   Block handle (opt.)

VR_CODE_GEN

Activates code generation on the current diagram.

arg2:   Pointer to C file name

VR_DISABLE_BLOCK_TYPE

Removes block matching name string from Blocks menu.
arg1:   LPSTR name string

VR_ENABLE_MENU_ITEM

Enables menu item.
arg1:   char* name of menu item to be enabled

VR_EXECUTE

Runs diagram but does not change time (no integration).

VR_EXECUTE_CONST_BLOCK

Reserved.

VR_EXPAND_PATH_ALIAS

Returns pointer (LPCSTR) to expanded path alias.
arg1:   Pointer (LPCSTR) to input alias

VR_GET_BLOCK_FLAGS

Returns existing block flags. VBF_* are the flogs. OR them together to get the flags you want.
arg1:   Block handle

VR_GET_BLOCK_ID

Returns an integer that uniquely identifies the block.

VR_GET_BLOCK_INPUT

Returns the pointer to the input SIGNAL vector.
arg1:   Block handle

VR_GET_BLOCK_OUTPUT

Returns the pointer to the output SIGNAL vector.
arg1:   Block handle

VR_GET_BLOCK_PARAMS

Returns block parameter pointer.
arg1:   Block handle

VR_GET_BLOCK_POS

Returns block position.

VR_GET_CODEGEN_FLAGS

Returns a bit vector of three possible flags that are OR’ed together. Flags can be check by AND’ing the named flag with the returned word. Flag names:
VRCG_FLG_HAS_COMM_INTERFACE: User checked “Include Embed Comm Interface” in the Code Gen dialog.
VRCG_FLG_WANT_STACK_CHECK: User wants a stack check.
VRCG_FLG_CALLABLE_FROM_USER_APP: User checked “Make Callable from User App” in Code Gen dialog.

VR_GET_CODEGEN_TARGET

Returns pointer (LPCSTR) to the name of the current code generation target.

VR_GET_CONNECT_PORT

Indicates if port is input or output.
arg1:   Block handle
arg2:   Port number. If positive, the port is an input; if negative, the port is an output.

VR_GET_CONNECTOR_COUNT

Gets either the input or the output connector count for the block.
arg1:   Block handle
arg2:   If arg2 is 1, it returns the number of inputs; if arg2 is 0, it returns the number of outputs.

VR_GET_CONSTRAINTS

Gets constraint values
arg1:   Double * constraint

VR_GET_CUR_BLOCK_HANDLE

Returns the handle to the current block.

VR_GET_EXPRESSION_ERROR

Returns char * string of syntax or semantic error from prior call to VR_GET_EXPRESSION_RESULT

VR_GET_EXPRESSION_RESULT

Returns char * result of expression evaluation
arg1:   char * C expression string

VR_GET_GLOBAL_CONSTRAINT_BOUNDS

Gets global constraint bounds.
arg1:   Double * upper bound
arg2:   Double * lower bound

VR_GET_GLOBAL_CONSTRAINTS

Gets global constraints.
arg1:   Double *

VR_GET_GLOBAL COST

Gets global cost.
arg1:   Double * global cost

VR_GET_GLOBAL_OPT_INFO

Gets global optimization settings.
arg1:   OPT_INFO

VR_GET_GLOBAL_UNKNOWN_BOUNDS

Gets global unknown bounds.
arg1:   Double * upper bound
arg2:   Double * lower bound

VR_GET_GLOBAL_UNKNOWNS

Gets global unknowns.
arg1:   Double *

VR_GET_GLOBAL_UNKNOWNS_INPUT

Gets global unknown input.
arg1:   Double * global unknown initial
             condition

VR_GET_IMPLICIT_SOLVER_RUNNING

Returns non-zero if implicit solver is running.

VR_GET_INTEGRATION_SUBSTEP

Returns integration substep for multistep methods. Note that 0 means start of new step.

VR_GET_LOCAL_TIME_STEP

Assigns local time step to *arg2
arg1:   Block handle
arg2:   Pointer to double *

VR_GET_OEM_NAME

Pointer (LPCSTR) to OEM name.

VR_GET_OPEN_FILE_PATH

Returns pointer (LPCSTR) to the file name or file path of the active diagram.
arg1:   If 0, then file name; if 1, then file path

VR_GET_OVERPLOT_DATALIST

Reserved.

VR_GET_PARAM_STR

Returns pointer to parameter string for block handle.
arg1:   Block handle

VR_GET RANDOM_SEED

Supplies the random seed.

VR_GET_RUN_STATE

Indicates if the simulation is running (TRUE) or not running (FALSE).

VR_GET_SOLVER_INFO

Gets settings from Implicit Solver tab in the System Properties dialog.
arg1:   Pointer to Implicit Solver

VR_GET_STARTUP_DIR

Returns Embed directory string.

VR_GET_STARTUP_SCRIPT

Returns pointer (LPCSTR) to current script file path.

VR_GET_SUB_VERSION

Returns version letter suffix.

VR_GET_TGT_CAPABILITIES

Returns a 32-bit value that indicates the capabilities bit mask for the current or given target.
arg1:   If 0, uses current target; otherwise treats as pointer to the target name

VR_GET_UNKNOWNS_INPUT

Get unknown inputs.
arg1:   Double *

VR_GET_VERSION

Returns major version in high byte and minor version in low byte.
arg1:   SIM_INFO pointer

VR_GET_VISSIM_STATE

Gets current simulation state and copy to pointer in arg1.

VR_GET_WINDOW_HANDLE

Returns Embed main window handle. Useful for model dialog creation.

VR_GRAY_MENU_ITEM

Grays out menu item.
arg1:   Pointer to the menu item name (LPSTR).

VR_MODIFY_BLOCK

Reserved.

VR_NEED_DISPLAY_UPDATE

Returns TRUE if display should be repainted.

VR_NULL

Reserved.

VR_REALLOC_USER_PARAM

Reallocates parameter vector and returns newly reallocated pointer.
arg1:   Block handle
arg2:   New parameter size

VR_RECORD_EVENT

Records an event in the Embed event log.
arg1:   event type (see EVENT_TYPE)
arg2:   LPSTR event message
EVENT_TYPE
tvsmEventMessage = 1
tvsmEventWarning= 2
tvsmEventError=3

VR_REPAINT_BLOCK

Repaints block given by block handle in arg1.
arg1:   if NULL, the currently active block is repainted

VR_REQUEST_PERMISSION

Reserved.

VR_REQUEST_PERMISSION2

Reserved.

VR_RESET_XFERS

For internal use only.

VR_RESYNC_REALTIME_CLOCK

Resynchronizes Embed’s real-time clock to the current time.

VR_RETYPE_CONNECTORS_FROM_SIGS

Requests retyping of connectors based on signal types.

VR_ROTATE_BLOCK

Rotates block 180o.
arg1:   Block handle
arg2:   0

VR_RUN_SIMULATION

Executes the current model.

VR_SET_BLOCK_CONNECTOR_COUNT

Sets the connector count on the block.
arg1:   Block handle
arg2:   input # = upper word
             output # = lower word

VR_SET_BLOCK_FLAGS

Sets block flags. VBF_* are the flogs. OR them together to get the flags you want.
arg1:   Block handle
arg2:   Flag bits (32-bit word)

VR_SET_BLOCK_MENU

Adds user-defined block to Blocks menu.
arg1:   Pointer to initialized USER_MENU_ITEM vector

VR_SET_BLOCK_POS

Sets position of the block.
arg1:   Block handle
arg2 (lower 16 bits):     xPos
arg2 (upper 16 bits):     yPos

VR_SET_CONNECTOR_CHAR

Sets indicator character on block connector.
arg1:   Character to set

VR_SET_CONNECTOR_LABEL

For internal use only.

VR_SET_EXPR_BLOCK_HANDLE

Sets the currently active C expression block to the block handle passed in arg1. This enables the C expression evaluator to highlight the block in red in the event of an error.

VR_SET_GLOBAL_UNKNOWNS

Sets global unknowns from supplied vector.
arg1:   Double * global unknown

VR_SET_PARAM_STR

Sets new parameter string for block handle. Note that the block will always copy arg2, so arg2 can be freed after the call.
arg1:   Block handle
arg2:   Pointer to parameter string (LPSTR)

VR_SET_RANDOM_SEED

Sets the random seed as an (unsigned int*).
arg1:   (unsigned int*)

VR_SET_STARTUP_SCRIPT

Sets script file.
arg1:   Pointer (LPCSTR) to script file path

VR_SET_UNKNOWNS

Sets unknown values from user-supplied vector.
arg1:   Double * unknown

VR_SET_VISSIM_STATE

Reserved.

VR_SHOW_HELP

Reserved.

VR_SHOW_HELP_ECD

Reserved.

VR_SNAP_STATES

Causes Embed to use current integrator/delay state as initial condition.

VR_UPDATE_STRING

Updates stringPtr in arg1 with newStrValue in arg2, reallocating memory if needed.

arg1: LPSTR* stringPtr

arg2: LPCSTR newStrVal

VR_WF_GET_CURRENT_VIEW 

Returns a block handle to the currently open compound block.

VR_WF_GET_SCROLL_INFO

Returns DWORD: upper 16 bits is Y position of scroll thumb; lower 16 bits is X position of scroll thumb.

VR_WF_OPEN_COMPOUND

Sets current view level to compound block.
arg1:   Block handle