Exemple #1
0
        /// <summary>
        /// Handles creation of different table types
        /// Passes XElement to the proper table
        /// </summary>
        /// <param name="xel"></param>
        /// <returns></returns>
        public static TableMetaData CreateTable(XElement xel, string tablename, ECUMetaData def)
        {
            TableMetaData basetable = null;

            if (def.GetBaseRomTable(tablename, out basetable))
            {
                //has a base table!! therefore not a base!
            }
            if (xel.Attribute("address") == null)
            {
                basetable = null;//sure???
            }
            return(CreateTableWithDimension(xel, def, basetable));
        }
Exemple #2
0
        public static Axis CreateAxis(XElement axis1, TableMetaData table, Axis axis2)
        {
            Axis axis;

            if (axis2.type.ContainsCI("static"))
            {
                axis = new StaticAxis(axis1, table);
            }
            else
            {
                axis = new Axis(axis1, table);
            }

            axis.parentAxis = axis2;
            return(axis);
        }
Exemple #3
0
        public bool GetBaseRomTable(string tablename, out TableMetaData basetable)
        {
            basetable = null;

            foreach (ECUMetaData d in inheritList)
            {
                foreach (TableMetaData t in d.RomTables)
                {
                    if (t.name.ToLower() == tablename.ToLower())
                    {
                        basetable = t;
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #4
0
        /// <summary>
        /// Construct from XML Element
        /// </summary>
        /// <param name="xel"></param>
        public TableMetaData(XElement xel, ECUMetaData def, TableMetaData bt)
            : this()
        {
            try
            {
                parentDef = def;
                baseTable = bt;
                xml       = xel;

                ParseAttributes(xel);
                ParseChildren(xel);
            }
            catch (Exception crap)
            {
                Trace.WriteLine("Error creating table " + this.name);
                Trace.WriteLine("XML: " + xel.ToString());
                Trace.WriteLine(crap.Message);
            }
        }
        public static TableMetaData CreateRamTableWithDimension(XElement xel, string storageType, ECUMetaData def, TableMetaData basetable, string id)
        {
            TableMetaData tempTable = null;
            string        type      = null;

            if (xel.Attribute("type") != null)
            {
                type = xel.Attribute("type").Value.ToString();
            }
            else if (basetable != null && basetable.type != null)
            {
                type = basetable.type;
            }
            if (type != null)
            {
                switch (type)
                {
                case "1D":
                    tempTable = new RamTable1DMetaData(xel, def, basetable);
                    break;

                case "2D":
                    tempTable = new RamTable2DMetaData(xel, def, basetable);
                    break;

                case "3D":
                    tempTable = new RamTable3DMetaData(xel, def, basetable);
                    break;

                default:
                    tempTable = new RamTable(xel, def, basetable);
                    break;
                }
            }
            if (tempTable == null)
            {
                tempTable = new RamTable(xel, def, basetable);
            }
            tempTable.storageTypeString = storageType;
            tempTable.id = id;
            return(tempTable);
        }
Exemple #6
0
 public RamTable3DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)
     : base(xel, def, basetable)
 {
 }
Exemple #7
0
 public Table3DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)
     : base(xel, def, basetable)
 {
     this.type = "3D";
 }
Exemple #8
0
        public void ExposeTable(string name, LookupTable lut)
        {
            TableMetaData baseTable = GetBaseTable(name);

            if (baseTable != null)
            {
                TableMetaData childTable = baseTable.CreateChild(lut, this);
                //TODO: HANDLE STATIC AXES!!
                if (lut.dataAddress < 0x400000)
                {
                    //TODO: HANDLE UPDATES TO EXISTING TABLES!!??
                    if (ExposedRomTables.ContainsKey(childTable.name))
                    {
                        ExposedRomTables.Remove(childTable.name);
                    }
                    ExposedRomTables.Add(childTable.name, childTable);
                }
                else
                {
                    if (ExposedRamTables.ContainsKey(childTable.name))
                    {
                        ExposedRamTables.Remove(childTable.name);
                    }
                    ExposedRamTables.Add(childTable.name, childTable);
                }
            }

            //if (bt == null) return;
            //bt.SetAttributeValue("address", lut.dataAddress.ToString("X"));//(System.Int32.Parse(temptable.Value.Attribute("offset").Value.ToString(), System.Globalization.NumberStyles.AllowHexSpecifier) + offset).ToString("X"));
            //IEnumerable<XAttribute> tempattr = bt.Attributes();
            //List<String> remattr = new List<String>();
            //foreach (XAttribute attr in tempattr)
            //{
            //    if (attr.Name != "address" && attr.Name != "name")
            //    {
            //        remattr.Add(attr.Name.ToString());
            //    }
            //}
            //foreach (String rem in remattr)
            //{
            //    bt.Attribute(rem).Remove();
            //}

            //List<String> eleremlist = new List<String>();

            //foreach (XElement ele in bt.Elements())
            //{
            //    IEnumerable<XAttribute> childtempattr = ele.Attributes();
            //    List<String> childremattr = new List<String>();

            //    if (ele.Name.ToString() != "table")
            //    {
            //        eleremlist.Add(ele.Name.ToString());
            //        continue;
            //    }
            //    if (ele.Attribute("type").Value.ContainsCI("static"))
            //    {
            //        eleremlist.Add(ele.Name.ToString());
            //    }
            //    else if (ele.Attribute("type").Value.ContainsCI("x axis"))
            //    {
            //        ele.Attribute("name").Value = "X";
            //    }
            //    else if (ele.Attribute("type").Value.ContainsCI("y axis"))
            //    {
            //        ele.Attribute("name").Value = "Y";
            //    }
            //    foreach (XAttribute attr in childtempattr)
            //    {
            //        if (attr.Name != "address" && attr.Name != "name")
            //        {
            //            childremattr.Add(attr.Name.ToString());
            //        }
            //    }
            //    foreach (String rem in childremattr)
            //    {
            //        ele.Attribute(rem).Remove();
            //    }
            //}
            //foreach (String rem in eleremlist)
            //{
            //    bt.Element(rem).Remove();
            //}
        }
Exemple #9
0
        public StaticAxis(XElement xel, TableMetaData table)
            : base(xel,table)
        {
            try
            {
                StaticData = new List<string>();
                foreach (XElement child in xel.Elements())
                {
                    string nam = child.Name.ToString();

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

                        default:
                            break;
                    }
                }
            }
            catch (Exception crap)
            {
                Trace.WriteLine("Error creating static axis in " + table);
                Trace.WriteLine("XML: " + xel.ToString());
                throw;
            }
        }
Exemple #10
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, TableMetaData table)
 {
     if (xel.Attribute("type") != null)
     {
         if (xel.Attribute("type").Value.ToString().ContainsCI("static"))
             return new StaticAxis(xel, table);
         return new Axis(xel, table);
     }
     return null;
 }
Exemple #11
0
 public static TableMetaData CreateRamTableWithDimension(XElement xel, string storageType, ECUMetaData def, TableMetaData basetable)
 {
     TableMetaData tempTable = null;
     string type = null;
     if (xel.Attribute("type") != null)
         type = xel.Attribute("type").Value.ToString();
     else if (basetable != null && basetable.type != null)
         type = basetable.type;
     if (type != null)
     {
         switch (type)
         {
             case "1D":
                 tempTable = new RamTable1DMetaData(xel, def, basetable);
                 break;
             case "2D":
                 tempTable = new RamTable2DMetaData(xel, def, basetable);
                 break;
             case "3D":
                 tempTable = new RamTable3DMetaData(xel, def, basetable);
                 break;
             default:
                 tempTable = new RamTable(xel, def, basetable);
                 break;
         }
     }
     if (tempTable == null)
         tempTable = new RamTable(xel, def, basetable);
     tempTable.storageTypeString = storageType;
     return tempTable;
 }
Exemple #12
0
 public RamTable(XElement xel, ECUMetaData def, TableMetaData basetable)// DeviceImage image)
     : base(xel, def, basetable)
 {
     RRXML = xel;
 }
Exemple #13
0
        public static TableMetaData CreateTableWithDimension(XElement xel, ECUMetaData def, TableMetaData basetable)
        {
            string type = null;

            if (xel.Attribute("type") != null)
            {
                type = xel.Attribute("type").Value.ToString();
            }
            else if (basetable != null && basetable.type != null)
            {
                type = basetable.type;
            }
            if (type != null)
            {
                switch (type)
                {
                case "1D":
                    return(new Table1DMetaData(xel, def, basetable));

                case "2D":
                    return(new Table2DMetaData(xel, def, basetable));

                case "3D":
                    return(new Table3DMetaData(xel, def, basetable));

                default:
                    break;
                }
            }
            return(new TableMetaData(xel, def, basetable));
        }
Exemple #14
0
 public Table1DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)
     : base(xel, def, basetable)
 {
     this.type = "1D";
 }
Exemple #15
0
 // DeviceImage image)
 public RamTable1DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable)
     : base(xel, def, basetable)
 {
 }
Exemple #16
0
        public bool GetBaseRomTable(string tablename, out TableMetaData basetable)
        {
            basetable = null;

            foreach (ECUMetaData d in inheritList)
            {
                foreach (TableMetaData t in d.RomTables)
                {
                    if (t.name.ToLower() == tablename.ToLower())
                    {
                        basetable = t;
                        return true;
                    }
                }
            }
            return false;
        }
Exemple #17
0
        private void AddRamTable(TableMetaData table, int line)
        {
            if (table.isBase)
            {
                if (!BaseRamTables.ContainsKey(table.name))
                    BaseRamTables.Add(table.name, table);
                else
                    Trace.WriteLine("Warning, duplicate table: " + table.name + ". Please check the definition: " + this.filePath + " Line number: " + line);
            }
            else
            {
                if (!ExposedRamTables.ContainsKey(table.name))
                    ExposedRamTables.Add(table.name, table);
                else
                    Trace.WriteLine("Warning, duplicate table: " + table.name + ". Please check the definition: " + this.filePath + " Line number: " + line);

            }
        }
Exemple #18
0
 public static TableMetaData CreateTableWithDimension(XElement xel, ECUMetaData def, TableMetaData basetable)
 {
     string type = null;
     if (xel.Attribute("type") != null)
         type = xel.Attribute("type").Value.ToString();
     else if (basetable != null && basetable.type != null)
         type = basetable.type;
     if(type != null)
     {
         switch (type)
         {
             case "1D":
                 return new Table1DMetaData(xel, def, basetable);
             case "2D":
                 return new Table2DMetaData(xel, def, basetable);
             case "3D":
                 return new Table3DMetaData(xel, def, basetable);
             default:
                 break;
         }
     }
     return new TableMetaData(xel,def, basetable);
 }
Exemple #19
0
        /// <summary>
        /// Constructor from XElement
        /// </summary>
        /// <param name="xel"></param>
        public Axis(XElement xel, TableMetaData table)
        {
            try
            {
                this.isXAxis   = true;
                this.name      = "base";
                this.elements  = new int();
                this.address   = new int();
                this.type      = "generic axis";
                this.floatList = new List <float>();
                this.baseTable = table;
                this.parentDef = table.parentDef;

                foreach (XAttribute attribute in xel.Attributes())
                {
                    switch (attribute.Name.ToString())
                    {
                    case "name":
                        if (attribute.Value.ToString().EqualsCI("y"))
                        {
                            this.isXAxis = false;
                        }
                        if (parentAxis != null && parentAxis.name != null)
                        {
                            break;
                        }
                        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 "scaling":
                        Scaling sca = new Scaling();
                        if (this.parentDef.ScalingList.TryGetValue(attribute.Value, out sca))
                        {
                            this.defaultScaling = sca;
                        }
                        else
                        {
                            Trace.WriteLine("Error finding scaling " + attribute.Value);
                        }
                        continue;
                    //TODO FIX: this.endian = this.defaultScaling.endian;

                    case "type":
                        this.type = attribute.Value.ToString();
                        if (this.type.ToString().ContainsCI("y"))
                        {
                            this.isXAxis = false;
                        }
                        continue;

                    default:
                        continue;
                    }
                }
            }
            catch (Exception crap)
            {
                Trace.WriteLine("Error creating axis in " + table);
                Trace.WriteLine("XML: " + xel.ToString());
                throw;
            }
        }
Exemple #20
0
        /// <summary>
        /// Construct from XML Element
        /// </summary>
        /// <param name="xel"></param>
        public TableMetaData(XElement xel, ECUMetaData def, TableMetaData bt)
            : this()
        {
            try
            {
                parentDef = def;
                baseTable = bt;
                xml = xel;

                ParseAttributes(xel);
                ParseChildren(xel);
            }
            catch (Exception crap)
            {
                Trace.WriteLine("Error creating table " + this.name);
                Trace.WriteLine("XML: " + xel.ToString());
                Trace.WriteLine(crap.Message);
            }
        }
Exemple #21
0
        public static Axis CreateAxis(XElement axis1, TableMetaData table, Axis axis2)
        {
            Axis axis;
            if(axis2.type.ContainsCI("static"))
                axis = new StaticAxis(axis1, table);
            else
                axis = new Axis(axis1, table);

            axis.parentAxis = axis2;
            return axis;
        }
Exemple #22
0
 // DeviceImage image)
 public RamTable(XElement xel, ECUMetaData def, TableMetaData basetable)
     : base(xel, def, basetable)
 {
     RRXML = xel;
 }
Exemple #23
0
        public Axis parentAxis; //todo: resolve accessibility!

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor from XElement
        /// </summary>
        /// <param name="xel"></param>
        public Axis(XElement xel, TableMetaData table)
        {
            try
            {
                this.isXAxis = true;
                this.name = "base";
                this.elements = new int();
                this.address = new int();
                this.type = "generic axis";
                this.floatList = new List<float>();
                this.baseTable = table;
                this.parentDef = table.parentDef;

                foreach (XAttribute attribute in xel.Attributes())
                {

                    switch (attribute.Name.ToString())
                    {
                        case "name":
                            if (parentAxis != null && parentAxis.name != null)
                                break;
                            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 "scaling":
                            Scaling sca = new Scaling();
                            if (this.parentDef.ScalingList.TryGetValue(attribute.Value, out sca))
                                this.defaultScaling = sca;
                            else
                                Trace.WriteLine("Error finding scaling " + attribute.Value);
                            continue;
                        //TODO FIX: this.endian = this.defaultScaling.endian;

                        case "type":
                            this.type = attribute.Value.ToString();
                            if (this.type.ToString().Contains("y"))
                            {
                                this.isXAxis = false;
                            }
                            continue;

                        default:
                            continue;
                    }
                }
            }
            catch (Exception crap)
            {
                Trace.WriteLine("Error creating axis in " + table);
                Trace.WriteLine("XML: " + xel.ToString());
                throw;
            }
        }
Exemple #24
0
 private void AddRamTable(TableMetaData table, int line)
 {
     TableMetaData dupe;
     if (table.isBase)
     {
         if (!BaseRamTables.ContainsKey(table.name))
             BaseRamTables.Add(table.name, table);
         else
         {
             BaseRamTables.TryGetValue(table.name, out dupe);
             Trace.WriteLine("Warning, duplicate table: " + table.name + ". Please check the definition: " + this.filePath + " Line numbers: " + line + " and " + dupe.LineNumber);
         }
     }
     else
     {
         if (!ExposedRamTables.ContainsKey(table.name))
             ExposedRamTables.Add(table.name, table);
         else
         {
             ExposedRamTables.TryGetValue(table.name, out dupe);
             Trace.WriteLine("Warning, duplicate table: " + table.name + ". Please check the definition: " + this.filePath + " Line numbers: " + line + " and " + dupe.LineNumber);
         }
     }
 }