versadac  1
versadac - Scalable Recorder Firmware
stdtypes.h
1 /* --------------------------------------------------------------------------
2  * Copyright (c) 2001 Eurotherm Controls Limited.
3  *
4  * File: stdtypes.h
5  * Author: Steve Robinson
6  * Date: 14th January, 2010
7  * Content: Standard general purpose data types
8  *
9  * --------------------------------------------------------------------------
10  */
11 
12 #ifndef STDTYPES_H
13 #define STDTYPES_H
14 
15 #ifndef WIN32
16 #include "semLib.h"
17 #endif
18 
19 #ifndef NULL
20 #define NULL (0)
21 #endif
22 
23 /* Enable for function block exection timing statistics */
24 /* #define FB_EXEC_TIMINGS_ENABLED (1) */
25 
26 #define MSG_MIN_REQ_SIZE (MSG_DATE_SIZE+MSG_TIME_SIZE+MSG_FIXED_TEXT+MSG_VCHAN_TEXT+MSG_CHAN_TEXT+1) /* Include NULL */
27 
28 /* Message summary message buffer sizes */
29 #define MSG_DATE_SIZE 9 /* "xx/xx/xx/ " */
30 #define MSG_TIME_SIZE 9 /* "xx:xx:xx " */
31 #define MSG_FIXED_TEXT 11 /* "Inactive: " */
32 #define MSG_VCHAN_TEXT (11*2*15) /* "VChxx(Alx) " * 2 alarms per channel * 15 Vchannels */
33 #define MSG_CHAN_TEXT (9*2*4) /* "Chx(Alx) " * 2 alarms per channel * 4 channels */
34 
35 #define SAFETOUSE 1
36 #define INITFAILED 0
37 
38 #define SUCCESS 0
39 #define FAIL 1
40 #define GROUP_IDENT 1
41 #define POINT_IDENT 2
42 #define ALARM_IDENT 3
43 
44 #define MAX_STRING_LENGTH 101 /* 100 characters + null terminator */
45 #define MAX_REC_MESSAGE_LENGTH 301 /* 300 characters + null terminator, for recorded messages */
46 
47 #ifdef WIN32
48 //**************************************************************************/
49 // Disable Compiler warning 4100 - unreferenced formal parameter
50 #pragma warning(disable:4100)
51 
52 // Disable Compiler warning 4101 - unreferenced local variable
53 //#pragma warning(disable:4101)
54 
55 // ***** WE MIGHT WANT TO REVIEW THIS AT SOME POINT ******/
56 // Disable Compiler warning 4214 - nonstandard extension used : bit field types other than int
57 #pragma warning(disable:4214)
58 
59 // ***** WE MIGHT WANT TO REVIEW THIS AT SOME POINT ******/
60 // Disable Compiler warning 4121 - alignment of a member was sensitive to packing
61 #pragma warning(disable:4121)
62 
63 // ***** WE MIGHT WANT TO REVIEW THIS AT SOME POINT ******/
64 // Disable Compiler warning C4310 - warning C4310: cast truncates constant value
65 //#pragma warning(disable:4310)
66 
67 #endif
68 
69 #ifndef __cplusplus
70 typedef unsigned char bool;
71 #endif
72 
73 typedef signed char int8;
74 typedef unsigned char uint8;
75 typedef signed short int16;
76 typedef unsigned short uint16;
77 typedef signed long int32;
78 typedef unsigned long uint32;
79 typedef unsigned long long uint64;
80 typedef signed long sint32;
81 typedef signed short sint16;
82 typedef signed char sint8;
83 typedef signed long long sint64;
84 typedef unsigned char byte;
85 typedef signed long time32;
86 typedef float float32;
87 typedef double float64;
88 typedef uint8 string_t; /* A string reference */
89 typedef char *string_p; /* Previously known as "string" */
90 typedef uint16 unicode_c; /* A single unicode character */
91 typedef unicode_c *unicode_p; /* Pointer to a single unicode character */
92 typedef unicode_c uc_char;
93 typedef unicode_c uc_string_5[5+1];
94 typedef unicode_c uc_string_7[7+1];
95 typedef unicode_c uc_string_8[8+1];
96 typedef unicode_c uc_string_20[20+1];
97 typedef unicode_c uc_string_30[30+1];
98 typedef unicode_c uc_string_40[40+1];
99 typedef unicode_c uc_string_60[60+1];
100 typedef unicode_c uc_string_100[100+1];
101 typedef unicode_c uc_string_200[200+1];
102 typedef unicode_c uc_string_300[300+1];
103 typedef char string_5[5+1];
104 typedef char string_7[7+1];
105 typedef char string_8[8+1];
106 typedef char string_20[20+1];
107 typedef char string_30[30+1];
108 typedef char string_40[40+1];
109 typedef char string_60[60+1];
110 typedef char string_100[100+1];
111 typedef char string_200[200+1];
112 typedef char string_300[300+1];
113 typedef sint8 status;
114 
115 /* Define special type consisting of a float and a status (used mainly for PV) types */
116 typedef struct {
117  float32 value;
118  uint8 status;
119 } f32_status_t;
120 
121 /* Special type for edge detection this is platform dependent */
122 typedef struct {
123  bool pad1:1;
124  bool pad2:1;
125  bool pad3:1;
126  bool pad4:1;
127  bool pad5:1;
128  bool pad6:1;
129  bool old_val:1; /* The previous value of the incoming wire */
130  bool value:1;
131 } edge_t;
132 
133 /* Define a union of values types */
134 typedef union {
135  uint8 u8;
136  int16 i16;
137  int32 i32;
138  time32 t32;
139  float32 f32;
140  f32_status_t f32_s;
141  unicode_p ustring_p;
142 } union_t;
143 
144 typedef struct
145 {
146  sint8 secs;
147  sint8 mins;
148  sint8 hours;
149  sint8 date;
150  sint8 month;
151  sint8 day;
152  sint16 year;
153 } time_date_t;
154 
155 typedef struct
156 {
157  double value;
158  uint8 status;
159  uint8 id;
160 } pv_t;
161 
162 typedef struct
163 {
164  double scale_high;
165  double scale_low;
166  uint8 type;
167  uint8 pv_format;
168  uc_string_8 open_str;
169  uc_string_8 close_str;
170  uc_string_5 units;
171  uc_string_7 tag;
172  uc_string_30 descriptor;
173 } pv_ident_t;
174 
175 typedef struct
176 {
177  double value;
178  uint8 status;
180 
181 
182 typedef struct q_reader
183 {
184  struct q_reader * reader_chain;
185  uint8 * head;
186  void * id;
187 } queue_reader;
188 
189 typedef struct q_hdr
190 {
191  struct q_hdr * queue_chain;
192  char queue_name[8];
193  uint8 * tail;
194  queue_reader * reader_chain;
195  uint8 * lock;
196  uint32 size;
197  uint16 users;
198  uint16 fail_size;
199 } queue_hdr;
200 
201 typedef const char * queue_name;
202 typedef queue_hdr * queue_id;
203 
204 typedef struct
205 {
206  queue_name q_name;
207  queue_id q_id;
208 } queue;
209 
210 typedef queue * queue_addr;
211 
212 #ifndef WIN32
213 typedef struct
214 {
215  bool used;
216  char name[4];
217  MSG_Q_ID msg_q;
218  uint8 state;
219 } xcb;
220 
221 typedef xcb * exchange_id;
222 
223 typedef struct
224 {
225  bool used;
226  char name[5];
227  uint8 priority;
228  uint16 sss;
229  uint16 uss;
230  int args[10];
231  int tid;
232  uint16 events_mask;
233  uint16 events_pending;
234  uint16 events_received;
235  uint8 state;
236  uint8 event_type;
237  SEM_ID event_sem;
238 } tcb;
239 
240 typedef tcb * process_id;
241 #endif
242 
243 typedef struct
244 {
245  unsigned char archive_to_ftp;
246  unsigned char archive_to_media;
247  unsigned char record;
248  uint8 trend_type;
249  uint8 circular_full_action;
250  uint8 circular_start_at;
251  uint8 grid_type;
252  uint8 grid_scale_type;
253  uint8 grid_divs_or_decades;
254  uint8 grid_divs_minor;
255  float32 grid_span_high;
256  float32 grid_span_low;
257  float32 grid_zone_high;
258  float32 grid_zone_low;
259  float32 grid_span_high_b;
260  float32 grid_span_low_b;
261  float32 grid_zone_high_b;
262  float32 grid_zone_low_b;
263  uint32 trend_update_rate;
264  uint32 trend_update_rate_b;
265  uint32 recording_interval;
266  uint32 recording_interval_b;
267  uc_string_20 descriptor;
268 } group_ident_t;
269 
270 typedef struct
271 {
272  float32 setpoint;
273  unsigned char enable;
274  uint8 type;
275  float32 deviation;
276  float32 amount;
277  uint16 changeTime;
278  void *pSpSrc;
279 } alarm_ident_t;
280 
281 typedef enum
282 {
283  ColourRed,
284  ColourBlue,
285  ColourGreen,
286  ColourHoney,
287  ColourViolet,
288  ColourRusset,
289  ColourDarkBlue,
290  ColourJade,
291  ColourMagenta,
292  ColourDuskyRose,
293 
294  ColourYellow,
295  ColourPowderBlue,
296  ColourDarkRed,
297  ColourAvocado,
298  ColourIndigo,
299  ColourDarkBrown,
300  ColourAegean,
301  ColourCyan,
302  ColourAubergine,
303  ColourDarkOrange,
304 
305  ColourPaleYellow,
306  ColourHyacinth,
307  ColourDarkGreen,
308  ColourSugarPink,
309  ColourBluebell,
310  ColourOrange,
311  ColourPink,
312  ColourButtersilk,
313  ColourTerracotta,
314  ColourBlueBabe,
315 
316  ColourLime,
317  ColourBlueJive,
318  ColourCucumber,
319  ColourEuroGreen,
320  ColourWheatgerm,
321  ColourSeaBlue,
322  ColourGinger,
323  ColourAquaPool,
324  ColourPaleRed,
325  ColourPaleBlue,
326 
327  ColourLilac,
328  ColourSkyBlue,
329  ColourWildMoss,
330  ColourTurquoise,
331  ColourPaleGreen,
332  ColourCoffee,
333  ColourWicker,
334  ColourBlack,
335  ColourDkDkGray,
336  ColourDarkGray,
337 
338  ColourGray,
339  ColourLtLtDkGray,
340  ColourLtDkGray,
341  ColourLightGray,
342  ColourLtLtGray,
343  ColourWhite
344 } colour_enum_t;
345 
346 typedef struct
347 {
348  float32 span_high;
349  float32 span_low;
350  float32 zone_high;
351  float32 zone_low;
352  float32 span_high_b;
353  float32 span_low_b;
354  float32 zone_high_b;
355  float32 zone_low_b;
356  uint8 type; /* i.e Analog, Math, counter, totaliser */
357  uint8 instance_of_type;
358  uint8 pv_format;
359  uint8 max_decimal_digits;
360  uint8 scale_type;
361  uint8 scale_divs_major;
362  uint8 scale_divs_minor;
363  uint8 colour;
364  uint8 colour_b;
365  uc_string_5 units;
366  uc_string_8 open_str;
367  uc_string_8 close_str;
368  uc_string_20 descriptor;
369 } point_ident_t;
370 
371 typedef struct
372 {
373  uint8 function; /* i.e add, subtract, comms, mV, V, test */
374  point_ident_t common;
376 
377 #endif
Definition: stdtypes.h:144
Definition: stdtypes.h:122
Definition: stdtypes.h:270
Definition: stdtypes.h:371
Definition: stdtypes.h:134
Definition: stdtypes.h:189
Definition: stdtypes.h:116
Definition: stdtypes.h:175
Definition: stdtypes.h:204
Definition: stdtypes.h:155
Definition: stdtypes.h:243
Definition: stdtypes.h:346
Definition: stdtypes.h:182
Definition: stdtypes.h:223
Definition: stdtypes.h:213
Definition: stdtypes.h:162