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)); }
public override TableMetaData CreateChild(LookupTable ilut, ECUMetaData d) { //TODO: This is a major KLUDGE. if (ilut.GetType() != typeof(LookupTable2D)) { return(base.CreateChild(ilut, d)); } XElement xel; LookupTable2D lut = (LookupTable2D)ilut; xel = new XElement("table"); xel.SetAttributeValue("name", name); xel.SetAttributeValue("address", ilut.dataAddress.ToString("X")); if (this.xAxis != null) { XElement tx = new XElement("table"); tx.SetAttributeValue("name", "X"); tx.SetAttributeValue("address", lut.colsAddress.ToString("X")); tx.SetAttributeValue("elements", lut.cols); xel.Add(tx); } else { XElement ty = new XElement("table"); ty.SetAttributeValue("name", "Y"); ty.SetAttributeValue("address", lut.colsAddress.ToString("X")); ty.SetAttributeValue("elements", lut.cols); xel.Add(ty); } return(TableFactory.CreateTable(xel, name, d)); //TODO also set attirbutes and split this up! Copy to table2D!! //return base.CreateChild(lut,d); //TODO FIX?? AND CHECK FOR STATIC AXES!! }
public override TableMetaData CreateChild(LookupTable ilut,ECUMetaData d) { //TODO: This is a major KLUDGE. if (ilut.GetType() != typeof(LookupTable2D)) return base.CreateChild(ilut, d); XElement xel; LookupTable2D lut = (LookupTable2D)ilut; xel = new XElement("table"); xel.SetAttributeValue("name", name); xel.SetAttributeValue("address", ilut.dataAddress.ToString("X")); if (this.xAxis != null) { XElement tx = new XElement("table"); tx.SetAttributeValue("name", "X"); tx.SetAttributeValue("address", lut.colsAddress.ToString("X")); tx.SetAttributeValue("elements", lut.cols); xel.Add(tx); } else { XElement ty = new XElement("table"); ty.SetAttributeValue("name", "Y"); ty.SetAttributeValue("address", lut.colsAddress.ToString("X")); ty.SetAttributeValue("elements", lut.cols); xel.Add(ty); } return TableFactory.CreateTable(xel, name, d); //TODO also set attirbutes and split this up! Copy to table2D!! //return base.CreateChild(lut,d); //TODO FIX?? AND CHECK FOR STATIC AXES!! }
private void DefinitionEditor_Load(object sender, EventArgs e) { Def = sharpTuner.activeImage.Definition; Exposed = Def.AggregateExposedRomTables; BaseTables = Def.AggregateBaseRomTables; TreeNode unexp = new TreeNode("Unexposed Rom Tables"); TreeNode exp = new TreeNode("Exposed Rom Tables"); //TODO SORT BY CATEGORY!! (ROUTINE IN DEFINITION) foreach (var t in BaseTables) { if (!Exposed.ContainsKey(t.Key)) { TreeNode tn = new TreeNode(t.Key);//TODO PUT THIS IN DEFINITION!! tn.Tag = t.Value; unexp.Nodes.Add(tn); } } foreach (var t in Exposed) { TreeNode tn = new TreeNode(t.Key); tn.Tag = t.Value; exp.Nodes.Add(tn); } defTreeView.Nodes.Add(exp); defTreeView.Nodes.Add(unexp); }
public ModDefinition(AvailableDevices ad, Mod parent) { availableDevices = ad; parentMod = parent; RomLutList = new List<LookupTable>(); RamTableList = new Dictionary<string, TableMetaData>(); definition = new ECUMetaData(availableDevices); }
///// <summary> ///// Creates a table XEL from the template file, adding proper addresses ///// </summary> ///// <param name="name"></param> ///// <param name="offset"></param> ///// <returns></returns> //public void ExposeTable(string name, Lut3D lut) //int offset) //{ // XElement bt = GetTableBase(name); // if (bt == null) return; // bt.SetAttributeValue("address", lut.dataAddress.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"; // ele.SetAttributeValue("address", lut.colsAddress.ToString("X")); // } // else if (ele.Attribute("type").Value.ContainsCI("y axis")) // { // ele.Attribute("name").Value = "Y"; // ele.SetAttributeValue("address", lut.rowsAddress.ToString("X")); // } // 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(); // } // if (lut.dataAddress < 0x400000) // { // RomTableList.Add(name, TableFactory.CreateTable(bt)); // } // else // { // RamTableList.Add(name, TableFactory.CreateTable(bt)); // } //} public void CopyTables(ECUMetaData d) { ExposedRomTables = new Dictionary <string, TableMetaData>(d.ExposedRomTables); ExposedRamTables = new Dictionary <string, TableMetaData>(d.ExposedRamTables); BaseRomTables = new Dictionary <string, TableMetaData>(d.BaseRomTables); BaseRamTables = new Dictionary <string, TableMetaData>(d.BaseRamTables); ScalingList = new Dictionary <string, Scaling>(d.ScalingList); }
public virtual TableMetaData CreateChild(LookupTable lut, ECUMetaData d) { XElement xel = new XElement("table"); xel.SetAttributeValue("name", name); xel.SetAttributeValue("address", lut.dataAddress.ToString("X")); return(TableFactory.CreateTable(xel, name, d)); //TODO also set attirbutes and split this up! }
/// <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)); }
/// <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 override TableMetaData CreateChild(LookupTable ilut, ECUMetaData d) { XElement xel; LookupTable3D lut = (LookupTable3D)ilut; xel = new XElement("table"); xel.SetAttributeValue("name", name); xel.SetAttributeValue("address", ilut.dataAddress.ToString("X")); XElement tx = new XElement("table"); tx.SetAttributeValue("name", "X"); tx.SetAttributeValue("address", lut.colsAddress.ToString("X")); tx.SetAttributeValue("elements", lut.cols); xel.Add(tx); XElement ty = new XElement("table"); ty.SetAttributeValue("name", "Y"); ty.SetAttributeValue("address", lut.rowsAddress.ToString("X")); ty.SetAttributeValue("elements", lut.rows); xel.Add(ty); return TableFactory.CreateTable(xel, name, d); //TODO also set attirbutes and split this up! Copy to table2D!! }
public override TableMetaData CreateChild(LookupTable ilut, ECUMetaData d) { XElement xel; LookupTable3D lut = (LookupTable3D)ilut; xel = new XElement("table"); xel.SetAttributeValue("name", name); xel.SetAttributeValue("address", ilut.dataAddress.ToString("X")); XElement tx = new XElement("table"); tx.SetAttributeValue("name", "X"); tx.SetAttributeValue("address", lut.colsAddress.ToString("X")); tx.SetAttributeValue("elements", lut.cols); xel.Add(tx); XElement ty = new XElement("table"); ty.SetAttributeValue("name", "Y"); ty.SetAttributeValue("address", lut.rowsAddress.ToString("X")); ty.SetAttributeValue("elements", lut.rows); xel.Add(ty); return(TableFactory.CreateTable(xel, name, d)); //TODO also set attirbutes and split this up! Copy to table2D!! }
// DeviceImage image) public RamTable(XElement xel, ECUMetaData def, TableMetaData basetable) : base(xel, def, basetable) { RRXML = xel; }
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); }
public Table1DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable) : base(xel, def, basetable) { this.type = "1D"; }
private void UndefinedWindow_Load(object sender, EventArgs e) { defList = new List<string>(sharpTuner.AvailableDevices.IdentList.OrderBy(x => x.ToString()).ToList()); def = new ECUMetaData(sharpTuner.AvailableDevices); List<string> dss = new List<string>(); dss.Add("DEFAULT"); dss.AddRange(defList); comboBoxCopyDef.DataSource = dss; List<string> iss = new List<string>(); iss.AddRange(defList); comboBoxIncludeDef.DataSource = iss; textBoxDefXml.Text = defaultShortDef; }
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); }
public override TableMetaData CreateChild(LookupTable lut,ECUMetaData d) { return base.CreateChild(lut,d); }
public virtual TableMetaData CreateChild(LookupTable lut, ECUMetaData d) { XElement xel = new XElement("table"); xel.SetAttributeValue("name", name); xel.SetAttributeValue("address", lut.dataAddress.ToString("X")); return TableFactory.CreateTable(xel,name, d); //TODO also set attirbutes and split this up! }
public RamTable(XElement xel, ECUMetaData def, TableMetaData basetable)// DeviceImage image) : base(xel, def, basetable) { RRXML = xel; }
/// <summary> /// Handles creation of different table types /// Passes XElement to the proper table /// </summary> /// <param name="xel"></param> /// <returns></returns> public static TableMetaData CreateRamTable(XElement xel, string tablename, string type, ECUMetaData def) { TableMetaData basetable = null; //if (def.GetBaseRamTable(tablename, out basetable)) //{ //has a base table!! therefore not a base! //} if (xel.Attribute("address") == null) basetable = null;//sure??? return CreateRamTableWithDimension(xel, type, def, basetable); }
/// <summary> /// /// </summary> /// <returns></returns> public bool TryReadDefs(String defPath) { Trace.WriteLine("Attempting to read patch definition metadata"); List<Blob> blobs = parentMod.blobList.Blobs; Blob metadataBlob; if (!this.parentMod.TryGetMetaBlob(defMetadataAddress, 10, out metadataBlob, blobs)) { Trace.WriteLine("This patch file does not contain metadata."); return false; } this.defBlob = metadataBlob; int offs = 0; if (!TryParseDefs(this.defBlob, ref offs, defPath)) return false; definition = new ECUMetaData(availableDevices, defPath, this.parentMod); return true; }
public Table3DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable) : base(xel, def, basetable) { this.type = "3D"; }
public bool GetDevices(string directory) { try { string[] files = Directory.GetFiles(directory); //Parallel.ForEach( // files, f => foreach(var f in files) { try { ECUMetaData d = new ECUMetaData(this, f); if(d.isBase) d.Populate(); lock(DefDictionary) { if (DefDictionary.ContainsKey(d.calibrationlId)) { Trace.WriteLine("Duplicate definition found for: " + d.calibrationlId + " in file: " + f + " Check the definitions!!"); Trace.WriteLine("Definition was previously found in file: " + DefDictionary[d.calibrationlId].filePath); } else { DefDictionary.Add(d.calibrationlId, d); lock (IdentList) { IdentList.Add(d.calibrationlId); DeviceCount++; } } } } catch (System.Exception excpt) { Trace.WriteLine("Error reading XML file " + f); Trace.WriteLine(excpt.Message); } } //}); List<string> directories = Directory.GetDirectories(directory).ToList(); //Parallel.ForEach( // directories, d => foreach(var d in directories) { if (!GetDevices(d)) { return false; } }// }); return true; } catch (System.Exception excpt) { Trace.WriteLine(excpt.Message); } return false; }
public RamTable3DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable) : base(xel, def, basetable) { }
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; }
///// <summary> ///// Creates a table XEL from the template file, adding proper addresses ///// </summary> ///// <param name="name"></param> ///// <param name="offset"></param> ///// <returns></returns> //public void ExposeTable(string name, Lut3D lut) //int offset) //{ // XElement bt = GetTableBase(name); // if (bt == null) return; // bt.SetAttributeValue("address", lut.dataAddress.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"; // ele.SetAttributeValue("address", lut.colsAddress.ToString("X")); // } // else if (ele.Attribute("type").Value.ContainsCI("y axis")) // { // ele.Attribute("name").Value = "Y"; // ele.SetAttributeValue("address", lut.rowsAddress.ToString("X")); // } // 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(); // } // if (lut.dataAddress < 0x400000) // { // RomTableList.Add(name, TableFactory.CreateTable(bt)); // } // else // { // RamTableList.Add(name, TableFactory.CreateTable(bt)); // } //} public void CopyTables(ECUMetaData d) { ExposedRomTables = new Dictionary<string,TableMetaData>(d.ExposedRomTables); ExposedRamTables = new Dictionary<string,TableMetaData>(d.ExposedRamTables); BaseRomTables = new Dictionary<string, TableMetaData>(d.BaseRomTables); BaseRamTables = new Dictionary<string, TableMetaData>(d.BaseRamTables); ScalingList = new Dictionary<string, Scaling>(d.ScalingList); }
// DeviceImage image) public RamTable1DMetaData(XElement xel, ECUMetaData def, TableMetaData basetable) : base(xel, def, basetable) { }
public bool GetDevices(string directory) { try { string[] files = Directory.GetFiles(directory); //Parallel.ForEach( // files, f => foreach (var f in files) { try { ECUMetaData d = new ECUMetaData(this, f); if (d.isBase) { d.Populate(); } lock (DefDictionary) { if (DefDictionary.ContainsKey(d.calibrationlId)) { Trace.WriteLine("Duplicate definition found for: " + d.calibrationlId + " in file: " + f + " Check the definitions!!"); Trace.WriteLine("Definition was previously found in file: " + DefDictionary[d.calibrationlId].filePath); } else { DefDictionary.Add(d.calibrationlId, d); lock (IdentList) { IdentList.Add(d.calibrationlId); DeviceCount++; } } } } catch (System.Exception excpt) { Trace.WriteLine("Error reading XML file " + f); Trace.WriteLine(excpt.Message); } } //}); List <string> directories = Directory.GetDirectories(directory).ToList(); //Parallel.ForEach( // directories, d => foreach (var d in directories) { if (!GetDevices(d)) { return(false); } } // }); return(true); } catch (System.Exception excpt) { Trace.WriteLine(excpt.Message); } return(false); }
public override TableMetaData CreateChild(LookupTable lut, ECUMetaData d) { return(base.CreateChild(lut, d)); }