Пример #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Task.Run(async() =>
     {
         DoUpdate doUpdate = new DoUpdate();
         await doUpdate.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UpdateConfig.json"), setText, setProgress);
         this.Invoke(new Action(() => { this.Close(); }));
     });
 }
Пример #2
0
        public ProcCacheDetails(bool version)
        {
            DoRefresh = new BackgroundWorker();

            InitializeComponent();
            InitializeBackgoundWorker();

            pre2005      = version;
            cmbRows.Text = "50";
            DropDownText = "50";
            ShowPlans    = false;
            UseDelegate  = false;

            MyCallBack = new DoUpdate(UpdateFormData);
        }
Пример #3
0
        private Text speechText;             // セリフ用吹き出しテキスト

        ///////////////////////////////////////////////////////////////////////////////////////////
        // 更新 メソッド

        // Awake is called when the script instance is being loaded.
        void Awake()
        {
            doUpdate      = DoUpdate.GetInstance();      // 状態フラグ構造体
            doFixedUpdate = DoFixedUpdate.GetInstance(); // 物理挙動フラグ構造体

            // SoundSystem 取得
            soundSystem = GameObject.Find("SoundSystem").GetComponent <SoundSystem>();

            // セリフ吹き出し大きさ取得
            var _rect = speechImage.GetComponent <RectTransform>();

            speechX = _rect.sizeDelta.x;
            speechY = _rect.sizeDelta.y;

            // セリフ吹き出しテキスト取得
            speechText = speechImage.GetComponentInChildren <Text>();
        }
Пример #4
0
        private void OnDoCommence(object sender, CommenceArgs e)
        {
            Today = StartDate;

            if (DoInitialSummary != null)
            {
                DoInitialSummary.Invoke(this, args);
            }

            if (StartOfSimulation != null)
            {
                StartOfSimulation.Invoke(this, args);
            }

            if (CLEMInitialiseResource != null)
            {
                CLEMInitialiseResource.Invoke(this, args);
            }

            if (CLEMInitialiseActivity != null)
            {
                CLEMInitialiseActivity.Invoke(this, args);
            }

            if (FinalInitialise != null)
            {
                FinalInitialise.Invoke(this, args);
            }

            if (CLEMValidate != null)
            {
                CLEMValidate.Invoke(this, args);
            }

            while (Today <= EndDate && (e.CancelToken == null || !e.CancelToken.IsCancellationRequested))
            {
                if (DoWeather != null)
                {
                    DoWeather.Invoke(this, args);
                }

                if (DoDailyInitialisation != null)
                {
                    DoDailyInitialisation.Invoke(this, args);
                }

                if (StartOfDay != null)
                {
                    StartOfDay.Invoke(this, args);
                }

                if (Today.Day == 1 && StartOfMonth != null)
                {
                    StartOfMonth.Invoke(this, args);
                }

                if (Today.DayOfYear == 1 && StartOfYear != null)
                {
                    StartOfYear.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                {
                    StartOfWeek.Invoke(this, args);
                }

                if (DoManagement != null)
                {
                    DoManagement.Invoke(this, args);
                }

                if (DoPestDiseaseDamage != null)
                {
                    DoPestDiseaseDamage.Invoke(this, args);
                }

                if (DoEnergyArbitration != null)
                {
                    DoEnergyArbitration.Invoke(this, args);
                }

                if (DoSoilWaterMovement != null)
                {
                    DoSoilWaterMovement.Invoke(this, args);
                }

                if (DoSoilTemperature != null)
                {
                    DoSoilTemperature.Invoke(this, args);
                }

                if (DoSoilOrganicMatter != null)
                {
                    DoSoilOrganicMatter.Invoke(this, args);
                }

                if (DoSurfaceOrganicMatterDecomposition != null)
                {
                    DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                }

                if (DoUpdateWaterDemand != null)
                {
                    DoUpdateWaterDemand.Invoke(this, args);
                }

                if (DoWaterArbitration != null)
                {
                    DoWaterArbitration.Invoke(this, args);
                }

                if (PrePhenology != null)
                {
                    PrePhenology.Invoke(this, args);
                }

                if (DoPhenology != null)
                {
                    DoPhenology.Invoke(this, args);
                }

                if (DoPotentialPlantGrowth != null)
                {
                    DoPotentialPlantGrowth.Invoke(this, args);
                }

                if (DoPotentialPlantPartioning != null)
                {
                    DoPotentialPlantPartioning.Invoke(this, args);
                }

                if (DoNutrientArbitration != null)
                {
                    DoNutrientArbitration.Invoke(this, args);
                }

                if (DoActualPlantPartioning != null)
                {
                    DoActualPlantPartioning.Invoke(this, args);
                }

                if (DoActualPlantGrowth != null)
                {
                    DoActualPlantGrowth.Invoke(this, args);
                }

                if (DoStock != null)
                {
                    DoStock.Invoke(this, args);
                }

                if (DoLifecycle != null)
                {
                    DoLifecycle.Invoke(this, args);
                }

                if (DoUpdate != null)
                {
                    DoUpdate.Invoke(this, args);
                }

                if (DoManagementCalculations != null)
                {
                    DoManagementCalculations.Invoke(this, args);
                }

                if (DoReportCalculations != null)
                {
                    DoReportCalculations.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                {
                    EndOfWeek.Invoke(this, args);
                }

                if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                {
                    EndOfYear.Invoke(this, args);
                }

                if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month?
                {
                    // CLEM events performed before APSIM EndOfMonth
                    if (CLEMStartOfTimeStep != null)
                    {
                        CLEMStartOfTimeStep.Invoke(this, args);
                    }
                    if (CLEMUpdateLabourAvailability != null)
                    {
                        CLEMUpdateLabourAvailability.Invoke(this, args);
                    }
                    if (CLEMUpdatePasture != null)
                    {
                        CLEMUpdatePasture.Invoke(this, args);
                    }
                    if (CLEMPastureReady != null)
                    {
                        CLEMPastureReady.Invoke(this, args);
                    }
                    if (CLEMDoCutAndCarry != null)
                    {
                        CLEMDoCutAndCarry.Invoke(this, args);
                    }
                    if (CLEMAnimalBreeding != null)
                    {
                        CLEMAnimalBreeding.Invoke(this, args);
                    }
                    if (CLEMAnimalMilkProduction != null)
                    {
                        CLEMAnimalMilkProduction.Invoke(this, args);
                    }
                    if (CLEMPotentialIntake != null)
                    {
                        CLEMPotentialIntake.Invoke(this, args);
                    }
                    if (CLEMGetResourcesRequired != null)
                    {
                        CLEMGetResourcesRequired.Invoke(this, args);
                    }
                    if (CLEMAnimalWeightGain != null)
                    {
                        CLEMAnimalWeightGain.Invoke(this, args);
                    }
                    if (CLEMCalculateManure != null)
                    {
                        CLEMCalculateManure.Invoke(this, args);
                    }
                    if (CLEMCollectManure != null)
                    {
                        CLEMCollectManure.Invoke(this, args);
                    }
                    if (CLEMAnimalDeath != null)
                    {
                        CLEMAnimalDeath.Invoke(this, args);
                    }
                    if (CLEMAnimalMilking != null)
                    {
                        CLEMAnimalMilking.Invoke(this, args);
                    }
                    if (CLEMCalculateEcologicalState != null)
                    {
                        CLEMCalculateEcologicalState.Invoke(this, args);
                    }
                    if (CLEMAnimalManage != null)
                    {
                        CLEMAnimalManage.Invoke(this, args);
                    }
                    if (CLEMAnimalStock != null)
                    {
                        CLEMAnimalStock.Invoke(this, args);
                    }
                    if (CLEMAnimalSell != null)
                    {
                        CLEMAnimalSell.Invoke(this, args);
                    }
                    if (CLEMDetachPasture != null)
                    {
                        CLEMDetachPasture.Invoke(this, args);
                    }
                    if (CLEMHerdSummary != null)
                    {
                        CLEMHerdSummary.Invoke(this, args);
                    }
                    if (CLEMAgeResources != null)
                    {
                        CLEMAgeResources.Invoke(this, args);
                    }
                    if (CLEMAnimalBuy != null)
                    {
                        CLEMAnimalBuy.Invoke(this, args);
                    }
                    if (CLEMEndOfTimeStep != null)
                    {
                        CLEMEndOfTimeStep.Invoke(this, args);
                    }
                    EndOfMonth.Invoke(this, args);
                }

                if (EndOfDay != null)
                {
                    EndOfDay.Invoke(this, args);
                }

                if (DoReport != null)
                {
                    DoReport.Invoke(this, args);
                }

                Today = Today.AddDays(1);
            }
            Today = EndDate;

            if (EndOfSimulation != null)
            {
                EndOfSimulation.Invoke(this, args);
            }

            Summary?.WriteMessage(this, "Simulation terminated normally");
        }
Пример #5
0
        private void OnDoCommence(object sender, Simulation.CommenceArgs e)
        {
            if (DoInitialSummary != null)
            {
                DoInitialSummary.Invoke(this, args);
            }

            if (StartOfSimulation != null)
            {
                StartOfSimulation.Invoke(this, args);
            }

            while (Today <= EndDate)
            {
                // If this is being run on a background worker thread then check for cancellation
                if (e != null && e.workerThread != null && e.workerThread.CancellationPending)
                {
                    Summary.WriteMessage(this, "Simulation cancelled");
                    return;
                }

                if (DoWeather != null)
                {
                    DoWeather.Invoke(this, args);
                }

                if (DoDailyInitialisation != null)
                {
                    DoDailyInitialisation.Invoke(this, args);
                }

                if (StartOfDay != null)
                {
                    StartOfDay.Invoke(this, args);
                }

                if (Today.Day == 1 && StartOfMonth != null)
                {
                    StartOfMonth.Invoke(this, args);
                }

                if (Today.DayOfYear == 1 && StartOfYear != null)
                {
                    StartOfYear.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                {
                    StartOfWeek.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                {
                    EndOfWeek.Invoke(this, args);
                }

                if (DoManagement != null)
                {
                    DoManagement.Invoke(this, args);
                }

                if (DoEnergyArbitration != null)
                {
                    DoEnergyArbitration.Invoke(this, args);
                }

                if (DoSoilWaterMovement != null)
                {
                    DoSoilWaterMovement.Invoke(this, args);
                }

                if (DoSoilTemperature != null)
                {
                    DoSoilTemperature.Invoke(this, args);
                }

                if (DoSoilOrganicMatter != null)
                {
                    DoSoilOrganicMatter.Invoke(this, args);
                }

                if (DoSurfaceOrganicMatterDecomposition != null)
                {
                    DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                }
                if (Today.DayOfYear == 16)
                {
                }
                if (DoWaterArbitration != null)
                {
                    DoWaterArbitration.Invoke(this, args);
                }

                if (DoPhenology != null)
                {
                    DoPhenology.Invoke(this, args);
                }

                if (DoPotentialPlantGrowth != null)
                {
                    DoPotentialPlantGrowth.Invoke(this, args);
                }

                if (DoPotentialPlantPartioning != null)
                {
                    DoPotentialPlantPartioning.Invoke(this, args);
                }

                if (DoNutrientArbitration != null)
                {
                    DoNutrientArbitration.Invoke(this, args);
                }

                if (DoActualPlantPartioning != null)
                {
                    DoActualPlantPartioning.Invoke(this, args);
                }

                if (DoActualPlantGrowth != null)
                {
                    DoActualPlantGrowth.Invoke(this, args);
                }

                if (DoPlantGrowth != null)
                {
                    DoPlantGrowth.Invoke(this, args);
                }

                if (DoUpdate != null)
                {
                    DoUpdate.Invoke(this, args);
                }

                if (DoManagementCalculations != null)
                {
                    DoManagementCalculations.Invoke(this, args);
                }

                if (DoStock != null)
                {
                    DoStock.Invoke(this, args);
                }

                if (DoLifecycle != null)
                {
                    DoLifecycle.Invoke(this, args);
                }

                if (DoReportCalculations != null)
                {
                    DoReportCalculations.Invoke(this, args);
                }

                if (Today == EndDate && EndOfSimulation != null)
                {
                    EndOfSimulation.Invoke(this, args);
                }

                if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                {
                    EndOfYear.Invoke(this, args);
                }

                if (Today.AddDays(1).Day == 1 && EndOfMonth != null)                 // is tomorrow the start of a new month?
                {
                    // WholeFarm events performed before APSIM EndOfMonth
                    if (WFUpdatePasture != null)
                    {
                        WFUpdatePasture.Invoke(this, args);
                    }
                    if (WFDoCutAndCarry != null)
                    {
                        WFDoCutAndCarry.Invoke(this, args);
                    }
                    if (WFAnimalBreeding != null)
                    {
                        WFAnimalBreeding.Invoke(this, args);
                    }
                    if (WFPotentialIntake != null)
                    {
                        WFPotentialIntake.Invoke(this, args);
                    }
                    if (WFGetResourcesRequired != null)
                    {
                        WFGetResourcesRequired.Invoke(this, args);
                    }
                    if (WFAnimalMilkProduction != null)
                    {
                        WFAnimalMilkProduction.Invoke(this, args);
                    }
                    if (WFAnimalWeightGain != null)
                    {
                        WFAnimalWeightGain.Invoke(this, args);
                    }
                    if (WFAnimalDeath != null)
                    {
                        WFAnimalDeath.Invoke(this, args);
                    }
                    if (WFAnimalMilking != null)
                    {
                        WFAnimalMilking.Invoke(this, args);
                    }
                    if (WFAnimalManage != null)
                    {
                        WFAnimalManage.Invoke(this, args);
                    }
                    if (WFAnimalStock != null)
                    {
                        WFAnimalStock.Invoke(this, args);
                    }
                    if (WFAnimalSell != null)
                    {
                        WFAnimalSell.Invoke(this, args);
                    }
                    if (WFAgeResources != null)
                    {
                        WFAgeResources.Invoke(this, args);
                    }

                    EndOfMonth.Invoke(this, args);
                }

                if (EndOfDay != null)
                {
                    EndOfDay.Invoke(this, args);
                }

                if (DoReport != null)
                {
                    DoReport.Invoke(this, args);
                }

                Today = Today.AddDays(1);
            }

            Summary.WriteMessage(this, "Simulation terminated normally");
        }
Пример #6
0
        private void OnDoCommence(object sender, Core.Runners.RunSimulation.CommenceArgs e)
        {
            try
            {
                if (DoInitialSummary != null)
                {
                    DoInitialSummary.Invoke(this, args);
                }

                if (StartOfSimulation != null)
                {
                    StartOfSimulation.Invoke(this, args);
                }

                while (Today <= EndDate && !e.CancelToken.IsCancellationRequested)
                {
                    if (DoWeather != null)
                    {
                        DoWeather.Invoke(this, args);
                    }

                    if (DoDailyInitialisation != null)
                    {
                        DoDailyInitialisation.Invoke(this, args);
                    }

                    if (StartOfDay != null)
                    {
                        StartOfDay.Invoke(this, args);
                    }

                    if (Today.Day == 1 && StartOfMonth != null)
                    {
                        StartOfMonth.Invoke(this, args);
                    }

                    if (Today.DayOfYear == 1 && StartOfYear != null)
                    {
                        StartOfYear.Invoke(this, args);
                    }

                    if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                    {
                        StartOfWeek.Invoke(this, args);
                    }

                    if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                    {
                        EndOfWeek.Invoke(this, args);
                    }

                    if (DoManagement != null)
                    {
                        DoManagement.Invoke(this, args);
                    }

                    if (DoEnergyArbitration != null)
                    {
                        DoEnergyArbitration.Invoke(this, args);
                    }

                    if (DoSoilWaterMovement != null)
                    {
                        DoSoilWaterMovement.Invoke(this, args);
                    }

                    if (DoSoilTemperature != null)
                    {
                        DoSoilTemperature.Invoke(this, args);
                    }

                    if (DoSoilOrganicMatter != null)
                    {
                        DoSoilOrganicMatter.Invoke(this, args);
                    }

                    if (DoSurfaceOrganicMatterDecomposition != null)
                    {
                        DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                    }

                    if (DoWaterArbitration != null)
                    {
                        DoWaterArbitration.Invoke(this, args);
                    }

                    if (DoPhenology != null)
                    {
                        DoPhenology.Invoke(this, args);
                    }

                    if (DoPotentialPlantGrowth != null)
                    {
                        DoPotentialPlantGrowth.Invoke(this, args);
                    }

                    if (DoPotentialPlantPartioning != null)
                    {
                        DoPotentialPlantPartioning.Invoke(this, args);
                    }

                    if (DoNutrientArbitration != null)
                    {
                        DoNutrientArbitration.Invoke(this, args);
                    }

                    if (DoActualPlantPartioning != null)
                    {
                        DoActualPlantPartioning.Invoke(this, args);
                    }

                    if (DoActualPlantGrowth != null)
                    {
                        DoActualPlantGrowth.Invoke(this, args);
                    }

                    if (DoPlantGrowth != null)
                    {
                        DoPlantGrowth.Invoke(this, args);
                    }

                    if (DoUpdate != null)
                    {
                        DoUpdate.Invoke(this, args);
                    }

                    if (DoManagementCalculations != null)
                    {
                        DoManagementCalculations.Invoke(this, args);
                    }

                    if (DoStock != null)
                    {
                        DoStock.Invoke(this, args);
                    }

                    if (DoLifecycle != null)
                    {
                        DoLifecycle.Invoke(this, args);
                    }

                    if (DoReportCalculations != null)
                    {
                        DoReportCalculations.Invoke(this, args);
                    }

                    if (Today == EndDate && EndOfSimulation != null)
                    {
                        EndOfSimulation.Invoke(this, args);
                    }

                    if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                    {
                        EndOfYear.Invoke(this, args);
                    }

                    if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month?
                    {
                        // WholeFarm events performed before APSIM EndOfMonth
                        if (WFUpdatePasture != null)
                        {
                            WFUpdatePasture.Invoke(this, args);
                        }
                        if (WFDoCutAndCarry != null)
                        {
                            WFDoCutAndCarry.Invoke(this, args);
                        }
                        if (WFAnimalBreeding != null)
                        {
                            WFAnimalBreeding.Invoke(this, args);
                        }
                        if (WFPotentialIntake != null)
                        {
                            WFPotentialIntake.Invoke(this, args);
                        }
                        if (WFGetResourcesRequired != null)
                        {
                            WFGetResourcesRequired.Invoke(this, args);
                        }
                        if (WFAnimalMilkProduction != null)
                        {
                            WFAnimalMilkProduction.Invoke(this, args);
                        }
                        if (WFAnimalWeightGain != null)
                        {
                            WFAnimalWeightGain.Invoke(this, args);
                        }
                        if (WFAnimalDeath != null)
                        {
                            WFAnimalDeath.Invoke(this, args);
                        }
                        if (WFAnimalMilking != null)
                        {
                            WFAnimalMilking.Invoke(this, args);
                        }
                        if (WFAnimalManage != null)
                        {
                            WFAnimalManage.Invoke(this, args);
                        }
                        if (WFAnimalStock != null)
                        {
                            WFAnimalStock.Invoke(this, args);
                        }
                        if (WFAnimalSell != null)
                        {
                            WFAnimalSell.Invoke(this, args);
                        }
                        if (WFAgeResources != null)
                        {
                            WFAgeResources.Invoke(this, args);
                        }

                        EndOfMonth.Invoke(this, args);
                    }

                    if (EndOfDay != null)
                    {
                        EndOfDay.Invoke(this, args);
                    }

                    if (DoReport != null)
                    {
                        DoReport.Invoke(this, args);
                    }

                    Today = Today.AddDays(1);
                }
                Summary.WriteMessage(this, "Simulation terminated normally");
            }
            catch (Exception ex)
            {
                Summary.WriteMessage(this, "Simulation terminated due to exception: " + ex.Message);
                // Is there a good mechanism for letting our invoker know that an error has occurred?
                // Throwing this back to the caller doesn't seem to work. This seems to be a consequence
                // of the Invoke method used to call us crossing the native/managed boundary. I'm not
                // sure why this is so...
                // throw ex;
            }
        }
Пример #7
0
        private static void Run <T>(IIndex <int, TRectangle, TPoint> index, IList <Tuple <int, T> > data,
                                    BuildSmallUpdates <T> makeSmallUpdate,
                                    BuildLargeUpdates <T> makeLargeUpdate,
                                    AddEntries <T> addEntries,
                                    DoUpdate <T> doUpdate)
        {
            // Get new randomizer.
            var random = new MersenneTwister(Seed);

            // Get stop watch for profiling.
            var watch = new Stopwatch();

            // Also allocate the ids to look up in advance.
            var rangeQueries = new List <Tuple <TPoint, float> >(Operations);
            var areaQueries  = new List <TRectangle>(Operations);

            // And updates.
            var smallUpdates = new List <Tuple <int, T> >(Operations);
            var largeUpdates = new List <Tuple <int, T> >(Operations);

            var addTime              = new DoubleSampling(Iterations);
            var rangeQueryTime       = new DoubleSampling(Iterations);
            var areaQueryTime        = new DoubleSampling(Iterations);
            var smallUpdateTime      = new DoubleSampling(Iterations);
            var largeUpdateTime      = new DoubleSampling(Iterations);
            var highLoadRemoveTime   = new DoubleSampling(Iterations);
            var mediumLoadRemoveTime = new DoubleSampling(Iterations);
            var lowLoadRemoveTime    = new DoubleSampling(Iterations);

            Console.Write("Doing {0} iterations... ", Iterations);

            for (var i = 0; i < Iterations; i++)
            {
                Console.Write("{0}. ", i + 1);

                // Clear the index.
                index.Clear();

                // Generate look up ids in advance.
                rangeQueries.Clear();
                for (var j = 0; j < Operations; j++)
                {
                    rangeQueries.Add(Tuple.Create(random.NextVector(Area), MinQueryRange + (MaxQueryRange - MinQueryRange) * (float)random.NextDouble()));
                }
                areaQueries.Clear();
                for (var j = 0; j < Operations; j++)
                {
                    areaQueries.Add(random.NextRectangle(Area, MinQueryRange * 2, MaxQueryRange * 2));
                }

                // Generate position updates.
                smallUpdates.Clear();
                largeUpdates.Clear();
                for (var j = 0; j < Operations; j++)
                {
                    // High chance it remains in the same cell.
                    makeSmallUpdate(smallUpdates, data, random, j);
                }
                for (var j = 0; j < Operations; j++)
                {
                    // High chance it will be outside the original cell.
                    makeLargeUpdate(largeUpdates, data, random, j);
                }

                // Test time to add.
                try
                {
                    watch.Reset();
                    watch.Start();
                    addEntries(index, data);
                    watch.Stop();
                    addTime.Put(watch.ElapsedMilliseconds / (double)NumberOfObjects);
                }
                catch (NotSupportedException)
                {
                }

                // Test update time.
                try
                {
                    watch.Reset();
                    watch.Start();
                    foreach (var update in smallUpdates)
                    {
                        doUpdate(index, update);
                    }
                    watch.Stop();
                    smallUpdateTime.Put(watch.ElapsedMilliseconds / (double)smallUpdates.Count);
                }
                catch (NotSupportedException)
                {
                }

                try
                {
                    watch.Reset();
                    watch.Start();
                    foreach (var update in largeUpdates)
                    {
                        doUpdate(index, update);
                    }
                    watch.Stop();
                    largeUpdateTime.Put(watch.ElapsedMilliseconds / (double)largeUpdates.Count);
                }
                catch (NotSupportedException)
                {
                }

                // Test look up time.
                try
                {
                    watch.Reset();
                    watch.Start();
                    for (var j = 0; j < Operations; j++)
                    {
#if USE_CALLBACK
                        index.Find(rangeQueries[j].Item1, rangeQueries[j].Item2, value => true);
#else
                        index.Find(rangeQueries[j].Item1, rangeQueries[j].Item2, ref DummyCollection <int> .Instance);
#endif
                    }
                    watch.Stop();
                    rangeQueryTime.Put(watch.ElapsedMilliseconds / (double)Operations);
                }
                catch (NotSupportedException)
                {
                }

                try
                {
                    watch.Reset();
                    watch.Start();
                    for (var j = 0; j < Operations; j++)
                    {
                        var rect = areaQueries[j];
#if USE_CALLBACK
                        index.Find(rect, value => true);
#else
                        index.Find(rect, ref DummyCollection <int> .Instance);
#endif
                    }
                    watch.Stop();
                    areaQueryTime.Put(watch.ElapsedMilliseconds / (double)Operations);
                }
                catch (NotSupportedException)
                {
                }

                // Test removal time.
                try
                {
                    watch.Reset();
                    watch.Start();
                    for (var j = 0; j < NumberOfObjects / 3; j++)
                    {
                        index.Remove(data[j].Item1);
                    }
                    watch.Stop();
                    highLoadRemoveTime.Put(watch.ElapsedMilliseconds / (double)(NumberOfObjects / 3));
                }
                catch (NotSupportedException)
                {
                }

                try
                {
                    watch.Reset();
                    watch.Start();
                    for (var j = NumberOfObjects / 3; j < NumberOfObjects * 2 / 3; j++)
                    {
                        index.Remove(data[j].Item1);
                    }
                    watch.Stop();
                    mediumLoadRemoveTime.Put(watch.ElapsedMilliseconds / (double)(NumberOfObjects / 3));
                }
                catch (NotSupportedException)
                {
                }

                try
                {
                    watch.Reset();
                    watch.Start();
                    for (var j = NumberOfObjects * 2 / 3; j < NumberOfObjects; j++)
                    {
                        index.Remove(data[j].Item1);
                    }
                    watch.Stop();
                    lowLoadRemoveTime.Put(watch.ElapsedMilliseconds / (double)(NumberOfObjects / 3));
                }
                catch (NotSupportedException)
                {
                }
            }

            Console.WriteLine("Done!");

            Console.WriteLine("Operation           | Mean      | Std.dev.\n" +
                              "Add:                | {0:0.00000}ms | {1:0.00000}ms\n" +
                              "Range query:        | {2:0.00000}ms | {3:0.00000}ms\n" +
                              "Area query:         | {4:0.00000}ms | {5:0.00000}ms\n" +
                              "Update (small):     | {6:0.00000}ms | {7:0.00000}ms\n" +
                              "Update (large):     | {8:0.00000}ms | {9:0.00000}ms\n" +
                              "Remove (high load): | {10:0.00000}ms | {11:0.00000}ms\n" +
                              "Remove (med. load): | {12:0.00000}ms | {13:0.00000}ms\n" +
                              "Remove (low load):  | {14:0.00000}ms | {15:0.00000}ms",
                              addTime.Mean(), addTime.StandardDeviation(),
                              rangeQueryTime.Mean(), rangeQueryTime.StandardDeviation(),
                              areaQueryTime.Mean(), areaQueryTime.StandardDeviation(),
                              smallUpdateTime.Mean(), smallUpdateTime.StandardDeviation(),
                              largeUpdateTime.Mean(), largeUpdateTime.StandardDeviation(),
                              highLoadRemoveTime.Mean(), highLoadRemoveTime.StandardDeviation(),
                              mediumLoadRemoveTime.Mean(), mediumLoadRemoveTime.StandardDeviation(),
                              lowLoadRemoveTime.Mean(), lowLoadRemoveTime.StandardDeviation());
        }
Пример #8
0
        private void OnDoCommence(object sender, EventArgs e)
        {
            System.ComponentModel.BackgroundWorker bw = sender as System.ComponentModel.BackgroundWorker;

            if (DoInitialSummary != null)
            {
                DoInitialSummary.Invoke(this, args);
            }

            if (StartOfSimulation != null)
            {
                StartOfSimulation.Invoke(this, args);
            }

            while (Today <= EndDate)
            {
                // If this is being run on a background worker thread then check for cancellation
                if (bw != null && bw.CancellationPending)
                {
                    Summary.WriteMessage(this, "Simulation cancelled");
                    return;
                }

                if (DoWeather != null)
                {
                    DoWeather.Invoke(this, args);
                }

                if (DoDailyInitialisation != null)
                {
                    DoDailyInitialisation.Invoke(this, args);
                }

                if (StartOfDay != null)
                {
                    StartOfDay.Invoke(this, args);
                }

                if (Today.Day == 1 && StartOfMonth != null)
                {
                    StartOfMonth.Invoke(this, args);
                }

                if (Today.DayOfYear == 1 && StartOfYear != null)
                {
                    StartOfYear.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                {
                    StartOfWeek.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                {
                    EndOfWeek.Invoke(this, args);
                }

                if (DoManagement != null)
                {
                    DoManagement.Invoke(this, args);
                }

                if (DoEnergyArbitration != null)
                {
                    DoEnergyArbitration.Invoke(this, args);
                }

                if (DoSoilWaterMovement != null)
                {
                    DoSoilWaterMovement.Invoke(this, args);
                }

                if (DoSoilOrganicMatter != null)
                {
                    DoSoilOrganicMatter.Invoke(this, args);
                }

                if (DoSurfaceOrganicMatterDecomposition != null)
                {
                    DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                }
                if (Today.DayOfYear == 16)
                {
                }
                if (DoWaterArbitration != null)
                {
                    DoWaterArbitration.Invoke(this, args);
                }

                if (DoPhenology != null)
                {
                    DoPhenology.Invoke(this, args);
                }

                if (DoPotentialPlantGrowth != null)
                {
                    DoPotentialPlantGrowth.Invoke(this, args);
                }

                if (DoPotentialPlantPartioning != null)
                {
                    DoPotentialPlantPartioning.Invoke(this, args);
                }

                if (DoNutrientArbitration != null)
                {
                    DoNutrientArbitration.Invoke(this, args);
                }

                if (DoActualPlantPartioning != null)
                {
                    DoActualPlantPartioning.Invoke(this, args);
                }

                if (DoActualPlantGrowth != null)
                {
                    DoActualPlantGrowth.Invoke(this, args);
                }

                if (DoPlantGrowth != null)
                {
                    DoPlantGrowth.Invoke(this, args);
                }

                if (DoUpdate != null)
                {
                    DoUpdate.Invoke(this, args);
                }

                if (DoManagementCalculations != null)
                {
                    DoManagementCalculations.Invoke(this, args);
                }

                if (DoReportCalculations != null)
                {
                    DoReportCalculations.Invoke(this, args);
                }

                if (Today == EndDate && EndOfSimulation != null)
                {
                    EndOfSimulation.Invoke(this, args);
                }

                if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                {
                    EndOfYear.Invoke(this, args);
                }

                if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month?
                {
                    EndOfMonth.Invoke(this, args);
                }

                if (EndOfDay != null)
                {
                    EndOfDay.Invoke(this, args);
                }

                if (DoReport != null)
                {
                    DoReport.Invoke(this, args);
                }

                Today = Today.AddDays(1);
            }

            Summary.WriteMessage(this, "Simulation terminated normally");
        }
Пример #9
0
 private void button1_Click(object sender, EventArgs e)
 {
     Directory.CreateDirectory("./update");
     DoUpdate.CreatConfigFile("./UpdateConfig.json");
 }