Exemplo n.º 1
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 */
Exemplo n.º 2
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;
}