/* Function: mdlSetOutputPortSampleTime =================================*/
void mdlSetOutputPortSampleTime(SimStruct *S,
                                      int_T     portIdx,
                                      real_T    sampleTime,
                                      real_T    offsetTime)
{
    /* Set input port sample time as well */
    if (portIdx == 0) {
        ssSetOutputPortSampleTime(S, portIdx, sampleTime);
        ssSetOutputPortOffsetTime(S, portIdx, offsetTime);
        ssSetInputPortSampleTime(S, 0, sampleTime);
        ssSetInputPortOffsetTime(S, 0, offsetTime);
    }
} /* end mdlSetOutputPortSampleTime */
Exemple #2
0
/* Function: mdlSetOutputPortSampleTime ========================================
 * Abstract:
 *	When asked by Simulink, set the sample time of the specified output
 *	port. This occurs when back propagating sample times (see sfuntmpl_doc.c).
 *
 *	When called to set one sample time, we set them all. 
 *	We also verify that the 
 */
static void mdlSetOutputPortSampleTime(SimStruct *S,
                                      int_T     portIdx,
                                      real_T    sampleTime,
                                      real_T    offsetTime)
{

    /***********************************************************************
     * Output sample time must be discrete and we don't support discrete " *
     * offsets.								   *
     ***********************************************************************/

    if (sampleTime <= 0.0 || offsetTime != 0.0) {
        ssSetErrorStatus(S,"This block must back-inherit to the output ports "
                           "a discrete (zero-offset) signal");
        return;
    }

    /*******************************************************************
     * Set all output and input sample times. Note enable port is only *
     * port which may have a known sample time.                        *
     *******************************************************************/
    {
        real_T k[NOUTPUTS];
        real_T signalTs;
        int_T  i;

        k[0] = mxGetPr(K1_PARAM(S))[0];
        k[1] = mxGetPr(K2_PARAM(S))[0];
        k[2] = mxGetPr(K3_PARAM(S))[0];

        signalTs = sampleTime/k[portIdx];

        for (i = 0; i < NOUTPUTS; i++) {
            ssSetOutputPortSampleTime(S, i, signalTs*k[i]);
            ssSetOutputPortOffsetTime(S, i, 0.0);
        }

        ssSetInputPortSampleTime(S, SIGNAL_IPORT, signalTs);
        ssSetInputPortOffsetTime(S, SIGNAL_IPORT, offsetTime);

        if (ssGetInputPortSampleTime(S, ENABLE_IPORT) == INHERITED_SAMPLE_TIME){
            ssSetInputPortSampleTime(S, ENABLE_IPORT, signalTs);
        } else {
            CheckInputSampleTimes(S);
        }
    }
    

} /* end mdlSetOutputPortSampleTime */
/* Function: mdlSetInputPortSampleTime ==================================*/
void mdlSetInputPortSampleTime(SimStruct *S,
                                      int_T     portIdx,
                                      real_T    sampleTime,
                                      real_T    offsetTime)
{
    if (portIdx == 0) {
        ssSetInputPortSampleTime(S, portIdx, sampleTime);
        ssSetInputPortOffsetTime(S, portIdx, offsetTime);
		/* Set the second outport port sample time temporarily to this,
		 * it will eventually be set in mdlSetOutputPortSampleTime.
		 * We have to do it temporarily here because there are cases 
		 * when mdlSetOutputPortSampleTime is not called at all,e.g.,
		 * when the output of S-function is connected to a scope. */     
        ssSetOutputPortSampleTime(S, 0, sampleTime);
        ssSetOutputPortOffsetTime(S, 0, offsetTime);
    } 
} /* end mdlSetInputPortSampleTime */
/* Function: mdlInitializeSizes =========================================*/
static void mdlInitializeSizes(SimStruct *S)
{

    ssSetNumSFcnParams(S, 0);  /* Number of expected parameters */
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        return;
    }

    /* Register the number and type of states the S-Function uses */
    ssSetNumContStates(    S, 0);   /* number of continuous states           */
    ssSetNumDiscStates(    S, 0);   /* number of discrete states             */
    ssAllowSignalsWithMoreThan2D(S);

    /*
     * Configure the input ports. First set the number of input ports. 
     */
    if (!ssSetNumInputPorts(S, 1)) return;    
    if(!ssSetInputPortDimensionInfo(S, 0, DYNAMIC_DIMENSION)) return;
    ssSetInputPortDataType(S, 0, DYNAMICALLY_TYPED);
    ssSetInputPortDirectFeedThrough(S, 0, 1);

    /*
     * Configure the output ports. First set the number of output ports.
     */
    if (!ssSetNumOutputPorts(S, 1)) return;
    if(!ssSetOutputPortDimensionInfo(S,0,DYNAMIC_DIMENSION)) return;
    ssSetOutputPortDataType(S, 0, DYNAMICALLY_TYPED);

    ssSetNumSampleTimes(S, PORT_BASED_SAMPLE_TIMES);
    ssSetInputPortSampleTime(S, 0, INHERITED_SAMPLE_TIME);
    ssSetOutputPortSampleTime(S, 0, INHERITED_SAMPLE_TIME);

    /*
     * Set size of the work vectors.
     */
    ssSetNumRWork(         S, 0);   /* number of real work vector elements   */
    ssSetNumIWork(         S, 0);   /* number of integer work vector elements*/
    ssSetNumPWork(         S, 0);   /* number of pointer work vector elements*/
    ssSetNumModes(         S, 0);   /* number of mode work vector elements   */
    ssSetNumNonsampledZCs( S, 0);   /* number of non-sampled zero crossings   */

    ssSetOptions(S, 0);   /* general options (SS_OPTION_xx)        */

} /* end mdlInitializeSizes */
static void mdlSetOutputPortSampleTime(SimStruct *S,int_T portIdx,real_T
  sampleTime,real_T offsetTime)
{
  int i;
  for (i = 0 ; i < 2; ++i) {
    ssSetInputPortSampleTime(S,i,sampleTime);
    ssSetInputPortOffsetTime(S,i,offsetTime);
  }

  for (i = 0 ; i < 1; ++i) {
    if (ssGetOutputPortSampleTime(S,i) == rtInf &&
        ssGetOutputPortOffsetTime(S,i) == 0.0) {
      continue;
    }

    ssSetOutputPortSampleTime(S,i,sampleTime);
    ssSetOutputPortOffsetTime(S,i,offsetTime);
  }
}
static void mdlInitializeSizes(SimStruct *S)
{
  ssSetNumSFcnParams(S, 0);
  if (S->mdlInfo->genericFcn != NULL) {
    _GenericFcn fcn = S->mdlInfo->genericFcn;
    (fcn)(S, GEN_FCN_CHK_MODELREF_SOLVER_TYPE_EARLY, 2, NULL);
  }

  ssSetRTWGeneratedSFcn(S, 2);
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  if (!ssSetNumInputPorts(S, 2))
    return;
  if (!ssSetInputPortVectorDimension(S, 0, 1))
    return;
  ssSetInputPortFrameData(S, 0, FRAME_NO);
  ssSetInputPortBusMode(S, 0, SL_NON_BUS_MODE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
  {
    ssSetInputPortDataType(S, 0, SS_DOUBLE);
  }

  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetInputPortRequiredContiguous(S, 0, 1);
  ssSetInputPortOptimOpts(S, 0, SS_NOT_REUSABLE_AND_GLOBAL);
  ssSetInputPortOverWritable(S, 0, FALSE);
  ssSetInputPortSampleTime(S, 0, 0.0);
  ssSetInputPortOffsetTime(S, 0, 0.0);
  if (!ssSetInputPortVectorDimension(S, 1, 1))
    return;
  ssSetInputPortFrameData(S, 1, FRAME_NO);
  ssSetInputPortBusMode(S, 1, SL_NON_BUS_MODE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
  {
    ssSetInputPortDataType(S, 1, SS_DOUBLE);
  }

  ssSetInputPortDirectFeedThrough(S, 1, 1);
  ssSetInputPortRequiredContiguous(S, 1, 1);
  ssSetInputPortOptimOpts(S, 1, SS_NOT_REUSABLE_AND_GLOBAL);
  ssSetInputPortOverWritable(S, 1, FALSE);
  ssSetInputPortSampleTime(S, 1, 0.0);
  ssSetInputPortOffsetTime(S, 1, 0.0);
  if (!ssSetNumOutputPorts(S, 1))
    return;
  if (!ssSetOutputPortVectorDimension(S, 0, 1))
    return;
  ssSetOutputPortFrameData(S, 0, FRAME_NO);
  ssSetOutputPortBusMode(S, 0, SL_NON_BUS_MODE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
  {
    ssSetOutputPortDataType(S, 0, SS_DOUBLE);
  }

  ssSetOutputPortSampleTime(S, 0, 0.0);
  ssSetOutputPortOffsetTime(S, 0, 0.0);
  ssSetOutputPortOkToMerge(S, 0, SS_OK_TO_MERGE);
  ssSetOutputPortOptimOpts(S, 0, SS_NOT_REUSABLE_AND_GLOBAL);
  rt_InitInfAndNaN(sizeof(real_T));

  {
    real_T minValue = rtMinusInf;
    real_T maxValue = rtInf;
    ssSetModelRefInputSignalDesignMin(S,0,&minValue);
    ssSetModelRefInputSignalDesignMax(S,0,&maxValue);
  }

  {
    real_T minValue = rtMinusInf;
    real_T maxValue = rtInf;
    ssSetModelRefInputSignalDesignMin(S,1,&minValue);
    ssSetModelRefInputSignalDesignMax(S,1,&maxValue);
  }

  {
    real_T minValue = rtMinusInf;
    real_T maxValue = rtInf;
    ssSetModelRefOutputSignalDesignMin(S,0,&minValue);
    ssSetModelRefOutputSignalDesignMax(S,0,&maxValue);
  }

  {
    static ssRTWStorageType storageClass[3] = { SS_RTW_STORAGE_AUTO,
      SS_RTW_STORAGE_AUTO, SS_RTW_STORAGE_AUTO };

    ssSetModelRefPortRTWStorageClasses(S, storageClass);
  }

  ssSetNumSampleTimes(S, PORT_BASED_SAMPLE_TIMES);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumZeroCrossingSignals(S, 0);
  ssSetOutputPortIsNonContinuous(S, 0, 0);
  ssSetOutputPortIsFedByBlockWithModesNoZCs(S, 0, 0);
  ssSetInputPortIsNotDerivPort(S, 0, 1);
  ssSetInputPortIsNotDerivPort(S, 1, 1);
  ssSetModelReferenceSampleTimeInheritanceRule(S,
    DISALLOW_SAMPLE_TIME_INHERITANCE);
  ssSetOptimizeModelRefInitCode(S, 0);
  ssSetModelReferenceNormalModeSupport(S, MDL_START_AND_MDL_PROCESS_PARAMS_OK);
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE |
               SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME |
               SS_OPTION_SUPPORTS_ALIAS_DATA_TYPES |
               SS_OPTION_WORKS_WITH_CODE_REUSE |
               SS_OPTION_CALL_TERMINATE_ON_EXIT);
  if (S->mdlInfo->genericFcn != NULL) {
    ssRegModelRefChildModel(S,1,childModels);
  }

#if SS_SFCN_FOR_SIM

  if (S->mdlInfo->genericFcn != NULL &&
      ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
    mr_vdmultRM_MdlInfoRegFcn(S, "vdmultRM");
  }

#endif

  if (!ssSetNumDWork(S, 1)) {
    return;
  }

#if SS_SFCN_FOR_SIM

  {
    int mdlrefDWTypeId;
    ssRegMdlRefDWorkType(S, &mdlrefDWTypeId);
    if (mdlrefDWTypeId == INVALID_DTYPE_ID )
      return;
    if (!ssSetDataTypeSize(S, mdlrefDWTypeId, sizeof(rtMdlrefDWork_mr_vdmultRM)))
      return;
    ssSetDWorkDataType(S, 0, mdlrefDWTypeId);
    ssSetDWorkWidth(S, 0, 1);
  }

#endif

  ssSetNeedAbsoluteTime(S, 1);
}
Exemple #7
0
/* Function: mdlSetInputPortSampleTime =========================================
 * Abstract:
 *	When asked by Simulink, set the sample time of the enable or
 *	signal port. If we know both sample times, also set the output
 *	port sample times.
 */
static void mdlSetInputPortSampleTime(SimStruct *S,
                                      int_T     portIdx,
                                      real_T    sampleTime,
                                      real_T    offsetTime)
{

    /*************************************
     * Check for valid input sample time *
     *************************************/

    if (portIdx == ENABLE_IPORT) {
        /*
         * Enable signal port
         */
        if (offsetTime != 0.0) {
            ssSetErrorStatus(S,"Enable (port 1) signal must be fed by a signal "
                             "with a sample time that doesn't have an offset");
            return;
        }

    } else {
        /*
         * source signal port (i.e. signal to be decimated). The sample time
         * of this signal must be discrete (constant equates to inf,
         * continuous equates to zero).
         */

        if (sampleTime <= 0.0) {
            ssSetErrorStatus(S,"Source signal (port 2) must be fed by a "
                             "discrete signal");
            return;
        }

        if (offsetTime != 0.0) {
            ssSetErrorStatus(S,"Source signal (port 2) must be fed by a siganl "
                             "with a sample time that doesn't have an offset");
            return;
        }

        /*
         * Set output port sample times. Note, we are assured that all output
         * port sample times are unknown since when the output port sample
         * time routine is called, all sample times will be set.
         *
         * (note offset is already zero for inherited sample time)
         */

        {
            int_T  i;
            real_T k[NOUTPUTS];

            k[0] = mxGetPr(K1_PARAM(S))[0];
            k[1] = mxGetPr(K2_PARAM(S))[0];
            k[2] = mxGetPr(K3_PARAM(S))[0];

            for (i = 0; i < NOUTPUTS; i++) {
                ssSetOutputPortSampleTime(S, i, sampleTime*k[i]);
                ssSetOutputPortOffsetTime(S, i, 0.0);
            }
        }
    }

    ssSetInputPortSampleTime(S, portIdx, sampleTime);
    ssSetInputPortOffsetTime(S, portIdx, offsetTime);

    if (ssGetInputPortSampleTime(S, (portIdx+1) % 2) != INHERITED_SAMPLE_TIME) {
        CheckInputSampleTimes(S);
    }

} /* end mdlSetInputPortSampleTime */
Exemple #8
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    Call mdlCheckParameters to verify that the parameters are okay,
 *    then setup sizes of the various vectors.
 *
 *    We specify 2 input and 3 output ports with inherited port based sample 
 *    times.
 */
static void mdlInitializeSizes(SimStruct *S)
{
    int_T  i;
    real_T ts;

    /* See sfuntmpl_doc.c for more details on the macros below */

    /* Set number of expected parameters */
    if (ssGetSFcnParamsCount(S) == NKPARAMS ||
        ssGetSFcnParamsCount(S) == NTOTALPARAMS) {
        ssSetNumSFcnParams(S, ssGetSFcnParamsCount(S));
    } else {
        ssSetNumSFcnParams(S, NKPARAMS);
    }
#if defined(MATLAB_MEX_FILE)
    if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) {
        mdlCheckParameters(S);
        if (ssGetErrorStatus(S) != NULL) {
            return;
        }
    } else {
        return; /* Parameter mismatch will be reported by Simulink */
    }
#endif

    /* Parameters can't be tuned */
    ssSetSFcnParamNotTunable(S,K1_IDX);
    ssSetSFcnParamNotTunable(S,K2_IDX);
    ssSetSFcnParamNotTunable(S,K3_IDX);

    /* Load ts for input and output ports */
    if (ssGetNumSFcnParams(S) == NTOTALPARAMS) {
        ssSetSFcnParamNotTunable(S,OPTIONAL_TS_IDX);
        ts = mxGetPr(OPTIONAL_TS_PARAM(S))[0];
    } else {
        ts = INHERITED_SAMPLE_TIME;
    }

    ssSetNumSampleTimes(S, PORT_BASED_SAMPLE_TIMES);

    /* Two inputs */
    if (!ssSetNumInputPorts(S, NINPUTS)) return;

    for (i = 0; i < NINPUTS; i++) {
        ssSetInputPortWidth(S, i, 1);
        ssSetInputPortDirectFeedThrough(S, i, 1);
        ssSetInputPortSampleTime(S, i, ts);
        ssSetInputPortOffsetTime(S, i, 0.0);
        ssSetInputPortOverWritable(S, i, 0); /* Output is decimated! */
    }

    /*
     * We are always looking at the enable input in the correct task so we can
     * optimize away this entry from the block I/O.
     */
    ssSetInputPortOptimOpts(S, ENABLE_IPORT, SS_REUSABLE_AND_LOCAL);

    /*
     * We are always looking at the enable input in the correct task so we can
     * optimize away this entry from the block I/O.
     */
    ssSetInputPortOptimOpts(S, SIGNAL_IPORT, SS_REUSABLE_AND_LOCAL);

    /* Three outputs */
    if (!ssSetNumOutputPorts(S, NOUTPUTS)) return;
    for (i = 0; i < NOUTPUTS; i++) {
        ssSetOutputPortWidth(S, i, 1);
        ssSetOutputPortOptimOpts(S, i, SS_NOT_REUSABLE_AND_GLOBAL);
                                           /* Need to be persistent since the
                                              since we don't update the
                                              outputs at every sample hit
                                              for this block */
        if (ts == INHERITED_SAMPLE_TIME) {
            ssSetOutputPortSampleTime(S, i, ts);
        } else {
            ssSetOutputPortSampleTime(S, i, ts*mxGetPr(ssGetSFcnParam(S,i))[0]);
        }
        ssSetOutputPortOffsetTime(S, i, 0.0);
    }

    ssSetNumIWork(S, 1);

    /* specify the sim state compliance to be same as a built-in block */
    ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);

    /* Take care when specifying exception free code - see sfuntmpl_doc.c */
    ssSetOptions(S,
                 SS_OPTION_WORKS_WITH_CODE_REUSE |
                 SS_OPTION_EXCEPTION_FREE_CODE |
                 SS_OPTION_USE_TLC_WITH_ACCELERATOR);

} /* end mdlInitializeSizes */
return ; } static void mdlInitializeSizes ( SimStruct * S ) {
ssSetNumSFcnParams ( S , 0 ) ; ssFxpSetU32BitRegionCompliant ( S , 1 ) ;
rt_InitInfAndNaN ( sizeof ( real_T ) ) ; if ( S -> mdlInfo -> genericFcn != (
NULL ) ) { _GenericFcn fcn = S -> mdlInfo -> genericFcn ; real_T lifeSpan =
rtInf ; real_T startTime = 0.0 ; real_T stopTime = rtInf ; int_T hwSettings [
15 ] ; int_T opSettings [ 1 ] ; boolean_T concurrTaskSupport = 0 ; boolean_T
hasDiscTs = 1 ; real_T fixedStep = 0.001 ; ( fcn ) ( S ,
GEN_FCN_CHK_MODELREF_SOLVER_TYPE_EARLY , 2 , ( NULL ) ) ; ( fcn ) ( S ,
GEN_FCN_MODELREF_RATE_GROUPED , 0 , ( NULL ) ) ; if ( ! ( fcn ) ( S ,
GEN_FCN_CHK_MODELREF_LIFE_SPAN , - 1 , & lifeSpan ) ) return ; if ( ! ( fcn )
( S , GEN_FCN_CHK_MODELREF_START_TIME , - 1 , & startTime ) ) return ; if ( !
( fcn ) ( S , GEN_FCN_CHK_MODELREF_STOP_TIME , - 1 , & stopTime ) ) return ;
hwSettings [ 0 ] = 16 ; hwSettings [ 1 ] = 16 ; hwSettings [ 2 ] = 16 ;
hwSettings [ 3 ] = 32 ; hwSettings [ 4 ] = 32 ; hwSettings [ 5 ] = 64 ;
hwSettings [ 6 ] = 16 ; hwSettings [ 7 ] = 0 ; hwSettings [ 8 ] = 1 ;
hwSettings [ 9 ] = 16 ; hwSettings [ 10 ] = 1 ; hwSettings [ 11 ] = 2 ;
hwSettings [ 12 ] = 2 ; hwSettings [ 13 ] = 64 ; hwSettings [ 14 ] = 0 ; if (
! ( fcn ) ( S , GEN_FCN_CHK_MODELREF_HARDWARE_SETTINGS , 15 , hwSettings ) )
return ; opSettings [ 0 ] = 0 ; if ( ! ( fcn ) ( S ,
GEN_FCN_CHK_MODELREF_OPTIM_SETTINGS , 1 , opSettings ) ) return ; if ( ! (
fcn ) ( S , GEN_FCN_CHK_MODELREF_CONCURRETNT_TASK_SUPPORT , ( int_T )
concurrTaskSupport , ( NULL ) ) ) return ; if ( ! ( fcn ) ( S ,
GEN_FCN_CHK_MODELREF_SOLVER_TYPE , 0 , & hasDiscTs ) ) return ; if ( ! ( fcn
) ( S , GEN_FCN_CHK_MODELREF_SOLVER_NAME , 0 , ( void * ) "FixedStepDiscrete"
) ) return ; if ( ! ( fcn ) ( S , GEN_FCN_CHK_MODELREF_SOLVER_MODE ,
SOLVER_MODE_SINGLETASKING , ( NULL ) ) ) return ; if ( ! ( fcn ) ( S ,
GEN_FCN_CHK_MODELREF_FIXED_STEP , 0 , & fixedStep ) ) return ; ( fcn ) ( S ,
GEN_FCN_CHK_MODELREF_FRAME_UPGRADE_DIAGNOSTICS , 1 , ( NULL ) ) ; } { static
const char * globalVarList [ ] = { "Cntrl_Status" , "DT_PRECISION_HI" ,
"DT_PRECISION_LO" , "EV_Param" , "Motor_Cmds" , "Power_Lims" ,
"brake_cmd_table" , "ctrlConst" , "decel_cmd_vec" , "regen_pwr_vec" } ;
ssRegModelRefGlobalVarUsage ( S , 10 , ( void * ) globalVarList ) ; }
ssSetRTWGeneratedSFcn ( S , 2 ) ; ssSetNumContStates ( S , 0 ) ;
ssSetNumDiscStates ( S , 0 ) ; if ( ! ssSetNumInputPorts ( S , 8 ) ) return ;
if ( ! ssSetInputPortVectorDimension ( S , 0 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 0 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 0 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 0 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 0 , 1 ) ;
ssSetInputPortRequiredContiguous ( S , 0 , 1 ) ; ssSetInputPortOptimOpts ( S
, 0 , SS_NOT_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 0 ,
FALSE ) ; ssSetInputPortSampleTime ( S , 0 , 0.001 ) ;
ssSetInputPortOffsetTime ( S , 0 , 0.0 ) ; if ( !
ssSetInputPortVectorDimension ( S , 1 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 1 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 1 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 1 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 1 , 1 ) ;
ssSetInputPortRequiredContiguous ( S , 1 , 1 ) ; ssSetInputPortOptimOpts ( S
, 1 , SS_NOT_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 1 ,
FALSE ) ; ssSetInputPortSampleTime ( S , 1 , 0.001 ) ;
ssSetInputPortOffsetTime ( S , 1 , 0.0 ) ; if ( !
ssSetInputPortVectorDimension ( S , 2 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 2 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 2 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 2 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 2 , 0 ) ;
ssSetInputPortRequiredContiguous ( S , 2 , 1 ) ; ssSetInputPortOptimOpts ( S
, 2 , SS_NOT_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 2 ,
FALSE ) ; ssSetInputPortSampleTime ( S , 2 , 0.001 ) ;
ssSetInputPortOffsetTime ( S , 2 , 0.0 ) ; if ( !
ssSetInputPortVectorDimension ( S , 3 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 3 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 3 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 3 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 3 , 0 ) ;
ssSetInputPortRequiredContiguous ( S , 3 , 1 ) ; ssSetInputPortOptimOpts ( S
, 3 , SS_NOT_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 3 ,
FALSE ) ; ssSetInputPortSampleTime ( S , 3 , 0.001 ) ;
ssSetInputPortOffsetTime ( S , 3 , 0.0 ) ; if ( !
ssSetInputPortVectorDimension ( S , 4 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 4 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 4 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 4 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 4 , 1 ) ;
ssSetInputPortRequiredContiguous ( S , 4 , 1 ) ; ssSetInputPortOptimOpts ( S
, 4 , SS_NOT_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 4 ,
FALSE ) ; ssSetInputPortSampleTime ( S , 4 , 0.001 ) ;
ssSetInputPortOffsetTime ( S , 4 , 0.0 ) ; if ( !
ssSetInputPortVectorDimension ( S , 5 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 5 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 5 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 5 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 5 , 1 ) ;
ssSetInputPortRequiredContiguous ( S , 5 , 1 ) ; ssSetInputPortOptimOpts ( S
, 5 , SS_NOT_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 5 ,
FALSE ) ; ssSetInputPortSampleTime ( S , 5 , 0.001 ) ;
ssSetInputPortOffsetTime ( S , 5 , 0.0 ) ; if ( !
ssSetInputPortVectorDimension ( S , 6 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 6 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 6 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 6 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 6 , 1 ) ;
ssSetInputPortRequiredContiguous ( S , 6 , 1 ) ; ssSetInputPortOptimOpts ( S
, 6 , SS_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 6 , FALSE )
; ssSetInputPortSampleTime ( S , 6 , 0.001 ) ; ssSetInputPortOffsetTime ( S ,
6 , 0.0 ) ; if ( ! ssSetInputPortVectorDimension ( S , 7 , 1 ) ) return ;
ssSetInputPortDimensionsMode ( S , 7 , FIXED_DIMS_MODE ) ;
ssSetInputPortFrameData ( S , 7 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetInputPortDataType ( S , 7 , SS_SINGLE ) ;
} ssSetInputPortDirectFeedThrough ( S , 7 , 1 ) ;
ssSetInputPortRequiredContiguous ( S , 7 , 1 ) ; ssSetInputPortOptimOpts ( S
, 7 , SS_REUSABLE_AND_LOCAL ) ; ssSetInputPortOverWritable ( S , 7 , FALSE )
; ssSetInputPortSampleTime ( S , 7 , 0.001 ) ; ssSetInputPortOffsetTime ( S ,
7 , 0.0 ) ; if ( ! ssSetNumOutputPorts ( S , 3 ) ) return ; if ( !
ssSetOutputPortVectorDimension ( S , 0 , 1 ) ) return ;
ssSetOutputPortDimensionsMode ( S , 0 , FIXED_DIMS_MODE ) ;
ssSetOutputPortFrameData ( S , 0 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) {
#if defined (MATLAB_MEX_FILE)
{ DTypeId dataTypeIdReg ; ssRegisterTypeFromNamedObject ( S , "Cntrl_Status"
, & dataTypeIdReg ) ; if ( dataTypeIdReg == INVALID_DTYPE_ID ) return ;
ssSetOutputPortDataType ( S , 0 , dataTypeIdReg ) ; }
#endif
} ssSetOutputPortSampleTime ( S , 0 , 0.001 ) ; ssSetOutputPortOffsetTime ( S
, 0 , 0.0 ) ; ssSetOutputPortDiscreteValuedOutput ( S , 0 , 0 ) ;
ssSetOutputPortOkToMerge ( S , 0 , SS_OK_TO_MERGE ) ;
ssSetOutputPortOptimOpts ( S , 0 , SS_NOT_REUSABLE_AND_GLOBAL ) ; if ( !
ssSetOutputPortVectorDimension ( S , 1 , 1 ) ) return ;
ssSetOutputPortDimensionsMode ( S , 1 , FIXED_DIMS_MODE ) ;
ssSetOutputPortFrameData ( S , 1 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) {
#if defined (MATLAB_MEX_FILE)
{ DTypeId dataTypeIdReg ; ssRegisterTypeFromNamedObject ( S , "Motor_Cmds" ,
& dataTypeIdReg ) ; if ( dataTypeIdReg == INVALID_DTYPE_ID ) return ;
ssSetOutputPortDataType ( S , 1 , dataTypeIdReg ) ; }
#endif
} ssSetOutputPortSampleTime ( S , 1 , 0.001 ) ; ssSetOutputPortOffsetTime ( S
, 1 , 0.0 ) ; ssSetOutputPortDiscreteValuedOutput ( S , 1 , 0 ) ;
ssSetOutputPortOkToMerge ( S , 1 , SS_OK_TO_MERGE ) ;
ssSetOutputPortOptimOpts ( S , 1 , SS_NOT_REUSABLE_AND_LOCAL ) ; if ( !
ssSetOutputPortVectorDimension ( S , 2 , 1 ) ) return ;
ssSetOutputPortDimensionsMode ( S , 2 , FIXED_DIMS_MODE ) ;
ssSetOutputPortFrameData ( S , 2 , FRAME_NO ) ; if ( ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { ssSetOutputPortDataType ( S , 2 , SS_SINGLE )
; } ssSetOutputPortSampleTime ( S , 2 , 0.001 ) ; ssSetOutputPortOffsetTime (
S , 2 , 0.0 ) ; ssSetOutputPortDiscreteValuedOutput ( S , 2 , 0 ) ;
ssSetOutputPortOkToMerge ( S , 2 , SS_OK_TO_MERGE ) ;
ssSetOutputPortOptimOpts ( S , 2 , SS_NOT_REUSABLE_AND_LOCAL ) ; { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 0 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 0 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 1 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 1 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 2 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 2 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 3 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 3 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 4 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 4 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 5 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 5 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 6 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 6 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefInputSignalDesignMin ( S , 7 , & minValue ) ;
ssSetModelRefInputSignalDesignMax ( S , 7 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefOutputSignalDesignMin ( S , 0 , & minValue ) ;
ssSetModelRefOutputSignalDesignMax ( S , 0 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefOutputSignalDesignMin ( S , 1 , & minValue ) ;
ssSetModelRefOutputSignalDesignMax ( S , 1 , & maxValue ) ; } { real_T
minValue = rtMinusInf ; real_T maxValue = rtInf ;
ssSetModelRefOutputSignalDesignMin ( S , 2 , & minValue ) ;
ssSetModelRefOutputSignalDesignMax ( S , 2 , & maxValue ) ; } { static
ssRTWStorageType storageClass [ 11 ] = { SS_RTW_STORAGE_AUTO ,
SS_RTW_STORAGE_AUTO , SS_RTW_STORAGE_AUTO , SS_RTW_STORAGE_AUTO ,
SS_RTW_STORAGE_AUTO , SS_RTW_STORAGE_AUTO , SS_RTW_STORAGE_AUTO ,
SS_RTW_STORAGE_AUTO , SS_RTW_STORAGE_AUTO , SS_RTW_STORAGE_AUTO ,
SS_RTW_STORAGE_AUTO } ; ssSetModelRefPortRTWStorageClasses ( S , storageClass
) ; } ssSetModelRefSignalLoggingSaveFormat ( S , SS_DATASET_FORMAT ) ;
ssSetNumSampleTimes ( S , PORT_BASED_SAMPLE_TIMES ) ; ssSetNumRWork ( S , 0 )
; ssSetNumIWork ( S , 0 ) ; ssSetNumPWork ( S , 0 ) ; ssSetNumModes ( S , 0 )
; { int_T zcsIdx = 0 ; } ssSetOutputPortIsNonContinuous ( S , 0 , 0 ) ;
ssSetOutputPortIsFedByBlockWithModesNoZCs ( S , 0 , 0 ) ;
ssSetOutputPortIsNonContinuous ( S , 1 , 0 ) ;
ssSetOutputPortIsFedByBlockWithModesNoZCs ( S , 1 , 0 ) ;
ssSetOutputPortIsNonContinuous ( S , 2 , 0 ) ;
ssSetOutputPortIsFedByBlockWithModesNoZCs ( S , 2 , 0 ) ;
ssSetInputPortIsNotDerivPort ( S , 0 , 1 ) ; ssSetInputPortIsNotDerivPort ( S
, 1 , 1 ) ; ssSetInputPortIsNotDerivPort ( S , 2 , 1 ) ;
ssSetInputPortIsNotDerivPort ( S , 3 , 1 ) ; ssSetInputPortIsNotDerivPort ( S
, 4 , 1 ) ; ssSetInputPortIsNotDerivPort ( S , 5 , 1 ) ;
ssSetInputPortIsNotDerivPort ( S , 6 , 1 ) ; ssSetInputPortIsNotDerivPort ( S
, 7 , 1 ) ; ssSetModelReferenceSampleTimeInheritanceRule ( S ,
DISALLOW_SAMPLE_TIME_INHERITANCE ) ; ssSetOptimizeModelRefInitCode ( S , 1 )
; ssSetAcceptsFcnCallInputs ( S ) ; { static const char * inlinedVars [ ] = {
"EV_Param" , "brake_cmd_table" , "ctrlConst" , "decel_cmd_vec" ,
"regen_pwr_vec" } ; ssSetModelRefInlinedVars ( S , 5 , ( void * ) inlinedVars
) ; } ssSetModelReferenceNormalModeSupport ( S ,
MDL_START_AND_MDL_PROCESS_PARAMS_OK ) ; ssSupportsMultipleExecInstances ( S ,
FALSE ) ; ssRegisterMsgForNotSupportingMultiExecInst ( S ,
 "<diag_root><diag id=\"Simulink:blocks:ImplicitIterSS_SigObjExpStorageClassNotSupportedInside\"><arguments><arg type=\"numeric\">1</arg><arg type=\"encoded\">RQBWAF8AUAB3AHIAXwBNAGEAbgBhAGcAZQByAC8AUABvAHcAZQByAF8AQwBvAG4AdAByAG8AbAAvAEUAcgByAG8AcgAgAFMAdQBtAAAA</arg><arg type=\"encoded\">cABvAHcAZQByAF8AZQByAHIAbwByAAAA</arg><arg type=\"encoded\">PABfAF8AaQBpAFMAUwBfAF8APgA8AC8AXwBfAGkAaQBTAFMAXwBfAD4AAAA=</arg><arg type=\"encoded\">PABfAF8AaQB0AGUAcgBCAGwAawBfAF8APgA8AC8AXwBfAGkAdABlAHIAQgBsAGsAXwBfAD4AAAA=</arg></arguments></diag>\n</diag_root>"
) ; ssHasStateInsideForEachSS ( S , FALSE ) ; ssSetModelRefHasParforForEachSS
( S , FALSE ) ; ssSetModelRefHasVariantModelOrSubsystem ( S , FALSE ) ;
ssSetNumAsyncTs ( S , 0 ) ; ssSetOptions ( S , SS_OPTION_EXCEPTION_FREE_CODE
| SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME |
SS_OPTION_SUPPORTS_ALIAS_DATA_TYPES | SS_OPTION_WORKS_WITH_CODE_REUSE ) ; if
( S -> mdlInfo -> genericFcn != ( NULL ) ) { ssRegModelRefChildModel ( S , 1
, childModels ) ; }
#if SS_SFCN_FOR_SIM
if ( S -> mdlInfo -> genericFcn != ( NULL ) && ssGetSimMode ( S ) !=
SS_SIMMODE_SIZES_CALL_ONLY ) { int_T retVal = 1 ;
mr_EV_Pwr_Manager_MdlInfoRegFcn ( S , "EV_Pwr_Manager" , & retVal ) ; if ( !
retVal ) return ; }
#endif
ssSetNumDWork ( S , 0 ) ; slmrSetHasNonVirtualConstantTs ( S , true ) ;
ssSetNeedAbsoluteTime ( S , 1 ) ; ssSetModelRefHasEnablePort ( S , 0 ) ; }
Exemple #10
0
/* Function to initialize sizes. */
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSampleTimes(S, 1);           /* Number of sample times */
    ssSetNumContStates(S, 0);            /* Number of continuous states */
    ssSetNumNonsampledZCs(S, 0);         /* Number of nonsampled ZCs */

    /* Number of output ports */
    if (!ssSetNumOutputPorts(S, 1))
        return;

    /* outport number: 0 */
    if (!ssSetOutputPortVectorDimension(S, 0, 1))
        return;
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
        ssSetOutputPortDataType(S, 0, SS_DOUBLE);
    }

    ssSetOutputPortSampleTime(S, 0, 0.06);
    ssSetOutputPortOffsetTime(S, 0, 0.0);
    ssSetOutputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);

    /* Number of input ports */
    if (!ssSetNumInputPorts(S, 1))
        return;

    /* inport number: 0 */
    {
        if (!ssSetInputPortVectorDimension(S, 0, 1))
            return;
        if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
            ssSetInputPortDataType(S, 0, SS_DOUBLE);
        }

        ssSetInputPortDirectFeedThrough(S, 0, 1);
        ssSetInputPortSampleTime(S, 0, 0.06);
        ssSetInputPortOffsetTime(S, 0, 0.0);
        ssSetInputPortOverWritable(S, 0, 0);
        ssSetInputPortOptimOpts(S, 0, SS_NOT_REUSABLE_AND_GLOBAL);
    }

    ssSetRTWGeneratedSFcn(S, 1);         /* Generated S-function */

    /* DWork */
    if (!ssSetNumDWork(S, 1)) {
        return;
    }

    /* '<S1>/LinearModel': DSTATE */
    ssSetDWorkName(S, 0, "DWORK0");
    ssSetDWorkWidth(S, 0, 1);
    ssSetDWorkUsedAsDState(S, 0, 1);

    /* Tunable Parameters */
    ssSetNumSFcnParams(S, 0);

    /* Number of expected parameters */
#if defined(MATLAB_MEX_FILE)

    if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) {

#if defined(MDL_CHECK_PARAMETERS)

        mdlCheckParameters(S);

#endif                                 /* MDL_CHECK_PARAMETERS */

        if (ssGetErrorStatus(S) != (NULL) ) {
            return;
        }
    } else {
        return;                            /* Parameter mismatch will be reported by Simulink */
    }

#endif                                 /* MATLAB_MEX_FILE */

    /* Options */
    ssSetOptions(S, (SS_OPTION_RUNTIME_EXCEPTION_FREE_CODE |
                     SS_OPTION_PORT_SAMPLE_TIMES_ASSIGNED ));

#if SS_SFCN_FOR_SIM

    {
        ssSupportsMultipleExecInstances(S, false);
        ssRegisterMsgForNotSupportingMultiExecInst(S,
                "<diag_root><diag id=\"Simulink:blocks:BlockDoesNotSupportMultiExecInstances\"><arguments><arg type=\"encoded\">SABhAG0AbQBlAHIAcwB0AGUAaQBuAC8ASABhAG0AbQBlAHIAcwB0AGUAaQBuAC0AVwBpAGUAbgBlAHIAIABNAG8AZABlAGwAMQAvAFAAdwBsAGkAbgBlAGEAcgAxAAAA</arg><arg type=\"encoded\">PABfAF8AaQBpAFMAUwBfAF8APgA8AC8AXwBfAGkAaQBTAFMAXwBfAD4AAAA=</arg><arg type=\"encoded\">PABfAF8AaQB0AGUAcgBCAGwAawBfAF8APgA8AC8AXwBfAGkAdABlAHIAQgBsAGsAXwBfAD4AAAA=</arg></arguments></diag>\n</diag_root>");
        ssHasStateInsideForEachSS(S, false);
    }

#endif

}
Exemple #11
0
/* Function: SimInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
void SimInitializeSizes(SimStruct * S, Sim * sim_temp)
{
    // Counter and time variable
    int i;
    double n;

    // Print Io map
    sim_temp->getInterfaceContainer()->printInfo();

    // Set up the number of continuous and discrete states from temp_sim
    ssSetNumContStates(S, sim_temp->getInterfaceContainer()->getNumContinuousStates());
    ssSetNumDiscStates(S, sim_temp->getInterfaceContainer()->getNumDiscreteStates());

    // We will used port-based sample times to allow hybrid flexibility
    ssSetNumSampleTimes(S, PORT_BASED_SAMPLE_TIMES);

    // Set up the width of the (actice) input ports from temp_sim
    // Also set up sample times and offsets for active ports
    for(i=0; i<sim_temp->getInterfaceContainer()->getNumActiveInputPorts(); i++)
    {
        ssSetInputPortWidth(S, i, sim_temp->getInterfaceContainer()->getActiveInputPortWidth(i));
        ssSetInputPortDirectFeedThrough(S, i, 1);

        // Set up sample time and offset
        n = sim_temp->getInterfaceContainer()->getActiveInputPortSampleTime(i);
        if (n == InterfaceContainer::SAMPLE_TIME_CONTINUOUS)
        {
            ssSetInputPortSampleTime(S, i, CONTINUOUS_SAMPLE_TIME);
            ssSetInputPortOffsetTime(S, i, 0.0);
        }
        else
        {
            ssSetInputPortSampleTime(S, i, n);
            ssSetInputPortOffsetTime(S, i, sim_temp->getInterfaceContainer()->getActiveInputPortSampleOffset(i));
        }
    }

    // Set up the width of the (actice) output ports from temp_sim
    // Also set up sample times and offsets for active ports
    for(i=0; i<sim_temp->getInterfaceContainer()->getNumActiveOutputPorts(); i++)
    {
        ssSetOutputPortWidth(S, i, sim_temp->getInterfaceContainer()->getActiveOutputPortWidth(i));

        // Set up sample time and offset
        n = sim_temp->getInterfaceContainer()->getActiveOutputPortSampleTime(i);
        if (n == InterfaceContainer::SAMPLE_TIME_CONTINUOUS)
        {
            ssSetOutputPortSampleTime(S, i, CONTINUOUS_SAMPLE_TIME);
            ssSetOutputPortOffsetTime(S, i, 0.0);
        }
        else
        {
            ssSetOutputPortSampleTime(S, i, n);
            ssSetOutputPortOffsetTime(S, i, sim_temp->getInterfaceContainer()->getActiveOutputPortSampleOffset(i));
        }
    }

    // Set up the number of parameters
    ssSetNumSFcnParams(S, sim_temp->getInterfaceContainer()->getNumActiveParams());  //Number of expected parameters
    ssSetNumSFcnParams(S, 0);  //Number of expected parameters
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        return; // Parameter mismatch will be reported by Simulink
    }

    // Take care when specifying exception free code - see sfuntmpl.doc
#ifdef SIM_EXCEPTION_FREE_CODE
    ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
#endif

    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 1); // reserve element in the pointers vector to store a C++ object
    ssSetNumModes(S, 0);
    ssSetNumNonsampledZCs(S, 0);
}