KSquare Utilities
FlowMeterTracker.h
Go to the documentation of this file.
1 #if !defined(_FLOWMETERTRACKER_)
2 #define _FLOWMETERTRACKER_
3 
4 #include "KKBaseTypes.h"
5 #include "DateTime.h"
6 #include "GoalKeeper.h"
7 #include "KKStrParser.h"
8 #include "RunLog.h"
9 using namespace KKB;
10 
11 
12 namespace KKLSC
13 {
14  /**
15  *@brief Class that keeps track the Flow-Meter-Counter values by scan-lines; using these values it will compute
16  * estimated flow rate.
17  *
18  *@details
19  *@code
20  * Glossary
21  *
22  *
23  * FlowRate(FR) = Rate of water flow in (Meters/Sec)
24  *
25  * FlowRateRatio(FRR) = Number TemporalPixel's per SpatialPixel with respect to physical distance; aka FlowRateFactor. (TP's/SP's)
26  *
27  * ScanRate(SR) = Number of camera scan lines captured per second. (ScanLines/Sec) or (TP's/Sec)
28  *
29  * SpatialPixel(SP) = From the image chambers width perspective;
30  *
31  * TemporalPixel(TP) = One scan line; The physical distance a pixel covers with respect to flow is dependent
32  * on both scan rate and flow rate. TP = (FRR)(SP).
33  *
34  * ChamberWidthSpatialy (CWS) Distance across Imaging Chamber width as measured in meters (m).
35  * ChamberWidthPixels (CWP) Number of pixels imaged across the imaging chamber. (1 + CropLeft - CropRight). (SP's)
36  * ChamberWidthTemporal (CWT) Time it would take for Camera to cover same distance in direction of flow.
37  *
38  * FlowRateRatio = ((CWS)(SR)) / ((FR)(CWP)).
39  * FlowRate = ((CWS)(SR)) / ((FRR)(CWP))
40  *
41  *
42  *@endcode
43  */
45  {
46  public:
48 
50 
51  FlowMeterTracker (const FlowMeterTracker& entry);
52 
53  ~FlowMeterTracker ();
54 
55  /**
56  * @param[in] _flowMeterPresent Indicates if there is a Flow Meter or will FlowRate and FlowRateRatio be derived from configuration; see _flowRateRatioDefault.
57  * @param[in] _flowRateRatioDefault When flow meter s not present or unable to compute FlowRate will utilize this value to return FlowRate and FlowRateRatio.
58  * @param[in] _historyTableSize The number of FlowMeter readings that will be tracked.
59  * @param[in] _scanRate Scan-Lines per second that camera is operating at.
60  * @param[in] _imagingWidthMeters Width in meters that is being imaged.
61  * @param[in] _imagingWidthPixels Number of pixels that is being imaged; this is the same as distance refereed to by _imagingWidthMeters.
62  * @param[in] _ticsPerMeter The number counter ticks that occur per meter; this value will help compute FlowRate.
63  */
64  void Initialize (bool _flowMeterPresent,
65  float _flowRateRatioDefault,
66  kkint32 _historyTableSize,
67  float _scanRate,
68  float _imagingWidthMeters,
69  kkint32 _imagingWidthPixels,
70  float _ticsPerMeter
71  );
72 
74 
75  // Access Methods
76  bool FlowMeterPresent () const {return flowMeterPresent;}
77  float FlowRateDefault () const {return flowRateDefault;}
78  float FlowRateRatioDefault () const {return flowRateRatioDefault;}
79  kkint32 HistoryTableSize () const {return historyTableSize;}
80  float ImagingWidthMeters () const {return imagingWidthMeters;}
81  kkint32 ImagingWidthPixels () const {return imagingWidthPixels;}
82  float TicsPerMeter () const {return ticsPerMeter;}
83 
84  float ComputeFlowRateFromFlowRateRatio (float _flowRateRatio);
85  float ComputeFlowRateRatioFromFlowRate (float _flowRate);
86 
87 
88  void AddEntry (kkuint32 _scanLineNum,
89  kkuint32 _counterValue
90  );
91 
92 
93  /** Computes flow rate using the two most current count entries. */
94  float FlowRateInstantaneous ();
95 
96 
97  /** Computes flow rate using full range of history table. */
98  float FlowRateTrend ();
99 
100  void FlowRateRatioDefaultChanged (float _flowRateRatioDefault);
101 
102  void GetFlowRateInstantaneous (float& flowRate,
103  float& flowRateRatio
104  );
105 
106 
107  void GetFlowRateTrend (float& flowRate,
108  float& flowRateRatio
109  );
110 
111 
112  void ScanRateChanged (float _newScanRate);
113 
114 
115  private:
116  struct Entry
117  {
118  Entry ();
119  kkuint32 scanLineNum;
120  kkuint32 counterValue;
121  };
122  typedef Entry* EntryPtr;
123 
124  bool flowMeterPresent;
125  float flowRateDefault; /**< Default value to be used if Flow-Meter not present. */
126  float flowRateRatioDefault; /**< Default value to be used if Flow-Meter not present. */
127  EntryPtr history;
128  kkint32 historyTableSize;
129  kkint32 historyLastIdxAdded;
130  kkint32 historyOldestIdx;
131  float imagingWidthMeters;
132  kkint32 imagingWidthPixels; /**< Should represent the width of the imaging chamber in pixels. */
133  float scanRate;
134  float ticsPerMeter; /**< Assuming that flow-rate(m/s) is a linear function of Flow-Meter-Count. */
135  }; /* FlowMeterTracker */
136 
137 
138  typedef FlowMeterTracker::FlowMeterTrackerPtr FlowMeterTrackerPtr;
139 
140 }; /* KKLSC */
141 
142 #endif
kkint32 ImagingWidthPixels() const
float FlowRateRatioDefault() const
__int32 kkint32
Definition: KKBaseTypes.h:88
float ComputeFlowRateFromFlowRateRatio(float _flowRateRatio)
FlowMeterTracker(const FlowMeterTracker &entry)
void Initialize(bool _flowMeterPresent, float _flowRateRatioDefault, kkint32 _historyTableSize, float _scanRate, float _imagingWidthMeters, kkint32 _imagingWidthPixels, float _ticsPerMeter)
void GetFlowRateTrend(float &flowRate, float &flowRateRatio)
bool FlowMeterPresent() const
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
KKTHread * KKTHreadPtr
void GetFlowRateInstantaneous(float &flowRate, float &flowRateRatio)
float ComputeFlowRateRatioFromFlowRate(float _flowRate)
float FlowRateDefault() const
Class that keeps track the Flow-Meter-Counter values by scan-lines; using these values it will comput...
kkint32 HistoryTableSize() const
FlowMeterTracker * FlowMeterTrackerPtr
Contains Classes that are specific to Cameras physical characteristics.
void ScanRateChanged(float _newScanRate)
void AddEntry(kkuint32 _scanLineNum, kkuint32 _counterValue)
float ImagingWidthMeters() const
float TicsPerMeter() const
void FlowRateRatioDefaultChanged(float _flowRateRatioDefault)