/// <summary>Attaches the specified model.</summary> /// <param name="model">The model.</param> /// <param name="view">The view.</param> /// <param name="explorerPresenter">The explorer presenter.</param> public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.explorerPresenter = explorerPresenter; this.weatherData = (model as Weather); this.weatherDataView = (view as IMetDataView); this.weatherDataView.BrowseClicked += this.OnBrowse; this.WriteTableAndSummary(this.weatherData.FullFileName); }
public void Initialise() { Simulations basicFile = Utilities.GetRunnableSim(); IModel simulation = Apsim.Find(basicFile, typeof(Simulation)); IModel paddock = Apsim.Find(basicFile, typeof(Zone)); // Add a weather component. Models.Weather weather = new Models.Weather(); weather.Name = "Weather"; weather.FileName = "asdf.met"; Structure.Add(weather, simulation); // Add a second weather component. Models.Weather weather2 = new Models.Weather(); weather2.FileName = "asdf.met"; weather2.Name = "Weather2"; Structure.Add(weather2, simulation); // Add a third weather component. Models.Weather weather3 = new Models.Weather(); weather3.FileName = "asdf.met"; weather3.Name = "Weather3"; Structure.Add(weather3, simulation); // Add a third weather component. Models.Weather weather4 = new Models.Weather(); weather4.FileName = "asdf.met"; weather4.Name = "Weather4"; Structure.Add(weather4, simulation); // Add a report. Models.Report report = new Models.Report(); report.Name = "Report"; Structure.Add(report, paddock); basicFile.Write(basicFile.FileName); fileName = basicFile.FileName; // Create a new .apsimx file containing two weather nodes. Simulations test = Utilities.GetRunnableSim(); IModel sim = Apsim.Find(test, typeof(Simulation)); Models.Weather w1 = new Models.Weather(); w1.FileName = "w1.met"; w1.Name = "w1"; Structure.Add(w1, sim); Models.Weather w2 = new Models.Weather(); w2.Name = "w2"; w2.FileName = "w2.met"; Structure.Add(w2, sim); extFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".apsimx"); test.Write(extFile); }
/// <summary>Attaches the specified model.</summary> /// <param name="model">The model.</param> /// <param name="view">The view.</param> /// <param name="explorerPresenter">The explorer presenter.</param> public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.explorerPresenter = explorerPresenter; this.weatherData = (model as Weather); this.weatherDataView = (view as IMetDataView); this.weatherDataView.BrowseClicked += this.OnBrowse; this.weatherDataView.GraphRefreshClicked += this.GraphRefreshValueChanged; this.weatherDataView.ExcelSheetChangeClicked += this.ExcelSheetValueChanged; this.WriteTableAndSummary(this.weatherData.FullFileName, this.weatherData.ExcelWorkSheetName); }
public void ExcelWeatherFileTest() { Simulation baseSim = new Simulation(); baseSim.Name = "Base"; string weatherFilePath = Path.ChangeExtension(Path.GetTempFileName(), ".xlsx"); using (FileStream file = new FileStream(weatherFilePath, FileMode.Create, FileAccess.Write)) { Assembly.GetExecutingAssembly().GetManifestResourceStream("UnitTests.Weather.WeatherTestsExcelFile.xlsx").CopyTo(file); } var excelWeather = new Models.Weather() { Name = "Weather", Parent = baseSim, FullFileName = weatherFilePath, ExcelWorkSheetName = "Sheet1" }; Clock clock = new Clock() { Name = "Clock", Parent = baseSim, StartDate = new DateTime(1998, 11, 9), EndDate = new DateTime(1998, 11, 12) }; MockSummary summary = new MockSummary() { Name = "Summary", Parent = baseSim }; baseSim.Children = new List <Model>() { excelWeather, clock, summary }; MockStorage storage = new MockStorage(); Simulations simsToRun = Simulations.Create(new List <IModel> { baseSim, storage }); IJobManager jobManager = Runner.ForSimulations(simsToRun, simsToRun, false); IJobRunner jobRunner = new JobRunnerSync(); jobRunner.JobCompleted += Utilities.EnsureJobRanGreen; jobRunner.Run(jobManager, true); }
public void Initialise() { Simulations basicFile = Utilities.GetRunnableSim(); IModel simulation = Apsim.Find(basicFile, typeof(Simulation)); IModel paddock = Apsim.Find(basicFile, typeof(Zone)); // Add a weather component. Models.Weather weather = new Models.Weather(); weather.Name = "Weather"; weather.FileName = "asdf.met"; Structure.Add(weather, simulation); // Add a second weather component. Models.Weather weather2 = new Models.Weather(); weather2.FileName = "asdf.met"; weather2.Name = "Weather2"; Structure.Add(weather2, simulation); // Add a third weather component. Models.Weather weather3 = new Models.Weather(); weather3.FileName = "asdf.met"; weather3.Name = "Weather3"; Structure.Add(weather3, simulation); // Add a third weather component. Models.Weather weather4 = new Models.Weather(); weather4.FileName = "asdf.met"; weather4.Name = "Weather4"; Structure.Add(weather4, simulation); // Add a report. Models.Report report = new Models.Report(); report.Name = "Report"; Structure.Add(report, paddock); // Add the wheat model. string json = ReflectionUtilities.GetResourceAsString(typeof(IModel).Assembly, "Models.Resources.Wheat.json"); Plant wheat = FileFormat.ReadFromString <IModel>(json, out _).Children[0] as Plant; wheat.ResourceName = "Wheat"; Structure.Add(wheat, paddock); Manager manager = new Manager(); manager.Code = @"using Models.PMF; using Models.Core; using System; namespace Models { [Serializable] public class Script : Model { [Description(""an amount"")] public double Amount { get; set; } } }"; Structure.Add(manager, paddock); Physical physical = new Physical(); physical.BD = new double[5]; physical.AirDry = new double[5]; physical.LL15 = new double[5]; Structure.Add(physical, paddock); basicFile.Write(basicFile.FileName); fileName = basicFile.FileName; // Create a new .apsimx file containing two weather nodes. Simulations test = Utilities.GetRunnableSim(); IModel sim = Apsim.Find(test, typeof(Simulation)); Models.Weather w1 = new Models.Weather(); w1.FileName = "w1.met"; w1.Name = "w1"; Structure.Add(w1, sim); Models.Weather w2 = new Models.Weather(); w2.Name = "w2"; w2.FileName = "w2.met"; Structure.Add(w2, sim); extFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".apsimx"); test.Write(extFile); }