My Project
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Friends
Macros
Pages
scan.h
1
#ifndef GCP_CONTROL_SCAN_H
2
#define GCP_CONTROL_SCAN_H
3
4
#include "input.h"
5
#include "output.h"
6
#include "cache.h"
7
#include "scancache.h"
8
9
#define SCAN_NET_NPT 10
10
11
/*
12
* The opaque ScanCatalog type contains a catalog of scans, indexed
13
* by name and number. Its definition and implementation is private
14
* to scan.c.
15
*/
16
typedef
struct
ScanCatalog
ScanCatalog
;
17
18
/*
19
* Create an empty scan catalog.
20
*/
21
ScanCatalog
*new_ScanCatalog(
void
);
22
23
/*
24
* Delete a scan catalog.
25
*/
26
ScanCatalog
*del_ScanCatalog(
ScanCatalog
*sc);
27
28
/*
29
* Read scan catalog entries from an input stream. Note that
30
* the new scans are added to the existing catalog. If a new scan
31
* has the same name as an existing catalog entry, the existing catalog
32
* entry is overwritten with the new one.
33
*/
34
int
input_ScanCatalog(
ScanCatalog
*sc,
InputStream
*stream);
35
36
/*
37
* Read scan catalog entries from a file. This is a wrapper around
38
* input_ScanCatalog().
39
*/
40
int
read_ScanCatalog(
ScanCatalog
*sc,
char
*dir,
char
*file);
41
42
/*
43
* Write scan catalog entries to an output stream, using the format
44
* expected by input_ScanCatalog().
45
*/
46
int
output_ScanCatalog(
ScanCatalog
*sc,
OutputStream
*stream);
47
48
/*
49
* Write scan catalog entries to a file. This is a wrapper around
50
* output_ScanCatalog().
51
*/
52
int
write_ScanCatalog(
ScanCatalog
*sc,
char
*dir,
char
*file);
53
54
/*
55
* The opaque Scan datatype is a union of all scan types.
56
* Its definition is private to scan.c. Be careful about
57
* cacheing (Scan *) pointers. If add_Scan() et al. is called
58
* to change the definition of an existing scan (identified by name),
59
* then the original (Scan *) pointer associated with that name will
60
* become invalid and should not be used. It is safer to record catalog
61
* numbers or scan names (see get_ScanId).
62
*/
63
namespace
gcp {
64
namespace
control {
65
66
typedef
union
ScanUnion Scan;
67
68
/*
69
* Enumerate the supported types of scans
70
*/
71
enum
ScanType {
72
SCAN_NORMAL,
/* A scan pattern that begins and ends at zero velocity */
73
SCAN_CONTINUOUS,
/* For instance, circular scans, which have no zero
74
velocity point, and require an extra track to
75
into the pattern */
76
SCAN_BOGUS,
/* A fake scan */
77
SCAN_ALIAS
/* An alternative name for another scan */
78
};
79
80
/*
81
* Set the max length of a scan name (including '\0').
82
* This should be set equal to SCAN_LEN in quadregs.h.
83
*/
84
enum
{SCAN_NAME_MAX=30};
85
86
/*
87
* All scans share an initial member of the following type.
88
*
89
* When a given scan name is enterred into a ScanCatalog for the
90
* first time, it is assigned a catalog index. This index can thereafter
91
* be used as a unique synonym for the scan name, since it doesn't change
92
* even if the definition of the scan associated with that name is
93
* modified.
94
*/
95
struct
ScanId
{
96
ScanType type;
/* The enumerated type of the scan */
97
char
name[SCAN_NAME_MAX];
/* The name of the scan */
98
int
number;
/* The catalog index tied to name[] */
99
};
100
101
/*
102
* The following scan type is for non-sidereal scans whos positions
103
* are recorded in ephemeris files. The ephemeris file is not kept
104
* open at all times, instead up to EPHEM_CACHE_SIZE contemporary
105
* entries are kept in a cache. At any given time three points from
106
* this cache are loaded into quadratic interpolators, to provide more
107
* precise positions. The middle of these three entries is at element
108
* 'midpt' of the cache. When the cache has been exhausted, it will
109
* be refreshed from the ephemeris file.
110
*/
111
struct
NormalScan
{
112
ScanId
id;
/* The generic scan identification header */
113
char
*file;
/* The pathname of the scan file */
114
ScanCache
cache;
/* A cache of size <= SCAN_CACHE_SIZE entries */
115
};
116
117
enum
NormalScanKeyword {
118
NORM_SCAN_MSPERSAMPLE,
119
NORM_SCAN_NONE,
120
NORM_SCAN_INVALID,
121
};
122
123
/*
124
* A scan with no zero-velocity point.
125
*/
126
struct
ContinuousScan
{
127
ScanId
id;
/* The generic scan identification header */
128
char
*file;
/* The pathname of the scan file */
129
ScanCache
cache;
/* A cache of size <= SCAN_CACHE_SIZE entries */
130
};
131
132
enum
ContinuousScanKeyword {
133
CONT_SCAN_MSPERSAMPLE,
134
CONT_SCAN_START,
135
CONT_SCAN_BODY,
136
CONT_SCAN_END,
137
CONT_SCAN_NONE,
138
CONT_SCAN_INVALID,
139
};
140
141
/*
142
* This is just a placeholder. So that the scan catalog can contain
143
* entries like "none"
144
*/
145
struct
BogusScan
{
146
ScanId
id;
/* The generic scan identification header */
147
};
148
152
struct
AliasScan
{
153
ScanId
id;
/* The generic scan identification header */
154
Scan
**sptr;
/* The catalog entry of the scan. Using this relies */
155
/* on the fact the only destructive operation that */
156
/* is allowed on an existing catalog entry is */
157
/* to replace its contents with a new scan of the */
158
/* same name. We can't actually store the (Scan *) */
159
/* pointer because that can change. */
160
};
161
162
/*
163
* Define a generic scan container. This is d to Scan
164
* in scan.h.
165
*/
166
union
ScanUnion
{
167
ScanId
id;
/* The first members of all scan types */
168
NormalScan
normal;
/* An ordinary scan */
169
ContinuousScan
continuous;
/* An ordinary scan */
170
BogusScan
bogus;
/* A fake scan */
171
AliasScan
alias;
/* A link to another scan */
172
};
173
};
174
};
175
176
/*
177
* The following function returns non-zero if a given character is
178
* valid within a scan name.
179
*/
180
int
valid_scan_char(
int
c);
181
182
/*
183
* Get a copy of the identification header of a given Scan.
184
* On error it returns non-zero. If resolve is true and the
185
* scan is an alias to another scan, the id of the aliased
186
* scan will be returned in its place (this rule is applied
187
* recursively).
188
*/
189
int
get_ScanId(
gcp::control::Scan
*scan,
int
resolve,
gcp::control::ScanId
*
id
);
190
191
/*
192
* Return the scan-catalog index of a given scan (-1 on error).
193
* See the documentation of ScanId for the usage of such indexes.
194
* The resolve member is used as described for get_ScanId().
195
*/
196
int
get_Scan_number(
gcp::control::Scan
*scan,
int
resolve);
197
198
/*
199
* Use the following functions to add scans to the catalog.
200
* Each function returns NULL on failure.
201
*/
202
gcp::control::Scan
*add_NormalScan(
ScanCatalog
*sc,
char
*name,
char
* file);
203
gcp::control::Scan
*add_ContinuousScan(
ScanCatalog
*sc,
char
*name,
char
* file);
204
gcp::control::Scan
*add_BogusScan(
ScanCatalog
*sc,
char
*name);
205
gcp::control::Scan
*add_AliasScan(
ScanCatalog
*sc,
char
*name,
char
*scan);
206
207
/*
208
* Use the following functions to look up a scan. The first is
209
* useful for finding a scan named by a user. It uses a hash table
210
* so it should be relatively fast. The second uses the ordinal
211
* position of the scan in the catalog. This should be more
212
* efficient for repeat lookups of the same scan and can also be
213
* used to step through the catalog. Note that if you have a ScanId
214
* object, the ordinal number of the scan is given by the 'number'
215
* field.
216
*/
217
gcp::control::Scan
* find_ScanByName(
ScanCatalog
* sc,
char
* name);
218
gcp::control::Scan
* find_ScanByNumber(
ScanCatalog
* sc,
int
number);
219
220
/*
221
* Return the number of scans that are currently in a scan catalog.
222
*/
223
int
size_ScanCatalog(
ScanCatalog
* sc);
224
225
int
get_scan_window(
ScanCatalog
* scanc,
gcp::control::Scan
* scan,
double
tt,
226
gcp::control::CacheWindow
* win);
227
228
gcp::control::Scan
* resolve_ScanAliases(
gcp::control::Scan
* scan);
229
230
#endif
gcp::control::ScanId
Definition:
scan.h:95
gcp::control::NormalScan
Definition:
scan.h:111
InputStream
Definition:
input.h:87
gcp::control::AliasScan
Definition:
scan.h:152
gcp::control::ContinuousScan
Definition:
scan.h:126
gcp::control::ScanUnion
Definition:
scan.h:166
gcp::control::CacheWindow
Definition:
cache.h:14
ScanCatalog
Definition:
scan.c:119
gcp::control::BogusScan
Definition:
scan.h:145
OutputStream
Definition:
output.h:40
ScanCache
Definition:
scancache.h:62
gcpCbass
control
code
unix
libscan_src
scan.h
Generated on Thu Jun 21 2018 14:30:00 for My Project by
1.8.6