📄 simstruc.h
字号:
* one and there was no alteration of the dialog parameter
*/
RTPARAM_NOT_TRANSFORMED = 0,
/*
* Your run-time parameter is transformed if nDialogParamIndices > 1 or
* there was an alteration of the dialog parameter value or data type.
*/
RTPARAM_TRANSFORMED = 1,
/*
* Your run-time parameter can be marked as 'make transformed tunable'
* if nDialogParamIndices is one and you altered the dialog parameter
* value or data type. If the parameter field contains a single
* tunable variable, say 'k', then the transformed data type, etc.
* version of k will be used in the generated code. All references to
* tunable parameters that have been transformed must be done so in
* the same fashion, otherwise an error will be generated.
*/
RTPARAM_MAKE_TRANSFORMED_TUNABLE = 2
} TransformedFlag;
typedef struct ssParamRec_tag {
/*
* The parameter characteristics
*/
const char *name; /* Name of the parameter. This must point
* to persistent memory. Do not set to a local
* variable (static char name[32] or strings
* "name" are okay)
*/
int_T nDimensions; /* Number of dimensions for this parameter */
int_T *dimensions; /* Array giving the dimension (sizes) of
* the paramter */
DTypeId dataTypeId; /* For built-in data types, see BuiltInDTypeId
* in simstruc_types.h */
boolean_T complexSignal; /* FALSE or TRUE */
/*
* The data pointer. This is the data values for the run-time parameter.
* Simulink needs this when creating the model.rtw file. Complex Simulink
* signals are store interleaved. Likewise complex run-time parameters
* must be stored interleaved.
*
* Note that mxArrays store the real and complex parts of complex
* matrices as two separate contiguous pieces of data instead of
* interleaving the real and complex parts. */
void *data;
/*
* The data attributes pointer is a persistent storage location where the
* user can store additional information describing the data and then
* recover this information later (potentially in a different function).
*/
const void *dataAttributes;
/*
* Run-time parameters to dialog parameter map.
*
* For proper interaction with 'tunable parameter variables' that
* are set via the "Tunable Parameters Dialog", Simulink requires
* information about how the run-time parameters are derived.
*
* It is an implicit assumption that all run-time parameters are derived
* from the dialog parameters, i.e., ssGetSFcnParam(S,i). Thus each
* run-time parameter is derived from a subset of the dialog parameters:
* run-time_parameter = some_function(subset of dialog parameters).
* In the simplest case,
* run-time_parameter = a specific dialog parameter
*
* The following information specifies which dialog parameters are
* used in deriving a specific run-time parameter. For the simplest case,
* we have
* nDialogParamIndices = 1;
* dialogParamIndices = k;
* transformed = false;
* This case is important to identify because this will allow for
* efficient and correct code generation of run-time parameters when they
* map directly back to tunable parameter variables specified in
* the 'Tunable Parameters Dialog'.
*/
int_T nDlgParamIndices;
int_T *dlgParamIndices; /* Array of length nDialogParamIndices
* indicating the dialog parameters that
* are used in deriving the run-time
* parameter */
TransformedFlag transformed; /* Transformed status */
boolean_T outputAsMatrix; /* Write out parameter as a vector (false)
* [default] or a matrix (true)
*/
} ssParamRec;
#endif
/* Masks for determining the parameter attributes (see ssSfcnParams struct). */
#define SFCNPARAM_NOT_TUNABLE (1 << 0x0)
#define SFCNPARAM_TUNABLE (1 << 0x1)
#define SFCNPARAM_CLEAR_TUNABLE (~(SFCNPARAM_NOT_TUNABLE | SFCNPARAM_TUNABLE))
struct _ssSFcnParams {
int_T dlgNum; /* Number of S-function parameters passed in */
mxArray **dlgParams; /* The S-function parameters */
uint_T *dlgAttribs; /* Disable parameter changes during simulation?*/
/* union preserves the memory map of the Simstruc; the size of an integer
* is always less than or equal to that of a pointer
*/
union {
int_T numRtp;
void *placeholder;
} numRtp;
ssParamRec **rtp;
};
struct _ssWork {
int_T *iWork; /* integer work vector */
real_T *rWork; /* real work vector */
void **pWork; /* pointer work vector */
int_T *modeVector; /* mode work vector */
void *userData; /* User/application specific data */
union {
struct _ssDWorkRecord *sfcn;
void *root;
} dWork; /* data type work vector */
struct _ssDWorkAuxRecord *dWorkAux;
void *reservedForFuture[1];
};
/*
* The _ssBlkInfo structure can by used by S-function blocks to determine
* status about the model in which they reside.
*/
struct _ssBlkInfo2 {
void *rtwSfcnInfo; /* Used only in RTW by the S-function */
void *reservedPtrs[16];
int_T reserved[16];
};
struct _ssBlkInfo {
int_T inputConnected; /* Is input connected to a nonvirtual block? */
int_T outputConnected; /* Is output connected to a nonvirtual block?*/
const char_T *placementGroup; /* Name of group to place block in. Only
applies to sources and sinks. Blocks with
same group name will appear adjacent in
the sorted list. */
void *block; /* The owner slBlock * of the s-function */
struct _ssBlkInfo2 *blkInfo2; /* More block info */
int_T absTolOffset; /* Offset from the root SimStruct absTol */
int_T reservedForFutureInt;
};
/*==================================================================*
* Mode of simulation - single vs multitaking. Note, variable *
* step solvers ignore this property and are always singletasking *
*==================================================================*/
typedef enum {
GEN_FCN_SET_NUM_RUN_TIME_PARAMS,
GEN_FCN_REG_RUN_TIME_PARAM,
GEN_FCN_UPDATE_RUN_TIME_PARAM,
GEN_FCN_REG_ALL_TUNE_PRM_AS_RTP,
GEN_FCN_UPDATE_ALL_TUNE_PRM_AS_RTP,
GENFCNFIXPT_DIMS_SUM_IN,
GENFCNFIXPT_DIMS_SUM_OUT,
GENFCNFIXPT_DIMS_SUM_DEFAULT,
GENFCNFIXPT_DIMS_PROD_IN,
GENFCNFIXPT_DIMS_PROD_OUT,
GENFCNFIXPT_DIMS_PROD_DEFAULT,
GENFCNFIXPT_DIMS_MPSWITCH_IN,
GENFCNFIXPT_DIMS_MPSWITCH_OUT,
GENFCNFIXPT_DIMS_LOGIC_IN,
GENFCNFIXPT_DIMS_LOGIC_OUT,
GENFCNFIXPT_DIMS_LOGIC_DEFAULT,
GENFCNFIXPT_DIMS_GAIN_IN,
GENFCNFIXPT_DIMS_GAIN_OUT,
GENFCNFIXPT_DIMS_GAIN_DEFAULT,
GENFCNFIXPT_LICENSE,
GEN_FCN_IS_RTPARAM_TUNABLE,
GEN_FCN_GET_BLOCK_HANDLE,
GEN_FCN_SET_SAMPLE_TIME_AS_MODEL_EVENT,
GEN_FCN_SET_NUM_MODEL_EVENTS_POSTED,
GEN_FCN_SET_MODEL_EVENT_POSTED,
GEN_FCN_POST_MODEL_EVENT,
GEN_FCN_COMPUTE_INPUT,
GEN_FCN_GET_DBLOVERRIDE,
GEN_FCN_GET_MINMAXLOG,
GEN_FCN_GET_MINMAXARCHIVE,
GEN_FCN_REG_CONST_RUN_TIME_PARAM,
GEN_FCN_SF_INLINABLE,
GEN_FCN_REG_AND_CNV_RUN_TIME_PARAM,
GEN_FCN_UPDATE_AND_CNV_RUN_TIME_PARAM
} GenFcnType;
#if SS_SL_INTERNAL || SS_SFCN_FOR_SIM
/* following return 1 on success and 0 on failure */
typedef int_T (*_WriteRTWStrFcn)( void *writeRTWFcnArg,
const char_T *str);
typedef int_T (*_WriteRTWNameValuePairFcn)( void *writeRTWFcnArg,
int_T type,
const char_T *name,
const void *value,
DTypeId dataTypeId,
int_T nRows,
int_T nCols);
typedef int_T (*_WriteRTWParameterFcn)( void *writeRTWFcnArg,
int_T type,
const char_T *name,
const char_T *str,
const void *value,
DTypeId dataTypeId,
int_T nRows,
int_T nCols);
typedef void (*_AccelRunBlockFcn)( SimStruct *S,
int sysidx,
int blkidx,
int enumFunction);
typedef int_T (*_GenericFcn) ( SimStruct *S,
GenFcnType type,
int_T arg1,
void *arg2);
#endif
#if SS_SL_INTERNAL || SS_SFCN_FOR_SIM
/*
* The following return error string on failure, NULL on success.
* See <matlabroot>/simulink/src/barplot.c for an example of using
* these functions.
*/
/*
* Returns an array of output port pointers corresponding to the selected
* signals in the window that the s-function block resides (i.e., the signals
* whose lines have selection handles). There are two options that can
* be passed to this function (sigSetOpt):
* SIGSET_GRAPH: return only the selected signals in the window in
* which the s-function resides.
* SIGSET_GRAPH_N_CHILDREN: return selected signals in the window in
* which the s-function resides and all
* children windows.
*/
typedef const char *(*SelectedSignalsFcn)(
const void *voidBlock,
const int sigSetOpt,
void ***voidOutPortObjs, /* the ports */
int *outnPortObjs); /* the number of ports */
/*
* Given an array of output ports, create a signal list so that the signal
* data may be accessed (also see sigmapdef.h). Return an error string on
* failure or NULL on success.
*/
typedef const char *(*SigListCreateFcn)(
const void *voidBlock,
const int nPorts,
void **voidPortObjs,
const unsigned int excludeFlags,
void **voidOutSigList);
/*
* Destroy a signal list.
*/
typedef void (*SigListDestroyFcn)(void *voidSigList);
/*
* Access into Simulink memory manager's free function. Used to destroy
* objects that were created by calling into Simulink (e.g., ssCall..). This
* function is accessed via the ssCallGenericDestroyFcn macro.
*/
typedef void (*utFreeFcn)(void *ptr);
/*
* Given a pointer to a port, return it's name (signal label).
*/
typedef const char *(*GetPortNameFcn)(void *voidPortObj);
/*
* Given a signal list, detect and alert users to any signals that
* are not available for viewing.
*/
typedef void (*SigListUnavailSigAlertFcn)(void *voidSigList);
/*
* Given a port, unselect it's line.
*/
typedef void (*UnselectSigFcn)(void *voidPortObj);
typedef struct _SignalAccess_tag {
SelectedSignalsFcn SelectedSignals;
SigListCreateFcn SigListCreate;
SigListDestroyFcn SigListDestroy;
SigListUnavailSigAlertFcn SigListUnavailSigAlert;
utFreeFcn utFree;
GetPortNameFcn GetPortName;
UnselectSigFcn UnselectSig;
} SignalAccess;
#endif
typedef enum {
GEN_DTA_INT_PROP_SIZE,
GEN_DTA_INT_PROP_ID_ALIASED_TO,
GEN_DTA_INT_PROP_ID_RESOLVES_TO,
GEN_DTA_INT_PROP_PROPERTIES_SIZE
} GenDTAIntPropType;
typedef enum {
GEN_DTA_VOID_PROP_NAME,
GEN_DTA_VOID_PROP_ZERO,
GEN_DTA_VOID_PROP_PROPERTIES
} GenDTAVoidPropType;
typedef enum {
GEN_DTA_UNARY_FCN_IS_POSITIVE,
GEN_DTA_UNARY_FCN_IS_NEGATIVE
} GenDTAUnaryFcnType;
typedef enum {
GEN_DTA_BINARY_FCN_GREATER_THAN,
GEN_DTA_BINARY_FCN_GREATER_EQUAL
} GenDTABinaryFcnType;
typedef enum {
GEN_DTA_DATA_OVERFLOW,
GEN_DTA_INT32_TO_FLOAT,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -