public void Tick() { FCalc.Tick(); FlowRate FlowRateInstance = new FlowRate(FCalc.LHTT, FCalc.LHT); Push(FlowRateInstance); //avg flowrateinstances AvgIncFlowRate = 0; foreach (FlowRate element in FlowInstances) { AvgIncFlowRate += (int)element.IncRate; AvgOutFlowRate += (int)element.OutRate; } AvgIncFlowRate = AvgIncFlowRate / FlowInstances.Count; AvgOutFlowRate = AvgOutFlowRate / FlowInstances.Count; }
public void Push(FlowRate flowRateInstance) { FlowInstances.Enqueue(flowRateInstance); while (FlowInstances.Count > 60)//Each tick is 5 seconds. We want 5 minutes worth of ticks. 60secs/(5 sec intervals) => 12 ticks per min * 5mins = 60 { FlowInstances.Dequeue(); } }