Using the DLL wizard

If you want a quick way to generate the skeletal code for a custom block, you can use the DLL Wizard. The DLL Wizard takes you step-by-step through the process of creating a custom block in Microsoft Visual Studio.

The DLL Wizard performs the following functions:

      Creates all the source files, including .CPP, .H, and .RC file

      Adds the source, resource, and VISSIM32.LIB files to the project file

      Specifies the number of inputs, outputs, connector label names for the custom block

      Adds sample code to generate a customizable MFC dialog box

To use the DLL Wizard, Microsoft Visual Studio must be installed on your computer.

To run the DLL Wizard

This step-by-step process uses Microsoft Visual Studio v2019.

1.    Start Microsoft Visual Studio.

2.    Choose File > New > Project.

The following dialog box appears.  

3.    Choose Altair Embed Add-On DLL Wizard 2020 and click Next.

The following dialog box appears.

4.    You can change the project name, location that the project is stored, and solution name. See the Microsoft Visual Studio documentation for information on these options.

5.    Click Create, or press ENTER.

The Embed DLL Wizard starts up.

6.    This dialog box contains default Embed block properties to review and edit. If you do not need to make any changes, click Finish to exit the DLL Wizard. To make changes, click Next or Block Name.

The following dialog box appears:

7.    To edit the block and function name:

a.    In the Base Function Name box, enter the base name of the function. The name you enter appears in the title bar of the dialog box that corresponds to the custom block you are creating.

b.    In the Block Name box, enter the name of the block. The name you enter appears on the block. For long block names, use “\n” to span the name over multiple lines. For example, My Block\nIs Awesome.

c.     For consistency, the block name you specify here should also be used in step 13.

d.    Click Next or Input/Output.

The following dialog box appears:

8.    This dialog box lets you label the input and output pins on the block. Although it is recommended that you label the pins, it is not required. If you choose not to label the pins, simply enter the pin count in the Block Inputs and Block Outputs boxes. To label the pins, do the following:

a.    In the Input Label window, enter the pin name and click New. The name appears in the list box. Repeat these steps for each label. Pins are labeled from top to bottom. To re-arrange the labels in the list box, use the Up and Down buttons.

b.    In the Output Label window, enter the pin name and click New. The name appears in the list box. Repeat these steps for each label. Pins are labeled from top to bottom. To re-arrange the labels in the list box, use the Up and Down buttons.

9.    Click Next or Data Types.

The following dialog box appears:

10.  To create custom data types for your input and output pins, activate Use Custom Data Types and do the following:

a.    Input pins: In the Input box, select the pin number; in the Type box, select the data type. If you choose matrix or scaled integer, enter the dimension or radix and word size.

b.    Output pins: In the Output box, select the pin number; in the Type box, select the data type. If you choose matrix or scaled integer, enter the dimension or radix and word size.

11.  When done, click Next or C Code.

The following dialog box appears:

12.  To generate C code for your custom block, activate This block should generate C code and do the following:

a.    In the list box, click the DOWN ARROW to see code generation events to which your block can respond. The window below the list box shows the string to be included in your code. To edit the string, position the pointer in the window and click the mouse. If you do not want a particular string to be included in your code, delete it from the window.

b.    Click Next or Block Menu.

The following dialog box appears:

13.  This dialog box lets you choose where your block appears in an Embed menu. Note that the block is not accessible from Embed until after you add the corresponding DLL to the Embed initialization file.

a.    In Top Level Menu Name, specify the name of the menu in Embed’s menu bar under which the category containing your block will appear. If you want to use the standard Blocks menu, enter &Blocks.

b.    In Block Category Name, specify the name of the category under which your block will appear. You can use an existing category name (for example, Linear Systems or Arithmetic) or you can enter a new name.

c.     In Block Name, specify the name of your block. For consistency, you should use the block name specified in step 7.

d.    To generate a custom MFC dialog box for your block, activate Include Custom MFC dialog. For information on editing the resource file to customize the dialog box, see the appropriate Microsoft documentation.

e.    Click Finish.

14.  To build a DLL, in the Microsoft Visual Studio window, choose Build > Build projectname.DLL, where projectname is the name specified in step 3.

To edit the VSI.CPP file

The DLL Wizard creates a VSI.CPP file which contains the source C++ code for the DLL, as well as placeholders for simulation level functions and block level functions that you may use in your DLL. To edit VSI.CPP, start up the Microsoft Developer Studio and open VSI.CPP.