Exemple #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);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Add a DMDemandFunction constant function to all Root nodes that don't have one
 /// </summary>
 /// <param name="node">The node to modifiy</param>
 /// <param name="fileName">The name of the .apsimx file</param>
 private static void UpgradeToVersion9(XmlNode node, string fileName)
 {
     foreach (XmlNode root in XmlUtilities.FindAllRecursivelyByType(node, "Root"))
     {
         XmlNode partitionFraction = APSIMFileConverterUtilities.FindModelNode(root, "PartitionFraction");
         if (partitionFraction != null)
         {
             root.RemoveChild(partitionFraction);
             XmlNode demandFunction = root.AppendChild(root.OwnerDocument.CreateElement("PartitionFractionDemandFunction"));
             XmlUtilities.SetValue(demandFunction, "Name", "DMDemandFunction");
             demandFunction.AppendChild(partitionFraction);
         }
     }
 }
Exemple #3
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);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Add nodes for new leaf tiller model
        /// </summary>
        /// <param name="node">The node to modifiy</param>
        /// <param name="fileName">The name of the .apsimx file</param>
        private static void UpgradeToVersion16(XmlNode node, string fileName)
        {
            foreach (XmlNode n in XmlUtilities.FindAllRecursivelyByType(node, "LeafCohortParameters"))
            {
                XmlNode    LagDurationAgeMultiplier        = XmlUtilities.CreateNode(node.OwnerDocument, "ArrayFunction", "");
                XmlNode    SenescenceDurationAgeMultiplier = XmlUtilities.CreateNode(node.OwnerDocument, "ArrayFunction", "");
                XmlNode    LeafSizeAgeMultiplier           = XmlUtilities.CreateNode(node.OwnerDocument, "ArrayFunction", "");
                XmlElement name    = node.OwnerDocument.CreateElement("Name");
                XmlElement element = node.OwnerDocument.CreateElement("Values");

                name.InnerText    = "LagDurationAgeMultiplier";
                element.InnerText = "1 1 1";
                LagDurationAgeMultiplier.AppendChild(name);
                LagDurationAgeMultiplier.AppendChild(element);

                name              = node.OwnerDocument.CreateElement("Name");
                name.InnerText    = "SenescenceDurationAgeMultiplier";
                element           = node.OwnerDocument.CreateElement("Values");
                element.InnerText = "1 1 1";
                SenescenceDurationAgeMultiplier.AppendChild(name);
                SenescenceDurationAgeMultiplier.AppendChild(element);

                name              = node.OwnerDocument.CreateElement("Name");
                element           = node.OwnerDocument.CreateElement("Values");
                name.InnerText    = "LeafSizeAgeMultiplier";
                element.InnerText = "1 1 1 1 1 1 1 1 1 1 1 1";
                LeafSizeAgeMultiplier.AppendChild(name);
                LeafSizeAgeMultiplier.AppendChild(element);

                if (APSIMFileConverterUtilities.FindModelNode(n, "LagDurationAgeMultiplier") == null)
                {
                    n.AppendChild(LagDurationAgeMultiplier);
                }
                if (APSIMFileConverterUtilities.FindModelNode(n, "SenescenceDurationAgeMultiplier") == null)
                {
                    n.AppendChild(SenescenceDurationAgeMultiplier);
                }
                if (APSIMFileConverterUtilities.FindModelNode(n, "LeafSizeAgeMultiplier") == null)
                {
                    n.AppendChild(LeafSizeAgeMultiplier);
                }
            }
        }
Exemple #5
0
        private static void UpgradeToVersion20(XmlNode node, string filename)
        {
            List <XmlNode> nodeList = new List <XmlNode>(XmlUtilities.FindAllRecursivelyByType(node, "Root"));

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

                if (APSIMFileConverterUtilities.FindModelNode(n, "MaintenanceRespirationFunction") == null)
                {
                    n.AppendChild(MRFnode);
                }
            }
        }