Native external functions: Results

This is the mechanism that allows external functions to provide custom results that can then be tabulated or graphed just like any other OrcaFlex result. The external function registers any results it supports in response to the eaRegisterResult action. The eaRegisterResult is called before the eaInitialise action for each external function, and before the first eaCalculate. The external function registers a result by calling C_RegisterExternalFunctionResult.

Storing results to an OrcaFlex simulation file

At every log interval, after the eaCalculate action, eaLogResultCreate is called. The external function must now store all data required to derive this result by allocating memory in the lpExtFnInfo->lpLogData pointer and copy the state information into this block of memory. The lpExtFnInfo->LengthOfLogData member must be set to the length of the block of memory allocated.

Note: As an alternative, an existing block of memory could be used here.

OrcaFlex now has access to this set of data and can write it to the simulation file.

The next action is eaLogResultDestroy where the external function must then free any memory allocated.

Note: If this is a tracking external function then at each log interval the eaTrackCalculation action is called instead of the eaCalculate action.

Calculating External Function Results from an OrcaFlex simulation file

When results are required, OrcaFlex will call the external function with the eaDeriveResult action passing a pointer to the data stored above in lpLogData, the ResultID and a TObjectExtra2 containing the user defined ExternalResultText string. The external function should set lpValue to the calculated result.

Note: External Function Results are only available once a model has begun dynamic simulation.

See also

Native External Functions, TExtFnInfo, TExtFnResultInfo, C_RegisterExternalFunctionResult.