Additional C Routines
Additional C routines are available for modeling in C. For generic use of these routines, the internal data structure of the current block must be specified in the routine's interface. The CTBlock and self methods are visible in each method.
The following routines are provided:
getTime
The getTime function returns the current simulation time as a real64 value:
t = getTime (CTBlock);
getdT
The getdT function returns the current interval for external communication as a real64 value:
step = getdT ();
getIntegrationStepsize
The getIntegrationStepsize function returns the current integration step size as a real64 value:
h = getIntegrationStepsize (CTBlock);
resetCTSolver
The integration algorithm can be reset explicitly with the resetCTSolver routine. An example for its use is resetting a continuous time state:
x = 0.0;
resetCTSolver (CTBlock);
Whenever one or more continuous time states have been set explicitly, the internal structures need to be reset when finished. Note that the resetCTSolver command should always be issued after a value has been assigned to a continuous time state.
sizeU
The sizeU function returns the number of block inputs as an int32 value:
sizeU = sizeU (CTBlock);
If some of the inputs are arrays, the total number of the scalar elements is returned. More complex inputs, such as records, structures or classes, are counted as one element.
sizeY
The sizeY function returns the number of block outputs as an int32 value:
sizeY = sizeY (CTBlock);
If some of the outputs are arrays, the total number of the scalar elements is returned. More complex outputs, such as records, structures or classes, are counted as one element.
sizeV
The sizeV function returns the number of block parameters (parameters and dependent parameters) as an int32 value:
sizeV = sizeV (CTBlock);
If some of the parameter states are arrays, the total number of the scalar elements is returned.
sizeX
The sizeX function returns the number of continuous states as an int32 value:
sizeX = sizeX (CTBlock);
If some of the continuous states are arrays, the total number of the scalar elements is returned.
sizeXK
The sizeXK function returns the number of discrete states as an int32 value:
nofX = sizeXK (CTBlock);
If some of the discrete states are arrays, the total number of the scalar elements is returned.
The get and reset routines provide additional ESDL library routines; the size routine allows a generic model design if the number or array size of instance variables has to be changed.
The following describes the use of the additional C routines in more detail. There are no semantic checks and usage restrictions provided with these routines. It is the user's responsibility to ensure they are used correctly.