private void ConvertToData(List <byte> package) { int CMD = package[9] * 256 + package[10]; switch (CMD) { case FinalConst.CMD_TYPE_CHECK_DEVICE: { break; } case FinalConst.CMD_TYPE_READY_STOP: { SerialPortSendCMD(CMDSender.sendCMD_UpdateStop()); break; } case FinalConst.CMD_TYPE_RESETDEVICE: //0xEE { nTimer.Start(); break; } case 0x10: { ConnectionTimer.Stop(); break; } case 0x08: { break; } case FinalConst.CMD_TYPE_READY_PROGRAM: //0xEF { nTimer.Stop(); break; } case FinalConst.CMD_TYPE_DO_PROGRAM: //0xF0 { int SegementIndex = package[11]; Data.ProgressBarValue = SegementIndex + 1; if (SegementIndex < Data.ProgressBarMax) { byte[] tempByteArray = new byte[FinalConst.MaxLength]; for (int i = 0; i < FinalConst.MaxLength; i++) { tempByteArray[i] = FileData[SegementIndex, i]; } SerialPortSendCMD(CMDSender.sendCMD_UpdateFirmware(SegementIndex, tempByteArray)); } if (SegementIndex + 1 == Data.ProgressBarMax) { } break; } case FinalConst.CMD_TYPE_FINISH_PROGRAM: //0xF1 { Data.FileInfo += "Update finished,please select Disconnect and close software.Please restart device after 2 minutes\n"; Data.UpdateState = false; break; } case FinalConst.CMD_TYPE_GETADDRS_RECALL: //0x21 { Data.FileInfo += "GETADDR\n"; Thread.Sleep(1000); byte[] GAADRsendBuf = { 0x01, 0x20, 0x03, 0x00, 0x0E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x60, 0x40 }; SerialPortSendCMD(GAADRsendBuf); break; } case FinalConst.CMD_TYPE_READPRESETLIST: //0x15 { int count = 11; for (int r = 0; r < 16; r++) { for (int i = 0; i < 13; i++) { //MyPreset[r, i] = package[count++]; CoreData.m_preset[r, i] = package[count++]; } } Application.Current.Dispatcher.Invoke(() => { Data.PresetCollection.Clear(); for (int i = 0; i < 16; i++) { Data.PresetCollection.Add(CoreData.gPresetName(i)); } }); Data.ManagePresetState = "List of Global Presets completed!"; break; } case FinalConst.CMD_TYPE_RecallSinglePreset: { Application.Current.Dispatcher.Invoke(() => { exportPresetDataToFile(package); }); break; } case FinalConst.CMD_TYPE_LoadPreset_fromPC: { break; } case FinalConst.CMD_TYPE_MemoryExportFromDevice: { int index = package[11]; int Progress = (index + 1) / 16 * 100; Data.DownloadProgress = string.Format("{0}%", Progress); if (index >= 0 && index < 16) { for (int i = 0; i < FinalConst.Len_Sence_Pack; i++) { CoreData.m_memory[index, i] = package[i]; } if (index == 15) { Application.Current.Dispatcher.Invoke(() => { ExportMemoryToFile(); }); } } break; } case FinalConst.CMD_TYPE_MemoryImportFromPC: { int index = package[11]; int Progress = (index + 1) / 16 * 100; Data.UploadProgress = string.Format("{0}%", Progress); if (index < 15) { SerialPortSendCMD(CMDSender.sendCMD_MemoryImport_Scence(index + 1)); } break; } } Message.Clear(); }