forked from Discriminator/PDW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decode.cpp
750 lines (621 loc) · 17.8 KB
/
decode.cpp
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
// Decode.cpp
//
// Serial port decoding routines.
//
// pdw_decode():
//
// - Decides which functions to call for decoding:
// POCSAG/FLEX/ACARS/MOBITEX or ERMES signals.
// - Decides when to log/messages statistics info.
// - Calls the signal indicator.
//
#ifndef STRICT
#define STRICT 1
#endif
#include <windows.h>
#include "headers\PDW.h"
#include "headers\initapp.h"
#include "headers\sigind.h"
#include "headers\decode.h"
#include "headers\acars.h"
#include "headers\mobitex.h"
#include "headers\ermes.h"
#include "headers\helper_funcs.h"
#include "utils\debug.h"
FILE *pd_raw_fp = NULL; // Debug - Raw data file for logging POCSAG/FLEX symbol data.
char szCurrentDate[40]=""; // PH: Buffer for current date
char szCurrentTime[40]=""; // PH: Buffer for current time
// Filter globals
FILTER filter;
// Statistics - globals
unsigned long hourly_stat[NUM_STAT][2];
unsigned long hourly_char[NUM_STAT][2];
unsigned long daily_stat[NUM_STAT][2];
unsigned long daily_char[NUM_STAT][2];
SYSTEMTIME statTime;
SYSTEMTIME prev_statTime;
int stat_timer = 0;
char ob[32];
//unsigned int bch[1025];
//unsigned int ecs[25]; // error correction sequence
int ircver=0;
double ct1600, ct3200, ct_bit;
double rcver[64]; // rcv clock error ring buf
double exc=0.0;
// receive symbol clock tightness - lower numbers mean slower loop response
double rcv_clkt = 0.065; // rcv loop clock tightness
double rcv_clkt_hi = 0.065; // coarse rcv clock (sync ups only)
double rcv_clkt_fl = 0.015; // fine rcv clock (data) - FLEX
double rcv_clkt_po = 0.025; // fine rcv clock (data) - POCSAG/ACARS
double rcv_clkt_mb = 0.080; // sync ups & data - Mobitex
double rcv_clkt_em = 0.030; // sync ups & data - Ermes
// Flex globals
FLEX phase_A, phase_B, phase_C, phase_D; // FLEX phases
int flex_timer = 0; // FLEX active timer
bool bReflex = false; // Reflex mode flag
bool bFlexActive = false; // FLEX mode flag
// Pocsag globals
POCSAG pocsag;
int pocsag_baud_rate; // Pocsag baudrate
int pocbit = 0; // Pocsag mode flag
// this table translates received modem status line combinations into
// the received symbol; it gives the number of modem status lines that
// are high (other than RI) for a given line status nybble
int rcv[16]={ 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3 };
// These hold or track VxD input data from comport
unsigned long bufsize;
unsigned long *cpstn = NULL;
unsigned short int *freqdata = NULL;
unsigned char *linedata = NULL;
unsigned int pd_i=0, pd_cw1=49, pd_cw0=48, pd_ldsr=0;
unsigned int pd_lcw=0, pd_dsr=0;
signed int pd_ct5=0, pd_ct12=0, pd_ct16=0, pd_ct24=0, pd_dinc=0;
double pd_clk=0.0, pd_rer=0.0;
int sig_flg=0;
// HWi Add variables to hold the original values when in playback mode
unsigned long old_bufsize;
unsigned long *old_cpstn;
unsigned short int *old_freqdata;
unsigned char *old_linedata;
// Reset all main variables, when switching between
// serial port and soundcard.
void pd_reset_all(void)
{
pd_i=0, pd_cw1=49, pd_cw0=48, pd_ldsr=0;
pd_dsr=0, pd_lcw=0;
pd_ct5=0, pd_ct12=0, pd_ct16=0, pd_ct24=0, pd_dinc=0;
pd_clk=0.0, pd_rer=0.0;
mb.reset(); // reset mobitex routines
acars.reset(); // reset acars routines
pocsag.frame(-1); // reset pocsag routines
flex_reset(); // reset flex routines
if (Profile.monitor_acars) // Decoding ACARS?
{
exc = 0.0;
rcv_clkt = rcv_clkt_po;
ct_bit = 496.4;
}
else if (Profile.monitor_mobitex) // Decoding Mobitex?
{
exc = 0.0;
rcv_clkt = rcv_clkt_mb; // sync-ups & data.
ct_bit = 1.0/((float) mb.bitrate * 839.22e-9);
// ct_bit = 993.0;
}
else if (Profile.monitor_ermes) // Decoding Ermes?
{
em.frame(-1); // Reset ermes routines!
exc = 0.0;
rcv_clkt = rcv_clkt_em; // sync-ups & data
ct_bit = 1.0/(3125.0*838.8e-9);
}
else if (Profile.monitor_paging)
{
ct_bit = ct1600; // reset rcv clock to 1600 baud
rcv_clkt = rcv_clkt_hi; // widen up rcv clk loop again
}
}
// RAH: Record and playback
FILE *pRecording = NULL; // Pointer to recording file
bool bPlayback = false; // Playback in progress
bool bRecording = false; // Recording in progress
bool bAutoRecording = false; // AutoRecording in progress
struct
{
unsigned short int freqdata;
unsigned char linedata;
} recdata;
int recsize = 3; // Ignore word alignment, 3 bytes exact
unsigned long nextcpstn = 1; // Ahead of cpstn for playback
unsigned long rcpstn = 0; // Index used by cpstn for playback
unsigned short int ltick; // Last tick for pocflex rec compatibility
#define RECBUFSIZE 4096
#define FILEBUFSIZE 2048
// Playback and file buffers
unsigned short int rfreqdata[RECBUFSIZE];
unsigned char rlinedata[RECBUFSIZE];
char rbuffer[FILEBUFSIZE];
// RAH: Start playback of recording
bool Start_Playback(LPTSTR lpstrFile)
{
pd_reset_all();
// HWi Save values to restore it after the playback
old_cpstn = cpstn;
old_freqdata = freqdata;
old_linedata = linedata;
old_bufsize = bufsize;
cpstn = &rcpstn; // Set pointers to fixed locations
freqdata = &rfreqdata[0];
linedata = &rlinedata[0];
bufsize = RECBUFSIZE;
ltick = 0;
if ((pRecording = fopen(lpstrFile,"rb")) == NULL) // read
{
MessageBox(NULL,"Error opening playback file.","PDW",MB_ICONWARNING);
bPlayback = false;
}
else
{
setbuf(pRecording,rbuffer);
bPlayback = true;
}
return(bPlayback);
}
// RAH: Stop playback of recording
void Stop_Playback(void)
{
bPlayback = false;
if (pRecording)
{
fclose(pRecording);
pRecording = NULL;
MessageBeep(MB_OK);
}
// HWi Restore values after the playback
cpstn = old_cpstn;
freqdata = old_freqdata;
linedata = old_linedata;
bufsize = old_bufsize;
}
// RAH: Handle playback of recording
void pdw_playback(void)
{
BOOL bMore = TRUE;
BOOL bAnything = FALSE;
while (bMore)
{
bMore = fread(&recdata,recsize,1,pRecording);
if (bMore)
{ // Data from playback file
freqdata[rcpstn] = ltick - recdata.freqdata; // Calculate time since last
linedata[rcpstn] = recdata.linedata;
ltick = recdata.freqdata;
rcpstn = nextcpstn++;
bAnything = TRUE;
if (nextcpstn >= RECBUFSIZE) nextcpstn = 0;
if (nextcpstn == pd_i) break; // Interpret now
}
}
if (bAnything)
{
pdw_decode();
}
else // Done
{
Stop_Playback();
}
}
// RAH: Start recording
// HWi Inserted recording again
void Start_Recording(LPTSTR lpstrFile)
{
// HWi
char szBuffer[80];
sprintf(szBuffer, "Recording %s", lpstrFile);
SetWindowText(ghWnd, (LPSTR) szBuffer);
bRecording = true;
if ((pRecording = fopen(lpstrFile,"ab")) == NULL) // append
{
MessageBox(NULL,"Error opening output file for recording.","PDW",MB_ICONWARNING);
bRecording = false;
// HWi
SetWindowText(ghWnd, (LPSTR) pdw_version);
}
else
{
setbuf(pRecording,rbuffer);
fflush(pRecording);
}
}
// RAH: Stop recording
void Stop_Recording(void)
{
bRecording = false;
if (pRecording)
{
fclose(pRecording);
pRecording = NULL;
}
SetWindowText(ghWnd, (LPSTR) pdw_version);
}
// RAH: Select a file for recording
BOOL Open_Recording(OPENFILENAME *pofn, LPTSTR lpstrFile, bool bOpennotsave)
{
static char szRec[] = {"Recordings (*.rec)\0*.rec\0All Files (*.*)\0*.*\0\0"};
char szTitle[256];
char szExt[] = ".rec";
char szInitialDir[MAX_PATH];
sprintf(szInitialDir, "%s\\Recordings", szPath);
strcpy(szTitle, bOpennotsave ? "Playback Recording" : "Start Recording");
pofn->lStructSize = sizeof(OPENFILENAME);
pofn->hwndOwner = ghWnd;
pofn->lpstrFilter = szRec;
pofn->nFilterIndex = 1;
pofn->lpstrFile = lpstrFile;
pofn->nMaxFile = MAX_PATH;
pofn->lpstrInitialDir = bOpennotsave ? szInitialDir : szPath;
pofn->Flags = OFN_HIDEREADONLY;
pofn->lpstrTitle = szTitle;
pofn->lpstrDefExt = szExt;
return(GetOpenFileName(pofn));
}
void pdw_decode_acars(void)
{
if (pd_i != *cpstn)
{
UpdateSigInd(0); // Move signal indicator left 1
}
while (pd_i != *cpstn)
{
pd_clk += freqdata[pd_i];
pd_cw0 = linedata[pd_i] >> 4;
pd_cw1 = rcv[pd_cw0];
// if two level interface: force symbol to be either 0 or 3 and
// process as if 4 level interface were used. Phases B & D then
// always get a long stream of 0's and don't produce any output.
if (!Profile.fourlevel && (pd_cw1 > 0)) pd_cw1 = 3;
if (Profile.invert) pd_cw1 ^= 0x03; // if in invert mode - invert both bits
while (pd_clk >= (exc + 0.5 * ct_bit))
{
acars.frame(pd_cw1 > 1); // Put into ACARS decoding routine
pd_clk = pd_clk - ct_bit;
if (acars.ac_alive)
{
if (sig_flg < 3) // Move signal indicator right 1
{
UpdateSigInd(1);
sig_flg++;
}
}
}
// clk now holds new boundary position. update exc slowly...
// for now only use center transitions to adjust rcv clock
if (pd_cw1 > 1) pd_dsr = 0;
else pd_dsr = 1;
// was 0.02 ....
pd_rer = pd_clk - exc;
if (pd_dsr != pd_ldsr) exc = exc + rcv_clkt * (pd_rer);
pd_ldsr = pd_dsr;
pd_i++;
if (pd_i == bufsize) pd_i = 0;
}
}
void pdw_decode_mobitex(void)
{
if (mb.timer) // Check if dropped out of mobitex mode.
{
mb.timer--;
if (mb.timer == 0) display_showmo(MODE_IDLE);
UpdateSigInd(1); // Move signal indicator right 1
}
else if (pd_i != *cpstn)
{
UpdateSigInd(0); // Move signal indicator left 1
}
while (pd_i != *cpstn)
{
pd_clk += freqdata[pd_i];
pd_cw0 = linedata[pd_i] >> 4;
pd_cw1 = rcv[pd_cw0];
// if two level interface: force symbol to be either 0 or 3 and
// process as if 4 level interface were used. Phases B & D then
// always get a long stream of 0's and don't produce any output.
if (!Profile.fourlevel && (pd_cw1 > 0)) pd_cw1 = 3;
if (Profile.invert) pd_cw1 ^= 0x03; // if in invert mode - invert both bits
while (pd_clk >= (exc + 0.5 * ct_bit))
{
mb.frame_sync(pd_cw1 > 1); // Put into MOBITEX decoding routine
pd_clk = pd_clk - ct_bit;
}
// clk now holds new boundary position. update exc slowly...
// for now only use center transitions to adjust rcv clock
if (pd_cw1 > 1) pd_dsr = 0;
else pd_dsr = 1;
// was 0.02 ....
pd_rer = pd_clk - exc;
if (pd_dsr != pd_ldsr) exc = exc + rcv_clkt * (pd_rer);
pd_ldsr = pd_dsr;
pd_i++;
if (pd_i == bufsize) pd_i = 0;
}
}
void pdw_decode_ermes(void)
{
if (em.timer) // Check if dropped out of ermes mode.
{
em.timer--;
if (em.timer == 0) display_showmo(MODE_IDLE);
UpdateSigInd(1); // Move signal indicator right 1
}
else if (pd_i != *cpstn)
{
UpdateSigInd(0); // Move signal indicator left 1
}
while (pd_i != *cpstn)
{
pd_clk += freqdata[pd_i];
pd_cw0 = linedata[pd_i] >> 4;
pd_cw1 = rcv[pd_cw0];
// if two level interface: force symbol to be either 0 or 3 and
// process as if 4 level interface were used. Phases B & D then
// always get a long stream of 0's and don't produce any output.
if (!Profile.fourlevel && (pd_cw1 > 0)) pd_cw1 = 3;
if (Profile.invert) pd_cw1 ^= 0x03; // if in invert mode - invert both bits
while (pd_clk >= (exc + 0.5 * ct_bit))
{
em.frame(pd_cw1); // Put into ERMES decoding routine
pd_clk = pd_clk - ct_bit;
}
// clk now holds new boundary position. update exc slowly...
// for now only use center transitions to adjust rcv clock
if (pd_cw1 > 1) pd_dsr = 0;
else pd_dsr = 1;
// was 0.02 ....
pd_rer = pd_clk - exc;
if (pd_dsr != pd_ldsr) exc = exc + rcv_clkt * (pd_rer);
pd_ldsr = pd_dsr;
pd_i++;
if (pd_i == bufsize) pd_i = 0;
}
}
// Decode POCSAG/FLEX/ACARS/MOBITEX/ERMES.....
void pdw_decode(void)
{
if (bRecording) // Hwi Added for recording function
{
static unsigned int last_write;
static unsigned int tmp;
while (tmp != *cpstn)
{
last_write -= freqdata[tmp];
fwrite(&last_write, 2, 1, pRecording);
fwrite(&linedata[tmp], 1, 1, pRecording);
tmp++;
if (tmp == bufsize) tmp = 0;
}
}
sig_flg=0;
check_save_data(); // Log messages/status info.
if (Profile.monitor_mobitex) // Decoding Mobitex..
{
pdw_decode_mobitex();
return;
}
if (Profile.monitor_ermes) // Decoding Ermes..
{
pdw_decode_ermes();
return;
}
if (Profile.monitor_acars) // Decoding ACARS..
{
pdw_decode_acars();
return;
}
if (flex_timer) // Check if dropped out of flex mode.
{
flex_timer--;
if (flex_timer == 0)
{
display_showmo(MODE_IDLE);
}
UpdateSigInd(1); // Move signal indicator right 1
sig_flg++;
}
else if (pd_i != *cpstn)
{
UpdateSigInd(0); // Move signal indicator left 1
}
while (pd_i != *cpstn)
{
// pd_clk += freqdata[pd_i];
if (Profile.comPortRS232 > 1) pd_clk = freqdata[pd_i];
else pd_clk += freqdata[pd_i];
pd_cw0 = linedata[pd_i] >> 4;
pd_cw1 = rcv[pd_cw0];
// if two level interface: force symbol to be either 0 or 3 and
// process as if 4 level interface were used. Phases B & D then
// always get a long stream of 0's and don't produce any output.
if (!Profile.fourlevel && (pd_cw1 > 0)) pd_cw1 = 3;
if (Profile.invert) pd_cw1 ^= 0x03; // if in invert mode - invert both bits
if (Profile.decodepocsag && !bFlexActive && ((pd_cw1 >> 1) != pd_lcw))
{
// look for POCSAG preamble sequence...
if ((pd_dinc > 421) && (pd_dinc < 571)) pd_ct24++;
else if (pd_ct24 > 5) pd_ct24 -= 3;
if ((pd_dinc > 842) && (pd_dinc < 1142)) pd_ct12++;
else if (pd_ct12 > 5) pd_ct12 -= 3;
if ((pd_dinc > 1976) && (pd_dinc < 2674)) pd_ct5++;
else if (pd_ct5 > 5) pd_ct5 -= 3;
if (pd_ct24 > 180)
{
pd_ct24 = 0;
if (Profile.pocsag_2400)
{
display_showmo(MODE_POCSAG+MODE_P2400);
ct_bit = Profile.comPortRS232 ? 500 : 496.4;
pocsag_baud_rate = STAT_POCSAG2400;
if (!pocbit)
{
exc = 0.0;
pd_clk = 0.0;
}
rcv_clkt = rcv_clkt_po;
pocbit = 600;
}
}
else if (pd_ct12 > 180)
{
pd_ct12 = 0;
if (Profile.pocsag_1200)
{
display_showmo(MODE_POCSAG+MODE_P1200);
ct_bit = Profile.comPortRS232 ? 1000 : 993.0;
pocsag_baud_rate = STAT_POCSAG1200;
if (!pocbit)
{
exc = 0.0;
pd_clk = 0.0;
}
rcv_clkt = rcv_clkt_po;
pocbit = 600;
}
}
else if (pd_ct5 > 180)
{
pd_ct5 = 0;
if (Profile.pocsag_512)
{
display_showmo(MODE_POCSAG+MODE_P512);
ct_bit = Profile.comPortRS232 ? 2000 : 2327.4;
pocsag_baud_rate = STAT_POCSAG512;
if (!pocbit)
{
exc = 0.0;
pd_clk = 0.0;
}
rcv_clkt = rcv_clkt_po;
pocbit = 600;
}
}
pd_dinc = freqdata[pd_i];
pd_lcw = pd_cw1 >> 1;
}
else pd_dinc += freqdata[pd_i]; // didn't have transition across center
while (pd_clk >= (exc + 0.5 * ct_bit))
{
// if (Profile.comPortRS232 == 2) pd_clk=0;
// else pd_clk = pd_clk - ct_bit;
pd_clk = pd_clk - ct_bit;
if (Profile.decodeflex && !pocbit)
{
frame_flex(pd_cw1); // Put into FLEX decoding routine
rcver[ircver++] = pd_rer;
if (ircver > 63) ircver = 0;
}
else if (Profile.decodepocsag && pocbit)
{
if (sig_flg < 3)
{
UpdateSigInd(1); // Move signal indicator right 1
sig_flg++;
}
pocsag.frame(pd_cw1 > 1); // Put into POCSAG decoding routine
// decrement pocsag bit counter; if zero we're back to flex
// note : pocbit is reset by pocsag processing routines whenever
// a good word has been received
pocbit--;
if (pocbit == 0) // we have just dropped out of POCSAG mode
{
display_showmo(MODE_IDLE);
pocsag.frame(-1); // reset pocsag routine
ct_bit = ct1600; // reset rcv clock to 1600 baud
rcv_clkt = rcv_clkt_hi; // widen up rcv clk again
}
}
if (Profile.comPortRS232 > 1) break;
}
if (Profile.comPortRS232 < 2)
{
// clk now holds new boundary position. update exc slowly...
// for now only use center transitions to adjust rcv clock
if (pd_cw1 > 1) pd_dsr = 0;
else pd_dsr = 1;
// was 0.02 ....
pd_rer = pd_clk - exc;
if (pd_dsr != pd_ldsr) exc = exc + rcv_clkt * (pd_rer);
pd_ldsr = pd_dsr;
}
pd_i++;
if (pd_i == bufsize) pd_i = 0;
}
if (pocbit)
{
pocbit--;
if (pocbit == 0) // we have just dropped out of POCSAG mode
{
display_showmo(MODE_IDLE);
pocsag.frame(-1); // reset pocsag routine
ct_bit = ct1600; // reset rcv clock to 1600 baud
rcv_clkt = rcv_clkt_hi; // widen up rcv clk again
}
}
}
// Save statistics.
void check_save_data(void)
{
unsigned int index;
char filename[1024];
extern char szFilenameDate[16]; // Global buffer for date as filename
bool bDaily=false;
/*** Statistics output and statfile updates ***/
stat_timer--;
if (stat_timer == 0)
{
GetLocalTime(&statTime);
Get_Date_Time();
if (statTime.wDay != prev_statTime.wDay) bDaily=true;
if (statTime.wHour != prev_statTime.wHour)
{
if (Profile.stat_file_enabled)
{
if (Profile.stat_file_use_date)
{
CreateDateFilename(".st", bDaily ? &prev_statTime : NULL);
sprintf(filename, "%s\\%s", szLogPathName, szFilenameDate);
}
else sprintf(filename, "%s\\%s.st", szLogPathName, Profile.stat_file);
if ((pStatFile = fopen(filename, "a")) != NULL)
{
fprintf(pStatFile, "*************** HOURLY (%02d:00-%02d:00) ***************\n\n", prev_statTime.wHour, statTime.wHour);
WriteStatFileHourly(pStatFile);
if (bDaily)
{
fprintf(pStatFile, "*********************** DAILY **********************\n\n");
WriteStatFileDaily(pStatFile);
}
fclose(pStatFile);
pStatFile=NULL;
}
}
for (index=0; index<NUM_STAT; index++)
{
hourly_stat[index][STAT_NUMERIC] = 0L;
hourly_char[index][STAT_NUMERIC] = 0L;
hourly_stat[index][STAT_ALPHA] = 0L;
hourly_char[index][STAT_ALPHA] = 0L;
}
if (bDaily)
{
for (index=0; index<NUM_STAT; index++)
{
daily_stat[index][STAT_NUMERIC] = 0L;
daily_char[index][STAT_NUMERIC] = 0L;
daily_stat[index][STAT_ALPHA] = 0L;
daily_char[index][STAT_ALPHA] = 0L;
}
}
prev_statTime = statTime;
}
stat_timer = 100 - ((statTime.wSecond % 10) * 10);
}
}