Пример #1
0
        public Domain.Service.IJobIndexPointCalculator GetCalculator(Domain.Model.Calculations.CalculationId calculationId)
        {
            lock (providerLock)
            {
                if (calculators.Any(i => !i.Key.Equals(calculationId) && i.Value.State == CalculatorState.Running))
                {
                    throw new Exception("تنها اجرای یک محاسبه امکان پذیر است.");
                }

                return(calculators.AddOrUpdate(calculationId,
                                               id => (JobIndexPointCalculator)ServiceLocator.Current.GetInstance <IJobIndexPointCalculator>(),
                                               (id, old) =>
                {
                    if (old != null)
                    {
                        if (old.State == CalculatorState.Running)
                        {
                            return old;
                        }
                        else
                        {
                            ServiceLocator.Current.Release(old);
                        }
                    }
                    return (JobIndexPointCalculator)ServiceLocator.Current.GetInstance <IJobIndexPointCalculator>();
                }));
            }
        }
Пример #2
0
        public string GetStatus()
        {
            //send/receive calc time avg
            Int64 RcvTimeAvg = 0;

            if (LFrameRcv.Any())
            {
                foreach (KeyValuePair <Int64, Frame> fList in LFrameRcv)
                {
                    //foreach (Frame fList in LFrameRcv)
                    RcvTimeAvg += fList.Value.TimeRcvAnswer.Milliseconds;
                }
                RcvTimeAvg = RcvTimeAvg / LFrameRcv.Count;
            }

            return("[Frame min: " + TimeRcvAnswerMin.Milliseconds.ToString() +
                   " max: " + TimeRcvAnswerMax.Milliseconds.ToString() +
                   " avg: " + RcvTimeAvg.ToString() +
                   " @work: " + InWorkFrameCount() +
                   //" done: " + TotalFramesFinished.ToString() +
                   " send: " + TotalFramesSend +
                   " rcv: " + _udp_server.CountRcvFrames.ToString() + "/" + LFrameRcv.Count().ToString() +
                   " clients: " + ListClients.Count.ToString() +
                   "]");
        }