private static Farm4Prophet GetDefaultF4PSimulationSpec() { Farm4Prophet simulation = new Farm4Prophet { TaskName = "NameOfPaddock", FarmList = new List <FarmSystem>() }; //FlockDescr flock = new FlockDescr(); //flock.BreedingEweCount = 10; //flock.BreedParams = new BreedParameters(); //flock.BreedParams. FarmSystem farm = new FarmSystem(); farm.Area = 10; farm.StationNumber = 41023; farm.Name = "TestFarm"; farm.ReportName = "Test"; farm.CroppingRegion = "Southern LRZ"; //farm.LiveStock = new FarmLivestock(); //farm.LiveStock.Flocks = new List<FlockDescr>(); //farm.LiveStock.Flocks.Add(flock); farm.RunLength = 36; farm.SimTemplateType = SimulationType.stCropOnly; farm.StartSeasonDate = new DateTime(2015, 1, 1); simulation.FarmList.Add(farm); return(simulation); }
public void BuildAusfarmRuntimeEnvironment() { string binDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string runtimeDirectory = Path.Combine(binDirectory, "AusFarm-1.4.12"); // Remove old runtime directory if it exists. if (Directory.Exists(runtimeDirectory)) { Directory.Delete(runtimeDirectory, true); } // Build the new runtime environment. Farm4Prophet f4p = GetDefaultF4PSimulationSpec(); RuntimeEnvironment environment = new RuntimeEnvironment { AusfarmRevision = "AusFarm-1.4.12", }; RunF4PJob job = new RunF4PJob(f4p, environment); // Make sure it is built correctly. Assert.IsTrue(Directory.Exists(runtimeDirectory)); string ausfarmExe = Path.Combine(runtimeDirectory, "Ausfarm", "ausfarm.exe"); Assert.IsTrue(File.Exists(ausfarmExe)); // Remove newly created runtime directory Directory.Delete(runtimeDirectory, true); }
/// <summary> /// Adds a Farm4Prophet job to the APSIM cloud. /// </summary> /// <param name="f4p">The job specification.</param> /// <returns>The unique job name.</returns> public string AddFarm4Prophet(Farm4Prophet f4p) { string newJobName = DateTime.Now.ToString("yyyy-MM-dd (HH-mm-ss) ") + f4p.TaskName + "_F4P"; string xml = Farm4ProphetUtility.Farm4ProphetToXML(f4p); AddAsXML(newJobName, xml); return(newJobName); }
/// <summary>Uploads a job specified by the the yield prophet.</summary> /// <param name="fileName">The name of the file.</param> private void UploadFarm4Prophet(string fileName) { Farm4Prophet farm4Prophet = Farm4ProphetUtility.Farm4ProphetFromFile(fileName); using (JobsService.JobsClient jobsService = new JobsService.JobsClient()) { jobsService.AddFarm4Prophet(farm4Prophet); } }