Documentation Center

  • Trial Software
  • Product Updates

ssSetSimStateCompliance

Specify the behavior of a Simulink S-function when saving and restoring the SimState of a model containing the S-function.

Syntax

void ssSetSimStateCompliance(S, setting)

Arguments

S

SimStruct representing an S-function block.

setting

Define how to treat an S-function simulation state when saving and restoring the model simulation state. Permissible values are:

  • SIM_STATE_COMPLIANCE_UNKNOWN (default value)

  • USE_DEFAULT_SIM_STATE

  • HAS_NO_SIM_STATE

  • DISALLOW_SIM_STATE

  • USE_CUSTOM_SIM_STATE

Description

This function allows you to specify how Simulink® should treat an S-function during a save and restore of the model simulation state (SimState). If an S-functions does not specify its SimStateCompliance, then Simulink assumes the setting SIM_STATE_COMPLIANCE_UNKNOWN. This setting instructs Simulink to issue a warning and then switch to USE_DEFAULT_SIM_STATE in lieu of the SIM_STATE_COMPLIANCE_UNKNOWN. If the option is set to USE_DEFAULT_SIM_STATE and if the S-function does not use PWorks, then Simulink treats the S-function like a built-in block. Simulink saves and restores the same data as the SimState (e.g., continuous states and work vectors), as it would for a built-in block.

Languages

C, C++

Example

The following example uses this function to specify the simulation state compliance of an S-function in the mdlInitializeSizes method. The specification is based upon the first string parameter value.

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 = 0U;
        ssSimStateCompliance setting =
            GetSimSnapParameterSetting(S, &visibility);
        if (ssGetErrorStatus(S)) return;

        ssSetSimStateCompliance(S, setting);
        ssSetSimStateVisibility(S, visibility);
    }

See the full source code (/toolbox/simulink/simdemos/simfeatures/src sfun_simstate.csfun_simstate.c) for an example of how to get the S-function's simulation compliance.

Was this topic helpful?