コード例 #1
0
 /// <summary>
 /// Upgrades to version 7. Find all occurrences of ESW
 /// XProperty values.
 /// </summary>
 /// <param name="node">The node to upgrade.</param>
 /// <param name="fileName">The name of the .apsimx file</param>
 private static void UpgradeToVersion7(XmlNode node, string fileName)
 {
     foreach (XmlNode manager in XmlUtilities.FindAllRecursivelyByType(node, "manager"))
     {
         APSIMFileConverterUtilities.SearchReplaceManagerCodeUsingRegEx(manager, @"([\[\]\.\w]+\.ESW)", "MathUtilities.Sum($1)", "using APSIM.Shared.Utilities;");
     }
     foreach (XmlNode report in XmlUtilities.FindAllRecursivelyByType(node, "report"))
     {
         APSIMFileConverterUtilities.SearchReplaceReportCodeUsingRegEx(report, @"([\[\]\.\w]+\.ESW)", "sum($1)");
     }
 }
コード例 #2
0
        /// <summary>
        /// Rename Plant15 to Plant.
        /// </summary>
        /// <param name="node">The node to modifiy</param>
        /// <param name="fileName">The name of the .apsimx file</param>
        private static void UpgradeToVersion13(XmlNode node, string fileName)
        {
            APSIMFileConverterUtilities.RenameNode(node, "Plant15", "Plant");
            APSIMFileConverterUtilities.RenameVariable(node, "using Models.PMF.OldPlant;", "using Models.PMF;");
            APSIMFileConverterUtilities.RenameVariable(node, "Plant15", "Plant");

            foreach (XmlNode manager in XmlUtilities.FindAllRecursivelyByType(node, "manager"))
            {
                APSIMFileConverterUtilities.SearchReplaceManagerCodeUsingRegEx(manager, @"(\w+).plant.status *== *\042out\042", @"!$1.IsAlive", null);  // /042 is a "
            }
            foreach (XmlNode simulationNode in XmlUtilities.FindAllRecursivelyByType(node, "Simulation"))
            {
                List <XmlNode> plantModels = XmlUtilities.FindAllRecursivelyByType(simulationNode, "Plant");
                plantModels.RemoveAll(p => p.Name == "plant"); // remove lowercase plant nodes - these are in sugarcane

                if (plantModels.Count > 0)
                {
                    XmlUtilities.EnsureNodeExists(simulationNode, "SoilArbitrator");
                    XmlUtilities.EnsureNodeExists(plantModels[0].ParentNode, "MicroClimate");
                }
            }
        }