示例#1
0
        public override Table MergeTables(Table basetable)
        {
            foreach (KeyValuePair<string, string> property in basetable.properties)
            {
                //If property doesn't exist in the child, add it from the base!
                if (!this.properties.ContainsKey(property.Key))
                {
                    this.properties.Add(property.Key, property.Value);
                }
            }

            return this;
        }
示例#2
0
 public YAxis(XElement xel, Table table)
     : base(xel, table)
 {
 }
示例#3
0
        /// <summary>
        /// Handles creation of different table types
        /// Passes XElement to the proper table
        /// </summary>
        /// <param name="xel"></param>
        /// <returns></returns>
        public static Axis CreateAxis(XElement xel, Table table)
        {
            if (xel.Attribute("type") != null)
            {
                if (xel.Attribute("type").Value.ToString().ContainsCI("static"))
                {
                    //TODO Add function to handle X or Y static?
                    return new StaticYAxis(xel, table);
                }
                else if (xel.Attribute("type").Value.ToString().ContainsCI("y"))
                {
                    return new YAxis(xel, table);
                }
                else
                {
                    return new XAxis(xel, table);
                }
            }

            return new Axis(xel, table);
        }
示例#4
0
        /// <summary>
        /// Constructor from XElement
        /// </summary>
        /// <param name="xel"></param>
        public Axis(XElement xel, Table table)
        {
            this.properties = new Dictionary<string, string>();
            this.name = "base";
            this.elements = new int();
            this.address = new int();
            this.type = "generic axis";
            this.staticList = new List<string>();
            this.floatList = new List<float>();
            this.parentTable = table;

            //try
            //{

            foreach (XAttribute attribute in xel.Attributes())
            {
                this.properties.Add(attribute.Name.ToString(), attribute.Value.ToString());
                switch (attribute.Name.ToString())
                {
                    case "name":
                        this.name = attribute.Value.ToString();
                        continue;

                    case "address":
                        this.address = System.Int32.Parse(attribute.Value.ToString(), System.Globalization.NumberStyles.AllowHexSpecifier);
                        continue;

                    case "elements":
                        this.elements = System.Int32.Parse(attribute.Value.ToString(), System.Globalization.NumberStyles.Integer);
                        continue;

                    case "endian":
                        this.endian = attribute.Value.ToString();
                        continue;

                    case "units":
                        this.units = attribute.Value.ToString();
                        continue;

                    case "frexpr":
                        this.frexpr = attribute.Value.ToString();
                        continue;

                    case "min":
                        this.min = System.Int32.Parse(attribute.Value.ToString(), System.Globalization.NumberStyles.Float);
                        continue;

                    case "max":
                        this.max = System.Int32.Parse(attribute.Value.ToString(), System.Globalization.NumberStyles.Float);
                        continue;

                    case "inc":
                        this.inc = System.Int32.Parse(attribute.Value.ToString(), System.Globalization.NumberStyles.Float);
                        continue;

                    case "scaling":
                        this.defaultScaling = new Scaling();
                        this.defaultScaling = SharpTuner.DataScalings.Find(s => s.name == attribute.Value.ToString());
                        //TODO FIX: this.endian = this.defaultScaling.endian;
                        continue;

                    case "type":
                        this.type = attribute.Value.ToString();
                        if (this.type.ToString().Contains("static"))
                        {
                            this.isStatic = true;
                        }
                        continue;

                    default:
                        continue;
                }
            }

            foreach (XElement child in xel.Elements())
            {
                string name = child.Name.ToString();

                switch (name)
                {
                    case "data":
                        this.staticList.Add(child.Value.ToString());
                        break;

                    default:
                        break;
                }
            }
            //}
            //catch (System.Exception excpt)
            //{
            //    Trace.WriteLine(excpt.Message);
            //}
        }
示例#5
0
 private void AddRomTable(Table table)
 {
     if (table.isBase)
     {
         if (!BaseRomTables.ContainsKey(table.name))
             BaseRomTables.Add(table.name, table);
         else
             Trace.WriteLine("Warning, duplicate table: " + table.name + ". Please check the definition!!");
     }
     else
     {
         if (!ExposedRomTables.ContainsKey(table.name))
             ExposedRomTables.Add(table.name, table);
         else
             Trace.WriteLine("Warning, duplicate table: " + table.name + ". Please check the definition!!");
     }
 }