Using the Embed DLL wizard

Prerequisite: To use the Embed DLL Wizard, Microsoft Visual Studio must be installed on your computer

A quick way to generate the skeletal code for a custom block and create a simple dialog box for the block, use the Embed DLL Wizard in conjunction with Microsoft Visual Studio.

The Embed DLL Wizard performs the following functions:

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

      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 that can be edited in Microsoft Visual Studio

To run VSIX to install the Embed DLL Wizard in Microsoft Visual Studio

1.    Open File Explorer and go to your Embed install directory (typically C:/Altair/Embed2022).

2.    Double-click dllWiz20.vsix to install the Embed DLL Wizard in Microsoft Visual Studio.

 To create a block and corresponding dialog box with the Embed DLL Wizard

1.    Start Microsoft Visual Studio 2019.

2.    Choose File > New > Project.

3.    In the Create a new project dialog box, set the Project Type to Altair Embed.

4.    Click Next.

5.    In the Configure your new project dialog box, update the project name, location the project is stored, and solution name, accordingly. For more information on these settings, see Microsoft Visual Studio documentation. 

6.    Click Create, or press ENTER.

The Embed DLL Wizard starts up.

7.    This dialog box contains default Embed block properties to review and edit. To make changes:

8.    Click Next or select Block Name.

The following dialog box appears:

9.    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:

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

a.    In the Input Label window, enter the connector name and click New. The name appears in the list box. Repeat these steps for each label. Connectors 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 connector name and click New. The name appears in the list box. Repeat these steps for each label. Connectors are labeled from top to bottom. To re-arrange the labels in the list box, use the Up and Down buttons.

11.  Click Next or Data Types.

The following dialog box appears:

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

a.    Input connectors: 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 connectors: 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.

13.  When done, click Next or C Code.

The following dialog box appears:

14.  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:

15.  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 an MFC dialog box for your block, activate Include Custom MFC dialog.

e.    Click Finish.

A new project is created. The files of interest are VSI.CPP, VSMDIALOG.CPP, and VSMDIALOG.H.

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

17.  If you generated an MFC dialog box in step 15d, you can customize the dialog box using Microsoft Visual Studio. .

18.  Add the block to an Embed menu or bind the DLL to a userFunction block.