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);
  }
}
Exemplo n.º 2
0
/* Function: mdlInitializeSampleTimes =========================================
 * Abstract:
 *      Port based sample times have already been configured, therefore this
 *	method doesn't need to perform any action (you can check the
 *	current port sample times).
 */
static void mdlInitializeSampleTimes(SimStruct *S)
{
#if 0   /* set to 1 to see port sample times */
    const char_T *bpath = ssGetPath(S);
    int_T        i;

    for (i = 0; i < NINPUTS; i++) {
        ssPrintf("%s input port %d sample time = [%g, %g]\n", bpath, i,
                 ssGetInputPortSampleTime(S,i),
                 ssGetInputPortOffsetTime(S,i));
    }

    for (i = 0; i < NOUTPUTS; i++) {
        ssPrintf("%s output port %d sample time = [%g, %g]\n", bpath, i,
                 ssGetOutputPortSampleTime(S,i),
                 ssGetOutputPortOffsetTime(S,i));
    }
#endif
    ssSetModelReferenceSampleTimeDefaultInheritance(S); 
} /* end mdlInitializeSampleTimes */