📄 extsim.h
字号:
/* Copyright 1994-2000 The MathWorks, Inc.
*
* File : extsim.h $Revision: 1.13 $
* Abstract:
* Real-Time Workshop external simulation data structure.
*/
#ifndef __EXTSTRUC__
#define __EXTSTRUC__
#if defined(MathWorks_h)
/* SimStruct being used within Simulink itself */
#undef MATLAB_MEX_FILE
#endif
#include "ext_share.h"
typedef struct ExternalSim_tag ExternalSim;
typedef void (*TargetToHostDataTypeFcn) (
ExternalSim *ESim,
void *dst,
const char *src,
const int nEls,
const int dType); /* internal Simulink data type id */
typedef void (*HostToTargetDataTypeFcn)(
ExternalSim *ESim,
char *dst,
const void *src,
const int nEls,
const int dType); /* internal Simulink data type id */
typedef void (*GenericExtFcn) ( /*any fcn requiring only ESim and mxArray args*/
ExternalSim *ESim,
int_T nrhs,
const mxArray *prhs[]);
typedef int (*DTypeSizeFcn) (
const ExternalSim *ESim,
const int dType);
typedef void (*MexFuncGateWayFcn) (
int nlhs,
mxArray *plhs[],
int nrhs,
const mxArray *prhs[]);
#define EXTSIM_VERSION (sizeof(ExternalSim)*10000 + 200)
typedef enum {
EXTMODE_UNCONNECTED, /* must be 0 */
EXTMODE_CONNECTED,
EXTMODE_DISCONNECT_REQUESTED,
EXTMODE_DISCONNECT_PENDING,
EXTMODE_DISCONNECT_CONFIRMED
} ConnectionStatus;
struct ExternalSim_tag {
/*
* Common info.
*/
int version;
const char *modelName; /* the name of the model */
const void *bd; /* ptr to block diagram - internal use */
uint32_T targetModelCheckSum[4]; /* 128 bit model checksum */
TargetSimStatus targetSimStatus; /* status of target */
ExtModeAction action; /* action flag - determines current operation */
boolean_T verbose; /* verbose mode? */
ConnectionStatus connectionStatus;
char errMsg[1024]; /* msg to display upon error from an external
* call. Empty ('\0') if no error. */
void *userData; /* externally allocated and freed (e.g., ext_comm.c) */
struct {
const char *buf; /* communication buffer - used for downloads */
int nBytes; /* size of communication buffer - in host bytes */
} commBuf;
/*
* Reception of target messages.
*/
struct {
int_T pending;
ExtModeAction msg;
int bufSize; /* allocated size of the buffer */
char *buf; /* the buffer */
int nBytesInBuffer; /* number of valid bytes in buffer */
int nBytesNeeded; /* nbytes needed until we can process this buffer */
/*
* Function (implemented in ext_comm) that retrieves the msg
* from the target.
*/
GenericExtFcn recvIncomingMsgFcn;
} incomingMsg;
/*
* Reception of target logging data.
*/
struct {
int bufSize; /* allocated size of the buffer */
char *buf; /* the buffer */
int nBytesInBuffer; /* number of valid bytes in buffer */
int nBytesNeeded; /* nbytes needed until we can process this buffer */
/*
* Function (implemented in ext_comm) that retrieves the logging data
* from the target.
*/
GenericExtFcn recvIncomingLogDataFcn;
} incomingLogData;
/*
* Target data represention.
*/
struct {
boolean_T swapBytes; /* change byte order? */
uint8_T hostBytesPerTargetByte; /* Number of host bytes per target
* byte. A byte is not always 8 bits
* (see compiler for C30/C40).
*/
uint32_T numDataTypes; /* Number of data types in use in Simulink
* model. This is a read only field outsize of
* Simulink (used for consistency check). This
* is NOT the number of registeted data types,
* but the number of data types that are in use
* in a model!
*/
uint32_T *dataTypeSizes; /* Size (on the target, in target bytes) of
* each data type in use.
*/
/*
* Data Conversion functions for built-in Simulink Data Types.
*/
TargetToHostDataTypeFcn doubleTargetToHostFcn;
HostToTargetDataTypeFcn doubleHostToTargetFcn;
TargetToHostDataTypeFcn singleTargetToHostFcn;
HostToTargetDataTypeFcn singleHostToTargetFcn;
TargetToHostDataTypeFcn int8TargetToHostFcn;
HostToTargetDataTypeFcn int8HostToTargetFcn;
TargetToHostDataTypeFcn uint8TargetToHostFcn;
HostToTargetDataTypeFcn uint8HostToTargetFcn;
TargetToHostDataTypeFcn int16TargetToHostFcn;
HostToTargetDataTypeFcn int16HostToTargetFcn;
TargetToHostDataTypeFcn uint16TargetToHostFcn;
HostToTargetDataTypeFcn uint16HostToTargetFcn;
TargetToHostDataTypeFcn int32TargetToHostFcn;
HostToTargetDataTypeFcn int32HostToTargetFcn;
TargetToHostDataTypeFcn uint32TargetToHostFcn;
HostToTargetDataTypeFcn uint32HostToTargetFcn;
TargetToHostDataTypeFcn boolTargetToHostFcn;
HostToTargetDataTypeFcn boolHostToTargetFcn;
} TargetDataInfo;
/*
* Callbacks into Simulink to query data type info.
* NOTE:
* These functions are generally not valid until after both
* EXT_CONNECT_RESPONSE messages are processed by the host
* (Simulink).
*/
struct {
DTypeSizeFcn sizeOfTargetDataType; /* Return size of data type on
* target:
* target format/target bytes */
DTypeSizeFcn sizeOfDataType; /* Return size of data type on host (Simulink)
* (Simulink). */
} DTypeFcn;
/* "shortcut" for calling mexfile */
MexFuncGateWayFcn mexFunc;
};
/*==============================================================================
* Public access methods for external use (e.g., ext_comm.c).
*
* NOTE: Fields that do not have access macros should not be used
* externally (e.g., by ext_comm.c)!
*============================================================================*/
/*
* Common fields.
*/
#define esSetVersion(ESim, val) ((ESim)->version = (val))
#define esSetModelName(ESim, val) ((ESim)->modelName = (val))
#define esGetModelName(ESim) ((ESim)->modelName)
#define esSetTargetModelCheckSum(ESim, el, val) \
((ESim)->targetModelCheckSum[(el)] = (val))
#define esSetTargetSimStatus(ESim, val) ((ESim)->targetSimStatus = (val))
#define esGetTargetSimStatus(ESim) ((ESim)->targetSimStatus)
#define esGetAction(ESim) ((ESim)->action)
#define esSetVerbosity(ESim, val) ((ESim)->verbose = (val))
#define esGetVerbosity(ESim) ((ESim)->verbose)
#define esGetConnectionStatus(ESim) ((ESim)->connectionStatus)
#define esSetError(ESim, str) ((void)strcpy((ESim)->errMsg, (str)))
#define esGetError(ESim) ((ESim)->errMsg)
#define esClearError(ESim) ((*(ESim)->errMsg) = '\0')
#define esIsErrorClear(ESim) ((*(ESim)->errMsg) == '\0')
#define esSetUserData(ESim, val) ((ESim)->userData = (val))
#define esGetUserData(ESim) ((ESim)->userData)
#define esGetCommBuf(ESim) ((ESim)->commBuf.buf)
#define esGetCommBufSize(ESim) ((ESim)->commBuf.nBytes)
#define esSetIncomingMsgPending(ESim, val) ((ESim)->incomingMsg.pending = (val))
#define esSetIncomingMsg(ESim, val) ((ESim)->incomingMsg.msg = (val))
#define esGetIncomingMsgDataBufSize(ESim) ((ESim)->incomingMsg.bufSize)
#define esGetIncomingMsgDataBuf(ESim) ((ESim)->incomingMsg.buf)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -