← Back to dashboard

File view

plc_constants.lib

1
//$Id: plc_constants.lib,v 1.6 2008-09-04 10:49:49 charlie Exp $
2
/*
3
   $Log: plc_constants.lib,v $
4
5
6
*/
7
8
/*** BeginHeader */
9
10
#ifndef __ISM_CONSTANTS_
11
#define __ISM_CONSTANTS_
12
13
/*** EndHeader */
14
15
/*** BeginHeader
16
17
*/
18
19
////////////////////////////////////////////////
20
//  Version Status
21
#define VERSION_STATUS_DEVELOPMENT 		"D"
22
#define VERSION_STATUS_ALPHA 			"A"
23
#define VERSION_STATUS_BETA 			"B"
24
#define VERSION_STATUS_PRODUCTION 		""
25
#define VERSION_STRING_MAX_LENGTH 	16
26
#define VERSION_PREAMBLE 				"Version "
27
28
////////////////////////////////////////////////
29
//  Display Length
30
#define DISPLAY_LENGTH 						16
31
#define DISPLAY_LENGTH_DEF 			(DISPLAY_LENGTH + 1)
32
#define REMOTE_DISPLAY_LENGTH 				10
33
#define REMOTE_DISPLAY_LENGTH_DEF 	(REMOTE_DISPLAY_LENGTH + 1)
34
#define DSP_HOLD							1500
35
#define DSP_CHAN_HOLD 						300000 
36
37
#define DEBUG_POST_TIME 					5000
38
#define CYCLE_COUNTERS						2
39
40
// Bank Control Register Constants
41
42
#define ONE_WAIT 			0xC0
43
#define THREE_WAIT 			0X80
44
#define SEVEN_WAIT 			0x40
45
#define FIFTEEN_WAIT 		0x00
46
47
#define CHIP_SELECT 		0x00
48
#define READ_STROBE 		0x10
49
#define WRITE_STROBE 		0x20
50
#define BOTH_STROBE 		0x30
51
52
#define PERMIT_WRITE 		0x08
53
#define INHIBIT_WRITE 		0x00
54
55
// Global constants for keyboard scanner ************************************************
56
57
#define NONEPB  0
58
#define SETUPPB 8
59
#define TESTPB  6
60
#define PRINTPB 4
61
#define RESETPB 2
62
#define UPPB    5
63
#define CLEARPB 3
64
#define ENTERPB 1
65
#define DOWNPB  7
66
#define N_PB    8
67
68
// Various diagnostic print functions
69
70
#define ERROR(s)   printf("Error: %s", s)
71
#define WARNING(s) printf("Warning: %s", s)
72
#define DIAG       printf
73
74
// Various declorations
75
76
#define LEVEL95 	4
77
#define LEVEL90 	3
78
#define LEVEL70 	2
79
#define LEVEL60 	1
80
#define LEVEL10 	0
81
#define LEVEL0		-1
82
83
#define SAME		-1
84
#define UP		 	1
85
#define DOWN	 	0
86
87
#define ON 			1
88
#define OFF 		0
89
90
#define CODE 		1234
91
92
#define PROBELEVELS 			5
93
#define PROBEOFFSET 			1
94
95
#define ALARM95_OUTPUT_BIT 		7
96
#define ALARM10_OUTPUT_BIT 		6
97
98
#define BEEP_ON_MS 				66
99
#define BEEP_OFF_MS 			66
100
101
#define PRES_LOW				0
102
#define PRES_MED				1
103
#define PRES_HIGH				2
104
#define PLC_HIGH_PRES     		22
105
#define PLC_LOW_PRES      		14
106
107
#define DEFAULT_RESIL		50  	//TODO change this back to default after testing
108
#define DEFAULT_RUN       	24
109
#define DEFAULT_DELAY		105	//Time for main loop state? Was 420 changed
110
#define DEFAULT_HIGH_PRES 	22
111
#define DEFAULT_LOW_PRES  	14
112
#define DEFAULT_DELTA     	8
113
114
#define INPUT_INACTIVE		0   	// Inactive must be 0
115
#define INPUT_ACTIVE		1
116
#define INPUT_LEAD_EDGE		2
117
#define INPUT_TRAIL_EDGE	3
118
119
#define SUMP_OPEN			0
120
#define SUMP_CLOSED			1
121
122
#define AUTH_INPUT			0
123
#define AUTH_CASCADE		1
124
#define AUTH_DEMAND			2
125
126
#define OPEN_FILE			1
127
#define CLOSE_FILE			2
128
#define NEXT_ALARM			3
129
#define PREVIOUS_ALARM		4
130
131
#define N_ISM 				4
132
#define N_PROD 				4
133
#define N_LDN  				4
134
#define N_INPUTS 			8
135
#define N_AC_INPUTS 		8
136
#define AUTH_OFFSET 		0
137
#define N_OUTPUTS 			8
138
#define N_PRES_INPUTS 		4
139
#define N_SUMP_INPUTS 		4
140
#define SUMP_OFFSET 		0
141
#define PRES_OFFSET 		4
142
#define SO_OFFSET 			8
143
#define AUTH_TIME_ON    	0
144
#define AUTH_TIME_OFF   	1
145
#define N_AUTH_INPUTS 		4
146
#define CV_OFFSET 			4
147
148
#define AUTH_RUN        	2
149
150
#define MIN_RUN_TIME 		2
151
#define MAX_RUN_TIME 		99
152
153
#define MINIMUMTIME 		3
154
#define STABLE_TIME      	2       	//TODO set this a bit more dynamically.
155
#define PISTONDLY 		 	20
156
#define DONEDLY 			5
157
#define AUTHDLY          	2000
158
#define AUTH_DIS_TIME    	5000
159
#define PSDLY         		100
160
#define K_DELAY				2
161
#define PT_CYCLES			10
162
#define MAXPRESSDLY  		120           //max time to reestablish line pressure
163
#define PRESSUREDLY  		20            //delay for pressure detect is 20 sec
164
#define STANDBYDLY   		5            //5 sec delay for turbine start
165
#define KBDTIMEOUT   		30            //data entry time window
166
#define SHUNTSTART   		1000          //time to initialize shunt valve is 1 sec
167
#define P_CHECK_TIME 		5000          //CV Open time for pressure check, SCH2
168
#define MINHOLDTIME  		2             //Min time to wait after a shunt
169
#define MAXSHUNTTIME 		180           //Max time to spend in vent. 
170
171
#define MONTHINSEC 			2592000
172
173
// Define output
174
175
#define TURBINE0_OUTPUT_BIT 0
176
#define TURBINE1_OUTPUT_BIT 1
177
#define TURBINE2_OUTPUT_BIT 2
178
#define TURBINE3_OUTPUT_BIT 3
179
#define TURBINE4_OUTPUT_BIT 4
180
#define TURBINE5_OUTPUT_BIT 5
181
#define TURBINE6_OUTPUT_BIT 6
182
#define TURBINE7_OUTPUT_BIT 7
183
184
#define ALARM0_OUTPUT_BIT 7
185
#define ALARM1_OUTPUT_BIT 7
186
187
// Define inputs
188
189
#define PRES0_INPUT_BIT 0
190
#define PRES1_INPUT_BIT 2
191
#define PRES2_INPUT_BIT 4
192
#define PRES3_INPUT_BIT 6
193
#define SUMP0_INPUT_BIT 1
194
#define SUMP1_INPUT_BIT 3
195
#define SUMP2_INPUT_BIT 5
196
#define SUMP3_INPUT_BIT 7
197
#define AUTH0_INPUT_BIT 8
198
#define AUTH1_INPUT_BIT 9
199
#define AUTH2_INPUT_BIT 10
200
#define AUTH3_INPUT_BIT 11
201
#define AUTH4_INPUT_BIT 12
202
#define AUTH5_INPUT_BIT 13
203
#define AUTH6_INPUT_BIT 14
204
#define AUTH7_INPUT_BIT 15
205
206
//Alarm Codes
207
#define NO_ALARM			0 		// No hiatory recorded, turns off alarm annunciator
208
#define NO_PRES_ALARM	1		//	Low line pressure, pump unable to achieve high pressure
209
#define LOW_PRES_ALARM 	2		//	Mid line pressure, pump unable to achieve high pressure
210
#define NO_FLOW			3		// Flow switch fails to detect fuel flow
211
#define FAIL_3GPH		4		// 3 GPH or > detected
212
#define TEST_ABORT		5 		//	Operator aborted precision test sequence
213
#define SUMP_ALARM		6     	// Sump Alarm
214
#define SENSOR_ALARM    7     	// Sensor Out alarm
215
#define NO_PRES_DROP    8     	// Can not vent off pressure
216
#define DISP_ALARM		256		// Flag to display and print alarm
217
218
//Warning Codes
219
#define NO_WARNING      10
220
#define NO_PRES_WARN    11
221
#define FAIL_3GPH_WARN  12
222
#define TEST_ABORT_WARN 13
223
#define BAD_CHECK_WARN  14
224
225
// Define log types
226
227
#define ALM_OPEN				0
228
#define ALM_CLOSED				1
229
230
// Log Types
231
#define TEST_LOG 				1
232
#define ALRM_LOG 				2
233
#define SYST_LOG 				3
234
#define WARN_LOG				4
235
236
// System Codes
237
#define REBOOT					0
238
239
#define OPEN_FILE				1
240
#define CLOSE_FILE				2
241
#define NEXT_EVENT   			3
242
#define PREVIOUS_EVENT     		4
243
244
#define CONNECT_FAIL 		-10
245
#define OPEN_FAIL 			-11
246
#define SHORT_READ 			-12
247
#define NO_FREE_SPACE 		-13
248
249
#define SD_ALARM_ONLY      0
250
#define SD_PER_PRODUCT     1
251
#define SD_PER_CHANNEL     2
252
#define SD_NO_DISPENSE		3
253
254
// Comm Defines
255
#define COMM_FILTER     6
256
#define COMM_TEST       5
257
#define COMM_VENT       4
258
#define COMM_REPRESSURE 3
259
#define COMM_DISPENSE   2
260
#define COMM_IDLE       1
261
#define COMM_ALARM      0
262
263
// Define network
264
265
#define ERROR_MESSAGE_LENGTH 200
266
#define PRODUCT_NAME_STRING "    PLC-5201    "
267
#define MB_MASTER_BAUD_IDX 	6
268
#define NUM_LDN_COMM_RETRIES 	5
269
#define CONNECT_FAIL 		-10
270
#define OPEN_FAIL 			-11
271
#define SHORT_READ 			-12
272
#define NO_FREE_SPACE 		-13
273
#define PROGRAM_SERVER_HOST "humhost.com"
274
#define PROGRAM_SERVER_PORT 80
275
#define CONFIG_FILENAME 	"config.dat"
276
#define LOG_FILENAME 		"statuslog.dat"
277
278
// Baud Rate List
279
const int  BaudRateLength = 	13;
280
const long BaudRate[] = {  	110,
281
	                           300,
282
	                           1200,
283
	                           2400,
284
	                           4800,
285
	                           9600,
286
	                           19200,
287
	                           38400,
288
	                           57600,
289
	                           115200,
290
	                           230400,
291
	                           460800,
292
	                           921600 };
293
294
// Offset List
295
const int OffsetLength  = 		7;
296
const unsigned Offset[] = {	00000,
297
	                           10000,
298
	                           20000,
299
	                           30000,
300
	                           40000,
301
	                           50000,
302
	                           60000 };
303
304
extern char ErrorMessage[ERROR_MESSAGE_LENGTH + 1]; // global error message
305
306
// These function prototypes for autopak_battery_backup
307
//  must appear here, so that the module can go last
308
//  in memory
309
310
int  BatteryNotOK (void);
311
void SetTestWord  (void);
312
void ClearTestWord(void);
313
314
/*** EndHeader */
315
316
/*** BeginHeader */
317
#endif
318
/*** EndHeader */