⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simstruc.h

📁 simulink应用实例
💻 H
📖 第 1 页 / 共 5 页
字号:
    GEN_DTA_PARAMETER_OVERFLOW,
    GEN_DTA_PARAMETER_PRECISION_LOSS,
    GEN_DTA_PARAMETER_DOWNCAST
} GenDTADiagnosticType;

typedef struct slErrMsg_tag* (*RegisterDataTypeWithCheck) (void *, const char_T *, const char_T *, DTypeId *);

typedef DTypeId (*RegisterDataType) (void *, const char_T *, const char_T *);

typedef int_T (*GetNumDataTypes) (void *);

typedef DTypeId (*GetDataTypeId) (void *, const char_T *);

typedef int_T (*GetGenericDTAIntProp) (void *, const char_T *, DTypeId, 
                                       GenDTAIntPropType);
typedef int_T (*SetGenericDTAIntProp) (void *, const char_T *, DTypeId, int_T,
                                       GenDTAIntPropType);

typedef const void* (*GetGenericDTAVoidProp) (void *, const char_T *, DTypeId, 
                                              GenDTAVoidPropType);
typedef int_T (*SetGenericDTAVoidProp) (void *, const char_T *, DTypeId, 
                                        const void *, GenDTAVoidPropType);

typedef int_T (*ConvertBetweenFcn) (slDataTypeAccess *, const char_T *, 
                                    DTypeId, DTypeId, int_T, const void *, 
                                    const void *, void *);
typedef ConvertBetweenFcn (*GetConvertBetweenFcn) (void *, const char_T *, 
                                                   DTypeId);
typedef int_T (*SetConvertBetweenFcn) (void *, const char_T *, DTypeId, 
                                       ConvertBetweenFcn);

typedef int_T (*GenericDTAUnaryFcn) (slDataTypeAccess *, const char_T *, 
                                     DTypeId, int_T, const void *, 
                                     const void *, void *);
typedef GenericDTAUnaryFcn (*GetGenericDTAUnaryFcnGW) (void *, const char_T *, 
                                                       DTypeId, 
                                                       GenDTAUnaryFcnType);
typedef int_T  (*SetGenericDTAUnaryFcnGW) (void *, const char_T *, DTypeId,
                                           GenericDTAUnaryFcn, 
                                           GenDTAUnaryFcnType);
typedef int_T (*GenericDTAUnaryFcnGW) (slDataTypeAccess *, DTypeId, int_T, 
                                       const void *, const void *, void *,
                                       GenDTAUnaryFcnType);


typedef int_T (*GenericDTABinaryFcn) (slDataTypeAccess *, const char_T *, 
                                      DTypeId, int_T, const void *, 
                                      const void *, const void *, void *);
typedef GenericDTABinaryFcn (*GetGenericDTABinaryFcnGW) (void *, const char_T *, 
                                                         DTypeId, 
                                                         GenDTABinaryFcnType);
typedef int_T (*SetGenericDTABinaryFcnGW) (void *, const char_T *, 
                                           DTypeId, GenericDTABinaryFcn, 
                                           GenDTABinaryFcnType);
typedef int_T (*GenericDTABinaryFcnGW) (slDataTypeAccess *, DTypeId, 
                                        int_T, const void *, 
                                        const void *, const void *,
                                        void *, GenDTABinaryFcnType);

typedef int_T (*GetGenericDTADiagnostic) (void *, const char_T *, 
                                          GenDTADiagnosticType,
                                          BDErrorValue *);

struct _slDataTypeAccess_tag {
    void                      *dataTypeTable;

    const char_T              *errorString;

    RegisterDataType          registerFcn;

    GetNumDataTypes           getNumDataTypesFcn;

    GetDataTypeId             getIdFcn;

    GetGenericDTAIntProp      getGenericDTAIntProp;
    SetGenericDTAIntProp      setGenericDTAIntProp;

    GetGenericDTAVoidProp     getGenericDTAVoidProp;
    SetGenericDTAVoidProp     setGenericDTAVoidProp;

    GetGenericDTAUnaryFcnGW   getGenericDTAUnaryFcnGW;
    SetGenericDTAUnaryFcnGW   setGenericDTAUnaryFcnGW;

    GetGenericDTABinaryFcnGW  getGenericDTABinaryFcnGW;
    SetGenericDTABinaryFcnGW  setGenericDTABinaryFcnGW;

    GetConvertBetweenFcn      getConvertBetweenFcn;
    SetConvertBetweenFcn      setConvertBetweenFcn;

    GetGenericDTADiagnostic   getGenericDTADiagnostic;

    RegisterDataTypeWithCheck registerFcnWithCheck;

};

/*
 * Call into the s-functions external mode fcn - if it exists.  Returns
 * error string on failure, NULL on success.
 */
typedef const char *(*SFunExtModeFcn)(SimStruct *S, const ExtModeLogBlockMeth);

/* 
 * Non-continuous (sample time != 0) signals driving derivative ports
 * (eg. integrand input port of an integrator block) need to be tracked
 * in order to determine when to reset variable step solvers.
 */
typedef struct {
    int   sizeInBytes;
    char  *pCurrVal;
    char  *pPrevVal;
} ssNonContDerivSigInfo;


/*
 * The _ssMdlInfo structure is "valid" in the root SimStruct only.  All child
 * SimStruct's point to the root SimStruct mdlInfo field.  Care must be taken
 * to use the correct mapping of tid's when accessing some of mdlInfo fields
 * (e.g. t, sample hits, sample times, etc). from child SimStruct's (use macros
 * below).
 */

struct _ssMdlInfo {
  SS_SimMode  simMode;         /* This field indicates
                                  whether or not we are running a simulation
                                  or generating the model.rtw file */

  time_T      *t;              /* The current time for each task. This is
                                  of dimension sizes.numSampleTimes         */

  int_T       *sampleHits;     /* sample hits - does tid have a hit?  This is
                                  of dimension sizes.numSampleTimes         */

  time_T      tStart;          /* Model execution start time                 */
  time_T      tFinal;          /* Final model execution stop time            */
  time_T      timeOfLastOutput;/* Time of last model "output"                */

  time_T      minStepSize;     /* variable stepsize is always >= minStepSize */

  void        *timingData;     /* Data used by execution or simulation engine*/

  SimTimeStep simTimeStep;     /* Simulation time step "mode"                */

  int_T       stopRequested;   /* True if a "stop" has been requested        */
  int_T       logOutput;       /* Log output?                                */

  time_T      *outputTimes;    /* Times at which to log data                 */
  int_T       outputTimesIndex;/* Where we are in the OutputTimes vector     */
  int_T       numOutputTimes;  /* Length of OutputTimes                      */
  int_T       outputTimesOnly; /* Save [t,x,y] & continuous blocks at
                                  specified times only?                      */

  int_T       obsoletedNeedOutputAtTPlusTol;

  const char_T *solverName;    /* Name of solver/integration alogrithm       */
  int_T       variableStepSolver;/* true=variable or false=fixed step solver */
  void        *solverData;     /* Work area for solver                       */
  time_T      solverStopTime;  /* Solver stop time                           */
  time_T      stepSize;        /* The integration step size                  */
  int_T       solverNeedsReset;/* Do we need to reset the integrator?        */
  struct {
      unsigned int zcCacheNeedsReset    : 1; /* recompute zc value left?     */
      unsigned int derivCacheNeedsReset : 1; /* recompute derivatives?       */
      unsigned int blkStateChange       : 1; /* did blk state change?        */
      unsigned int reserved1            : 1; /* was skip intg phase (<=R12)  */
      unsigned int forceSfcnExceptionHandling : 1; /* add exception handling *
                                                    *for all S-function calls*/
      unsigned int inlineParameters   :1; /* is inline parameters selected
                                           * for the model?       */
      unsigned int solverAssertCheck    :1; /* true if consistency checking
                                               is enabled and active        */
      unsigned int reserved9            :9; /* remainder are reserved       */
      unsigned int reserved16           :16; /* remainder are reserved       */
  } mdlFlags;
  int_T       maxNumMinSteps;  /* Max number of steps taken at minimum       */
  int_T       solverRefineFactor;   /* state & output refinement factor      */
  real_T      solverRelTol;    /* Integration relative tolerance             */
  real_T      *solverAbsTol;   /* abs tol for each continuous state          */
  time_T      maxStepSize;     /* variable StepSize is always <= MaxStepSize */
  int_T       solverMaxOrder;  /* Maximum order for ode15s                   */
  time_T      fixedStepSize;   /* Step size for fixed-step integrators       */

  int_T                  numNonContDerivSigInfos;
  ssNonContDerivSigInfo* nonContDerivSigInfos;
  boolean_T*             solverAutoAbsTol;

  void  *unusedPtr2;

  RTWLogInfo        *rtwLogInfo;   /* Logging data structure for RTW         */
  RTWSolverInfo     *rtwSolverInfo; /* Solver info for RTW                   */

  void              *unused[2];
  void              *mexApiVoidPtr1; /* reserved for use by Simulink mex api */

  int_T             reservedInts[2];

  /*
   * External mode object
   */
  RTWExtModeInfo *extModeInfo;

  /* Base addresses of Block Outputs vector for the whole model   */

  void              *blockIO;      /* block inputs/outputs                   */

  /* Parameter vectors for use with Real-Time Workshop */

  void   *unusedPointer;
  real_T *defaultParam;       /* Default parameter vector.                   */
                              /* Note: DefaultParam points to global storage;
                               *  common to all instances of this model.
                               *  Used only by Accelerator to point to model
                               *  wide info.
                               */
  const void   *mappingInfo;  /* Used by RTW for providing external access
                                 to the parameters, block I/O, etc vectors   */


#if SS_SL_INTERNAL || SS_SFCN_FOR_SIM
  /*
   * Function pointers used in mdlRTW which write fields in the model.rtw file.
   */
    _WriteRTWStrFcn             writeRTWStrFcn;
    _WriteRTWNameValuePairFcn   writeRTWNameValuePairFcn;
    _WriteRTWParameterFcn       writeRTWParameterFcn;

    void                        *writeRTWFcnArg;

    _AccelRunBlockFcn           accelRunBlock;
    void                        *bdRefPtr;

    _GenericFcn                 genericFcn;

    void                        *reservedForFutureMLFcns[1];
    void                        *reservedForFutureMLArgs[4];
#endif

  int_T   mexApiInt2;                    /* for use by Simulink mex api */
  char_T  reservedString[32];            /* IMPORTANT:
                                            Keep it fixed at 32 characters 
                                            as it is needed for backward 
                                            compatibility */


   _ssSetInputPortDimensionInfoFcn    regInputPortDimsInfo;
   _ssSetOutputPortDimensionInfoFcn   regOutputPortDimsInfo;

#if SS_SL_INTERNAL || SS_SFCN_FOR_SIM
  SignalAccess       *signalAccess;
  slDataTypeAccess   *dataTypeAccess;
  void               *reservedForFutureVoid[2];
#endif

  void *reservedForXPC;

# if SS_MULTITASKING || SS_SL_INTERNAL || SS_SFCN_FOR_SIM
  int_T       *perTaskSampleHits; /* Matrix of dimension number of sample times
                                     by number of sample times giving sample
                                     hits as viewed in each task. Used by
                                     ssIsSpecialSampleHit within MEX files. */
# endif

  SolverMode   solverMode;          /* Simulation solver mode */
  RTWGenMode   rtwgenMode;  
  int_T        reservedForFutureInt[2];

  real_T       mexApiReal1;         /* reserved for use by Simulink mex api */
  real_T       mexApiReal2;         /* reserved for use by Simulink mex api */

  void       *reservedForFuture;
  real_T     *varNextHitTimesList;
  boolean_T  *tNextWasAdjusted;
  real_T     *reservedDoubleVect[1];

}; /* end struct _ssMdlInfo */


/* returns 1 on success and 0 on failure */
typedef int_T (*SysOutputFcn) (void *, int_T, int_T);

struct _ssCallSys {
  int_T                *outputs; /* Which output elements call a system    */
  void                 **args1;  /* 1st Argument(s) for system output fcn  */
  int_T                *args2;   /* 2nd Argument(s) for system output fcn  */
  SysOutputFcn         *fcns;    /* System output functions                */
};


/*------------------------ (S)->states.modelMethods2->resolveCBK ------------*/

/* callback function support type        *
 * returns 1 on success and 0 on failure */
typedef int_T (*_ResolveVarFcn)( const SimStruct *S,
				 const char *,
				 mxArray **);

/* callback structure */
struct _ssResolveCBK {
  _ResolveVarFcn       Resolver; /* Resolver function                */
  void 		       *slBlock; /* Block context for resolver fcn   */
};


/* callback access methods */
# define ssGetResolveMLVarCallbackStruct(S) \
          ((ssGetModelMethods2(S))->resolveCBK)
# define ssSetResolveMLVarCallbackFcn(S,val) \
          (ssGetResolveMLVarCallbackStruct(S)).Resolver = (val)
# define ssSetResolveMLVarCallbackContext(S,val) \
          (ssGetResolveMLVarCallbackStruct(S)).slBlock = (val)
# define ssResolveMLVarWithCallback(S,Var,mat) \
           (((ssGetResolveMLVarCallbackStruct(S)).Resolver != NULL) ? \
           (*(ssGetResolveMLVarCallbackStruct(S)).Resolver)(S, Var, mat) : \
           (1))

/*---------------------------------------------------------------------------*/

typedef DTypeId         (*OldRegisterDataType)(void *, char_T *);
typedef int_T           (*SetDataTypeSize) (void *, DTypeId, int_T );
typedef int_T           (*GetDataTypeSize) (void *, DTypeId);
typedef int_T           (*SetDataTypeZero) (void *, DTypeId, void *);
typedef const void *    (*GetDataTypeZero) (void *, DTypeId);
typedef const char_T *  (*GetDataTypeName) (void *, DTypeId);
typedef int_T           (*SetNumDWork)     (SimStruct *, int_T);


struct _ssRegDataType {
    void                *arg1;          /* 1st Argument for Register Data Type  */
    OldRegisterDataType registerFcn;    /* Register Data Type Function          */
    SetDataTypeSize     setSizeFcn;     /* Set Data Type Size Function          */
    GetDataTypeSize     getSizeFcn;     /* Get Data Type Size Function          */

    SetDataTypeZero     setZeroFcn;     /* Set Data Type Zero representation    */
    GetDataTypeZero     getZeroFcn;     /* Get Data Type Zero representation    */

    GetDataTypeName     getNameFcn;     /* Get Data Type Name Function          */
    GetDataTypeId       getIdFcn;       /* Get Data Type Id   Function          */

    SetNumDWork       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -