CARMA C++
MonitorCellScaled.h
Go to the documentation of this file.
1 // $Id: MonitorCellScaled.h,v 1.6 2013/11/19 03:41:12 iws Exp $
2 
3 #ifndef CARMA_UI_RTD_MONITORCELLSCALED_H
4 #define CARMA_UI_RTD_MONITORCELLSCALED_H
5 
16 
19 
20 #include "carma/szautil/DataType.h"
22 
24 
25 #include <boost/shared_ptr.hpp>
26 
27 #define MP_PACK_FN(fn) std::string (fn)(MonitorCellScaled* cell)
28 
29 namespace carma {
30  namespace ui {
31  namespace rtd {
32 
33  enum Operator {
34  OPER_NONE,
35  OPER_MULT,
36  OPER_DIV,
37  OPER_ADD,
38  OPER_SUB
39  };
40 
41  enum Grouping {
42  GROUP_EXACT,
43  GROUP_ANTTYPE,
44  GROUP_SUBARRAY
45  };
46 
47  class MonitorCellScaled : public MonitorCell {
48  public:
49 
50  //------------------------------------------------------------
51  // Class for managing a (potentially frequency-scalable) delta
52  //------------------------------------------------------------
53 
54  class Delta {
55  public:
56  double val_;
57  Operator freqOperator_;
58  sza::util::Frequency freqNormalization_;
59 
60  Delta() {
61  freqOperator_ = OPER_NONE;
62  }
63 
64  Delta(double val) {
65  val_ = val;
66  freqOperator_ = OPER_NONE;
67  };
68 
69  Delta(double val, Operator oper, sza::util::Frequency freqNormalization) {
70  val_ = val;
71  freqOperator_ = oper;
72  freqNormalization_ = freqNormalization;
73  };
74 
75 
76  double getValue(AntennaMapper::Antenna* antenna) {
77  return MonitorCellScaled::getFrequencyScaledValue(val_, antenna, freqOperator_, freqNormalization_);
78  };
79 
80  };
81 
82  //------------------------------------------------------------
83  // Class for managing a scaled monitor point
84  //------------------------------------------------------------
85 
86  class ScaledMp {
87  public:
88 
89  monitor::MonitorPoint* mp_;
90  Operator mpOperator_;
91  monitor::MonitorPoint* mp2_;
92  double multiplier_;
93  double offset_;
94  int sampleNo_;
95  int sampleNo2_;
96 
97  ScaledMp(monitor::MonitorPoint* mp, double multiplier=1.0, double offset=0.0, int sampleNo=0) {
98  mp_ = mp;
99  multiplier_ = multiplier;
100  offset_ = offset;
101  sampleNo_ = sampleNo;
102  mpOperator_ = OPER_NONE;
103  };
104 
105  ScaledMp(monitor::MonitorPoint* mp, Operator oper, monitor::MonitorPoint* mp2, double multiplier=1.0, double offset=0.0, int sampleNo=0, int sampleNo2=0) {
106  mp_ = mp;
107  mp2_ = mp2;
108  multiplier_ = multiplier;
109  offset_ = offset;
110  sampleNo_ = sampleNo;
111  sampleNo2_ = sampleNo2;
112  mpOperator_ = oper;
113  };
114 
115  double getNativeValAsDouble() {
116  return MonitorCellScaled::getNativeValAsDouble(mp_, sampleNo_, mpOperator_, mp2_, sampleNo2_);
117  }
118  };
119 
120  //------------------------------------------------------------
121  // Methods of MonitorCellScaled
122  //------------------------------------------------------------
123 
124  MonitorCellScaled( int cellWidth,
125  bool setMpWidth,
126  monitor::MonitorPoint& monitorPoint,
127  int sampleNo,
128  double multiplier=1.0,
129  double offset=0.0,
130  short int precision=3);
131 
132  MonitorCellScaled( int cellWidth,
133  monitor::MonitorPoint& monitorPoint,
134  double multiplier=1.0,
135  double offset=0.0,
136  short int precision=3);
137 
138  MonitorCellScaled( const int cellWidth,
139  const bool setMpWidth,
140  monitor::MonitorPoint & mp1,
141  const int sampleNo1,
142  Operator oper,
143  monitor::MonitorPoint & mp2,
144  const int sampleNo2,
145  double multiplier=1.0,
146  double offset=0.0,
147  short int precision=3);
148 
149  static MonitorCellPtr makeCell(const int cellWidth,
150  monitor::MonitorPoint& mp,
151  double multiplier=1.0,
152  double offset=0.0,
153  short int precision=3);
154 
155  static MonitorCellPtr makeCell(const int cellWidth,
156  monitor::MonitorPoint & mp1,
157  Operator oper,
158  monitor::MonitorPoint & mp2,
159  double multiplier=1.0,
160  double offset=0.0,
161  short int precision=3);
162 
166  virtual ~MonitorCellScaled();
167 
168  virtual ::std::string computeText();
169 
170  void recast();
171 
172  void setColor(CellColor);
173 
174  CellColor computeColor();
175 
176  //------------------------------------------------------------
177  // Return a double version of the value represented by mp
178  //------------------------------------------------------------
179 
180  double getScaledValAsDouble(monitor::MonitorPoint* mp, double multiplier, double offset, int sampleNo);
181  double getScaledValAsDouble(monitor::MonitorPoint* mp1, int sampleNo1, Operator oper, monitor::MonitorPoint* mp2, int sampleNo2,
182  double multiplier, double offset);
183 
184  static double getNativeValAsDouble(monitor::MonitorPoint* mp, int sampleNo);
185  static double getNativeValAsDouble(monitor::MonitorPoint* mp1, int sampleNo1, Operator oper, monitor::MonitorPoint* mp2, int sampleNo2);
186 
187  void scaleVal(double& dval, double multiplier, double offset);
188 
189  //------------------------------------------------------------
190  // Use this method to create a monitor point whose color
191  // represents whether or not
192  //
193  // fabs(mpval - mean(mp)) > permittedDelta
194  //------------------------------------------------------------
195 
196  void errorOnAbsDeviationFromMean(std::vector<ScaledMp>& mpVec, Delta permittedDelta,
197  Grouping group=GROUP_EXACT);
198  bool isOutlier();
199 
200  //------------------------------------------------------------
201  // Use this method to create a monitor point whose color
202  // represents whether or not
203  //
204  // fabs(mpval - val) > permittedDelta
205  //------------------------------------------------------------
206 
207  void errorOnAbsDeviationFromVal(double val, Delta permittedDelta);
208  bool deviatesFromVal();
209 
210  //------------------------------------------------------------
211  // Use this method to apply a frequency-dependent scaling to
212  // this monitor point's value. The frequency used in the
213  // scaling will be the current LO frequency of the subarray to
214  // which this monitor point's antenna currently belongs
215  //------------------------------------------------------------
216 
217  void scaleByFrequency(Operator oper, sza::util::Frequency normalization);
218 
219  protected:
220 
221  CellColor color_;
222  static const double eps_;
223  double multiplier_;
224  double offset_;
225  short int precision_;
226  MP_PACK_FN(*packFn_);
227 
228  static double getFrequencyScaledValue(double dval, AntennaMapper::Antenna* antenna, Operator oper, sza::util::Frequency& freqNorm);
229 
230  Grouping grouping_;
231  bool checkOutlier_;
232  std::vector<ScaledMp> outlierVec_;
233  Delta outlierDelta_;
234 
235  bool checkDeviationFromVal_;
236  double val_;
237  Delta valDelta_;
238 
239  Operator freqOperator_;
240  sza::util::Frequency freqNormalization_;
241 
242  monitor::MonitorPoint& mp2_;
243  unsigned sampleNo2_;
244  Operator mpOperator_;
245 
246  // For enumerated types, this will be a map of enum labels to
247  // double values. This is so that we can check outliers even
248  // for enumerated types
249 
250  void privateConstructor(monitor::MonitorPoint& mp,
251  double multiplier, double offset, short int precision);
252 
253  void privateConstructor(Operator oper, double multiplier, double offset, short int precision);
254 
255 
256  static MP_PACK_FN(packShort);
257  static MP_PACK_FN(packInt);
258  static MP_PACK_FN(packUint);
259  static MP_PACK_FN(packFloat);
260  static MP_PACK_FN(packDouble);
261  static MP_PACK_FN(packExpr);
262 
263  virtual std::string formatValue(double dval);
264 
265  }; // End class MonitorCellScaled
266 
267  typedef boost::shared_ptr<MonitorCellScaled> MonitorCellScaledPtr;
268 
269  } // End namespace rtd
270  } // End namespace ui
271 } // End namespace carma
272 
273 
274 
275 #endif // End #ifndef CARMA_MONITOR_UI_RTD_MONITORCELLSCALED_H
Tagged: Tue Jun 22 22:32:16 UTC 2004.
Abstract base class for all monitor points.
Exception class for errors.
Tagged: Sun Oct 24 17:05:09 PDT 2004.
Cell that takes a MonitorPoint and displays its current value.
Tagged: Tue Sep 24 14:08:19 PDT 2013.
enum carma::ui::rtd::CellColorEnum CellColor
Cell color choices.