This website uses local storage to ensure you get the best experience on our website.

Table of Contents

Writing a Controller as a Dynamic Link Library

A dynamic link library provides faster and more reliable communications between the controller and the Bladed simulation, and is recommended. The interface to Bladed is also simpler to write.

When the simulation starts up, the controller DLL file is loaded into memory from the path supplied by the user for the User-Defined Controller. In all versions of Bladed the run folder is the working directory while the simulation is running

The controller is written as a subroutine or procedure. The DLL export name of the procedure must evaluate to DISCON. The naming is case-sensitive and must be in upper case. Depending on the language system being used, it may be necessary to define this by means of an alias. The procedure does not generate a return value. It has five arguments, as follows (the names given here are arbitrary, and are given purely for ease of reference within this manual. Only the order is important):

DATA The address of the first record of an array of single-precision (4-byte) real numbers which is used for data exchange between the simulation and the controller. The contents of the array are defined in the Swap Array Interface Definition.

FLAG A 4-byte integer (passed by reference) which the DLL should set as follows:

  • 0 if the DLL call was successful

  • >0 if the DLL call was successful but the “MESSAGE” should be issued as a warning message. The simulation will continue.

  • <0 if the DLL call was unsuccessful or for any other reason the simulation is to be stopped at this point. MESSAGE is then issued as an error message.

INFILE The address of the first record of an array of 1-byte characters giving the name of the parameter file, which is currently DISCON.IN. This array should not be modified by the DLL. The number of characters in the name is given in DATA. See the Swap Array Interface Definition.

OUTNAME The address of the first record of an array of 1-byte characters giving the simulation run name, prefixed by the full path to the directory which will contain the simulation results. This may be useful if the controller wishes to write a permanent record of what it does to be stored with the simulation results. The results should be stored in a file whose name (including path) is generated by appending .xxx to OUTNAME. To avoid overwriting existing files the file extension should not match those of files produced by Bladed (such as .$ME or .$TE files). The number of characters in the name is given in DATA. The DLL may also send information back to Bladed for output in the same form by Logging Results.

MESSAGE The address of the first record of an array of 1-byte characters which may be used by the DLL to send a text message to Bladed, which appears on the screen and is stored together with any other calculation messages generated by Bladed.

Last updated 28-08-2024