cg_sfun.h 2.41 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
/* cg_sfun.h 
 *  
 * Entry point for user-written S-Functions when compiled for
 * use with the Simulink C-Code Generator.  This file should
 * be conditionally included at the bottom of any user-written
 * S-Function so as to enable the static functions within it
 * to be registered at startup.  Also, the macro S_FUNCTION_NAME
 * should be declared within the S-Function to specify the
 * entry point name--that is the name by which the S-Function
 * is to be known to the outside world.
 *
 * Copyright 1994-2005 The MathWorks, Inc.
 * $Revision: 1.15.4.9 $
 */

#ifdef __cplusplus
extern "C"
#endif

void S_FUNCTION_NAME(SimStruct *S)
{
#if S_FUNCTION_LEVEL == 1
  /* level 1 */
  ssSetmdlInitializeSizes(S, mdlInitializeSizes);
  ssSetmdlInitializeSampleTimes(S, mdlInitializeSampleTimes); 
  ssSetmdlInitializeConditionsLevel1(S, mdlInitializeConditions);
  ssSetmdlOutputsLevel1(S, mdlOutputs); 
  ssSetmdlUpdateLevel1(S, mdlUpdate); 
  ssSetmdlDerivativesLevel1(S, mdlDerivatives);
  ssSetmdlTerminate(S, mdlTerminate);
#else
  /* user level 2 */

  ssSetmdlInitializeSizes(S, mdlInitializeSizes);
  ssSetmdlInitializeSampleTimes(S, mdlInitializeSampleTimes); 

# if defined(MDL_INITIALIZE_CONDITIONS)
    ssSetmdlInitializeConditions(S, mdlInitializeConditions);
# endif
# if defined(MDL_START)
    ssSetmdlStart(S, mdlStart);
# endif

# if defined(RTW_GENERATED_ENABLE)
    ssSetRTWGeneratedEnable(S, mdlEnable);
# endif

# if defined(RTW_GENERATED_DISABLE)
    ssSetRTWGeneratedDisable(S, mdlDisable);
# endif

# if defined(MDL_ENABLE)
    ssSetmdlEnable(S, mdlEnable);
# endif

# if defined(MDL_DISABLE)
    ssSetmdlDisable(S, mdlDisable);
# endif

  ssSetmdlOutputs(S, mdlOutputs); 
# if defined(MDL_GET_TIME_OF_NEXT_VAR_HIT)
    ssSetmdlGetTimeOfNextVarHit(S, mdlGetTimeOfNextVarHit); 
# endif
# if defined(MDL_UPDATE)
    ssSetmdlUpdate(S, mdlUpdate); 
# endif
# if defined(MDL_DERIVATIVES)
    ssSetmdlDerivatives(S, mdlDerivatives);
# endif

# if defined(MDL_PROJECTION)
    ssSetmdlProjection(S, mdlProjection);
# endif

# if defined(MDL_FORCINGFUNCTION)
    ssSetmdlForcingFunction(S, mdlForcingFunction);
# endif

# if defined(MDL_MASSMATRIX)
    ssSetmdlMassMatrix(S, mdlMassMatrix);
# endif

# if defined(MDL_RTWCG)
    ssSetmdlRTWCG(S, mdlRTWCG);
# endif

# if defined(MDL_ZERO_CROSSINGS) && (defined(MATLAB_MEX_FILE) || defined(NRT))
    ssSetmdlZeroCrossings(S, mdlZeroCrossings);
# endif

  ssSetmdlTerminate(S, mdlTerminate);
#endif
}