-
Notifications
You must be signed in to change notification settings - Fork 0
/
adsIOrt.h
133 lines (93 loc) · 3.5 KB
/
adsIOrt.h
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
/*
-------------------------------------------------------------------------
OBJECT NAME: adsIOrt.h
FULL NAME: Class for reading real-time ADS images.
ENTRY POINTS:
DESCRIPTION: This class will allow forward scanning of ADS files.
COPYRIGHT: University Corporation for Atmospheric Research, 1999
-------------------------------------------------------------------------
*/
#ifndef ADSIORT_H
#define ADSIORT_H
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include "hdrAPI.h"
/* ADS image physical record types */
#define ADS_WORD 0x4144
#define HDR_WORD 0x5448
#define SDI_WORD 0x8681
#define AVAPS_WORD 0x4156
#define MCR_WORD 0x4d43
#define MASP_WORD 0x4450
#define PMS2DC1 0x4331
#define PMS2DC2 0x4332
#define PMS2DG1 0x4731
#define PMS2DG2 0x4732
#define PMS2DH1 0x4831
#define PMS2DH2 0x4832
#define PMS2DP1 0x5031
#define PMS2DP2 0x5032
#define PMS2_SIZE sizeof(P2d_rec)
#define PMS2_LRPPR (0x8000 / PMS2_SIZE)
#define PMS2_RECSIZE ((0x8000 / PMS2_SIZE) * PMS2_SIZE)
/* -------------------------------------------------------------------- */
class ADS_rtFile {
public:
ADS_rtFile();
~ADS_rtFile();
Header *hdr;
bool FirstSyncRecord(char buff[]);
bool NextSyncRecord(char buff[]);
bool LastSyncRecord(char buff[], int minusN);
bool LastSyncRecord(char buff[]) { return(LastSyncRecord(buff, 0)); }
bool FirstMCRRecord(Mcr_rec *buff);
bool NextMCRRecord(Mcr_rec *buff);
bool LastMCRRecord(Mcr_rec *buff);
bool FirstPMS2dRecord(P2d_rec *buff);
bool NextPMS2dRecord(P2d_rec *buff);
bool LastPMS2dRecord(P2d_rec *buff, int minusN);
bool LastPMS2dRecord(P2d_rec *buff) { return(LastPMS2dRecord(buff, 1)); }
bool FirstGreyRecord(char buff[]);
bool NextGreyRecord(char buff[]);
bool LastGreyRecord(char buff[]);
bool FirstAvapsRecord(char buff[]);
bool NextAvapsRecord(char buff[]);
bool LastAvapsRecord(char buff[]);
int HdrBlkToSeconds(Hdr_blk *r)
{ return((ntohs(r->hour)%24)*3600 + ntohs(r->minute)*60 +ntohs(r->second));}
int HdrBlkToSeconds(P2d_rec r)
{ return((ntohs(r.hour)%24)*3600 + ntohs(r.minute)*60 +ntohs(r.second)); }
int HdrBlkToSeconds(P2d_rec *r)
{ return((ntohs(r->hour)%24)*3600 + ntohs(r->minute)*60 +ntohs(r->second));}
int HdrBlkToSeconds(GreyParticle r)
{ return((ntohs(r.hour)%24)*3600 + ntohs(r.minute)*60 +ntohs(r.second)); }
int HdrBlkToSeconds(GreyParticle *r)
{ return((ntohs(r->hour)%24)*3600 + ntohs(r->minute)*60 +ntohs(r->second));}
int HdrBlkToSeconds(Mcr_rec r)
{ return((ntohs(r.hour)%24)*3600 + ntohs(r.minute)*60 +ntohs(r.second)); }
int HdrBlkToSeconds(Mcr_rec *r)
{ return((ntohs(r->hour)%24)*3600 + ntohs(r->minute)*60 +ntohs(r->second));}
int fileLengthSync()
{ return(!fstat(fileno(fpSync), &fileInfo) ? fileInfo.st_size : -1); }
int fileLength2D()
{ return(!fstat(fileno(fp2D), &fileInfo) ? fileInfo.st_size : -1); }
int fileLengthGrey()
{ return(!fstat(fileno(fpGrey), &fileInfo) ? fileInfo.st_size : -1); }
int fileLengthMCR()
{ return(!fstat(fileno(fpMCR), &fileInfo) ? fileInfo.st_size : -1); }
int fileLengthAVAPS()
{ return(!fstat(fileno(fpAVAPS), &fileInfo) ? fileInfo.st_size : -1); }
private:
FILE *fpSync, *fp2D, *fpGrey, *fpMCR, *fpAVAPS;
struct stat fileInfo;
time_t lastMod;
void readFileName(), checkFileName();
void openFiles(), closeFiles(), resetFiles();
int NextPhysicalRecord(char buff[], FILE *fp, int lrLen);
int headOffset;
char *projDir;
char fileBaseName[256], rtFileFileName[256];
char physRecord[MX_PHYS];
}; /* END ADSIORT.H */
#endif