public void SaveToDevice(HandleIO pObject) { try { string protectStart = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) + platformIO.Options.ProtectionStart + "$"; platform.SendPacket(new Packet(protectStart, DateTime.Now, null)); int[] pages = { 0, 1, 2, 3 }; foreach (int page in pages) { for (int line = 0; line < 16; line++) { string data = pObject.Eprom[page].Lines[line].ToString(); platformIO.Write(platformIO.Options.Device, page + 1, line * 16, 16, data); switch (platformIO.LastOperation) { case ResultOperation.Succes: if (eSaveCompleteReadEpromLine != null) { eSaveCompleteReadEpromLine(this, new EventArgs()); } break; case ResultOperation.Timeout: if (eSaveTimeoutReadEpromLine != null) { eSaveTimeoutReadEpromLine(this, new EventArgs()); } return; case ResultOperation.MorePopit: if (eSaveMorePopitReadEpromLine != null) { eSaveMorePopitReadEpromLine(this, new EventArgs()); } return; default: return; } } } } finally { string protectEnd = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) + platformIO.Options.ProtectionEnd + "$"; platform.SendPacket(new Packet(protectEnd, DateTime.Now, null)); } }
/// <summary> /// Сохранить таблицу калибровки в файл /// </summary> /// <param name="table">Таблица калибровки, которую необходимо сохранить</param> /// <param name="eprom">Виртуальный eprom устройства</param> public void SaveCalibrationTableToDevice(CalibrationTable table, Eprom eprom) { try { int[] Indices = { 0x0400, 0x0430, 0x0460, 0x0490, 0x04C0, 0x04F0, 0x0520, 0x0550 }; foreach (int index in Indices) { if (eprom.GetByte(index) == table.Name) { string protectStart = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) + platformIO.Options.ProtectionStart + "$"; platform.SendPacket(new Packet(protectStart, DateTime.Now, null)); for (int line = 0; line < calibrationTableCountLines; line++) { int offset = index + (line * 16); int pageNumber = (int)(offset / 256); int offsetPage = (int)(offset % 256); string data = string.Empty; for (int byteIndex = 0; byteIndex < calibrationLineByteCount; byteIndex++) { data += string.Format("{0:X2}", eprom.GetByte(offset++)); } platformIO.Write(platformIO.Options.Device, pageNumber, offsetPage, 16, data); switch (platformIO.LastOperation) { case ResultOperation.Succes: if (eSaveCompleteReadEpromLine != null) { eSaveCompleteReadEpromLine(this, new EventArgs()); } break; case ResultOperation.Timeout: if (eSaveTimeoutReadEpromLine != null) { eSaveTimeoutReadEpromLine(this, new EventArgs()); } return; case ResultOperation.MorePopit: if (eSaveMorePopitReadEpromLine != null) { eSaveMorePopitReadEpromLine(this, new EventArgs()); } return; default: return; } } } } } finally { string protectEnd = "@JOB#000#" + string.Format("{0:X2}", platformIO.Options.Device) + platformIO.Options.ProtectionEnd + "$"; platform.SendPacket(new Packet(protectEnd, DateTime.Now, null)); } }