Main Content

ssSetOperatingPointCompliance

Specify how the software handles S-function operating point information when saving and restoring model operating point

Syntax

void ssSetOperatingPointCompliance(S, setting)

Arguments

S

SimStruct that represents an S-Function block.

setting

Specify how the software handles the operating point information for the S-function when saving and restoring the operating point for the model. The table summarizes the possible values.

SettingResult
OPERATING_POINT_COMPLIANCE_UNKNOWN

This setting is the default when you do not explicitly specify the operating point compliance.

For S-functions that do not use PWorks, the software behaves the same as when you specify USE_DEFAULT_OPERATING_POINT and issues a warning.

For S-functions that use PWorks, the USE_DEFAULT_OPERATING_POINT option is not supported, and the software issues an error.

USE_DEFAULT_OPERATING_POINT

The software handles the operating point information for the S-function the same as for built-in blocks. The software saves and restores this information about the S-function as part of the Simulink.op.ModelOperatingPoint object for the model:

  • Continuous state values

  • Non-scratch DWork vector values, including IWork, RWork, and mode DWork vector values

  • Zero-crossing signal values

USE_EMPTY_OPERATING_POINT

The software does not save any information about the S-function as part of the Simulink.op.ModelOperatingPoint object for the model. Use this option when the S-function does not have state information that is relevant for saving and restoring the model operating point.

This option is common for sink blocks, or blocks with no output ports, that use PWork or DWork vectors to store handles to files or figure windows.

This option is not supported for S-functions that register discrete states, continuous states, or zero-crossing signals.

USE_CUSTOM_OPERATING_POINT

The software uses the custom mdlGetOperatingPoint and mdlSetOperatingPoint methods for saving and restoring information about the S-function as part of the Simulink.op.ModelOperatingPoint object for the model.

You must use this option for S-functions that use PWork vectors or static variables to hold data that the software updates during simulation.

When you implement a custom mdlGetOperatingPoint method, you must write your own code to include the state information for the S-function in the loggedStates property of the Simulink.op.ModelOperatingPoint object for the model.

For an example of how to implement these methods, see Custom Code and Hand Coded Blocks Using the S-Function API.

DISALLOW_OPERATING_POINT

The S-function does not allow saving or restoring its operating point. The software issues an error when you try to save or restore a Simulink.op.ModelOperatingPoint object for the model that contains the S-function.

This setting can be useful for S-functions that communicate with third-party libraries when state serialization is not possible.

Description

When you write an S-function, you must specify how the S-function interacts with the model operating point using ssSetOperatingPointCompliance.

A model operating point contains complete information about the state of a simulation at the time when the operating point is saved. When you use a model operating point to specify the initial state for a simulation, the simulation results exactly match results for an equivalent simulation that runs from the beginning rather than starting from the operating point. For more information, see Use Model Operating Point for Faster Simulation Workflow.

In addition to the option to use an operating point as the initial state for a simulation, several Simulink® features, such as fast restart, rely on the model operating point internally.

You can choose whether and how the software saves operating point information for your S-function in the model operating point based on the purpose and implementation of the S-function.

Languages

C, C++

Examples

Use the ssSetOperatingPointCompliance function in the mdlInitializeSizes method to specify the operating point compliance for the S-function. This example sets the compliance to USE_DEFAULT_OPERATING_POINT.

static void mdlInitializeSizes(SimStruct* S)
{
    ssSetNumSFcnParams(S, 2); /* two parameters */
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) 
        return;
    ssSetSFcnParamTunable(S, 0, false);
    ssSetSFcnParamTunable(S, 1, false);

    boolean_T visibility = true;
    ssOperatingPointCompliance setting = USE_DEFAULT_OPERATING_POINT;
    if (ssGetErrorStatus(S)) return;

    ssSetOperatingPointCompliance(S, setting);
    ssSetOperatingPointVisibility(S, visibility);
}

Version History

Introduced in R2019a

expand all