Пример #1
0
        /// <summary>
        /// Add RemobilisationCost to all organs
        /// </summary>
        /// <param name="node"></param>
        /// <param name="fileName"></param>
        private static void UpgradeToVersion21(XmlNode node, string fileName)
        {
            List <XmlNode> nodeList = new List <XmlNode>();

            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "Root"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "Leaf"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "GenericOrgan"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "ReproductiveOrgan"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "LeafCohortParameters"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "SimpleLeaf"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "Nodule"));

            foreach (XmlNode n in nodeList)
            {
                XmlNode DMnode;
                DMnode = XmlUtilities.CreateNode(node.OwnerDocument, "Constant", "");
                XmlElement name    = node.OwnerDocument.CreateElement("Name");
                XmlElement element = node.OwnerDocument.CreateElement("FixedValue");
                name.InnerText    = "RemobilisationCost";
                element.InnerText = "0";
                DMnode.AppendChild(name);
                DMnode.AppendChild(element);

                if (APSIMFileConverterUtilities.FindModelNode(n, "RemobilisationCost") == null)
                {
                    n.AppendChild(DMnode);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Add DMConversionEfficiency node
        /// </summary>
        /// <param name="node">The node to modifiy</param>
        /// <param name="fileName">The name of the .apsimx file</param>
        private static void UpgradeToVersion19(XmlNode node, string fileName)
        {
            //Rename existing DMConversionEfficiencyFunction nodes
            foreach (XmlNode n in XmlUtilities.FindAllRecursivelyByType(node, "Leaf"))
            {
                XmlNode dmFunction = APSIMFileConverterUtilities.FindModelNode(n, "DMConversionEfficiencyFunction");
                if (dmFunction != null)
                {
                    XmlUtilities.SetValue(dmFunction, "Name", "DMConversionEfficiency");
                }
            }

            List <XmlNode> nodeList = new List <XmlNode>();

            XmlUtilities.FindAllRecursively(node, "DMConversionEfficiencyFunction", ref nodeList);
            foreach (XmlNode n in nodeList)
            {
                APSIMFileConverterUtilities.RenameNode(n, "DMConversionEfficiencyFunction", "DMConversionEfficiency");
            }

            nodeList.Clear();
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "Root"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "Leaf"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "GenericOrgan"));
            nodeList.AddRange(XmlUtilities.FindAllRecursivelyByType(node, "ReproductiveOrgan"));

            foreach (XmlNode n in nodeList)
            {
                XmlNode DMnode;
                DMnode = XmlUtilities.CreateNode(node.OwnerDocument, "Constant", "");
                XmlElement name    = node.OwnerDocument.CreateElement("Name");
                XmlElement element = node.OwnerDocument.CreateElement("FixedValue");
                name.InnerText    = "DMConversionEfficiency";
                element.InnerText = "1.0";
                DMnode.AppendChild(name);
                DMnode.AppendChild(element);

                if (APSIMFileConverterUtilities.FindModelNode(n, "DMConversionEfficiency") == null)
                {
                    n.AppendChild(DMnode);
                }
            }
        }