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

📄 simstruc.h

📁 simulink应用实例
💻 H
📖 第 1 页 / 共 5 页
字号:
     *  See comments for: EXTLOGTASK_TERM_INTERMEDIATE_ONESHOT
     */
    EXTLOGTASK_TERM_SESSION

} ExtModeLogBlockMeth;
#endif

/*==================================*
 * Structures with in the SimStruct *
 *==================================*/

#ifndef _SIMSTRUCT
#  define _SIMSTRUCT
   /*
    * Use incomplete type for function prototypes within SimStruct itself
    */
   typedef struct SimStruct_tag SimStruct;
#endif

#ifndef _DATA_TYPE_ACCESS
#define _DATA_TYPE_ACCESS
   /*
    * Use incomplete type for function prototypes within DataTypeAccess itself
    */
   typedef struct _slDataTypeAccess_tag slDataTypeAccess;
#endif

typedef enum {                  /* What happens when a zero crossings occurs */
    DISCONTINUITY_AT_ZC,
    CONTINUITY_AT_ZC,
    TRIGGERED_DISCON_AT_ZC
} ZCType;


/* For Backward compatibility with R12Lcs */
#define  SS_UNORIENTED_OR_COL_VECT     SS_1_D_OR_COL_VECT
#define  SS_UNORIENTED_OR_ROW_VECT     SS_1_D_OR_ROW_VECT
#define  SS_UNORIENTED_ROW_OR_COL_VECT SS_1_D_ROW_OR_COL_VECT
#define  SS_UNORIENTED_VECT            SS_1_D_VECT

typedef enum ssVectorMode_tag{
    SS_UNKNOWN_MODE,
    SS_1_D_OR_COL_VECT,
    SS_1_D_OR_ROW_VECT,
    SS_1_D_ROW_OR_COL_VECT,
    SS_1_D_VECT,
    SS_COL_VECT,
    SS_ROW_VECT
} ssVectorMode;


/*
 * _ssSizes - valid in all SimStruct's. There is one sizes for a level-1
 * S-function and another sizes for a level 2 S-function.
 */

struct _ssSizes {
  int_T numContStates;     /* number of continuous states                    */
  int_T numDiscStates;     /* number of discrete states                      */
  union {
    int_T numOutputPorts;  /* number of output ports for S-functions         */
    int_T numY;            /* Length of the external output vector for models
                              i.e. the sum of the widths of the outports.
                              For level 1 S-functions, this is the output
                              port width.                                    */
  } out;
  union {
    int_T numInputPorts;   /* number of input ports for S-functions          */
    int_T numU;            /* Length of the external input vector for models
                              i.e. the sum of the widths of the inports.
                              For level 1 S-functions, this is the input
                              port width.                                    */
  } in;
  int_T mexApiInt1;          /* reserved for use by Simulink mex api         */

  int_T sysDirFeedThrough; /* Not used by s-functions - only for root models */


  int_T numSampleTimes;    /* # of different sample times and/or time offsets*/
  int_T numSFcnParams;     /* number of external matrices passed in          */

                           /* -------- Work vectors ------------------------ */
  int_T numIWork;          /* size of integer work vector                    */
  int_T numRWork;          /* size of real_T precision work vector           */
  int_T numPWork;          /* size of pointer work vector                    */

                           /* -------- Block counts ------------------------ */
  int_T numBlocks;         /* number of Blocks in the model                  */
  int_T numSFunctions;     /* number of S-Functions                          */

                           /* -------- Model bookkeeping ------------------- */
  int_T numBlockIO;        /* number of block outputs                        */
  int_T numBlockParams;    /* number of block parameters                     */
  uint32_T checksums[4];   /* Checksums  of model                            */

                           /* -------- Version ----------------------------- */
  int32_T simStructVer;    /* SimStruct version                              */

                           /* -------- Zero Crossings ---------------------- */
  int_T numNonsampledZCs;  /* number of nonsampled zero crossings            */
  int_T numZCEvents;       /* number of zero crossing events                 */

                           /* -------- Modes ------------------------------- */
  int_T numModes;          /* number of modes                                */

                           /* -------- Configuration options --------------- */
  uint32_T options;        /* General options                                */


                           /* -------- Vector Sizes In Bytes  -------------- */

  int_T sizeofY;           /* Sizeof of external input, Y, in bytes          */
  int_T sizeofU;           /* Sizeof of external input, U, in bytes          */
  int_T sizeofBlockIO;     /* size of block outputs (number of bytes)        */

  int_T sizeofGlobalBlockIO; /* size of the global block outputs in bytes*/

  int_T numDWork;          /* size of data type work vectors                 */
  int_T sizeofDWork;       /* Size of data type work vector. Depends on
                              dwork data types, complex signals, and
                              num dworks.                                    */
  int_T RTWGeneratedSFcn;  /* Flag which is set for rtw generated s-function */
                           /* Remove once all dstates are changed to dworks  */
                           /* ------------- Reserved ------------------------*/
  struct {
      unsigned int hasMdlDimensionsFcn: 1;  /* uses width or dimension method*/
      unsigned int usesNumPorts:        1;  /* used for distinguishing between
                                               union fields in. and out. */
      unsigned int vectMode:            4;  /* used in set dimension methods */
      unsigned int blockReduction:      1;  /* used to request block reduction */
      /* prevent lint warning about bit fields greater than 16 bits */
      unsigned int reserved9:           9; /* remainder are reserved        */
      unsigned int reserved16:          16; /* remainder are reserved        */
  } flags;

  int_T numJacobianNzMax;  /* number of nonzero elements in sparse Jacobian  */

  void       *rtModel;       /* rtModel pointer */
  const void *constBlockIO;  /* Pointer to invariant signals */

  /*
   * The funky statements below were necessitated because we originally
   * had 5 reserved integer fields. In order to get a (void *) field
   * we need one int on certain platforms and two on others. To
   * overcome this, we have the definition below.
   *
   * Note that there is only ONE remaining reserved int (for alpha
   * anyway, there are 3 on other platforms i.e. the ones where
   * sizeof(int) = sizeof(void*) )
   *
   * In order to use it, there will need to be added some appropriate
   * pre-processor definitions to keep from attempting to instantiate
   * an array of length 0.
   *
   * The problem is that on alpha sizeof(void *) = 64 and
   * sizeof(int) = 32 so we have:
   *   4 - 2*sizeof(void *)/sizeof(int) = 4 - 2*64/32 = 0
   */
  int  reservedForFuture[5 - 2*sizeof(void *)/sizeof(int)];
};

#define SIZES_LENGTH  (sizeof(struct _ssSizes)/sizeof(int_T))

/*
 * _ssPortInfo (S->portInfo), this is only used by level 2 S-functions.
 *
 */

typedef const void      * const * InputPtrsType;

typedef const real_T    * const * InputRealPtrsType;
typedef const real32_T  * const * InputReal32PtrsType;
typedef const int8_T    * const * InputInt8PtrsType;
typedef const uint8_T   * const * InputUInt8PtrsType;
typedef const int16_T   * const * InputInt16PtrsType;
typedef const uint16_T  * const * InputUInt16PtrsType;
typedef const int32_T   * const * InputInt32PtrsType;
typedef const uint32_T  * const * InputUInt32PtrsType;
typedef const boolean_T * const * InputBooleanPtrsType;

typedef void *                 OutputVectType;

#define GET_DATA_TYPE(dt)            ((dt) & 0xFFFF)
#define GET_COMPLEX_SIGNAL(dt)       (((dt) & 0x10000) != 0)
#define DTINFO(id, complexSignal)    ((complexSignal)?((id) | 0x10000):(id))

#define INVALID_DTYPE_ID       (-10)
#define INVALID_DTYPE_SIZE     (-1)
#define INVALID_DTYPE_SIGNED   (-1)
#define INVALID_NUM_DTYPES     (-1)
#define INVALID_PORT_IDX       (-1)

enum {
    COMPLEX_INHERITED = -1,
    COMPLEX_NO,
    COMPLEX_YES
};


typedef enum {
    SS_RTW_STORAGE_AUTO = 0,
    SS_RTW_STORAGE_EXPORTED_GLOBAL,
    SS_RTW_STORAGE_IMPORTED_EXTERN,
    SS_RTW_STORAGE_IMPORTED_EXTERN_POINTER
} ssRTWStorageType;

/*
 * Enumeration of work vector origin flag values.
 */
typedef enum {
    SS_DWORK_ORIGINATED_AS_DWORK  = 0,  /* default */
    SS_DWORK_ORIGINATED_AS_MODE,
    SS_DWORK_ORIGINATED_AS_RWORK,
    SS_DWORK_ORIGINATED_AS_IWORK,
    SS_DWORK_ORIGINATED_AS_PWORK,
    SS_DWORK_ORIGINATED_AS_DSTATE
} ssDWorkOriginType;

#define SS_NUM_DWORK_ORIGIN_TYPES   6

/*
 * Auxiliary DWork structure for S-Functions, one for each dwork.
 */
struct _ssDWorkAuxRecord {
    char_T           *rtwIdentifier;
    int_T            rtwStorageClass;
    char_T           *rtwTypeQualifier;
    struct {
        unsigned int DisableBoundsChecking:  1; /* disable bounds check   */
        unsigned int reserved15:            15; /* remainder are reserved */
        unsigned int reserved16:            16; /* remainder are reserved */
    } flags;
    int_T            unusedInts[4];
    void             *unusedPtrs[4];
};


#define SS_NOT_REUSABLE_AND_GLOBAL  0U /* default */
#define SS_REUSABLE_AND_LOCAL       1U
#define SS_REUSABLE_AND_GLOBAL      2U
#define SS_NOT_REUSABLE_AND_LOCAL   3U


/* Registration returns 1 for success and 0 for failure */
typedef int_T (*_ssRegNumInputPortsFcn) (void * arg1, int_T nInputPorts);
typedef int_T (*_ssRegNumOutputPortsFcn) (void * arg1, int_T nOutputPorts);

typedef int_T (*_ssSetInputPortDimensionInfoFcn)  (SimStruct        *arg1,
                                                   int_T            port,
                                                   const DimsInfo_T *dimsInfo);
typedef int_T (*_ssSetOutputPortDimensionInfoFcn) (SimStruct        *arg1,
                                                   int_T            port,
                                                   const DimsInfo_T *dimsInfo);


struct _ssPortInputs {
    int_T          width;               /* Number of elements in input
                                           port                          */
    int_T          directFeedThrough;   /* Direct feedthrough for input
                                           port                          */
    DTypeId        dataTypeId;          /* Data type of input port.      */
    CSignal_T      complexSignal;       /* Complex signal (-1=either,
                                           0=no, or 1=yes)?              */
    union {
        const void   *vect;
        InputPtrsType ptrs;
    } signal;                           /* Inputs for level 2 S-functions */

    int_T          connected;           /* Are there signals entering
                                           the input port of the Sfcn?   */
    struct {
        unsigned int overWritable       :  1;
        unsigned int optimOpts          :  2;
        unsigned int frameData          :  2;
        unsigned int contiguity         :  1;
        unsigned int acceptExprInRTW    :  1;
        unsigned int cinId              :  2;
        unsigned int reserved7          :  7;
        unsigned int reserved16         :  16;
    } attributes;

    real_T         sampleTime;          /* Sample and offset time when   */
    real_T         offsetTime;          /* block specifies port based ts */
    int_T          *dims;               /* port dimensions               */
    int_T          bufferDstPort;

    int_T          sampleTimeIndex;     /* Sample time index when using
                                           port based sample times       */
    int_T          numDims;             /* port number of dimensions     */
};

struct _ssPortOutputs {
    int_T          width;               /* Number of elements in output
                                           port                          */
    DTypeId        dataTypeId;          /* Data type of outputs          */
    CSignal_T      complexSignal;       /* Complex signal (-1=either,
                                           0=no, or 1=yes)?              */
    void           *signalVect;         /* Output signal                 */
    int_T          connected;           /* Are the signals leaving the
                                           Sfcn driving other blocks?    */
    struct {
        unsigned int optimOpts       :  2;
        unsigned int frameData       :  2;
        unsigned int cToMergeBlk     :  1;
        unsigned int constOutputExprInRTW   :  1;
        unsigned int outputExprInRTW :  1;
        unsigned int trivialOutputExprInRTW :  1;
        unsigned int reserved8       :  8;
        unsigned int reserved16      : 16;
    } attributes;

    real_T         sampleTime;          /* Sample and offset time when   */
    real_T         offsetTime;          /* block specifies port based ts */
    int_T          *dims;               /* port dimensions               */
    int_T          sampleTimeIndex;     /* Sample time index when using
                                           port based sample times       */
    int_T          reserved;
    int_T          numDims;             /* port number of dimensions     */
};

struct _ssPortInfo {

    _ssRegNumInputPortsFcn  regNumInputPortsFcn;
    void                    *regNumInputPortsFcnArg;
    _ssRegNumOutputPortsFcn regNumOutputPortsFcn;
    void                    *regNumOutputPortsFcnArg;

    struct _ssPortInputs    *inputs;    /* Info for each input port of blk  */
    struct _ssPortOutputs   *outputs;   /* Info for each output port of blk */
};


#ifndef _SS_PARAM_REC
# define _SS_PARAM_REC
/*
 * Typedef for the enumeration that keeps track of the "transformed"
 * status of run-time parameters.
 */
typedef enum {

    /*
     * Your run-time parameter is not transformed if nDialogParamIndices is

⌨️ 快捷键说明

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