USER API DLL

This block allows to create a co-simulation between VISION and user-defined DLL.

Figure: USER API DLL block


Figure: Dialog box


Inputs:

list of semi-colon separated input ports names, e.g.: input_ports=IN1;IN2;IN3

Outputs :

list of semi-colon separated output ports names, e.g.: output_ports=OUT1;OUT2

API_file:

DLL file path.

API module

module name within the DLL API (optional; necessary only if API implements several modules)

api_buffer:

block input buffering flag (default=1);

when api_buffer=1, the input signals to the module are buffered for total signal

frame length before the module function is called.

Parameter list :

list of semi-colon separated optional model parameters values, e.g.:

params_list=F0;1e3;4

Note: The module parameters are not named; users need to know the semantic of the parameters following their order in the list.



Buffered input :

block input buffering flag (default=1);

When api_buffer=1, the input signals to the module are buffered for total signal frame length before the module function is called.

Configuration file 1:

Configuration file 2:

Optional data file names for use by the model. These can be used to instruct the model.

DLL module callback functions prototypes:

A module contains P-input ports and Q-output ports. The number of input ports can be zero; there must be a least one output port. The ports signals are considered complex numbers, i.e. if a real port signal is needed, it must be considered complex with a zero imaginary part. The DLL module must implement the following 3 functions in C/C++ for communicating with the simulator.

#ifdef __cplusplus

extern "C" {

#endif

int DLLEngineCreate(

int nb_params, double* params, char* APImodule,char* config_file1, char*

config_file2, char* err_msg);

int DLLEngineRun(

int engine_no, int nb_params, double* params, int nb_samples,double

start_time, double sample_time, int nb_inputs, double** inputs, int

nb_outputs, double** outputs, char* err_msg);

int DLLEngineClose(

int engine_no);

}

DLLEngineCreate

DLLEngineCreate initializes the module model function calculations using the

arguments below.

nb_params: number of module parameters

params: vector of module parameters

APImodule: module name within the DLL API (optional; necessary only if API implements several

modules)

config_file1: optional configuration file (may be used to read input parameters or

backup any data)

config_file2: optional configuration file (may be used to read input parameters or

backup any data)

err_msg: return an error message text when an error occurs.

DLLEngineCreate must return -1 when an error occurs. Otherwise, it returns a zero or

a positive integer representing the API engine no.

DLLEngineRun

DLLEngineRun calculate the module output signals using the arguments below.

engine_no: API engine no returned by DLLEngineCreate.

nb_params: number of module parameters

params: vector of module parameters

nb_samples: number of time samples in the input signals

start_time: input signals start time

sample_time: time step value of the input signals

nb_inputs: number of input ports.

inputs: [2*nb_inputs ][nb_samples] array of input ports signal vectors (each port is

represented by 2 real vectors).

nb_outputs: number of output ports.

outputs: [2*nb_outputs][ nb_samples] array of output ports signal vectors (each port is

represented by 2 real vectors).

err_msg: return error message text when an error occurs.

DLLEngineRun must return 0 when an error occurs. Otherwise, it must return 1.

DLLEngineClose

DLLEngineClose terminate the DLL engine and clean memory; any necessary

data backup may be done in this call using config files.

DLLEngineClose function is not mandatory (i.e., optional implementation)