MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS Guide de l'utilisateur Page 198

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 210
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 197
4 Guidelines for Writing C MEX S-Functions
4-32
ssSetInputPortOverWritable(S, 0, TRUE);
if (!ssSetNumOutputPorts(S, 1)) return;
ssSetOutputPortWidth(S, 0, DYNAMICALLY_SIZED);
ssSetOutputPortTestPoint(S, 0, FALSE);
ssSetNumSampleTimes(S, 1);
ssSetSFcnParamNotTunable(S, XDATAEVENLYSPACED_PIDX);
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
} /* mdlInitializeSizes */
/* Function: mdlInitializeSampleTimes ==========================================
* Abstract:
* The lookup inherits its sample time from the driving block.
*/
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
ssSetOffsetTime(S, 0, 0.0);
} /* end mdlInitializeSampleTimes */
#define MDL_START /* Change to #undef to remove function */
#if defined(MDL_START)
/* Function: mdlStart ==========================================================
* Abstract:
* Here we cache the state (true/false) of the XDATAEVENLYSPACED parameter.
* We do this primarily to illustrate how to “cache” parameter values (or
* information that is computed from parameter values) that do not change
* for the duration of the simulation (or in the generated code). In this
* case, rather than repeated calls to mxGetPr, we save the state once.
* This results in a slight increase in performance.
*/
static void mdlStart(SimStruct *S)
{
SFcnCache *cache = malloc(sizeof(SFcnCache));
if (cache == NULL) {
ssSetErrorStatus(S,”memory allocation error”);
return;
}
ssSetUserData(S, cache);
if (mxGetScalar(XDATAEVENLYSPACED(S)) != 0.0){
cache->evenlySpaced = TRUE;
}else{
Vue de la page 197
1 2 ... 193 194 195 196 197 198 199 200 201 202 203 ... 209 210

Commentaires sur ces manuels

Pas de commentaire