Esempio n. 1
0
 static void mdlSetInputPortDimensionInfo(SimStruct        *S, 
                                          int_T            port,
                                          const DimsInfo_T *dimsInfo)
{
    boolean_T isNotVector = ((dimsInfo->numDims == 2 ) &&
                             (dimsInfo->dims[0] > 1 && dimsInfo->dims[1] > 1)) ;
    if(isNotVector){
        ssSetErrorStatus(S, "The block only accepts vector signals. "
                            "It does not accept a [mxn] matrix signal "
                            "where m > 1 and n > 1.");
    }else{
        int otherPort = (port == 0) ? 1 : 0;
        if(!ssSetInputPortDimensionInfo(S, port, dimsInfo)) return;

        /* 
         * If other port width is unknown, set the other port width.
         * Note1: we cannot update other port dimension info. 
         * Note2: For simplicity, this block cannot accept partial dimension,
         *        however, it may partially set other port dimension info.
         */
        if(ssGetInputPortWidth(S, otherPort) == DYNAMICALLY_SIZED &&
           ssGetInputPortWidth(S, port)      != DYNAMICALLY_SIZED){

            DECL_AND_INIT_DIMSINFO(dimsInfo);
            dimsInfo.width   = ssGetInputPortWidth        (S, port);
            dimsInfo.numDims = ssGetInputPortNumDimensions(S, otherPort);
            dimsInfo.dims    = ssGetInputPortDimensions   (S, otherPort);

            if(!ssSetInputPortDimensionInfo(S, otherPort, &dimsInfo)) return;

        }
    }
}
Esempio n. 2
0
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSFcnParams(S,  NUM_PARAMS);
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return;

    /* Inputs: */
    if (!ssSetNumInputPorts(S, 2)) return;

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

    if(!ssSetInputPortDimensionInfo(S, 0, DYNAMIC_DIMENSION)) return;
    if(!ssSetInputPortDimensionInfo(S, 1, DYNAMIC_DIMENSION)) return;

    ssSetInputPortFrameData(S, 0, FRAME_INHERITED);
    ssSetInputPortFrameData(S, 1, FRAME_INHERITED);

    ssSetInputPortComplexSignal(S, 0, COMPLEX_INHERITED);
    ssSetInputPortComplexSignal(S, 1, COMPLEX_INHERITED);

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

    ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
    ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);

    ssSetInputPortOverWritable(S, 0, 1);
    ssSetInputPortOverWritable(S, 1, 1);

    /* Outputs: */
    if (!ssSetNumOutputPorts(S, 1)) return;

    ssSetOutputPortDataType(S, 0, DYNAMICALLY_TYPED);

    if(!ssSetOutputPortVectorDimension(S, 0, 1)) return;

    ssSetOutputPortFrameData(S, 0, FRAME_NO);

    ssSetOutputPortComplexSignal(S, 0, COMPLEX_INHERITED);

    ssSetOutputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);

    ssSetNumSampleTimes(S, 1);

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

    ssSetOptions(S,
                 SS_OPTION_WORKS_WITH_CODE_REUSE |
                 SS_OPTION_EXCEPTION_FREE_CODE      |
                 SS_OPTION_CAN_BE_CALLED_CONDITIONALLY |
                 SS_OPTION_USE_TLC_WITH_ACCELERATOR |
                 SS_OPTION_NONVOLATILE);
}
Esempio n. 3
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *   Setup sizes of the various vectors.
 */
static void mdlInitializeSizes(SimStruct *S)
{

    DECL_AND_INIT_DIMSINFO(inputDimsInfo);
    DECL_AND_INIT_DIMSINFO(outputDimsInfo);
    ssSetNumSFcnParams(S, NPARAMS);
     if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
	 return; /* Parameter mismatch will be reported by Simulink */
     }

    ssSetNumContStates(S, NUM_CONT_STATES);
    ssSetNumDiscStates(S, NUM_DISC_STATES);

    if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
    /*Input Port 0 */
    inputDimsInfo.width = INPUT_0_WIDTH;
    ssSetInputPortDimensionInfo(S,  0, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S , 0, INPUT_0_WIDTH, INPUT_DIMS_0_COL);
    ssSetInputPortFrameData(S,  0, IN_0_FRAME_BASED);

    ssSetInputPortDataType(S, 0, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  0, INPUT_0_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/

    /*Input Port 1 */
    inputDimsInfo.width = INPUT_1_WIDTH;
    ssSetInputPortDimensionInfo(S,  1, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S , 1, INPUT_1_WIDTH, INPUT_DIMS_1_COL);
    ssSetInputPortFrameData(S,  1, IN_1_FRAME_BASED);

    ssSetInputPortDataType(S, 1, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  1, INPUT_1_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/


    if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
    ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
    ssSetOutputPortDataType(S, 0, SS_INT32);
    ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
    ssSetNumSampleTimes(S, 1);
    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 0);
    ssSetNumModes(S, 0);
    ssSetNumNonsampledZCs(S, 0);

    /* Take care when specifying exception free code - see sfuntmpl_doc.c */
    ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
		     SS_OPTION_WORKS_WITH_CODE_REUSE));
}
static void mdlSetOutputPortDimensionInfo(SimStruct        *S,
        int_T            port,
        const DimsInfo_T *dimsInfo)
{
#   ifdef DEBUG
    printf("  co_udp_receiver :: Now in mdlSetOutputPortDimensionInfo.\n");
#   endif
    /*
     * If the block has scalar parameter, the output dimensions are unknown.
     * Set the input and output port to have the same dimensions.
     */
    if(!ssSetOutputPortDimensionInfo(S, port, dimsInfo)) return;

    /* The block only accepts 2-D signals. Check number of dimensions. */

    if(dimsInfo->numDims != 1) {
        ssSetErrorStatus(S, "Invalid output port dimensions. The output signal "
                         "must be a vector signal.");
        return;
    } else {
        /* Set the input port dimensions */
        if(!ssSetInputPortDimensionInfo(S, port, dimsInfo)) return;
    }

}
Esempio n. 5
0
static void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port,
                                         const DimsInfo_T *dimsInfo)
{
    //TODO: for now accept the proposed size.
    //If we want to change the behaviour we have to implement some callbacks
    ssSetInputPortDimensionInfo(S, port, dimsInfo);
}
Esempio n. 6
0
void mdlSetOutputPortDimensionInfo(SimStruct *S, int_T port,
        const DimsInfo_T *dimsInfo)
{
    if (port == 0) {
        ssSetOutputPortDimensionInfo(S, port,dimsInfo);
        ssSetInputPortDimensionInfo(S, port,dimsInfo);
    }   
} /* end mdlSetOutputPortDimensionInfo */
/* Function: mdlSetInputPortDimensionInfo =================================
 * Abstract:
 *    This method is called with the candidate dimensions for an input port
 *    with unknown dimensions. If the proposed dimensions are acceptable, the
 *    method should go ahead and set the actual port dimensions.
 *    If they are unacceptable an error should be generated via
 *    ssSetErrorStatus.
 *    Note that any other input or output ports whose dimensions are
 *    implicitly defined by virtue of knowing the dimensions of the given
 *    port can also have their dimensions set.
 *
 */
static void mdlSetInputPortDimensionInfo(SimStruct *S, int_T portIndex, const
  DimsInfo_T *dimsInfo)
{
/* /* Set input port dimension */
if(!ssSetInputPortDimensionInfo(S, portIndex, dimsInfo)) return;



}
void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port, const DimsInfo_T *dimsInfo)
/* ========================================================================*/
{
    if (dimsInfo->numDims >= 2 && dimsInfo->dims[1] > 1)
        ssSetErrorStatus(S, "Wrong port dimensions")
    else if (BUFFER_SIZE / BYTES_PER_SAMPLE % dimsInfo->dims[0])
        ssSetErrorStatus(S, "Frame size must be a power of two (<= 2^18)")
    else
        ssSetInputPortDimensionInfo(S, port, dimsInfo);
}
Esempio n. 9
0
void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port, 
        const DimsInfo_T *dimsInfo)
{
    if (port == 0) {
        /* Set the size for all dynamic ports using dimsInfo */
        ssSetInputPortDimensionInfo(S, port,dimsInfo);
        ssSetOutputPortDimensionInfo(S, port, dimsInfo);
    } else {
        return;
    }
} /*mdlSetInputPortDimensionInfo */
Esempio n. 10
0
static void mdlSetInputPortDimensionInfo(SimStruct *S, int_T port,
		const DimsInfo_T *dimsInfo) {

	if (dimsInfo->numDims != 2 || dimsInfo->dims[0] != 3) {
		std::stringstream ss;
		ss << "Input port " << port << " should be a 3xN matrix.";
		ssSetErrorStatus(S, ss.str().c_str());
		return;
	}

	if (!ssSetInputPortDimensionInfo(S, port, dimsInfo))
		return;

}
Esempio n. 11
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *   Setup sizes of the various vectors.
 */
static void mdlInitializeSizes(SimStruct *S)
{

    DECL_AND_INIT_DIMSINFO(inputDimsInfo);
    DECL_AND_INIT_DIMSINFO(outputDimsInfo);
    ssSetNumSFcnParams(S, NPARAMS);  /* Number of expected parameters */
      #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

    ssSetNumContStates(S, NUM_CONT_STATES);
    ssSetNumDiscStates(S, NUM_DISC_STATES);

    if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
    inputDimsInfo.width = INPUT_0_WIDTH;
    ssSetInputPortDimensionInfo(S, 0, &inputDimsInfo);
    ssSetInputPortFrameData(S, 0, IN_0_FRAME_BASED);
    ssSetInputPortDataType(S, 0, SS_UINT32);
    ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/

    if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
    outputDimsInfo.width = OUTPUT_0_WIDTH;
    ssSetOutputPortDimensionInfo(S, 0, &outputDimsInfo);
    ssSetOutputPortFrameData(S, 0, OUT_0_FRAME_BASED);
    ssSetOutputPortDataType(S, 0, SS_DOUBLE);
    ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
    ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
    ssSetNumSampleTimes(S, 1);
    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 0);
    ssSetNumModes(S, 0);
    ssSetNumNonsampledZCs(S, 0);

    /* Take care when specifying exception free code - see sfuntmpl_doc.c */
    ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
		     SS_OPTION_WORKS_WITH_CODE_REUSE));
}
Esempio n. 12
0
  /* Function: mdlSetInputPortDimensionInfo ====================================
   */
static void mdlSetInputPortDimensionInfo(SimStruct        *S,         
                                         int_T            portIndex,
                                         const DimsInfo_T *dimsInfo)
{
    int outPortWidth = 0;
    if(!ssSetInputPortDimensionInfo(S, portIndex, dimsInfo)) return;

    outPortWidth = ssGetOutputPortWidth( S, 0 );
    
    if ( outPortWidth == DYNAMICALLY_SIZED )
    {
        if(!ssSetOutputPortDimensionInfo(S, 0, dimsInfo)) return;
    }
    else if ( outPortWidth != dimsInfo->width )
    {
        ssSetErrorStatus(S,"Input port width not compatible with output port width.");
    }
} /* mdlSetInputPortDimensionInfo */
Esempio n. 13
0
/* 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 */
Esempio n. 14
0
void mdlSetDefaultPortDimensionInfo(SimStruct *S)
{
    DECL_AND_INIT_DIMSINFO(dimsInfo);
    /* Either 2nd input or 2nd output should be already known */
    if (ssGetOutputPortWidth(S, 0) != DYNAMICALLY_SIZED) {
        /* It is the output that is known, get the dimensions first */
        dimsInfo.width   = ssGetOutputPortWidth(S, 0);
        dimsInfo.numDims = ssGetOutputPortNumDimensions(S, 0);
        dimsInfo.dims    = ssGetOutputPortDimensions(S, 0);
        
        /*set second input, first output if unknown */
        if (ssGetInputPortWidth(S, 0) == DYNAMICALLY_SIZED) {
            if(!ssSetInputPortDimensionInfo(S, 0, &dimsInfo)) return;
        }
        return;
     }
     else {
         if (ssGetInputPortWidth(S, 0) != DYNAMICALLY_SIZED) {
             /* It is the input that is known, get the dimensions */
             dimsInfo.width   = ssGetInputPortWidth(S, 0);
             dimsInfo.numDims = ssGetInputPortNumDimensions(S, 0);
             dimsInfo.dims    = ssGetInputPortDimensions(S, 0);
             
             /*set first and second output if unknown */
             if (ssGetOutputPortWidth(S, 0) == DYNAMICALLY_SIZED) {
                 if(!ssSetOutputPortDimensionInfo(S, 0, &dimsInfo)) return;
             }
             return;
         }
         else
         {
             /* Default everything to a scalar signal */
             ssSetOutputPortVectorDimension(S,  0, 1);
             ssSetInputPortVectorDimension(S,  0, 1);
             return;
         }
     }
} /* end mdlSetDefaultPortDimensionInfo */
Esempio n. 15
0
static void mdlSetDefaultPortDimensionInfo(SimStruct *S)
{
  DECL_AND_INIT_DIMSINFO(portDimsInfo);
  int_T dims[2] = { INPUT_0_WIDTH, 1 };
  bool  frameIn = ssGetInputPortFrameData(S, 0) == FRAME_YES;

  /* Neither the input nor the output ports have been set */

  portDimsInfo.width   = INPUT_0_WIDTH;
  portDimsInfo.numDims = frameIn ? 2 : 1;
  portDimsInfo.dims    = frameIn ? dims : &portDimsInfo.width;
  if (ssGetInputPortNumDimensions(S, 0) == (-1)) {  
   ssSetInputPortDimensionInfo(S, 0, &portDimsInfo);
  }
  portDimsInfo.width   = OUTPUT_0_WIDTH;
  dims[0]              = OUTPUT_0_WIDTH;
  dims[1]              = 1;
  portDimsInfo.dims    = frameIn ? dims : &portDimsInfo.width;
 if (ssGetOutputPortNumDimensions(S, 0) == (-1)) {  
  ssSetOutputPortDimensionInfo(S, 0, &portDimsInfo);
 }
  return;
}
static void mdlSetInputPortDimensionInfo(SimStruct        *S,
        int_T            port,
        const DimsInfo_T *dimsInfo)
{
    int_T  uNumDims = dimsInfo->numDims;
    int_T  uWidth   = dimsInfo->width;
    int_T  *uDims   = dimsInfo->dims;

    boolean_T  isOk = true;

    /* Set input port dimension */
    if(!ssSetInputPortDimensionInfo(S, port, dimsInfo)) return;

    /*
     * The block only accepts 2-D signals. Check number of dimensions.
     * If the parameter and the input signal are non-scalar, their dimensions
     * must be the same.
     */
#ifdef XXX
    if (port==0)
    {
        isOk = ((uNumDims == 1) && (uDims[0]==24)) ;

        if(!isOk) {
            printf("%d, %d, \n", uNumDims, uDims[0]);
            /*ssSetErrorStatus(S, "Invalid input port dimensions. The input must be "
                             "a 24 vector.");
            return;*/
        }
        else {
            /* Set the output port dimensions */
            /*ssSetOutputPortWidth(S, 0, uDims[0]);*/
        }
    }
#endif
}
static void mdlSetInputPortDimensionInfo(SimStruct        *S, 
                                         int_T            port,
                                         const DimsInfo_T *dimsInfo)
{
    if(!ssSetInputPortDimensionInfo(S, port, dimsInfo)) return;
}
Esempio n. 18
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *   Setup sizes of the various vectors.
 */
static void mdlInitializeSizes(SimStruct *S)
{

    DECL_AND_INIT_DIMSINFO(inputDimsInfo);
    DECL_AND_INIT_DIMSINFO(outputDimsInfo);
    ssSetNumSFcnParams(S, NPARAMS);
     if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
	 return; /* Parameter mismatch will be reported by Simulink */
     }

    ssSetNumContStates(S, NUM_CONT_STATES);
    ssSetNumDiscStates(S, NUM_DISC_STATES);

    if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
    /*Input Port 0 */
    inputDimsInfo.width = INPUT_0_WIDTH;
    ssSetInputPortDimensionInfo(S,  0, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S , 0, INPUT_0_WIDTH, INPUT_DIMS_0_COL);
    ssSetInputPortFrameData(S,  0, IN_0_FRAME_BASED);

    ssSetInputPortDataType(S, 0, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  0, INPUT_0_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/

    /*Input Port 1 */
    inputDimsInfo.width = INPUT_1_WIDTH;
    ssSetInputPortDimensionInfo(S,  1, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S , 1, INPUT_1_WIDTH, INPUT_DIMS_1_COL);
    ssSetInputPortFrameData(S,  1, IN_1_FRAME_BASED);

    ssSetInputPortDataType(S, 1, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  1, INPUT_1_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/

    /*Input Port 2 */
    inputDimsInfo.width = INPUT_2_WIDTH;
    ssSetInputPortDimensionInfo(S,  2, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S , 2, INPUT_2_WIDTH, INPUT_DIMS_2_COL);
    ssSetInputPortFrameData(S,  2, IN_2_FRAME_BASED);

    ssSetInputPortDataType(S, 2, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  2, INPUT_2_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/

    /*Input Port 3 */
    inputDimsInfo.width = INPUT_3_WIDTH;
    ssSetInputPortDimensionInfo(S,  3, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S , 3, INPUT_3_WIDTH, INPUT_DIMS_3_COL);
    ssSetInputPortFrameData(S,  3, IN_3_FRAME_BASED);

    ssSetInputPortDataType(S, 3, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  3, INPUT_3_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 3, INPUT_3_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 3, 1); /*direct input signal access*/

    /*Input Port 4 */
    inputDimsInfo.width = INPUT_4_WIDTH;
    ssSetInputPortDimensionInfo(S,  4, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S , 4, INPUT_4_WIDTH, INPUT_DIMS_4_COL);
    ssSetInputPortFrameData(S,  4, IN_4_FRAME_BASED);

    ssSetInputPortDataType(S, 4, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  4, INPUT_4_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 4, INPUT_4_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 4, 1); /*direct input signal access*/

    /*Input Port 5 */
    ssSetInputPortWidth(S,  5, INPUT_5_WIDTH); /* */
    ssSetInputPortDataType(S, 5, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  5, INPUT_5_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 5, INPUT_5_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 5, 1); /*direct input signal access*/

    /*Input Port 6 */
    ssSetInputPortWidth(S,  6, INPUT_6_WIDTH); /* */
    ssSetInputPortDataType(S, 6, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  6, INPUT_6_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 6, INPUT_6_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 6, 1); /*direct input signal access*/

    /*Input Port 7 */
    inputDimsInfo.width = INPUT_7_WIDTH;
    ssSetInputPortDimensionInfo(S, 7, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S ,7, INPUT_7_WIDTH, INPUT_DIMS_7_COL);
    ssSetInputPortFrameData(S, 7, IN_7_FRAME_BASED);
    ssSetInputPortDataType(S, 7, SS_DOUBLE);
    ssSetInputPortComplexSignal(S, 7, INPUT_7_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 7, INPUT_7_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 7, 1); /*direct input signal access*/

    /*Input Port 8 */
    inputDimsInfo.width = INPUT_8_WIDTH;
    ssSetInputPortDimensionInfo(S, 8, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S ,8, INPUT_8_WIDTH, INPUT_DIMS_8_COL);
    ssSetInputPortFrameData(S, 8, IN_8_FRAME_BASED);
    ssSetInputPortDataType(S, 8, SS_DOUBLE);
    ssSetInputPortComplexSignal(S, 8, INPUT_8_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 8, INPUT_8_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 8, 1); /*direct input signal access*/

    /*Input Port 9 */
    inputDimsInfo.width = INPUT_9_WIDTH;
    ssSetInputPortDimensionInfo(S, 9, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S ,9, INPUT_9_WIDTH, INPUT_DIMS_9_COL);
    ssSetInputPortFrameData(S, 9, IN_9_FRAME_BASED);
    ssSetInputPortDataType(S, 9, SS_DOUBLE);
    ssSetInputPortComplexSignal(S, 9, INPUT_9_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 9, INPUT_9_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 9, 1); /*direct input signal access*/

    /*Input Port 10 */
    inputDimsInfo.width = INPUT_10_WIDTH;
    ssSetInputPortDimensionInfo(S, 10, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S ,10, INPUT_10_WIDTH, INPUT_DIMS_10_COL);
    ssSetInputPortFrameData(S, 10, IN_10_FRAME_BASED);
    ssSetInputPortDataType(S, 10, SS_UINT8);
    ssSetInputPortComplexSignal(S, 10, INPUT_10_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 10, INPUT_10_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 10, 1); /*direct input signal access*/

    /*Input Port 11 */
    inputDimsInfo.width = INPUT_11_WIDTH;
    ssSetInputPortDimensionInfo(S, 11, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S ,11, INPUT_11_WIDTH, INPUT_DIMS_11_COL);
    ssSetInputPortFrameData(S, 11, IN_11_FRAME_BASED);
    ssSetInputPortDataType(S, 11, SS_UINT8);
    ssSetInputPortComplexSignal(S, 11, INPUT_11_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 11, INPUT_11_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 11, 1); /*direct input signal access*/

    /*Input Port 12 */
    inputDimsInfo.width = INPUT_12_WIDTH;
    ssSetInputPortDimensionInfo(S, 12, &inputDimsInfo);
    ssSetInputPortMatrixDimensions(  S ,12, INPUT_12_WIDTH, INPUT_DIMS_12_COL);
    ssSetInputPortFrameData(S, 12, IN_12_FRAME_BASED);
    ssSetInputPortDataType(S, 12, SS_UINT8);
    ssSetInputPortComplexSignal(S, 12, INPUT_12_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 12, INPUT_12_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 12, 1); /*direct input signal access*/


    if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;

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

    /* Take care when specifying exception free code - see sfuntmpl_doc.c */
    ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
		     SS_OPTION_WORKS_WITH_CODE_REUSE));
}
Esempio n. 19
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 */