Esempio n. 1
0
        /// <summary>
        /// Triggers calculation of
        /// </summary>
        /// <param name="timestamp"></param>
        /// <returns></returns>
        internal void CalculateValuesAsync(DateTime timestamp)
        {
            // Trigger kpi calculation
            DateTime actKeyTimestamp = m_lastValueTimestamp + m_valueInterval;

            while (actKeyTimestamp < timestamp)
            {
                DateTime actMaxTimestamp = actKeyTimestamp;
                DateTime actMinTimestamp = actKeyTimestamp - m_calculationInterval;
                if (actMinTimestamp < m_startupTimestamp)
                {
                    actMinTimestamp = m_startupTimestamp;
                }

                // Calculate reporting values
                foreach (CalculatorInfo actCalculatorInfo in m_calculatorsBag)
                {
                    PerformanceAnalyzeResultBase actResult = actCalculatorInfo.Calculator.Calculate(
                        actKeyTimestamp,
                        actMinTimestamp, actMaxTimestamp,
                        m_calculationInterval);
                    actCalculatorInfo.Results.Add(actResult);
                }

                // Handle next value timestamp
                m_lastValueTimestamp = actKeyTimestamp;
                actKeyTimestamp      = m_lastValueTimestamp + m_valueInterval;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Refreshes the gui in a sync call.
        /// </summary>
        public void RefreshUICollections()
        {
            m_uiDurationKpisCurrents.Clear();

            foreach (CalculatorInfo actCalculatorInfo in m_calculatorsBag)
            {
                PerformanceAnalyzeResultBase actResult = null;
                while (actCalculatorInfo.Results.TryTake(out actResult))
                {
                    this.HandleResultForUI(actResult);
                }
            }
        }
        /// <summary>
        /// Handles the given result object for the UI layer.
        /// </summary>
        /// <param name="actResult">The result to be processed.</param>
        private void HandleResultForUI(PerformanceAnalyzeResultBase actResult)
        {
            // Handle duration kpi results
            DurationPerformanceResult actDurationResult = actResult as DurationPerformanceResult;

            if (actDurationResult != null)
            {
                HandleResultForUIForFlowRateKpi(
                    actDurationResult,
                    m_uiDurationKpisHistorical, m_uiDurationKpisCurrents);
                return;
            }

            // Put here other result handlers
            FlowRatePerformanceResult actFlowRateResult = actResult as FlowRatePerformanceResult;

            if (actFlowRateResult != null)
            {
                HandleResultForUIForFlowRateKpi(
                    actFlowRateResult,
                    m_uiFlowRateKpisHistorical, m_uiFlowRateKpisCurrents);
                return;
            }
        }