private void writeChipStripButton_Click(object sender, EventArgs e) { this.FormClosing += M24CXXDumpForm_FormClosing; if (_programmer.IsBusy || (_programmer == null)) { return; } Action <ProgrammingCompleteInfo> complete = delegate(ProgrammingCompleteInfo pcInfo) { if (pcInfo.error != null) { if (pcInfo.error is VerificationException) { VerificationException ve = pcInfo.error as VerificationException; infoPanel.SetErrorState( "Verification error. At address: " + ve.ErrorAddress.ToString("X") + " write: " + ve.WrittenByte.ToString("X") + " read: " + ve.ReadByte.ToString("X")); } else { infoPanel.SetErrorState(pcInfo.error.Message); } } else { infoPanel.SetOkState("Write complete"); } this.FormClosing -= M24CXXDumpForm_FormClosing; }; infoPanel.SetProgressState("Writing"); MemoryRegion region = new MemoryRegion(0, (uint)s02512[chipSelectStripComboBox.SelectedItem.ToString()], 1); region.WriteData(0, _dataBytes.GetBytes()); _programmer.ProgramChip(chipSelectStripComboBox.SelectedItem.ToString(), region, complete, infoPanel.GetProgressDelegate()); }
private void M24CXXWrite(string subtype, string name, string serialnumtype, string templatefile) { if ((_programmer == null) || !(_programmer is IM24CXXProgrammer)) { SetAlarmText("Connect the compatible resetter"); return; } IM24CXXProgrammer prog = _programmer as IM24CXXProgrammer; if (prog.IsBusy) { SetInfoText("Resetter is busy"); return; } this.FormClosing += AutoForm_FormClosing; thisBusy = true; MemoryRegion region = null; Action <ProgrammingCompleteInfo> programmComplete = delegate(ProgrammingCompleteInfo pcInfo) { progressBar.Value = progressBar.Minimum; if (pcInfo.error != null) { if (pcInfo.error is VerificationException) { VerificationException ve = pcInfo.error as VerificationException; SetAlarmText( "Verification error At address: " + ve.ErrorAddress.ToString() + " write: " + ve.WrittenByte.ToString() + " read: " + ve.ReadByte.ToString()); } else { SetAlarmText(pcInfo.error.Message); } thisBusy = false; this.FormClosing -= AutoForm_FormClosing; } else if (serialnumtype == "No") { SetOkText(pcInfo.Message); thisBusy = false; this.FormClosing -= AutoForm_FormClosing; } else { Action <FileWorkerIOCompleteInfo> writeComplete = delegate(FileWorkerIOCompleteInfo fwiocInfo) { if (fwiocInfo.Error != null) { SetAlarmText(fwiocInfo.Error.Message); } else { SetOkText(pcInfo.Message); } thisBusy = false; this.FormClosing -= AutoForm_FormClosing; }; _dumpCoprrectors[serialnumtype](region.Data); _fileWorker.Write(templatefile, new List <MemoryRegion>() { region }, writeComplete); } }; Action <FileWorkerIOCompleteInfo> readFileComplete = delegate(FileWorkerIOCompleteInfo fwiocInfo) { if (fwiocInfo.Error != null) { SetAlarmText(fwiocInfo.Error.Message); thisBusy = false; this.FormClosing -= AutoForm_FormClosing; } else { if (prog.IsBusy) { SetInfoText("Resetter is busy"); thisBusy = false; this.FormClosing -= AutoForm_FormClosing; return; } region = fwiocInfo.Regions[0]; prog.ProgramChip(subtype, fwiocInfo.Regions[0], programmComplete, Progress); } }; MemoryRegionInfo regionInfo = new MemoryRegionInfo() { Address = 0, Size = 0, Type = 1 }; regionInfo.Size = (uint)s02512[subtype]; _fileWorker.Read(templatefile, new List <MemoryRegionInfo>() { regionInfo }, readFileComplete); }