Настройки среды VisSim

Настройка экрана под пользователя

In addition to changing general VisSim settings, you can also change many other settings to customize how VisSim looks, such as the use of colors and text fonts in your diagrams, the shape and color of connector tabs, and the amount of information displayed with each block in a diagram.

These settings are controlled with the Edit > Preferences command and the commands under the View menu. When you select a setting, it takes effect immediately and remains in effect until you change it.

Изменение настроек экрана в VisSim-е

To Do this
Hide input connector tabs and shrink the size of output connector tabs Choose View > Presentation Mode.
Hide wires and connector tabs, freeze blocks in place, and with the exception of interactive elements on button and slider blocks, lock block parameter values Choose View > Display Mode.

Typically this mode is used when there is animation in your simulation or you’ve constructed an instrumentation panel to monitor and control your simulation.

Display mode can be turned on or off for individual block diagram levels.

Color connector tabs according to the type of data entering or exiting the block Choose View > Data Types.

The four types of data and their corresponding connector tab colors are double-floating point (red), signed integer (green), unsigned integer (blue), and vector (magenta).
Display connector labels on compound blocks Choose View > Connector Labels.
Change how text is displayed on blocks Choose View > Fonts. Select the text attributes.

Character format can be selectively applied to label.

Rich text format can be retained in comment blocks, as described below.
Retain character format in comment blocks Choose Edit > Preferences. Select the Preferences tab. Activate Use Rich Text Format.
Change the color of the VisSim screen; plotting background on plot, stripChart, and histogram blocks; wires; and diagram text Choose View > Colors. Select the color for the corresponding screen element.

When you choose a default color for the plotting background, VisSim uses the specified color on all meter, plot, and stripChart blocks except those whose background colors were explicitly set in their Properties dialog boxes.
Display block names beneath each block Choose Edit > Preferences. Select the Preferences tab. Activate Training Mode Labels. Then choose View > Block Labels.
Display parameter values, file names, and block names beneath each block Choose Edit > Preferences. Select the Preferences tab. Clear Training Mode Labels. Then choose View > Block Labels.
Color compound blocks light blue Choose Edit > Preferences. Select the Preferences tab. Activate Color Compound Blocks.
Display block diagrams in black and white Choose Edit > Preferences. Select the Preferences tab. Clear Color Compound Blocks and Color Display.

Создание пользовательских неявных решателей

You can write an implicit static solver as a .DLL file. VisSim recognizes and uses a user-written solver only if:

Исходники для подключения решателя пользователя

The following table lists the source files for building an implicit static solver. These files are installed in \VISSIM45\VSOLVER and \VISSIM45\VSDK. They contain code for building a simplified Gauss-Seidel static solver. You may find it easier to edit the files to create your own static solver. To use these files, they must remain in the directories in which they currently reside.

Source file Description
VSOLVER.FOR or VSOLVER.C A Fortran or C source file for the implicit static solver. The heart of the solver is the vissimRequest() function that you call to obtain the inputs to the constraint blocks and to supply values to the outputs of the unknown blocks. Using vissimRequest(), you can write a wide variety of solvers. For more information, see Using vissimRequest() in a custom implicit solver.
VSOLVER.DEF A definition file with linker commands to build a .DLL file from object code. Windows requires that you use a definition file to link the object code.
VSOLVER.MAK A make file with rules for automatically building a .DLL file.
VSUSER.H A C language header file with function prototypes and command definitions for the vissimRequest() function.

Использование vissimRequest() в решателе пользователя

The vissimRequest() function is a general-purpose function for making requests to VisSim. A user-written solver uses vissimRequest() to read and write optimization information in a block diagram. The general format of vissimRequest() is:

long FAR vissimRequest(long req, long arg2, long arg3 )

The first argument (long req) is a message code describing the action for VisSim to take. The list of message codes is defined in the file named VSUSER.H, which is installed in \VISSIM45\VSOLVER. The message codes that pertain to writing a local static solver are listed in the table below.

Message code Description
VR_EXECUTE Executes the diagram on iteration without moving time.
VR_GET_BLOCK_PARAMS Returns a pointer to a block’s parameters.
VR_GET_CONSTRAINTS Arg2 returns a vector of local constraint values. Ordering of the elements vector can be determined by the value of the ID parameter for the constraint block. VisSim sorts in sequential order, from low to high.
VR_GET_SOLVER_INFO Arg2 returns information related to the diagram and the implicit solver dialog settings in the following manner:

arg2[ 0 ] = number of constraints

arg2[ 1 ] = number of unknowns

arg2[ 2 ] = relaxation value

arg2[ 3 ] = maximum iteration value

arg2[ 4 ] = error tolerance value

VR_GET_UNKNOWNS Arg2 returns a vector of current local unknown output values. Ordering of the elements vector can be determined by the value of the ID parameter for the unknown block. VisSim sorts in sequential order, from low to high.
VR_GET_UNKNOWNS_INPUT Arg2 returns a vector of current inputs to the unknown blocks. Ordering of the elements vector can be determined by the value of the ID parameter for the unknown block. VisSim sorts in sequential order, from low to high. (This is useful for initial condition setting.)
VR_GET_VERSION Returns the current version of VisSim.
VR_GET_VISSIM_STATE Gets information related to the global state of VisSim. The information provided is a copy of the current internal state; modifying it will not change VisSim’s state. Arg2 should contain a pointer to a SIM_INFO structure, defined in VSUSER.H, which will be filled in by the vissimRequest() function. Arg3 should contain the size of this structure (sizeof(SIM_INFO)) to allow for version compatibility checking.
VR_SET_UNKNOWNS Sets diagram unknowns based on the vector passed as arg2. Ordering of the elements vector can be determined by the value of the ID parameter for the unknown block. VisSim sorts in sequential order, from low to high.

Построение решателя пользователя

Most languages have a Project Build facility that automates the process of building a .DLL file. The following procedure guides you through the process of building a project in general terms. Refer to the documentation for the application language you’re using for specific instructions.

To build a custom implicit solver:

  1. Invoke the Compiler environment.
  2. Add all the source files listed under Source files for building a custom implicit solver to the project or make file.
  3. Under project options, specify the project type as a Windows Dynamic Link Library (.DLL).
  4. Under compiler preprocessor options, specify \VISSIM45\VSDK as the include directory.
  5. Build the project.

Использование блока 'constraint' с решателем пользователя

To indicate the number that VisSim uses to sort the block when presented as a vector in a user-written solver, enter it in the ID box of the Constraint Properties dialog box. VisSim does not require the ID to be unique or contiguous; it sorts them in sequential order. The default is 0.

#########

Создание пользовательских глобальных оптимизаторов

You can write a global optimizer as a .DLL file. VisSim recognizes a user-written global optimizer when it is named VOPT.DLL and resides in your current directory. VOPT.DLL should also contain an exported function in the following format:

int FAR EXPORT USER_OPT_FUNC(DOUBLE *unknownVec, int unknownCount, int costCount, int globalConstraintCount);

Optimize has a prototype declared in VSUSER.H.

Before you initiate global optimization, make sure VOPT.DLL is in your current directory and the User Solver parameter in the dialog box for the Simulate menu’s Optimization Setup command is activated.

Исходники для подключения глобального оптимизатора пользователя

The following table lists the source files for building a global optimizer. These files are installed in \VISSIM45\VSOLVER and \VISSIM45\VSDK.

Source file Description
VOPT.C A C source file for a sample global optimizer. The heart of the optimizer is the vissimRequest() function that you call to obtain the inputs to the cost blocks and to supply values to the outputs of the parameterUnknown blocks. Using vissimRequest(), you can write a wide variety of optimization algorithms. For more information, see the description below.
VOPT.DEF A definition file that contains linker commands to build a .DLL file from object code.
VOPT.MAK A make file that contains rules for automatically building a .DLL file.
VSUSER.H A C language header file that contains function prototypes and command definitions for the vissimRequest() call.
IMPSIM.LIB VisSim import library that describes the address of vissimRequest().

Использование vissimRequest() в глобальном оптимизаторе пользователя

The vissimRequest() function is a general-purpose function for making requests to VisSim. A user-written global optimizer uses vissimRequest() to read and write global optimization information in a block diagram. The general format of vissimRequest() is:

long FAR vissimRequest(long req, long arg2, long arg3 )

The first argument (long req) is a message code describing the action for VisSim to take. The list of message codes is defined in the file named VSUSER.H, which is installed in \VISSIM45\VSOLVER. The message codes that pertain to writing a global optimizer are as follows:

Message code Description
VR_GET_GLOBAL_COST Writes a vector of current cost block input values into a vector pointed at by arg2.
VR_GET_GLOBAL_CONSTRAINTS Writes a vector of current globalConstraint block input values into a vector pointed at by arg2.
Message code Description
VR_GET_GLOBAL_CONSTRAINT_BOUNDS Writes a vector of globalConstraint block low bounds into a vector pointed at by arg2, and a vector of globalConstraint block high bounds into a vector pointed at by arg3.
VR_GET_GLOBAL_OPT_INFO Gets information related to the global optimization settings in the dialog box for the Optimization Setup command. The information provided is a copy of the current optimization state; modifying it will not change VisSim’s state. Arg2 should contain a pointer to an OPT_INFO structure, defined in VSUSER.H, which will be filled in by the vissimRequest() call. Arg3 should contain the size of this structure (sizeof(OPT_INFO)) to allow for version compatibility checking.
VR_GET_GLOBAL_UNKNOWNS Writes a vector of current parameterUnknown block output values into the vector pointed at by arg2. Ordering of the elements vector can be determined by the value of the ID parameter for the parameterUnknown block. VisSim sorts in sequential order, from low to high.
VR_GET_GLOBAL_UNKNOWNS_INPUT Writes a vector of current parameterUnknown block input values into the vector pointed at by arg2. Ordering of the elements vector can be determined by the value of the ID parameter for the parameterUnknown block. VisSim sorts in sequential order, from low to high.
VR_GET_GLOBAL_UNKNOWN_BOUNDS Writes a vector of parameterUnknown block low bounds into a vector pointed at by arg2, and a vector of parameterUnknown block high bounds into a vector pointed at by arg3.
VR_GET_VERSION Returns the current version of VisSim.
VR_GET_VISSIM_STATE Gets information related to the global state of VisSim. The information provided is a copy of the current internal state; modifying it will not change VisSim’s state. Arg2 should contain a pointer to a SIM_INFO structure, defined in VSUSER.H, which will be filled in by the vissimRequest() function. Arg3 should contain the size of this structure (sizeof(SIM_INFO)) to allow for version compatibility checking.
VR_RESET_XFERS For internal use only.
Message code Description
VR_RUN_SIMULATION Starts a simulation run.
VR_SET_GLOBAL_UNKNOWNS Sets current parameterUnknown block output values from arg2.

Построение глобального оптимизатора пользователя

Most languages have a Project Build facility that automates the process of building a .DLL file. The following procedure guides you through the process of building a project in general terms. Refer to the documentation for the application language you’re using for specific instructions.

To build a custom global optimizer:

  1. Invoke the Compiler environment.
  2. Add all the source files listed under Source files for building a custom global optimizer to the project or make file.
  3. Under project options, specify the project type as a Windows DLL.
  4. Under compiler options, specify the following:
  5. Build the project

VisSim Viewer is a run-time version of VisSim that allows you to distribute your block diagram models to end users not licensed to use VisSim. VisSim Viewer provides end users with all the features and capabilities of VisSim, with the following exceptions: