protected string ComputeDuringString(SimulationPath path) { for (int i = 0; i < path.Length; i++) { for (int j = 0; j < path[i].Length; j++) { int byteIndex = j / 8; int bitIndex = j % 8; if (path[i].GetGlobalBit(bitIndex, byteIndex)) { return(this.ComputeReadableString(path[i][j], true)); } } } return(string.Empty); }
public void GetScope(SimulationPath path, out string to) { to = string.Empty; if (0 < path.Length) { int num = 1; if (path.ContainsAt(Path <SimulationObject> .Parent, 0) || path.ContainsAt(Path <SimulationObject> .FirstParent, 0) || path.ContainsAt(Path <SimulationObject> .Root, 0)) { num++; } this.GetScope(path[path.Length - 1], out to, num < path.Length); } else { to = "%PathEmpty"; } }
/// <summary> /// The specified ApsimFile has a factorial in it. Create a series of jobs and add to ApsimJobs. /// </summary> private int FillProjectWithSpecifiedFactorialJobs(ApsimFile AFile, string FileName, string[] SimulationPaths, ref List <IJob> jobs) { int numFound = 0; if (AFile.FactorComponent != null) { foreach (string SimulationPath in SimulationPaths) { string[] simPathParts = SimulationPath.Split(new string[] { "@factorial=" }, StringSplitOptions.None); string simXmlPath = simPathParts [0]; string simPathFactorInstance = ""; if (simPathParts.Length < 2) { continue; } simPathFactorInstance = simPathParts [1].Trim(new char[] { '\'', ' ' }); List <string> allFactorials = Factor.CalcFactorialList(AFile, simXmlPath); int totalCount = allFactorials.Count; int instanceCount = 1 + allFactorials.IndexOf(simPathFactorInstance); if (instanceCount < 1) { throw new Exception("Factor level " + simPathFactorInstance + "wasnt found"); } FactorBuilder b = new FactorBuilder(AFile.FactorComponent); Component Simulation = AFile.Find(simXmlPath); string rootName = Simulation.Name; if (b.SaveExtraInfoInFilename) { rootName += ";" + simPathFactorInstance; } else { //write a spacer to list sims in order eg: 01 or 001 or 0001 depending on count string sPad = ""; double tot = Math.Floor(Math.Log10(totalCount) + 1); double file = Math.Floor(Math.Log10(instanceCount) + 1); for (int i = 0; i < (int)(tot - file); ++i) { sPad += "0"; } rootName += "_" + sPad + instanceCount; } Job J = new Job(); J.WorkingDirectory = Path.GetDirectoryName(FileName); J.CommandLine += StringManip.DQuote(Path.Combine(Configuration.ApsimBinDirectory(), "ApsimToSim.exe")) + " " + StringManip.DQuote(FileName) + " " + StringManip.DQuote("Simulation=" + SimulationPath); J.CommandLineUnix = "mono " + J.CommandLine; J.Name = "ApsimToSim " + FileName + " " + SimulationPath; J.DependsOn = new List <DependsOn> (); J.SendStdErrToConsole = false; jobs.Add(J); J = new Job(); J.WorkingDirectory = Path.GetDirectoryName(FileName); J.CommandLine += StringManip.DQuote(Path.Combine(Configuration.ApsimBinDirectory(), "ApsimModel.exe")) + " " + StringManip.DQuote(rootName + ".sim"); J.CommandLineUnix = J.CommandLine; J.Name = "ApsimModel " + rootName + ".sim"; J.DependsOn = new List <DependsOn> (); J.DependsOn.Add(new DependsOn("ApsimToSim " + FileName + " " + SimulationPath)); J.SendStdErrToConsole = false; J.StdOutFilename = Path.Combine(Path.GetDirectoryName(FileName), rootName + ".sum"); jobs.Add(J); J = CleanupJob(Path.Combine(Path.GetDirectoryName(FileName), rootName + ".sim"), "ApsimModel " + rootName + ".sim"); jobs.Add(J); numFound++; } } return(numFound); }