Пример #1
0
        public void ImportMapFile(string filepath, DeviceImage image)
        {
            EcuMap im = new EcuMap();

            im.ImportFromMapFileOrText(filepath);
            ReadMap(im, image);
        }
Пример #2
0
 public void ReadMap(IdaMap idaMap, DeviceImage image)
 {
     //loop through base def and search for table names in map
     foreach (var romtable in AggregateBaseRomTables)
     {
         foreach (var idan in idaMap.IdaCleanNames)
         {
             if (romtable.Key.EqualsIdaString(idan.Key))
             {
                 ExposeTable(romtable.Key, LutFactory.CreateLut(romtable.Key, uint.Parse(idan.Value.ToString(), NumberStyles.AllowHexSpecifier), image.imageStream));
                 break;
             }
         }
     }
     ////TODO RAMTABLES
     //foreach (var ramtable in baseDef.RamTableList)
     //{
     //    foreach (var idan in idaMap.IdaCleanNames)
     //    {
     //        if (ramtable.Key.EqualsIdaString(idan.Key))
     //        {
     //            break;
     //        }
     //    }
     //}
 }
Пример #3
0
        public void ImportMapText(string text, DeviceImage image)
        {
            EcuMap im = new EcuMap();

            im.ImportFromMapFileOrText(text);
            ReadMap(im, image);
        }
Пример #4
0
        public virtual void Read(DeviceImage image)
        {
            //TODO, pull this ot and make as extension to generic axis
            //remove "scaling" reference -> populate object during construction
            this.scaling = this.defaultScaling;

            lock (image.imageStream)
            {
                image.imageStream.Seek(this.address, SeekOrigin.Begin);
                this.byteValues    = new List <byte[]>();
                this.floatValues   = new List <float>();
                this.displayValues = new List <string>();

                for (int i = 0; i < this.elements; i++)
                {
                    if (this.isStatic)
                    {
                        this.displayValues = this.staticList;
                        break;
                    }
                    byte[] b = new byte[this.scaling.storageSize];
                    image.imageStream.Read(b, 0, this.scaling.storageSize);
                    if (this.endian == "big")
                    {
                        b.ReverseBytes();
                    }
                    this.byteValues.Add(b);
                    this.displayValues.Add(this.scaling.toDisplay(b));
                    //Must add scaling stuff in here!
                }
            }
        }
Пример #5
0
        public override void Read()
        {
            DeviceImage image = this.parentImage;

            this.elements       = this.yAxis.elements; // * this.yAxis.elements;
            this.defaultScaling = SharpTuner.DataScalings.Find(s => s.name.ToString().Contains(this.properties["scaling"].ToString()));
            this.scaling        = this.defaultScaling;

            lock (image.imageStream)
            {
                image.imageStream.Seek(this.address, SeekOrigin.Begin);
                this.byteValues    = new List <byte[]>();
                this.floatValues   = new List <float>();
                this.displayValues = new List <string>();

                for (int i = 0; i < this.elements; i++)
                {
                    byte[] b = new byte[this.scaling.storageSize];
                    image.imageStream.Read(b, 0, this.scaling.storageSize);
                    if (this.scaling.endian == "big")
                    {
                        b.ReverseBytes();
                    }
                    this.byteValues.Add(b);
                    this.displayValues.Add(this.scaling.toDisplay(b));
                }
            }
        }
Пример #6
0
 public override void Read(DeviceImage image)
 {
     //TODO, pull this ot and make as extension to generic axis
     //remove "scaling" reference -> populate object during construction
     this.scaling       = this.defaultScaling;
     this.displayValues = new List <string>();
     foreach (string value in this.staticList)
     {
         this.displayValues.Add(value.ToString());
     }
 }
Пример #7
0
        public virtual void Write()
        {
            DeviceImage image = this.parentTable.parentImage;

            lock (image.imageStream)
            {
                image.imageStream.Seek(this.address, SeekOrigin.Begin);

                //write this.bytevalues!
                foreach (byte[] bytevalue in this.byteValues)
                {
                    if (this.scaling.endian == "big")
                    {
                        bytevalue.ReverseBytes();
                    }
                    image.imageStream.Write(bytevalue, 0, bytevalue.Length);
                }
            }
        }
Пример #8
0
        public override void Write()
        {
            DeviceImage image = this.parentImage;

            lock (image.imageStream)
            {
                //No need to write axes, they don't really exist for 1D tables!
                image.imageStream.Seek(this.address, SeekOrigin.Begin);

                //write this.bytevalues!
                foreach (byte[] bytevalue in this.byteValues)
                {
                    if (this.scaling.endian == "big")
                    {
                        bytevalue.ReverseBytes();
                    }
                    image.imageStream.Write(bytevalue, 0, bytevalue.Length);
                }
            }
        }
Пример #9
0
        public override void Write()
        {
            DeviceImage image = this.parentImage;

            lock (image.imageStream)
            {
                //2D only has Y axis
                this.yAxis.Write();
                image.imageStream.Seek(this.address, SeekOrigin.Begin);

                //write this.bytevalues!
                foreach (byte[] bytevalue in this.byteValues)
                {
                    if (this.scaling.endian == "big")
                    {
                        bytevalue.ReverseBytes();
                    }
                    image.imageStream.Write(bytevalue, 0, bytevalue.Length);
                }
            }
        }
Пример #10
0
        public override void Read()
        {
            DeviceImage image = this.parentImage;

            this.elements       = 1;
            this.defaultScaling = SharpTuner.DataScalings.Find(s => s.name.ToString().Contains(this.properties["scaling"].ToString()));
            this.scaling        = this.defaultScaling;

            ////Check SSM interface ID vs the device ID
            //if (SharpTuner.ssmInterface.EcuIdentifier != this.parentImage.CalId)
            //{
            //    throw new System.Exception("Device Image does not match connected device!");
            //}

            //SsmInterface ssmInterface = SharpTuner.ssmInterface;

            //May have an issue with this while logging???
            //Is it necessary??
            //TODO: Find out
            //lock (ssmInterface)
            //{
            //    this.byteValues = new List<byte[]>();
            //    this.displayValues = new List<string>();

            //    byte[] b = new byte[this.scaling.storageSize];
            //    IAsyncResult result = ssmInterface.BeginBlockRead(this.address, this.scaling.storageSize, null, null);
            //    result.AsyncWaitHandle.WaitOne();
            //    b = ssmInterface.EndBlockRead(result);
            //    if (this.scaling.endian == "big")
            //    {
            //        b.ReverseBytes();
            //    }
            //    this.byteValues.Add(b);
            //    this.displayValues.Add(this.scaling.toDisplay(b));
            //}
        }
Пример #11
0
        public void ImportMapText(string text, DeviceImage image)
        {
            IdaMap idaMap = new IdaMap(text);

            ReadMap(idaMap, image);
        }
Пример #12
0
        public void ImportMapFile(string filepath, DeviceImage image)
        {
            IdaMap idaMap = new IdaMap(filepath);

            ReadMap(idaMap, image);
        }
Пример #13
0
 public void openDeviceImage(string filename)
 {
     //Construct new romimage
     DeviceImage newImage = new DeviceImage(filename);
     if (newImage.CalId == null)
     {
         Trace.TraceWarning(String.Format("Unable to identify rom at {0}", newImage.FilePath.ToString()));
         MessageBox.Show("Unable to idenfity rom at " + newImage.FilePath.ToString());
         return;
     }
     foreach (DeviceImage image in SharpTuner.ImageList)
     {
         if (image.FilePath == filename)
         {
             Console.Write("Rom is already open!");
             return;
         }
     }
     this.closeDeviceImageToolStripMenuItem.Enabled = true;
     obfuscateCALIDToolStripMenuItem.Enabled = true;
     SharpTuner.AddImage(newImage);
     this.openDeviceListBox.Items.Add(SharpTuner.ActiveImage.FileName);
     Trace.WriteLine("Successfully opened " + SharpTuner.ActiveImage.CalId + " filename: " + SharpTuner.ActiveImage.FileName);
     Refresh();
 }
Пример #14
0
        public virtual void Read(DeviceImage image)
        {
            //TODO, pull this ot and make as extension to generic axis
            //remove "scaling" reference -> populate object during construction
            this.scaling = this.defaultScaling;

            lock (image.imageStream)
            {
                image.imageStream.Seek(this.address, SeekOrigin.Begin);
                this.byteValues = new List<byte[]>();
                this.floatValues = new List<float>();
                this.displayValues = new List<string>();

                for (int i = 0; i < this.elements; i++)
                {
                    if (this.isStatic)
                    {
                        this.displayValues = this.staticList;
                        break;
                    }
                    byte[] b = new byte[this.scaling.storageSize];
                    image.imageStream.Read(b, 0, this.scaling.storageSize);
                    if (this.endian == "big")
                    {
                        b.ReverseBytes();
                    }
                    this.byteValues.Add(b);
                    this.displayValues.Add(this.scaling.toDisplay(b));
                    //Must add scaling stuff in here!
                }
            }
        }
Пример #15
0
 public void ImportMapFile(string filepath, DeviceImage image)
 {
     IdaMap idaMap = new IdaMap(filepath);
     ReadMap(idaMap,image);
 }
Пример #16
0
 public void ImportMapText(string text, DeviceImage image)
 {
     IdaMap idaMap = new IdaMap(text);
     ReadMap(idaMap,image);
 }
Пример #17
0
 public void ReadMap(IdaMap idaMap,DeviceImage image)
 {
     //loop through base def and search for table names in map
     foreach (var romtable in AggregateBaseRomTables)
     {
         foreach (var idan in idaMap.IdaCleanNames)
         {
             if (romtable.Key.EqualsIdaString(idan.Key))
             {
                 ExposeTable(romtable.Key, LutFactory.CreateLut(romtable.Key, uint.Parse(idan.Value.ToString(), NumberStyles.AllowHexSpecifier), image.imageStream));
                 break;
             }
         }
     }
     ////TODO RAMTABLES
     //foreach (var ramtable in baseDef.RamTableList)
     //{
     //    foreach (var idan in idaMap.IdaCleanNames)
     //    {
     //        if (ramtable.Key.EqualsIdaString(idan.Key))
     //        {
     //            break;
     //        }
     //    }
     //}
 }
Пример #18
0
 public override void Read(DeviceImage image)
 {
     //TODO, pull this ot and make as extension to generic axis
     //remove "scaling" reference -> populate object during construction
     this.scaling = this.defaultScaling;
     this.displayValues = new List<string>();
     foreach (string value in this.staticList)
     {
         this.displayValues.Add(value.ToString());
     }
 }
Пример #19
0
 //public static void setSsmInterface(SsmInterface s)
 //{
 //    ssmInterface = s;
 //}
 public static void AddImage(DeviceImage d)
 {
     ImageList.Add(d);
     ActiveImage = d;
 }