rtw_matlogging.h 6.97 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 * Copyright 1990-2007 The MathWorks, Inc.
 *
 * File: rtw_matlogging.h     $Revision: 1.1.6.1 $
 *
 * Abstract:
 *   Type definitions for MAT-file logging support.
 */

#ifndef __RTW_MATLOGGING_H__
#define __RTW_MATLOGGING_H__

/*
 * 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;

#ifndef NO_FLOATS /* ERT integer-only */

typedef struct RTWLogDataTypeConvert_tag {

    int conversionNeeded;
    BuiltInDTypeId dataTypeIdLoggingTo;
    DTypeId        dataTypeIdOriginal;
    int            bitsPerChunk;
    int            numOfChunk;
    unsigned int   isSigned;
    real_T         fracSlope;
    int            fixedExp;
    real_T         bias;

} RTWLogDataTypeConvert;


typedef struct RTWLogSignalInfo_tag {
    int_T           numSignals;
    int_T          *numCols;
    int_T          *numDims;
    int_T          *dims;
    boolean_T      *isVarDims; /* Dimension Mode: true -- VarDims / false -- fixed dims */
    int_T          **currSigDims; 
                             /* current signal dimensions */
    BuiltInDTypeId *dataTypes;
    int_T          *complexSignals;
    int_T          *frameData;

    union {
        const char_T** cptr;
        char_T**       ptr;
    } labels;

    char_T         *titles;
    int_T          *titleLengths;
    int_T          *plotStyles;

    union {
        const char_T** cptr;
        char_T**       ptr;
    } blockNames;

    union {
        const char_T** cptr;
        char_T**       ptr;
    } stateNames;

    boolean_T      *crossMdlRef;

    RTWLogDataTypeConvert *dataTypeConvert;

} RTWLogSignalInfo;

/* =============================================================================
 * Logging object
 * =============================================================================
 */
typedef struct _RTWLogInfo_tag {
  void              *logInfo;      /* Pointer to a book keeping structure    *
                                    * used in rtwlog.c                       */

  union {
      LogSignalPtrsType cptr; /* Pointers to the memory location    */
      const int8_T**    ptr;  /* of the data to be logged into the  * 
                               * states structure. Not used if      * 
                               * logging data in matrix format.     */
      
  } logXSignalPtrs;

  union {
      LogSignalPtrsType cptr; /* Pointers to the memory location    */
      const int8_T**    ptr;  /* of the data to be logged into the  *
                               * outputs structure. Not used if     *
                               * logging data in matrix format.     */
  } logYSignalPtrs;

  union {
      LogSignalPtrsType cptr; /* Pointers to the memory location  */
      const int8_T**    ptr; /* of the data to be logged into    *
                                           * the signal logging structure.    */
  }sigLogSignalPtrs;

  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 char_T  *logSL;          /* Name of variable(s) to log signal logging */

  union { /* Info about the states             */
      const RTWLogSignalInfo *cptr;
      RTWLogSignalInfo       *ptr;
  } logXSignalInfo;

  union {/* Info about the outptus            */
      const RTWLogSignalInfo *cptr;
      RTWLogSignalInfo       *ptr;
  }logYSignalInfo;

  union { /* Info about the sigLog signals   */
      const RTWLogSignalInfo *cptr;
      RTWLogSignalInfo       *ptr;
  } sigLogSignalInfo;

  void (*mdlLogData)(void *rtli, void *tPtr);

  const void * mmi;    /* Add the ModelMapping Info to the LogInfo 
                        * so we can get at it for state logging */


} RTWLogInfo;

#endif

/* 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))

#define rtliGetLogY(rtli)     (rtli)->logY
#define rtliSetLogY(rtli,ly)  ((rtli)->logY = (ly))

#define rtliGetSigLog(rtli)     (rtli)->logSL
#define rtliSetSigLog(rtli,lsl)  ((rtli)->logSL = (lsl))

#define rtliGetLogXFinal(rtli)     (rtli)->logXFinal
#define rtliSetLogXFinal(rtli,lxf) ((rtli)->logXFinal = (lxf))

#define rtliGetLogXSignalInfo(rtli)     (rtli)->logXSignalInfo.cptr
#define rtliSetLogXSignalInfo(rtli,lxi) ((rtli)->logXSignalInfo.cptr = (lxi))
#define _rtliGetLogXSignalInfo(rtli)    (rtli)->logXSignalInfo.ptr

#define rtliGetLogYSignalInfo(rtli)     (rtli)->logYSignalInfo.cptr
#define rtliSetLogYSignalInfo(rtli,lyi) ((rtli)->logYSignalInfo.cptr = (lyi))
#define _rtliGetLogYSignalInfo(rtli)    (rtli)->logYSignalInfo.ptr

#define rtliGetSigLogSignalInfo(rtli)     (rtli)->sigLogSignalInfo.cptr
#define rtliSetSigLogSignalInfo(rtli,sli) ((rtli)->sigLogSignalInfo.cptr = (sli))
#define _rtliGetSigLogSignalInfo(rtli)    (rtli)->sigLogSignalInfo.ptr

#define rtliGetLogXSignalPtrs(rtli)     (rtli)->logXSignalPtrs.cptr
#define rtliSetLogXSignalPtrs(rtli,lxp) ((rtli)->logXSignalPtrs.cptr = (lxp))
#define _rtliGetLogXSignalPtrs(rtli)    (rtli)->logXSignalPtrs.ptr

#define rtliGetLogYSignalPtrs(rtli)     (rtli)->logYSignalPtrs.cptr
#define rtliSetLogYSignalPtrs(rtli,lyp) ((rtli)->logYSignalPtrs.cptr = (lyp))
#define _rtliGetLogYSignalPtrs(rtli)    (rtli)->logYSignalPtrs.ptr

#define rtliGetSigLogSignalPtrs(rtli)     (rtli)->sigLogSignalPtrs.cptr
#define rtliSetSigLogSignalPtrs(rtli,slp) ((rtli)->sigLogSignalPtrs.cptr = (slp))
#define _rtliGetSigLogSignalPtrs(rtli)    (rtli)->sigLogSignalPtrs.ptr

#define rtliGetMMI(rtli)     (rtli)->mmi
#define rtliSetMMI(rtli,mmiIn) ((rtli)->mmi = ((void *)mmiIn))

/* ========================================================================== */

#endif /* __RTW_MATLOGGING_H__ */