This is an example of a User Defined Profile utilizing User DLL built with Visual Studio .NET. It includes:
· OptiBPM Project file (UserDLL_NET.bpd)
· The User DLL binary (UserDLL_NET.dll)
· The C++ source code (Visual Studio .NET project)
The User Defined Profile utilizing a DLL is a very powerful tool, adding flexibility to OptiBPM. Developing a Profile DLL with use of the older compilers, like Visual Studio 6.0, is fairly straightforward. The situation changed with Visual Studio .NET, which will not compile provided source code into a functioning DLL. It will add linker dependent “adornments” to names of the exported functions, rendering them unusable within OptiBPM.
This example demonstrates how to make Visual Studio .NET to create a C-like DLLs, which could be used with OptiBPM. The critical item here is a simple text file - UserDLL_NET.def – added to the VS .NET project. This file lists names of the exported functions, the same way as they are defined in the source code and as they are expected to appear within the compiled DLL.
The supplied example OptiBPM project file, UserDLL_NET.bpd, is provided for illustration purposes only. The example DLL (UserDLL_NET.dll) exports few functions, which are used as “additive” in UserDLL_NET.bpd project file. The functions return high refractive index values, so they could be easily observed in the “Refractive Index” tab of Layout Designer or Simulator, without adjusting the palette or data clamping of the View Tab.
1. Observe the refractive index distribution generated with User_NET.dll
· Open the supplied UserDLL_NET.bpd project in Layout Designer
· Select the “Ref. Index (n) – 3D XY Plane View” tab
· Observe the cross-section of the waveguides created with the DLL functions
You should be able to observe four waveguides with gradient refractive index distribution, like the ones on the snap-shot images below. Listed from the left:
- A semi-sphere shape, with high gradient edges and low values in the middle (a semi-cup like distribution)
- A triangular shape with high refractive index values on top of its base (top of the substrate level)
- A sphere buried in the substrate. The refractive index distribution is also spherical
- A semi-sphere cut in the middle at the substrate level, with spherical refractive index distribution
On the right-most side you may observe a “marker” waveguide. It is a simple channel waveguide of 1[um]x5[um] size, placed at 2.5[um] depth. Its material has 2.0 refractive index value.
One can also simulate the provided Layout Design, and observe the refractive index values in a Simulator as well.
2. Compiling the User_NET project into Visual Studio .NET
· Load the User_NET project into the Visual Studio .NET
The sources of the User_NET.dll project can be found in the \UserDLL_NET\ folder. Open the UserDLL_NET.vcproj of UserDLL_NET.sln file in Visual Studio .NET, and examine the code structure. The source code consists of:
o MyFunctions.cpp - implementation of the C-type functions supplying the refractive index values
o MyFunctions.h - header file with declaration of the exported functions
o UserDLL_NET.def - definition file instructing the .NET compiler and linker to export the function names as specified. This text file content is very simple:
LIBRARY UserDLL_NET <- DLL library name
Sphere <- Exported function name
SemiSphere <- Exported function name
Func2 <- Exported function name
Triangle <- Exported function name
You can modify, adapt and distribute the provided sources as needed.
· Compile the project
Set the desired build configuration (i.e. Release or Debug), compile the sources. Visual Studio will build the DLL binary in the appropriate \Release\ or \Debug\ subfolder. In order to observe the impact of the code changes, you need to copy the compiled DLL next to your OptiBPM project file, or into \UserDLLs\ folder of OptiBPM installation directory. OptiBPM applications (Layout Designer, Simulators) will look up the mentioned locations for the required DLLs.
OptiBPM applications (Layout Designer, Simulators) will lock the required DLLs upon loading. Locking will prohibit overwriting (copy over) the existing DLLs. In order to unlock the binaries, one has to close the OptiBPM applications utilizing the DLLs