CARMA C++
AHW_Output.h
1 /*
2  * AstroHeaderWriter Output
3  */
4 
5 #ifndef AHW_OUTPUT
6 #define AHW_OUTPUT
7 
8 #include <carma/util/types.h>
9 
10 #include <boost/shared_ptr.hpp>
11 
12 #include <string>
13 #include <vector>
14 
15 namespace carma {
16 namespace sdp {
17 
18 /*
19  * All possible conversion flags
20  */
21 enum AHW_Conv
22 {
23  // No conversion
24  NONE,
25  // Convert list of antenna numbers to MIRIAD-compatible antenna types
26  ANTENNAS_SPM,
27  // Convert list subarray numbers to MIRIAD-compatible antenna types
28  ANTENNAS_SUB,
29  // Convert arcmin to rad: val / (60 * 180) * M_PI
30  ARCMIN_TO_RAD,
31  // Convert MPML bitmode enumeration to actual number of bits
32  BITMODE,
33  // Convert MPML bitmode enumeration into correlator efficiency
34  COREFF,
35  // Convert MPML imgVsSnr enumeration into MIRIAD-compatible string
36  IMGSNR,
37  // Convert nanoseconds to meters: val * (1e9 / carma::services::constants::Physical::C)
38  NSEC_PER_METER,
39  // Convert list of transitions into single obsline
40  OBSLINE,
41  // Using LO1 Frequency, convert LineLength to phase
42  // TODO FIXME: document the hidden dependency on lo1 frequency monitor point
43  PHASEM1,
44  // Convert MPML pointstatus enumeration into MIRIAD-compatible integer
45  POINTSTATUS,
46  // Convert any positive value to 1, others to 0
47  POSITIVE_BOOLEAN,
48  // Always convert the value to a 0
49  STATIC_ZERO,
50  // Convert float >= 9.8 to 0.0 (and drop)
51  TAU230,
52  // Convert MPML velframe enumeration into MIRIAD-compatible string
53  VELTYPE,
54 };
55 
56 /*
57  * A class to hold major tokens.
58  *
59  * This stores the line number of the token, to allow display of exact
60  * line numbers when there are parsing errors.
61  */
62 class AHW_Token
63 {
64 public:
65  AHW_Token(const std::string &token, unsigned int lineNumber);
66 
67  const std::string token;
68  const unsigned int lineNumber;
69 };
70 
71 typedef boost::shared_ptr<AHW_Token> AHW_Token_Ptr;
72 typedef std::vector<AHW_Token_Ptr> AHW_Token_Vec;
73 
74 class AHW_Output
75 {
76 public:
77  AHW_Output(const AHW_Token_Vec &vec);
78 
79  /* print support */
80  std::string print() const;
81 
82  /* output variable name and type */
83  std::string outputName() const;
84  std::string outputType() const;
85 
86  /* flags */
87  enum AHW_Conv conv() const;
88 
89  std::string defaultValue() const;
90 
91  bool drop() const;
92  unsigned int duplicate() const;
93 
94  carma::util::frameType frameCountStart() const;
95  carma::util::frameType frameCountEnd() const;
96 
97  std::vector<std::string> order() const;
98  bool valid() const;
99 
100  /* MonitorPoint template */
101  std::string mpTemplate() const;
102 
103 private:
104 
105  std::string name_;
106  std::string type_;
107 
108  enum AHW_Conv conv_;
109 
110  bool default_;
111  std::string default_string_;
112 
113  bool drop_;
114  unsigned int duplicate_;
115  carma::util::frameType fc_start_;
116  carma::util::frameType fc_end_;
117  std::vector<std::string> order_;
118  bool valid_;
119  std::string mp_;
120 
121  /* parser helpers */
122  void parseFlags(const AHW_Token_Ptr &p);
123  void parseOneFlag(const AHW_Token_Ptr &p);
124  void parseBooleanFlag(const std::string &key, const unsigned int lineNumber);
125  void parseKVFlag(const std::string &key, const std::string &val, const unsigned int lineNumber);
126  void parseConv(const std::string &val, const unsigned int lineNumber);
127  void parseDefault(const std::string &val, const unsigned int lineNumber);
128  void parseDuplicate(const std::string &val, const unsigned int lineNumber);
129  void parseFrameCount(const std::string &val, const unsigned int lineNumber);
130  void parseOrder(const std::string &val, const unsigned int lineNumber);
131 };
132 
133 /* Configuration File Parser */
134 std::vector<AHW_Output> parseAHWControlFile(const std::string &fileName);
135 
136 } // namespace carma
137 } // namespace sdp
138 
139 #endif /* AHW_OUTPUT */
140 
141 /* vim: set ts=4 sts=4 sw=4 noet tw=92: */
unsigned int frameType
Half second frames since Jan 1, 2000.
Definition: types.h:29
Various type definitions for util classes.