📄 simstruc_types.h
字号:
/*
* Copyright (c) 1990-2002 The MathWorks, Inc.
*
* File: simstruc_types.h $Revision: 1.35 $
*
* Abstract:
* The embedded RTW code formats do not include simstruc.h, but
* needs these common types.
*
*/
#ifndef __SIMSTRUC_TYPES_H__
#define __SIMSTRUC_TYPES_H__
#include "tmwtypes.h"
#define UNUSED_ARG(arg) (void)arg
#ifndef fcn_call_T
# define fcn_call_T real_T
#endif
#ifndef action_T
# define action_T real_T
#endif
/*
* UNUSED_PARAMETER(x)
* Used to specify that a function parameter (argument) is required but not
* accessed by the function body.
*/
#ifndef UNUSED_PARAMETER
# if defined(__LCC__)
# define UNUSED_PARAMETER(x) /* do nothing */
# else
/*
* This is the semi-ANSI standard way of indicating that a
* unused function parameter is required.
*/
# define UNUSED_PARAMETER(x) (void) (x)
# endif
#endif
typedef enum {
SS_SIMMODE_NORMAL, /* Running a "normal" Simulink simulation */
SS_SIMMODE_SIZES_CALL_ONLY, /* Block edit eval to obtain number of ports */
SS_SIMMODE_RTWGEN, /* Generating code */
SS_SIMMODE_EXTERNAL /* External mode simulation */
} SS_SimMode;
/* Must be used when SS_SimMode is SS_SIMMODE_RTWGEN */
typedef enum {
SS_RTWGEN_UNKNOWN,
SS_RTWGEN_RTW_CODE, /* Code generation for RTW */
SS_RTWGEN_ACCELERATOR /* Code generation for accelerator */
} RTWGenMode;
typedef enum {
SOLVER_MODE_AUTO, /* only occurs in
mdlInitializeSizes/mdlInitializeSampleTimes */
SOLVER_MODE_SINGLETASKING,
SOLVER_MODE_MULTITASKING
} SolverMode;
typedef enum {
MINOR_TIME_STEP,
MAJOR_TIME_STEP
} SimTimeStep;
typedef enum { /* Disabled/enabled modes */
SUBSYS_DISABLED = 0,
SUBSYS_ENABLED = 1,
SUBSYS_BECOMING_DISABLED = 2,
SUBSYS_BECOMING_ENABLED = 3
} EnableStates;
typedef enum { /* What direction to look for zero crossing */
FALLING_ZERO_CROSSING = -1,
ANY_ZERO_CROSSING = 0,
RISING_ZERO_CROSSING = 1
} ZCDirection;
typedef enum {
NEG_ZCSIG = -1,
ZERO_ZCSIG = 0,
POS_ZCSIG = 1,
ZERO_RISING_EV_ZCSIG = 100, /* zero and had a rising event */
ZERO_FALLING_EV_ZCSIG = 101, /* zero and had a falling event */
UNINITIALIZED_ZCSIG = INT_MAX
} ZCSigState;
typedef enum { /* What type of zero crossing event occurred */
FALLING_ZCEVENT = -1,
NO_ZCEVENT = 0,
RISING_ZCEVENT = 1
} ZCEventType;
typedef enum {
SS_DOUBLE = 0, /* real_T */
SS_SINGLE = 1, /* real32_T */
SS_INT8 = 2, /* int8_T */
SS_UINT8 = 3, /* uint8_T */
SS_INT16 = 4, /* int16_T */
SS_UINT16 = 5, /* uint16_T */
SS_INT32 = 6, /* int32_T */
SS_UINT32 = 7, /* uint32_T */
SS_BOOLEAN = 8 /* boolean_T */
/* if last in list changes also update define below */
} BuiltInDTypeId;
#define SS_NUM_BUILT_IN_DTYPE ((int)SS_BOOLEAN+1)
typedef enum {
SS_INTEGER = 10,
SS_POINTER = 11
/* if last in list changes also update define below */
} PreDefinedDTypeId;
#define SS_NUM_PREDEFINED_DTYPES 2
#ifndef _DTYPEID
# define _DTYPEID
typedef int_T DTypeId;
#endif
typedef int_T CSignal_T;
/* DimsInfo_T structure is for S-functions */
#ifndef _DIMSINFO_T
#define _DIMSINFO_T
struct DimsInfo_tag{
int width; /* number of elements */
int numDims; /* number of dimensions */
int *dims; /* dimensions */
struct DimsInfo_tag *nextSigDims; /* for composite signals */
};
typedef struct DimsInfo_tag DimsInfo_T;
/*
* DECL_AND_INIT_DIMSINFO(variableName):
* Macro for setting up a DimsInfo in an S-function to DYNAMIC_DIMENSION.
* This macro must be placed at the start of a deceleration, for example:
*
* static void mdlInitializeSizes(SimStruct *S)
* {
* DECL_AND_INIT_DIMSINFO(diminfo1);
*
* ssSetNumSFcnParams(S, 0);
* <snip>
* }
*
* The reason that this macro must be placed in the deceleration section of a
* function or other scope is that this macro **creates** a local variable of
* the specified name with type DimsInfo_T. The variable is initialized
* to DYNAMIC_DIMENSION.
*/
#define DECL_AND_INIT_DIMSINFO(variableName) \
DimsInfo_T variableName = {-1,-1,NULL,NULL}
#endif /* _DIMSINFO_T */
/*
* Enumeration of work vector used as flag values.
*/
typedef enum {
SS_DWORK_USED_AS_DWORK = 0, /* default */
SS_DWORK_USED_AS_DSTATE, /* will be logged, loaded, etc */
SS_DWORK_USED_AS_SCRATCH /* will be reused */
} ssDWorkUsageType;
#define SS_NUM_DWORK_USAGE_TYPES 3
/*
* DWork structure for S-Functions, one for each dwork.
*/
struct _ssDWorkRecord {
int_T width;
DTypeId dataTypeId;
CSignal_T complexSignal;
void *array;
const char_T *name;
ssDWorkUsageType usedAs;
};
/*
* INHERITED_SAMPLE_TIME - Specify for blocks that inherit their sample
* time from the block that feeds their input.
*
* CONTINUOUS_SAMPLE_TIME - A continuous sample time indicates that the
* block executes every simulation step.
*
* VARIABLE_SAMPLE_TIME - Specifies that this sample time is discrete
* with a varying period.
*
* FIXED_IN_MINOR_STEP_OFFSET - This can be specified for the offset of either
* the inherited or continuous sample time
* indicating that the output does not change
* in minor steps.
*/
#define INHERITED_SAMPLE_TIME ((real_T)-1.0)
#define CONTINUOUS_SAMPLE_TIME ((real_T)0.0)
#define VARIABLE_SAMPLE_TIME ((real_T)-2.0)
#define MODEL_EVENT_SAMPLE_TIME ((real_T)-3.0)
#define FIXED_IN_MINOR_STEP_OFFSET ((real_T)1.0)
/*
* The RTWLogSignalInfo and RTWLogInfo structures are for use by
* the Real-Time Workshop and should not be used by S-functions.
*/
typedef const int8_T * const * LogSignalPtrsType;
typedef struct RTWLogSignalInfo_tag {
int_T numSignals;
const int_T *numCols;
const int_T *numDims;
const int_T *dims;
const BuiltInDTypeId *dataTypes;
const int_T *complexSignals;
const int_T *frameData;
const char_T *labels;
const int_T *labelLengths;
const char_T *titles;
const int_T *titleLengths;
const int_T *plotStyles;
const char_T *blockNames;
const int_T *blockNameLengths;
} RTWLogSignalInfo;
/* =============================================================================
* Logging object
* =============================================================================
*/
typedef struct _RTWLogInfo_tag {
void *logInfo; /* Pointer to a book keeping structure *
* used in rtwlog.c */
LogSignalPtrsType logXSignalPtrs;/* Pointers to the memory location *
* of the data to be logged into the *
* states structure. Not used if logging *
* data in matrix format. */
LogSignalPtrsType logYSignalPtrs;/* Pointers to the memory location *
* of the data to be logged into the *
* outputs structure. Not used if logging *
* data in matrix format. */
int_T logFormat; /* matrix=0, struct=1, or strut_wo_time=2 */
int_T logMaxRows; /* Max number of rows (0 for no limit) */
int_T logDecimation; /* Data logging interval */
const char_T *logVarNameModifier;/* pre(post)fix string modifier for the *
* log variable names */
const char_T *logT; /* Name of variable to log time */
const char_T *logX; /* Name of variable to log states */
const char_T *logXFinal; /* Name of varaible to log final state */
const char_T *logY; /* Name of variable(s) to log outputs */
const RTWLogSignalInfo *logXSignalInfo;/* Info about the states */
const RTWLogSignalInfo *logYSignalInfo;/* Info about the outptus */
void (*mdlLogData)(void *rtli, void *tPtr);
} RTWLogInfo;
/* Macros associated with RTWLogInfo */
#define rtliGetLogInfo(rtli) ((LogInfo*)(rtli)->logInfo)
#define rtliSetLogInfo(rtli,ptr) (rtli)->logInfo = ((void *)ptr)
#define rtliGetLogFormat(rtli) (rtli)->logFormat
#define rtliSetLogFormat(rtli,f) (rtli)->logFormat = (f)
#define rtliGetLogVarNameModifier(rtli) (rtli)->logVarNameModifier
#define rtliSetLogVarNameModifier(rtli,name) (rtli)->logVarNameModifier=(name)
#define rtliGetLogMaxRows(rtli) (rtli)->logMaxRows
#define rtliSetLogMaxRows(rtli,num) (rtli)->logMaxRows = (num)
#define rtliGetLogDecimation(rtli) (rtli)->logDecimation
#define rtliSetLogDecimation(rtli,l) (rtli)->logDecimation = (l)
#define rtliGetLogT(rtli) (rtli)->logT
#define rtliSetLogT(rtli,lt) (rtli)->logT = (lt)
#define rtliGetLogX(rtli) (rtli)->logX
#define rtliSetLogX(rtli,lx) (rtli)->logX = (lx)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -