24 using namespace KKLSC;
30 flowMeterPresent (
false),
31 flowRateDefault (1.0f),
32 flowRateRatioDefault (1.0f),
34 historyTableSize (-1),
35 historyLastIdxAdded (-1),
36 historyOldestIdx (-1),
37 imagingWidthMeters (0.0635f),
38 imagingWidthPixels (2048),
47 flowMeterPresent (entry.flowMeterPresent),
48 flowRateDefault (entry.flowRateDefault),
49 flowRateRatioDefault (entry.flowRateRatioDefault),
51 historyTableSize (entry.historyTableSize),
52 historyLastIdxAdded (entry.historyLastIdxAdded),
53 historyOldestIdx (entry.historyOldestIdx),
54 imagingWidthMeters (entry.imagingWidthMeters),
55 imagingWidthPixels (entry.imagingWidthPixels),
56 scanRate (entry.scanRate),
57 ticsPerMeter (entry.ticsPerMeter)
59 history =
new Entry[historyTableSize];
60 for (
kkint32 x = 0; x < historyTableSize; ++x)
61 history[x] = entry.history[x];
75 float _flowRateRatioDefault,
78 float _imagingWidthMeters,
83 flowMeterPresent = _flowMeterPresent;
84 flowRateRatioDefault = _flowRateRatioDefault;
86 imagingWidthMeters = _imagingWidthMeters;
87 imagingWidthPixels = _imagingWidthPixels;
88 ticsPerMeter = _ticsPerMeter;
90 historyTableSize = _historyTableSize;
92 history =
new Entry[historyTableSize];
93 historyLastIdxAdded = -1;
94 historyOldestIdx = -1;
104 if (historyTableSize > 0)
105 mem +=
sizeof (Entry) * historyTableSize;
113 flowRateRatioDefault = _flowRateRatioDefault;
121 scanRate = _newScanRate;
132 if (historyLastIdxAdded < 0)
134 historyLastIdxAdded = 0;
135 historyOldestIdx = 0;
139 ++historyLastIdxAdded;
140 if (historyLastIdxAdded >= historyTableSize)
141 historyLastIdxAdded = 0;
142 if (historyLastIdxAdded == historyOldestIdx)
145 if (historyOldestIdx >= historyTableSize)
146 historyOldestIdx = 0;
149 history[historyLastIdxAdded].scanLineNum = _scanLineNum;
150 history[historyLastIdxAdded].counterValue = _counterValue;
165 if ((historyLastIdxAdded == historyOldestIdx) || (ticsPerMeter == 0.0f) || (scanRate == 0.0f))
166 return flowRateDefault;
168 kkint32 prevIdx = historyLastIdxAdded - 1;
170 prevIdx = historyTableSize - 1;
172 EntryPtr lastPtr = history + historyLastIdxAdded;
173 EntryPtr prevPtr = history + prevIdx;
175 kkint32 tics = lastPtr->counterValue - prevPtr->counterValue;
176 kkint32 scanLines = lastPtr->scanLineNum - prevPtr->scanLineNum;
178 float meters = tics / ticsPerMeter;
179 float secs = scanLines / scanRate;
181 return meters / secs;
189 if ((historyLastIdxAdded == historyOldestIdx) || (ticsPerMeter == 0.0f) || (scanRate == 0.0f))
190 return flowRateDefault;
192 EntryPtr lastPtr = history + historyLastIdxAdded;
193 EntryPtr prevPtr = history + historyOldestIdx;
195 kkint32 tics = lastPtr->counterValue - prevPtr->counterValue;
196 kkint32 scanLines = lastPtr->scanLineNum - prevPtr->scanLineNum;
198 if ((tics == 0) || (scanLines == 0))
201 float meters = tics / ticsPerMeter;
202 float secs = scanLines / scanRate;
204 return meters / secs;
214 if (!flowMeterPresent)
216 flowRate = flowRateDefault;
217 flowRateRatio = flowRateRatioDefault;
232 if ((!flowMeterPresent) || (
this->historyLastIdxAdded < 0) || (historyLastIdxAdded ==
this->historyOldestIdx))
234 flowRate = flowRateDefault;
235 flowRateRatio = flowRateRatioDefault;
239 if (!flowMeterPresent)
241 flowRate = flowRateDefault;
242 flowRateRatio = flowRateRatioDefault;
256 if ((_flowRateRatio == 0.0f) || (imagingWidthPixels == 0.0f))
257 return flowRateDefault;
260 float flowRate = (_flowRateRatio * scanRate * imagingWidthMeters) / imagingWidthPixels;
269 if ((_flowRate == 0.0f) || (imagingWidthPixels == 0.0f))
270 return flowRateRatioDefault;
273 float flowRateRatio = (_flowRate * imagingWidthPixels) / (imagingWidthMeters * scanRate);
275 return flowRateRatio;
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)
unsigned __int32 kkuint32
void GetFlowRateInstantaneous(float &flowRate, float &flowRateRatio)
float ComputeFlowRateRatioFromFlowRate(float _flowRate)
kkint32 MemoryConsumedEstimated()
Class that keeps track the Flow-Meter-Counter values by scan-lines; using these values it will comput...
Contains Classes that are specific to Cameras physical characteristics.
void ScanRateChanged(float _newScanRate)
void AddEntry(kkuint32 _scanLineNum, kkuint32 _counterValue)
float FlowRateInstantaneous()
void FlowRateRatioDefaultChanged(float _flowRateRatioDefault)