Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            ConnectionViewModel vmc = new ConnectionViewModel(portName, serialPortSettings, logger, 12, new DateTime(2015, 06, 14));
            connection.DataContext = vmc;

            ResetViewModel vmr = new ResetViewModel(portName, serialPortSettings, logger);
            reset.DataContext = vmr;

            ReadLockViewModel vmrl = new ReadLockViewModel(portName, serialPortSettings, logger, 0x67);
            readLock.DataContext = vmrl;

            ReadFuseViewModel vmrf = new ReadFuseViewModel(portName, serialPortSettings, logger, new byte[] {0x23, 0x56, 0xAF});
            readFuse.DataContext = vmrf;

            HexFileManager hfm = new HexFileManager();
            var memory = new Memory(0x40000);
            hfm.OpenFile("Flash.hex", memory);
            var memoryEeprom = new Memory(0x1000);
            hfm.OpenFile("Eeprom.hex", memoryEeprom);

            EraseViewModel vmref = new EraseViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory);
            eraseFlash.DataContext = vmref;

            EraseViewModel vmree = new EraseViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom);
            eraseEeprom.DataContext = vmree;
            ReadViewModel vmrrf = new ReadViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory);
            readFlash.DataContext = vmrrf;

            ReadViewModel _vmrrf = new ReadViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom);
            readEeprom.DataContext = _vmrrf;

            IsEmptyViewModel _vmref = new IsEmptyViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory);
            isEmptyFlash.DataContext = _vmref;

            IsEmptyViewModel _vmrre = new IsEmptyViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom);
            isEmptyEeprom.DataContext = _vmrre;

            WriteViewModel __vmref = new WriteViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory);
            writeFlash.DataContext = __vmref;

            WriteViewModel __vmrre = new WriteViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom);
            writeEeprom.DataContext = __vmrre;
        }
        public void HexFile()
        {
            IHexFileManager fileManager = new HexFileManager();
            IMemory memory = new Memory(0x40000);
            fileManager.OpenFile(Directory.GetCurrentDirectory() + "\\HexFile\\file1.hex", memory);
            fileManager.SaveFile(Directory.GetCurrentDirectory() + "\\HexFile\\saved_file1.hex", memory);

            IMemory memory1 = new Memory(0x40000);
            fileManager.OpenFile(Directory.GetCurrentDirectory() + "\\HexFile\\saved_file1.hex", memory1);

            Assert.IsTrue(memory.Equals(memory1));

            memory = new Memory(0x40000);
            fileManager.OpenFile(Directory.GetCurrentDirectory() + "\\HexFile\\file2.hex", memory);
            fileManager.SaveFile(Directory.GetCurrentDirectory() + "\\HexFile\\saved_file2.hex", memory);

            memory1 = new Memory(0x40000);
            fileManager.OpenFile(Directory.GetCurrentDirectory() + "\\HexFile\\saved_file2.hex", memory1);

            Assert.IsTrue(memory.Equals(memory1));
        }