コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Table3D.cs プロジェクト: segapsh2/SharpTune
 public override Table CreateChild(Lut ilut,Definition d)
 {
     Lut3D lut = (Lut3D)ilut;
     xml = new XElement("table");
     xml.SetAttributeValue("name", name);
     xml.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);
     xml.Add(tx);
     XElement ty = new XElement("table");
     ty.SetAttributeValue("name", "Y");
     ty.SetAttributeValue("address", lut.rowsAddress.ToString("X"));
     ty.SetAttributeValue("elements", lut.rows);
     xml.Add(ty);
     return TableFactory.CreateTable(xml, d);
     //TODO also set attirbutes and split this up! Copy to table2D!!
 }
コード例 #3
0
ファイル: Table1D.cs プロジェクト: segapsh2/SharpTune
 // DeviceImage image)
 public RamTable1D(XElement xel, Definition d, bool b)
     : base(xel, d, b)
 {
 }
コード例 #4
0
ファイル: Table1D.cs プロジェクト: segapsh2/SharpTune
 public override Table CreateChild(Lut lut,Definition d)
 {
     return base.CreateChild(lut,d);
 }
コード例 #5
0
        public bool GetDevices(string directory)
        {
            try
            {
                string[] files = Directory.GetFiles(directory);
                Parallel.ForEach(
                    files, f =>
                    {
                        try
                        {
                            Definition d = new Definition(f);
                            if (d.isBase)
                                d.LoadRomId();
                            lock(DefDictionary)
                            {
                                if (DefDictionary.ContainsKey(d.internalId))
                                {
                                    Trace.WriteLine("Duplicate definition found for: " + d.internalId + " in file: " + f + " Check the definitions!!");
                                    Trace.WriteLine("Definition was previously found in file: " + DefDictionary[d.internalId].defPath);
                                }
                                else
                                {
                                    DefDictionary.Add(d.internalId, d);

                                    lock (IdentList)
                                    {
                                        IdentList.Add(d.internalId);
                                        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 =>
                    {
                        if (!GetDevices(d))
                        {
                            return;
                        }
                    });

                return true;
            }
            catch (System.Exception excpt)
            {
                Trace.WriteLine(excpt.Message);
            }

            return false;
        }
コード例 #6
0
ファイル: Table3D.cs プロジェクト: segapsh2/SharpTune
 public Table3D(XElement xel, Definition d, bool b)
     : base(xel, d, b)
 {
 }
コード例 #7
0
ファイル: Table.cs プロジェクト: segapsh2/SharpTune
        /// <summary>
        /// Construct from XML Element
        /// </summary>
        /// <param name="xel"></param>
        public Table(XElement xel, Definition d, bool b)
        {
            parentDef = d;
            InheritanceList = new List<Table>();
            isBase = b;
            if(xel.Attribute("name") != null)
                name = xel.Attribute("name").Value.ToString();
            if (d != null && d.inheritList != null)
            {
                foreach (Definition id in d.inheritList)
                {
                    if (id.BaseRomTables.ContainsKey(name)) //TOOD THIS IS INCOMPATIBLE WITH RAM TABLES
                    {
                        if (id.BaseRomTables[name].InheritanceList != null)
                            InheritanceList.AddRange(id.BaseRomTables[name].InheritanceList);
                        InheritanceList.Add(id.BaseRomTables[name]);
                        break;
                    }
                }

                foreach (Table t in InheritanceList)
                {
                    if (t.category != null)
                    {
                        category = t.category;
                        break;
                    }
                }
            }

            xml = xel;

            dataTable = new DataTable();

            properties = new Dictionary<string, string>();

            foreach (XAttribute attribute in xel.Attributes())
            {
                this.properties.Add(attribute.Name.ToString(), attribute.Value.ToString());
            }

            if (!this.properties.ContainsKey("name"))
            {
                this.properties.Add("name", "unknown");
            }

            else
            {
                this.name = this.properties["name"].ToString();
                this.Tag = this.name + ".table";
            }

            foreach (KeyValuePair<string, string> property in this.properties)
            {
                switch (property.Key.ToString())
                {
                    case "name":
                        this.name = property.Value.ToString();
                        continue;

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

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

                    case "scaling":
                        this.scaling = new Scaling();
                        this.scaling = SharpTuner.DataScalings.Find(s => s.name == property.Value.ToString());
                        continue;

                    case "type":
                        this.type = property.Value.ToString();
                        continue;

                    case "category":
                        this.category = property.Value.ToString();
                        continue;

                    default:
                        continue;
                }
            }

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

                switch (cname)
                {
                    case "table":
                        this.AddAxis(child);
                        break;

                    case "description":
                        this.description = child.Value.ToString();
                        break;

                    default:
                        break;
                }
            }
        }
コード例 #8
0
ファイル: Table.cs プロジェクト: segapsh2/SharpTune
 public static Table CreateTableWithDimension(XElement xel, Definition d, bool b)
 {
     if (xel.Attribute("type") != null)
     {
         switch (xel.Attribute("type").Value.ToString())
         {
             case "1D":
                 return new Table1D(xel,d,b);
             case "2D":
                 return new Table2D(xel,d,b);
             case "3D":
                 return new Table3D(xel,d,b);
             default:
                 break;
         }
     }
     return new Table(xel,d,b);
 }
コード例 #9
0
ファイル: Table.cs プロジェクト: segapsh2/SharpTune
 /// <summary>
 /// Handles creation of different table types
 /// Passes XElement to the proper table
 /// </summary>
 /// <param name="xel"></param>
 /// <returns></returns>
 public static Table CreateTable(XElement xel, Definition d)
 {
     bool b = false;
     if (xel.Attribute("address") == null)
         b = true;
     return CreateTableWithDimension(xel, d, b);
 }
コード例 #10
0
ファイル: Table.cs プロジェクト: segapsh2/SharpTune
 public virtual Table CreateChild(Lut lut, Definition d)
 {
     XElement xml = new XElement("table");
     xml.SetAttributeValue("name", name);
     xml.SetAttributeValue("address", lut.dataAddress.ToString("X"));
     return TableFactory.CreateTable(xml, d);
     //TODO also set attirbutes and split this up!
 }
コード例 #11
0
ファイル: Definition.cs プロジェクト: segapsh2/SharpTune
 ///// <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(Definition d)
 {
     ExposedRomTables = new Dictionary<string,Table>(d.ExposedRomTables);
     ExposedRamTables = new Dictionary<string,Table>(d.ExposedRamTables);
     BaseRomTables = new Dictionary<string, Table>(d.BaseRomTables);
     BaseRamTables = new Dictionary<string, Table>(d.BaseRamTables);
     ScalingList = new Dictionary<string, Scaling>(d.ScalingList);
 }
コード例 #12
0
ファイル: ModDefinition.cs プロジェクト: segapsh2/SharpTune
        //TODO remove defpath and ref the static global
        /// <summary>
        /// Cycles through the template definition and replaces "0" addresses with addresses from the patch file.
        /// TODO: Replace template with inheritance from 32BITBASE Tables and a patch parameter that specifies the child template to use.
        /// </summary>
        /// <returns></returns>
        public bool TryReadDefs(String defPath)
        {
            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 Definition(defPath, this.parentMod);

            //TODO: move RR stuff into definition?
            //prompt to select logger type
            NewRRLogDefInheritWithTemplate(this.RamTableList, SharpTuner.RRLoggerDefPath + @"\MerpMod\" + parentMod.ModBuild + @"\" + parentMod.ModIdent + ".xml", SharpTuner.RRLoggerDefPath + @"\MerpMod\base.xml", parentMod.InitialEcuId.ToString(), parentMod.FinalEcuId.ToString());
            return true;
        }
コード例 #13
0
ファイル: Table2D.cs プロジェクト: segapsh2/SharpTune
 public override Table CreateChild(Lut lut,Definition d)
 {
     return base.CreateChild(lut,d);
     //TODO FIX?? AND CHECK FOR STATIC AXES!!
 }
コード例 #14
0
ファイル: UndefinedWindow.cs プロジェクト: segapsh2/SharpTune
        private void UndefinedWindow_Load(object sender, EventArgs e)
        {
            defList = new List<string>(SharpTuner.AvailableDevices.IdentList.OrderBy(x => x.ToString()).ToList());
            def = new Definition();
            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;
        }