Exemplo n.º 1
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSFcnParams(S, 0);  /* Number of expected parameters */
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        /* Return if number of expected != number of actual parameters */
        return;
    }

    ssSetNumContStates(S, 0);
    ssSetNumDiscStates(S, 0);

    if (!ssSetNumInputPorts(S, 1)) return;
    ssSetInputPortWidth(S, 0, 1);
    ssSetInputPortRequiredContiguous(S, 0, true); /*direct input signal access*/
    /*
     * Set direct feedthrough flag (1=yes, 0=no).
     * A port has direct feedthrough if the input is used in either
     * the mdlOutputs or mdlGetTimeOfNextVarHit functions.
     * See matlabroot/simulink/src/sfuntmpl_directfeed.txt.
     */
    
    
   if (!ssSetNumOutputPorts(S, 1)) return;
    ssSetOutputPortWidth(S, 0, 2);

   ssSetInputPortDataType(S,0,DYNAMICALLY_TYPED);
   ssSetInputPortDirectFeedThrough(S,0,1);

   ssSetInputPortRequiredContiguous(S,0,1);
   ssSetInputPortReusable(S,0,1);
    
        
    ssSetNumSampleTimes(S, 1);
    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 0);
    ssSetNumModes(S, 0);
    ssSetNumNonsampledZCs(S, 0);

    ssSetOptions(S, 0);
    ssFxpSetU32BitRegionCompliant(S, 1);
}
Exemplo n.º 2
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
    int_T nInputPorts  = 1;  /* number of input ports  */
    int_T nOutputPorts = 1;  /* number of output ports */
    int_T needsInput   = 1;  /* direct feed through    */

    int_T inputPortIdx  = 0;
    int_T outputPortIdx = 0;

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

    if (ssGetErrorStatus(S) != NULL) 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             */


    /*
     * Configure the input ports. First set the number of input ports. 
     */
    if (!ssSetNumInputPorts(S, nInputPorts)) return;   
    if(!ssSetInputPortDimensionInfo(S, inputPortIdx, DYNAMIC_DIMENSION)) return; 

    ssSetInputPortWidth(S, inputPortIdx, DYNAMICALLY_SIZED);
    ssSetInputPortRequiredContiguous(S, inputPortIdx, TRUE); /*direct input signal access*/ 

    ssSetInputPortDataType(S, inputPortIdx,DYNAMICALLY_TYPED);
    ssSetInputPortDirectFeedThrough(S, inputPortIdx,TRUE);
    ssSetInputPortOverWritable(S, inputPortIdx, FALSE);
    ssSetInputPortReusable(S, inputPortIdx,TRUE);
    ssSetInputPortComplexSignal( S, inputPortIdx, COMPLEX_INHERITED);

    /*
     * Configure the output ports. First set the number of output ports.
     */
    if (!ssSetNumOutputPorts(S, nOutputPorts)) return;
    if(!ssSetOutputPortDimensionInfo(S,outputPortIdx,DYNAMIC_DIMENSION)) return;

    ssSetOutputPortWidth(S, outputPortIdx, DYNAMICALLY_SIZED);

    /* register data type
     */ 

    ssSetOutputPortDataType( S, outputPortIdx, DYNAMICALLY_TYPED );
    ssSetOutputPortReusable(            S, outputPortIdx, TRUE);
    ssSetOutputPortComplexSignal(S, outputPortIdx, COMPLEX_INHERITED );

    ssSetNumSampleTimes(   S, 1);   /* number of sample times                */

    /*
     * 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 nonsampled zero crossings   */

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

} /* end mdlInitializeSizes */