📄 simstruc.h
字号:
/*
* Copyright 1990-2000 The MathWorks, Inc.
*
* File: simstruc.h $Revision: 1.269 $
*
* Abstract:
* Data structures and access methods for S-functions.
*
* A Simulink model is an S-function. The SimStruct contains all entry
* points within the S-function (e.g. mdlOutputs) as well any data
* associated with the S-function.
*
* This file contains details of SimStruct (Simulink data structure)
* which is used to store attributes of the model such as pointers to
* storage vectors.
*
* Multiple SimStructs are, in general, used by a model. These SimStruct's
* are arranged as a "tree". The "root" SimStruct is used by
* the Simulink model. There is one child SimStruct for each S-function
* block with in the model.
*
* The SimStruct can be used in three environments:
* o With MATLAB/Simulink (MATLAB_MEX_FILE)
* o With Real-Time Workshop in nonreal-time (NRT)
* o With Real-Time Workshop in real-time (RT)
*
* Defines:
* One of the following must be defined.
* MATLAB_MEX_FILE - Must be defined when compiling as a MEX file,
* otherwise must not be defined.
* NRT - Define if creating non-real-time executable
* RT - Define if creating real-time executable.
*
* See ENVIRONMENT MACROS section below for more info.
*
* Defines which must be declared by the Real-Time Workshop
* generated model source.
* Simulink_NAME="name"
* NSAMPLE_TIMES=n
*
* Defines for use with the Real-Time Workshop (these are configured
* by the template makefile, do not add directly to make command):
* MULTITASKING - Optional (use MT for a synonym).
* NUMST=n - Number of sample times in the root SimStruct.
* TID01EQ=1 or 0 - Optional. Only define to 1 if sample time task
* id's 0 and 1 have equal rates.
* =============================================================================
*/
#ifndef __SIMSTRUC__
#define __SIMSTRUC__
/*===========================================================================*
* BEGIN SECTION
* LIST OF KEY DEFINES CONTROLLING CONDITIONAL COMPILATION
*
* Simstruc properties such as definitions, access methods, etc.
* are conditionally compiled depending on "who" is using the simstruc
* and in what mode.
*
* This section list all the key #define macros controlling the inclusion/
* exclusion of features, defintions, etc.
*
* Typically, this section only assigns a default value (such as false).
* The final value is adjusted in a subsequent section.
*===========================================================================*/
/*=======================================================*
* MODE: SINGLE-TASKING OR MULTI-TASKING
*/
#define SS_MULTITASKING (0)
/*=======================================================*
* MODE: SIMULATION OR GENERATED CODE
*
* The following #defines determine whether the simstruc is used in "normal"
* Simulink simulation or in Real Time Workshop generated code.
*
* This is designed to be a mutually exclusive set.
* One and only one should be defined to be true.
*/
#define SS_SIM (0)
#define SS_RTW (0)
/*=======================================================*
* MODE: WHO IS USING THE SIMSTRUC
*
* The following #defines determine "who" is using the simstruc.
*
* This is designed to be a mutually exclusive set.
* One and only one should be defined to be true.
*/
#define SS_SFCN_LEVEL_1 (0)
#define SS_SFCN_NORMAL (0)
#define SS_GENERATED_S_FUNCTION (0)
#define SS_SL_INTERNAL (0)
#define SS_RTW_INTERNAL (0)
#define SS_SHARED_MODULE (0)
/*=======================================================*
* MODE: GENERATED CODE IS REAL-TIME OR NON-REAL-TIME
*
* Both can be false, but both can't be true
*/
#define SS_RT (0)
#define SS_NRT (0)
/*=======================================================*
* MODE: ENFORCE NDEBUG
*/
#define SS_NDEBUG (0)
/*=======================================================*
* MODE: ENVIRONMENT HAS STANDARD IO AVAILABLE
*/
#define SS_HAVESTDIO (0)
/*=======================================================*
* MODE: TID_EQUALS_SAMPLE_TIME_INDEX -
* The model will function correctly if this define is false, however if
* this define is true the model's performance may be increased depending
* upon whether or not the model has fast to slow rate transitions.
*/
#define TID_EQUALS_SAMPLE_TIME_INDEX (0)
/*=======================================================*
* MODE: TID01EQ == 1
*/
#define SS_TID01EQ_EQUAL_ONE (0)
/*===========================================================================*
* END SECTION
* LIST OF KEY DEFINES CONTROLLING CONDITIONAL COMPILATION
*===========================================================================*/
/*=================*
* Nested includes *
*=================*/
#include <limits.h>
#include <string.h>
#include "tmwtypes.h"
#include "simstruc_types.h"
/*===========================================================================*
* BEGIN SECTION
* DETERMINE FINAL VALUES OF KEY DEFINES CONTROLLING CONDITIONAL COMPILATION
*===========================================================================*/
/*====================================*
* Determine => MODE: SINGLE-TASKING OR MULTI-TASKING
*
* This must come after the inclusion of simstruc_types.h
*/
#if defined(MULTITASKING)
# undef SS_MULTITASKING
# define SS_MULTITASKING (1)
#endif
/*====================================*
* Determine => MODE: SIMULATION OR GENERATED CODE
*/
#if defined(MATLAB_MEX_FILE) || defined(MathWorks_h) || defined(FIPXT_SHARED_MODULE)
# undef SS_SIM
# define SS_SIM (1)
#else
# undef SS_RTW
# define SS_RTW (1)
#endif
/*====================================*
* Determine => MODE: WHO IS USING THE SIMSTRUC
*/
#if !defined(S_FUNCTION_LEVEL)
# if defined(S_FUNCTION_NAME)
# define S_FUNCTION_LEVEL 1 /* Backwards compatibility old S-functions */
# else
# define S_FUNCTION_LEVEL 2
# endif
#endif
#if S_FUNCTION_LEVEL != 1 && S_FUNCTION_LEVEL != 2
# error Invalid S_FUNCTION_LEVEL
#endif
#if defined(RTW_GENERATED_S_FUNCTION)
/*
* Used by RTW Generated S Function, ex s-fcn target.
* This flag is independent of how the
* s-function is built (i.e., it is a #define in the code, not a build
* flag). It is true when building the s-function for use with simulink and
* when building the s-function for use with RTW.
*/
# undef SS_GENERATED_S_FUNCTION
# define SS_GENERATED_S_FUNCTION (1)
#elif S_FUNCTION_LEVEL == 1
/*
* Used with any LEVEL 1 s-function (user written) including:
* o build for use with a normal simulation (via mex command)
* o build for use with rtw (grt)
*/
# undef SS_SFCN_LEVEL_1
# define SS_SFCN_LEVEL_1 (1)
#elif defined(S_FUNCTION_NAME)
/*
* Used with any s-function (user written) including:
* o build for use with a normal simulation (via mex command)
* o build for use with rtw (grt)
*/
# undef SS_SFCN_NORMAL
# define SS_SFCN_NORMAL (1)
#elif defined(MathWorks_h) || defined(RSIM_WITH_SL_SOLVER)
/*
* Used internally by Simulink (simulink.dll).
*/
# undef SS_SL_INTERNAL
# define SS_SL_INTERNAL (1)
#elif defined(RT) || defined(NRT)
/*
* Used in "root" model of generated code, but not in
* non-inlined, s-functions being compiled for use with the
* generated code (i.e., rt_main and model.c have access, but
* sfunc.c does not).
*/
# undef SS_RTW_INTERNAL
# define SS_RTW_INTERNAL (1)
#elif defined(FIPXT_SHARED_MODULE)
/*
* Used in shared module (such as a dll) that needs to be able to
* use some feature of the simstruc.
*/
/*
* Currently, shared module will be treated as if they are
* normal sfunctions.
*
# undef SS_SHARED_MODULE
# define SS_SHARED_MODULE (1)
*/
# undef SS_SFCN_NORMAL
# define SS_SFCN_NORMAL (1)
#elif defined(MATLAB_MEX_FILE)
/* Used in mex function that is NOT an S-Function mex
*/
/*
* Currently, plain mex functions will be treated as if they are
* normal sfunctions.
*
# undef SS_MEX
# define SS_MEX (1)
*/
# undef SS_SFCN_NORMAL
# define SS_SFCN_NORMAL (1)
#else
# error Unrecognized use.
#endif
/*=======================================================*
* Determine => MODE: GENERATED CODE IS REAL-TIME OR NON-REAL-TIME
*/
#if defined(RT)
# undef SS_RT
# define SS_RT (1)
#endif
#if defined(NRT)
# undef SS_NRT
# define SS_NRT (1)
#endif
/*=======================================================*
* Determine => MODE: ENFORCE NDEBUG
*/
#if defined(NDEBUG)
# undef SS_NDEBUG
# define SS_NDEBUG (1)
#endif
/*=======================================================*
* Determine => MODE: ENVIRONMENT HAS STANDARD IO AVAILABLE
*/
#if defined(HAVESTDIO)
# undef SS_HAVESTDIO
# define SS_HAVESTDIO (1)
#endif
/*=======================================================*
* Determine => MODE: TID_EQUALS_SAMPLE_TIME_INDEX -
*/
#if SS_SL_INTERNAL
# undef TID_EQUALS_SAMPLE_TIME_INDEX
# define TID_EQUALS_SAMPLE_TIME_INDEX (1)
#else
# if defined(NUMST) && defined(NSAMPLE_TIMES)
# if NUMST < NSAMPLE_TIMES
# error NUMST specified incorrectly
# elif NUMST == NSAMPLE_TIMES
# undef TID_EQUALS_SAMPLE_TIME_INDEX
# define TID_EQUALS_SAMPLE_TIME_INDEX (1)
# endif
# endif
#endif
/*=======================================================*
* Determine => MODE: TID01EQ == 1
*/
#if defined(TID01EQ)
# if TID01EQ == 1
# undef SS_TID01EQ_EQUAL_ONE
# define SS_TID01EQ_EQUAL_ONE (1)
# endif
#endif
/*===========================================================================*
* END SECTION
* DETERMINE FINAL VALUES OF KEY DEFINES CONTROLLING CONDITIONAL COMPILATION
*===========================================================================*/
/*===========================================================================*
* BEGIN SECTION
* CHECK PROPER USAGE
*
* Issue errors if incompatible modes have been selected
*===========================================================================*/
#if (defined(RT) + defined(NRT) + defined(MATLAB_MEX_FILE) + defined(MathWorks_h) + defined(FIPXT_SHARED_MODULE) != 1)
# error Must define one of RT, NRT, MATLAB_MEX_FILE, MathWorks_h, or FIPXT_SHARED_MODULE
# if defined(RT)
# error defined(RT)
# endif
# if defined(NRT)
# error defined(NRT)
# endif
# if defined(MATLAB_MEX_FILE)
# error defined(MATLAB_MEX_FILE)
# endif
# if defined(MathWorks_h)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -