예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HLBackgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
            }
            else if (e.Error != null)
            {
            }
            else
            {
            }

            if (Notifier != null)
            {
                Notifier();
            }

            HLBackGroundWorker hlbw = (HLBackGroundWorker)sender;

            //hlbw.Sim.OutputModelController.Finalise();

            NoSimsComplete++;

            //Update Progress
            if (this.QuietOutput == false)
            {
                Console.Write("\r{0} % Done.", ((double)NoSimsComplete / SimulationElements.Count * 100).ToString("0.00"));


                if (NoSimsComplete > Simulations.Count)
                {
                    DateTime end = DateTime.Now;

                    TimeSpan ts = end - StartRunTime;

                    Console.WriteLine(ts);
                }
            }

            Simulation nextSim = GetSimulationElement();

            if (nextSim == null)
            {
                return;
            }
            else
            {
                hlbw.Sim = nextSim;
                //hlbw.RunWorkerAsync(new List<object>(new object[] { nextSim }));
                hlbw.RunWorkerAsync();
            }

            if (NoSimsComplete == Simulations.Count)
            {
                if (OutputType == OutputType.SQLiteOutput)
                {
                    SQLConn.Close();
                }
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HLBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            HLBackGroundWorker hlbw = (HLBackGroundWorker)sender;

            List <object> Arguments = e.Argument as List <object>;

            Simulation sim = (Simulation)Arguments[0];

            //hlbw.Sim = SimulationFactory.GenerateSimulationXML(simElement, InputDataModels);
            //hlbw.Sim.Id = SimulationElements.IndexOf(simElement) + 1;

            hlbw.Sim       = sim;
            hlbw.Sim.Index = Simulations.IndexOf(sim) + 1;

            //Setup output controllers

            if (OutputType == OutputType.CSVOutput)
            {
                hlbw.Sim.OutputModelController = new CSVOutputModelController(hlbw.Sim, OutputPath);
            }
            else if (OutputType == OutputType.SQLiteOutput)
            {
                hlbw.Sim.OutputModelController = new SQLiteOutputModelController(hlbw.Sim, SQLConn);

                //HLRDB.Simulation DBSim = new HLRDB.Simulation { Id = hlbw.Sim.Id, Name = hlbw.Sim.Name };
                //DBSim.Data = new List<HLRDB.Data>();
                //DBSim.Models = new List<Model>();

                //foreach (InputModel im in hlbw.Sim.InputModels)
                //{
                //    DBSim.Models.Add(new HLRDB.Model { Name = im.Name, Type = im.GetType().ToString(), Content = "" });
                //}

                //DBContext.Simulations.Add(new HLRDB.Simulation { Id = hlbw.Sim.Id, Name = hlbw.Sim.Name });

                //DBContext.SaveChanges();
            }
            else if (OutputType == OutputType.NetCDF)
            {
                //hlbw.Sim.OutputModelController = new NetCDFOutputModelController(hlbw.Sim, HLNC);
            }

            hlbw.Sim.Run();
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HLBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            HLBackGroundWorker hlbw = (HLBackGroundWorker)sender;

            //List<object> Arguments = e.Argument as List<object>;

            //Simulation sim = (Simulation)Arguments[0];

            ////hlbw.Sim = SimulationFactory.GenerateSimulationXML(simElement, InputDataModels);
            ////hlbw.Sim.Id = SimulationElements.IndexOf(simElement) + 1;

            //hlbw.Sim = sim;
            //hlbw.Sim

            //Setup output controllers
            try
            {
                hlbw.Sim.Run();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }