public static void ProbeDLL(BaseController Controller) { if ((!(BaseActions.FileSave(Controller)))) { return; } string XmlFileName = Controller.ApsimData.FileName; //Dim P As Process = Process.Start(Configuration.ApsimBinDirectory + "\Plant2Documentation", Arguments) Process P = Utility.RunProcess(Path.Combine(Configuration.ApsimBinDirectory(), "ProbeDLL.exe"), XmlFileName, Path.GetDirectoryName(XmlFileName)); Utility.CheckProcessExitedProperly(P); MessageBox.Show("Finished writing to <info> section.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static void Plant2Documentation(BaseController Controller) { if ((!(BaseActions.FileSave(Controller)))) { return; } string XmlFileName = Controller.ApsimData.FileName; //Dim HtmlFileName As String = Path.GetTempPath() + Path.GetFileNameWithoutExtension(XmlFileName) + ".html" //removed from temp dir as Firefox can't handle abs dirs. JF string HtmlFileName = Path.Combine("..", "Documentation", "Plant2Docs", Path.GetFileNameWithoutExtension(XmlFileName) + ".html"); string Arguments = StringManip.DQuote(XmlFileName) + " " + StringManip.DQuote(HtmlFileName); //Dim P As Process = Process.Start(Configuration.ApsimBinDirectory + "\Plant2Documentation", Arguments) Process P = Utility.RunProcess(Path.Combine(Configuration.ApsimBinDirectory(), "Plant2Documentation.exe"), Arguments, Path.GetDirectoryName(XmlFileName)); Utility.CheckProcessExitedProperly(P); Process.Start(HtmlFileName); }
public static void CheckPoint(BaseController Controller) { if (MessageBox.Show("Are you sure you want to save and checkpoint your simulation and outputfiles, overwriting any previous checkpoints?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { // Save first if ((!(BaseActions.FileSave(Controller)))) { return; } // empty the checkpoint sub folder. string CheckPointFolder = Path.Combine(Path.GetDirectoryName(Controller.ApsimData.FileName), "CheckPoint"); if (Directory.Exists(CheckPointFolder)) { Directory.Delete(CheckPointFolder, true); } Directory.CreateDirectory(CheckPointFolder); // Get a complete list of files names (.out, .sum & .apsim) to copy to checkpoint folder. List <string> FileNames = new List <string>(); FileNames.Add(Controller.ApsimData.FileName); UIUtility.OutputFileUtility.GetOutputFiles(Controller, Controller.ApsimData.RootComponent, FileNames); UIUtility.OutputFileUtility.GetSummaryFiles(Controller, Controller.ApsimData.RootComponent, FileNames); // Copy all files to checkpoint folder. If any files don't exist then // create zero byte files. foreach (string FileName in FileNames) { string DestFileName = CheckPointFolder + Path.DirectorySeparatorChar + Path.GetFileName(FileName); if (File.Exists(FileName)) { File.Copy(FileName, DestFileName, true); } else { StreamWriter Out = new StreamWriter(DestFileName); Out.Close(); } } MessageBox.Show("All simulation, output and summary files have been checkpointed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void Run(BaseController Controller) { // ------------------------------------------------ // Go looking for simulations to run. Look at the // currently selected nodes first and progressively // their parents until some simulations are found. // ------------------------------------------------ if (Configuration.Instance.Setting("ReloadPlugInsBeforeRunningAPSIM") == "Yes") { PlugIns.LoadAll(); } if ((bool)BaseActions.FileSave(Controller)) { Control[] RunPanels = Controller.MainForm.Controls.Find("RunToolStrip", true); if (RunPanels.Length == 1) { ApsimRunToolStrip.Instance.RunApsim((ToolStrip)RunPanels[0], Controller); //_ //Controller.ApsimData, _ //Controller.SelectedPaths) } } }
public static void RunOnCluster(BaseController Controller) { if ((!(BaseActions.FileSave(Controller)))) { return; } StatusStrip StatusBar = (StatusStrip)Controller.MainForm.Controls.Find("StatusStrip1", true)[0]; ProgressBar = (ToolStripProgressBar)StatusBar.Items[0]; ProgressLabel = (ToolStripStatusLabel)StatusBar.Items[1]; StatusBar.Visible = true; try { UIBits.ClusterForm F = new UIBits.ClusterForm(); if (F.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; F.SaveSettings(); List <string> FilesToRun = new List <string>(); if (F.runThisSimulation && !string.IsNullOrEmpty(Controller.ApsimData.FileName)) { FilesToRun.Add(Controller.ApsimData.FileName); } else if (!F.runThisSimulation && !string.IsNullOrEmpty(F.FolderOfFiles)) { Utility.FindFiles(F.FolderOfFiles, "*.apsim", ref FilesToRun); } if ((FilesToRun.Count > 0)) { CondorJob c = new CondorJob(); c.NiceUser = F.NiceUser; c.arch = 0; if (F.archIsUnix) { c.arch |= Configuration.architecture.unix; } if (F.archIsWin32) { c.arch |= Configuration.architecture.win32; } c.SelfExtractingExecutableLocation = F.sfxLocation; if (!Directory.Exists(F.OutputFolder)) { Directory.CreateDirectory(F.OutputFolder); } c.DestinationFolder = F.OutputFolder; c.numberSimsPerJob = F.simsPerJobNumber; c.useSingleCPU = F.useSingleCPU; c.Go(FilesToRun, UpdateProgress); MessageBox.Show("Your job has been placed in your dropbox folder. Your outputs will appear adjacent.", "For your information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Cursor.Current = Cursors.Default; StatusBar.Visible = false; }