Beispiel #1
0
        /// <summary>
        /// Creats a deep copy of this constant
        /// </summary>
        /// <returns></returns>
        public new Petrolog_Constant Clone()
        {
            Petrolog_Constant tmp = new Petrolog_Constant();

            tmp.m_Node      = this.m_Node.Clone();
            tmp.Name        = this.Name;
            tmp.Unit        = this.Unit;
            tmp.Value       = this.Value;
            tmp.Description = this.Description;
            return(tmp);
        }
        /// <summary>
        /// Sets a constant value
        /// </summary>
        /// <param name="name">name of the constant</param>
        /// <param name="val">value of the constant</param>
        /// <param name="unit">value of the constant</param>
        /// <param name="description">value of the constant</param>
        public void Set_ConstantValue(string name, string val, string unit, string description)
        {
            int runnumber = 0;

            for (int i = 1; i < 100; i++)
            {
                string s = "Run_" + i.ToString("0") + "_";
                if (!name.StartsWith(s))
                {
                    continue;
                }
                runnumber = i;
                name      = name.Substring(s.Length);
                break;
            }
            if (runnumber > 0)
            {
                Set_ConstantValue(runnumber, name, val, unit, description);
                return;
            }
            foreach (Petrolog_Constant pc in General)
            {
                if (pc.Name != name)
                {
                    continue;
                }
                pc.Value = val;
                return;
            }
            foreach (Petrolog_Constant pc in Remarks)
            {
                if (pc.Name != name)
                {
                    continue;
                }
                pc.Value = val;
                return;
            }
            Petrolog_Constant tmp = new Petrolog_Constant(name, unit, val, description);
            string            t   = name.ToUpper();

            if (!t.StartsWith("R"))
            {
                General.Add(tmp);
                return;
            }
            t = t.Substring(1);
            try
            {
                int i = Convert.ToInt32(t);
                if (i > 0)
                {
                    tmp.Description = "";
                    Remarks.Add(tmp);
                }
                else
                {
                    General.Add(tmp);
                }
            }
            catch (Exception) { General.Add(tmp); }
        }
        private void AddConstant(XmlNode node, List <Petrolog_Constant> Constants)
        {
            Petrolog_Constant tmp = new Petrolog_Constant(node);

            Constants.Add(tmp);
        }