20.6.10.2. C Function

The C Function block is available for the inputted file made by Julia/Python code or C code which user defined.

  • The function format of C Function has to be extern “C” __declspec(dllexport) int __cdecl C_Function(double *y, double *u) and the solver calls only C_Function in the C code. Here, y is the outputted array and u is the inputted array. The return value is the error code and it is used later on.

Listing 20.1 C Function Example
extern "C" __declspec(dllexport) int __cdecl C_Function(double* y, double* u)
{
   y[0] = 2.5*u[0];
   y[1] = 2.0*u[1];
   return 1;
}

20.6.10.2.1. Jl Function

  • The function format of Julia Function has to be function Jl_Function(y, u) and the solver calls only “Jl_Function” function in the Julia code. Here, y is the output array and u is the input array. The return value is the error code and it is used later on.

Listing 20.2 Jl Function Example
function Jl_Function( y, u)
   #u : input to the block
   #y : output from the block
   y[1] = 2.5*u[1]
   y[2] = 2.0*u[2]
   return 0;
end

To see the contents supported the Julia Script.

Dialog box

../_images/image232.png

Figure 20.155 C Function dialog box

Table 20.93 Parameters

Parameter(s)

Description

Input Data Size

Enters the number of inputted double value

Output Data Size

Enters the number of outputted double value

Type

When the user uses the Julia code, select Jl Function and when the user uses the DLL, select C DLL.

File

When Type is the Jl Function, the Jl file can be selected. when Type is C DLL, the DLL file can be selected.

20.6.10.2.2. Py Function

  • The function format of Python Function has to be function Py_Function(y, u) and the solver calls only “Py_Function” function in the Python code. Here, y is the output array and u is the input array. The return value is the error code and it is used later on.

Listing 20.3 Py Function Example
def Py_Function(y, u):
   #u : input to the block
   #y : output from the block
   y[0] = 2.5*u[0]
   y[1] = 2.0*u[1]
   return

To see the contents supported the Python Script.

Dialog box

../_images/image2321.png

Figure 20.156 C Function dialog box

Table 20.94 Parameters

Parameter(s)

Description

Input Data Size

Enters the number of inputted double value

Output Data Size

Enters the number of outputted double value

Type

When the user uses the Python code, select Py Function and when the user uses the DLL, select C DLL.

File

When Type is the Py Function, the py file can be selected. when Type is C DLL, the dll file can be selected.