コード例 #1
0
ファイル: Avg.cs プロジェクト: zhchxxx/scada-community
        /// <summary>
        /// Calculates average of the current input channel over the time span.
        /// </summary>
        public double TimeAvg(int timeSpanSec, int maxPointCount, double cnlVal)
        {
            TimeAvgItem timeAvgItem = GetOrAddTimeAvgItem(CnlNum, timeSpanSec, maxPointCount);

            timeAvgItem.Append(cnlVal);
            return(timeAvgItem.Avg);
        }
コード例 #2
0
ファイル: Avg.cs プロジェクト: zhchxxx/scada-community
        /// <summary>
        /// Adds a new or gets an existing TimeAvgItem.
        /// </summary>
        public TimeAvgItem GetOrAddTimeAvgItem(int cnlNum, int timeSpanSec, int maxPointCount)
        {
            MovAvgItem movAvgItem;

            if (MovAvgItems.TryGetValue(cnlNum, out movAvgItem) && movAvgItem is TimeAvgItem)
            {
                return((TimeAvgItem)movAvgItem);
            }
            else
            {
                TimeAvgItem timeAvgItem = new TimeAvgItem(timeSpanSec, maxPointCount);
                MovAvgItems[cnlNum] = timeAvgItem;
                return(timeAvgItem);
            }
        }