Daily_QC
pro_qtrly.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 extern _SQCURSOR *_iqnprep();
3 #line 1 "/users2/elk/ccp/ifx/pro_qtrly.ec"
4 #include "prototypes.h"
5 /*
6  * EXEC SQL include sqlca.h;
7  */
8 #line 2 "/users2/elk/ccp/ifx/pro_qtrly.ec"
9 #line 1 "/usr/informix/incl/esql/sqlca.h"
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 #ifndef SQLCA_INCL
36 
37 #define SQLCA_INCL
38 
39 struct sqlca_s
40  {
41  long sqlcode;
42  char sqlerrm[72];
43  char sqlerrp[8];
44  long sqlerrd[6];
45 
46 
47 
48 
49 
50 
51  struct sqlcaw_s
52  {
53  char sqlwarn0;
54  char sqlwarn1;
55 
56  char sqlwarn2;
57 
58  char sqlwarn3;
59 
60  char sqlwarn4;
61 
62  char sqlwarn5;
63  char sqlwarn6;
64  char sqlwarn7;
65  } sqlwarn;
66  };
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 #ifdef VMS
77 noshare
78 #endif
79 extern struct sqlca_s sqlca;
80 
81 extern long SQLCODE;
82 
83 #define SQLNOTFOUND 100
84 
85 #endif
86 #line 3 "/users2/elk/ccp/ifx/pro_qtrly.ec"
87 
88 /*
89  * EXEC SQL BEGIN DECLARE SECTION;
90  */
91 #line 4 "/users2/elk/ccp/ifx/pro_qtrly.ec"
92 
93 int eyr, emo, edy;
94 int byr, bmo, bdy;
95 extern struct pro_qrtly_rec
96  {
97  char id[6];
98  char pe1[2];
99  char pe2[2];
100  char dur[2];
101  char t[2];
102  char s[2];
103  char e[2];
104  char p[2];
105  int cal_yr;
106  int mon;
107  int zday;
108  double z00;
109  double z06;
110  double z12;
111  double z18;
112  char qz00[2];
113  char qz06[2];
114  char qz12[2];
115  char qz18[2];
117 /*
118  * EXEC SQL END DECLARE SECTION;
119  */
120 #line 33 "/users2/elk/ccp/ifx/pro_qtrly.ec"
121 
122 
123 extern struct data_rec {
124  char id[9];
125  char source[9];
126  char pe1;
127  char pe2;
128  char dur;
129  char t;
130  char s;
131  char e;
132  char p;
133  int zdate;
134  int ztime;
135  int czdate;
136  int cztime;
137  int idur;
138  double codp;
139  char lwal;
140  int idote;
141  int irev;
142  double value;
143  double values[96];
144  char lwals[96];
145  char pedtsep[8];
147 
148 void change_date();
149 
150 int pro_qtrly(char *hb5,char *parm,struct stim begin_date,struct stim
151 end_date, char *qual, struct stn_values *stn_values)
152 
153 {
154 
155 int i,jtotal,k,atime;
156 int etime,btime;
157 int hour,min;
158 int zdate,hh,qlen;
159 
160 /*
161  * EXEC SQL BEGIN DECLARE SECTION;
162  */
163 #line 72 "/users2/elk/ccp/ifx/pro_qtrly.ec"
164 
165 int edate, bdate;
166 int month, day, year;
167 char sparm[10];
168 struct stat
169  {
170  char hb5[6];
171  char pe1[2];
172  char pe2[2];
173  char dur[2];
174  char t[2];
175  char s[2];
176  char e[2];
177  char p[2];
178  } stat;
179 /*
180  * EXEC SQL END DECLARE SECTION;
181  */
182 #line 89 "/users2/elk/ccp/ifx/pro_qtrly.ec"
183 
184 
185 
186 qlen=strlen(qual);
187 
188 stat.pe1[1]=0;
189 stat.pe2[1]=0;
190 stat.dur[1]=0;
191 stat.t[1]=0;
192 stat.s[1]=0;
193 stat.e[1]=0;
194 stat.p[1]=0;
195 
196 strcpy(stat.hb5,hb5);
197 stat.pe1[0]=parm[0];
198 stat.pe2[0]=parm[1];
199 stat.dur[0]=parm[2];
200 stat.t[0]=parm[3];
201 stat.s[0]=parm[4];
202 stat.e[0]=parm[5];
203 stat.p[0]=parm[6];
204 
205 eyr=end_date.year;
206 emo=end_date.month;
207 edy=end_date.day;
208 etime=end_date.hour*10000+
209  end_date.minute*100;
210 
211 byr=begin_date.year;
212 bmo=begin_date.month;
213 bdy=begin_date.day;
214 btime=begin_date.hour*10000+
215  begin_date.minute*100;
216 
217 year=byr;
218 month=bmo;
219 day=bdy;
220 
221 jtotal=0;
222 
223 for(;;) {
224 
225 /*
226  * EXEC SQL select *
227  * into :qtrly_rec
228  * from proqtrly
229  * where id=:stat.hb5 and
230  * pe1=:stat.pe1 and
231  * pe2=:stat.pe2 and
232  * dur=:stat.dur and
233  * t=:stat.t and
234  * s=:stat.s and
235  * e=:stat.e and
236  * p=:stat.p and
237  * cal_yr=:year and
238  * mon=:month and
239  * zday=:day;
240  */
241 #line 131 "/users2/elk/ccp/ifx/pro_qtrly.ec"
242  {
243 #line 131 "/users2/elk/ccp/ifx/pro_qtrly.ec"
244  static char *sqlcmdtxt[] =
245 #line 131 "/users2/elk/ccp/ifx/pro_qtrly.ec"
246  {
247 #line 131 "/users2/elk/ccp/ifx/pro_qtrly.ec"
248  " select * from proqtrly where id = ? and pe1 = ? and pe2 = ? and dur = ? and t = ? and s = ? and e = ? and p = ? and cal_yr = ? and mon = ? and zday = ?",
249  0
250  };
251 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
252  static _SQCURSOR _SQ0 = {0};
253  static struct sqlvar_struct _sqibind[] =
254  {
255  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
256  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
257  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
258  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
259  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
260  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
261  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
262  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
263  { 102, sizeof(year), 0, 0, 0, 0, 0, 0, 0 },
264  { 102, sizeof(month), 0, 0, 0, 0, 0, 0, 0 },
265  { 102, sizeof(day), 0, 0, 0, 0, 0, 0, 0 },
266 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
267  };
268  static struct sqlvar_struct _sqobind[] =
269  {
270  { 100, 6, 0, 0, 0, 0, 0, 0, 0 },
271  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
272  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
273  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
274  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
275  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
276  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
277  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
278  { 102, sizeof((qtrly_rec).cal_yr), 0, 0, 0, 0, 0, 0, 0 },
279  { 102, sizeof((qtrly_rec).mon), 0, 0, 0, 0, 0, 0, 0 },
280  { 102, sizeof((qtrly_rec).zday), 0, 0, 0, 0, 0, 0, 0 },
281  { 105, sizeof((qtrly_rec).z00), 0, 0, 0, 0, 0, 0, 0 },
282  { 105, sizeof((qtrly_rec).z06), 0, 0, 0, 0, 0, 0, 0 },
283  { 105, sizeof((qtrly_rec).z12), 0, 0, 0, 0, 0, 0, 0 },
284  { 105, sizeof((qtrly_rec).z18), 0, 0, 0, 0, 0, 0, 0 },
285  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
286  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
287  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
288  { 100, 2, 0, 0, 0, 0, 0, 0, 0 },
289 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
290  };
291 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
292  _sqibind[0].sqldata = stat.hb5;
293 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
294  _sqibind[1].sqldata = stat.pe1;
295 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
296  _sqibind[2].sqldata = stat.pe2;
297 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
298  _sqibind[3].sqldata = stat.dur;
299 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
300  _sqibind[4].sqldata = stat.t;
301 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
302  _sqibind[5].sqldata = stat.s;
303 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
304  _sqibind[6].sqldata = stat.e;
305 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
306  _sqibind[7].sqldata = stat.p;
307 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
308  _sqibind[8].sqldata = (char *) &year;
309 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
310  _sqibind[9].sqldata = (char *) &month;
311 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
312  _sqibind[10].sqldata = (char *) &day;
313 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
314  _sqobind[0].sqldata = (qtrly_rec).id;
315 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
316  _sqobind[1].sqldata = (qtrly_rec).pe1;
317 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
318  _sqobind[2].sqldata = (qtrly_rec).pe2;
319 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
320  _sqobind[3].sqldata = (qtrly_rec).dur;
321 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
322  _sqobind[4].sqldata = (qtrly_rec).t;
323 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
324  _sqobind[5].sqldata = (qtrly_rec).s;
325 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
326  _sqobind[6].sqldata = (qtrly_rec).e;
327 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
328  _sqobind[7].sqldata = (qtrly_rec).p;
329 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
330  _sqobind[8].sqldata = (char *) &(qtrly_rec).cal_yr;
331 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
332  _sqobind[9].sqldata = (char *) &(qtrly_rec).mon;
333 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
334  _sqobind[10].sqldata = (char *) &(qtrly_rec).zday;
335 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
336  _sqobind[11].sqldata = (char *) &(qtrly_rec).z00;
337 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
338  _sqobind[12].sqldata = (char *) &(qtrly_rec).z06;
339 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
340  _sqobind[13].sqldata = (char *) &(qtrly_rec).z12;
341 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
342  _sqobind[14].sqldata = (char *) &(qtrly_rec).z18;
343 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
344  _sqobind[15].sqldata = (qtrly_rec).qz00;
345 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
346  _sqobind[16].sqldata = (qtrly_rec).qz06;
347 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
348  _sqobind[17].sqldata = (qtrly_rec).qz12;
349 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
350  _sqobind[18].sqldata = (qtrly_rec).qz18;
351 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
352  _iqslct(&_SQ0, sqlcmdtxt, 11, _sqibind, 19, _sqobind, 0);
353 #line 144 "/users2/elk/ccp/ifx/pro_qtrly.ec"
354  }
355 
356  if(sqlca.sqlcode < 0)
357  return(sqlca.sqlcode);
358 
359  if(sqlca.sqlcode == 0) {
360 
361  get_val06_array();
362 
363  for(k=3;k>=0;k--) {
364 
365  hour=k;
366  atime=hour*60000;
367  zdate=qtrly_rec.cal_yr*10000+qtrly_rec.mon*100+qtrly_rec.zday;
368 
369  if(year==eyr && month==emo && day==edy &&
370  atime < etime)
371  break;
372 
373  if(year==byr && month==bmo && day==bdy &&
374  atime > btime)
375  continue;
376 
377  if(data_record.values[k] < -98)
378  continue;
379 
380  if(*qual != 0) {
381 
382  for(hh=0;hh<qlen;hh++)
383  if(*(qual+hh) == data_record.lwals[k])
384  break;
385 
386  if(hh==qlen)
387  continue;
388 
389  }
390 
391  stn_values[jtotal].value=data_record.values[k];
392  stn_values[jtotal].zdate=zdate;
393  stn_values[jtotal].qual= data_record.lwals[k];
394 
395  stn_values[jtotal++].ztime=atime;
396 
397  }
398 
399 
400  }
401 
402  if(jtotal > 9600)
403  break;
404 
405  if(year==eyr && month==emo && day==edy)
406  break;
407 
409 
410  }
411 
412 return(jtotal);
413 
414 }
415 
417 {
418 
427 
428  return(0);
429 }
430 
431 int mday[]={31,28,31,30,31,30,31,31,30,31,30,31} ;
432 
433 void change_date(int *year,int *month, int*day)
434 
435 {
436 
437 char buf[10];
438 XmString btn_text;
439 Arg args[10];
440 
441 if ((*year)==1972 || (*year)==1976 || (*year)==1980 ||
442  (*year)==1984 || (*year)==1988 || (*year)==1992 ||
443  (*year)==1996 || (*year)==2000 || (*year)==2004 ||
444  (*year)==2008)
445  mday[1]=29;
446 
447 else
448  mday[1]=28;
449 
450 (*day)--;
451 
452 if(*day <= 0) {
453 
454  (*month)--;
455  if(*month==0) {
456 
457  (*year)--;
458  *month=12;
459 
460  }
461 
462  *day=mday[*month-1];
463 
464  }
465 
466 else if(*day > mday[*month-1]) {
467 
468  *(month)++;
469 
470  if(*month > 12) {
471 
472  (*year)++;
473  *month=1;
474 
475  }
476 
477  *day=1;
478 
479  }
480 
481 
482 }
483 
484 
char pe2
Definition: build_list.c:122
char s
Definition: build_list.c:122
char pe1
Definition: build_list.c:122
char dur
Definition: build_list.c:122
char t
Definition: build_list.c:122
char * mon[]
Definition: daily_qc.c:13
int hour
Definition: display_data.c:30
char qual[10]
Definition: display_data.c:29
int day
Definition: display_data.c:30
int year
Definition: display_data.c:30
int month
Definition: display_data.c:30
int get_val06_array()
Definition: pro_qtrly.c:416
int emo
Definition: pro_qtrly.c:93
struct data_rec data_record
long SQLCODE
int bdy
Definition: pro_qtrly.c:94
int mday[]
Definition: pro_qtrly.c:431
int eyr
Definition: pro_qtrly.c:93
int edy
Definition: pro_qtrly.c:93
int bmo
Definition: pro_qtrly.c:94
void change_date()
struct pro_qrtly_rec qtrly_rec
struct sqlca_s sqlca
int byr
Definition: pro_qtrly.c:94
int pro_qtrly(char *hb5, char *parm, struct stim begin_date, struct stim end_date, char *qual, struct stn_values *stn_values)
Definition: pro_qtrly.c:150
_SQCURSOR * _iqnprep()
Definition: can.c:329
int idote
Definition: can.c:346
int cztime
Definition: can.c:342
char source[9]
Definition: can.c:331
char pe2
Definition: can.c:333
char t
Definition: can.c:335
char s
Definition: can.c:336
int irev
Definition: can.c:347
char p
Definition: can.c:338
double values[96]
Definition: can.c:349
char lwal
Definition: can.c:345
int zdate
Definition: can.c:339
char lwals[96]
Definition: can.c:350
int idur
Definition: can.c:343
int ztime
Definition: can.c:340
char pedtsep[8]
Definition: can.c:351
double codp
Definition: can.c:344
char dur
Definition: can.c:334
char pe1
Definition: can.c:332
double value
Definition: can.c:348
char e
Definition: can.c:337
int czdate
Definition: can.c:341
long sqlerrd[6]
Definition: build_list.c:50
long sqlcode
Definition: build_list.c:47
struct sqlca_s::sqlcaw_s sqlwarn
char sqlerrm[72]
Definition: build_list.c:48
char sqlerrp[8]
Definition: build_list.c:49
Definition: misc.h:55
int minute
Definition: misc.h:61
int day
Definition: misc.h:59
int year
Definition: misc.h:57
int hour
Definition: misc.h:60
int month
Definition: misc.h:58
char qual
Definition: misc.h:93
int zdate
Definition: misc.h:90
int ztime
Definition: misc.h:91
float value
Definition: misc.h:92