/// <summary> /// Формирует команду /// </summary> /// <param name="Number">Номер устройства</param> /// <param name="Cmd">Комадна на чтени, запись, чтени/запись</param> /// <param name="pNumber">Номер страницы</param> /// <param name="Offset">Смещенеи на странице</param> /// <param name="lenghtOfData">Длинна данных</param> /// <param name="Data">Данные</param> /// <returns>Сформированная команда</returns> public string CreateCommand(Device Number, Command Cmd, PageNumber pNumber, int Offset, int lenghtOfData, string Data) { if ((Offset + lenghtOfData) > 256) { throw new ArgumentException("Invalid Offset value and lenghtOfData value. The summa must less than 255."); } if (Data != null) { if (Data != string.Empty) { if ((Data.Length / 2) != lenghtOfData) { throw new ArgumentException("Data.Lenght != lenghtOfData"); } } } string ladd = GetDeviceNumber(Number); int l_pack = 7; if (Data != null && Data != string.Empty) l_pack += Data.Length / 2; byte _cmd = 0x00; switch (pNumber) { case PageNumber.P0: _cmd = 0x00; break; case PageNumber.P1: _cmd = 0x20; break; case PageNumber.P2: _cmd = 0x40; break; case PageNumber.P3: _cmd = 0x60; break; case PageNumber.P4: _cmd = 0x80; break; case PageNumber.P5: _cmd = 0xA0; break; case PageNumber.P6: _cmd = 0xC0; break; case PageNumber.P7: _cmd = 0xE0; break; } switch (Cmd) { case Command.Read: _cmd |= 0x02; break; case Command.Write: _cmd |= 0x01; break; case Command.ReadWrite: _cmd |= 0x03; break; } string adr = string.Format("{0:X2}", Offset); string ldata = string.Format("{0:X2}", lenghtOfData); string status = "00"; string total = ladd + string.Format("{0:X2}", l_pack) + string.Format("{0:X2}", _cmd) + adr + ldata; if (Data != null && Data != string.Empty) total += Data; total += status + "$"; return "@JOB#000#" + total; }
private void WriteEprom() { try { Invoke(initer, 0, rInfo.countCommands); DataGridView page = null; List<string> Datas = new List<string>(); IProtocol protocol = app.GetProtocol(ProtocolVersion.x100); if (rInfo.UsingAnAlgorithmWithDataProtection) { string protectCommand = "@JOB#000#" + string.Format("{0:X2}", rInfo.DeviceNumber) + rInfo.ProtectionStart + "$"; app.SendPacket(new Packet(protectCommand, DateTime.Now, null)); } for (int pageIndex = 0; pageIndex < 7; pageIndex++) { if (rInfo.Pages[pageIndex] != -1) { page = GetPage(pageIndex); PageNumber pageNumber = PageNumber.P0; if (rInfo.Pages[pageIndex] == 1) pageNumber = PageNumber.P1; if (rInfo.Pages[pageIndex] == 2) pageNumber = PageNumber.P2; if (rInfo.Pages[pageIndex] == 3) pageNumber = PageNumber.P3; if (rInfo.Pages[pageIndex] == 4) pageNumber = PageNumber.P4; if (rInfo.Pages[pageIndex] == 5) pageNumber = PageNumber.P5; if (rInfo.Pages[pageIndex] == 6) pageNumber = PageNumber.P6; if (rInfo.Pages[pageIndex] == 7) pageNumber = PageNumber.P7; for (int lineIndex = 0; lineIndex < 16; lineIndex++) { string wrdata = string.Empty; for (int i = 0; i < 16; i++) { if (page[i, lineIndex].Value == null) { MessageBox.Show("Конфигурация не записанна в устройство. Так как один из параметров имеет не допустимое значение", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (page[i, lineIndex].Value.ToString() == string.Empty) { MessageBox.Show("Конфигурация не записанна в устройство. Так как один из параметров имеет не допустимое значение", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } wrdata += page[i, lineIndex].Value.ToString(); } int offset = lineIndex * 16; string command = protocol.CreateCommand(rInfo.Device, Command.ReadWrite, pageNumber, offset, 16, wrdata); bool needNext = true; ResultOperation result = ResultOperation.Default; for (int attempts = 0; attempts <= rInfo.NumberOfDataChecks; attempts++) { if (!needNext) break; result = ChekerToWriteEprom(new Packet(command, DateTime.Now, null)); switch (result) { case ResultOperation.Succes: Datas.Add(protocol.GetData(data)); data = CheckDatas(Datas); if (data != string.Empty) { Invoke(incer, 1); if (data.Length != 32) { MessageBox.Show("Поступившие данные не корректны. Скорее всего к линии подключенно более одного устройства.", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Datas.Clear(); needNext = false; } break; case ResultOperation.Timeout: Datas.Clear(); MessageBox.Show("Превышен лимит времени ожидания", "Сообщение", MessageBoxButtons.OK); return; case ResultOperation.MorePopit: Datas.Clear(); MessageBox.Show("Превышен лимит попыток чтения/записи", "Сообщение", MessageBoxButtons.OK); return; default: Datas.Clear(); break; } Thread.Sleep(rInfo.TimeoutBetweenRead); } } } } } finally { if (rInfo.UsingAnAlgorithmWithDataProtection) { string restartCommand = "@JOB#000#" + string.Format("{0:X2}", rInfo.DeviceNumber) + rInfo.ProtectionEnd + "$"; app.SendPacket(new Packet(restartCommand, DateTime.Now, null)); } workHandle.operation = Operation.Default; } }
private void ReadEprom() { try { Invoke(initer, 0, rInfo.countCommands); DataGridView page = null; List<string> Datas = new List<string>(); IProtocol protocol = app.GetProtocol(ProtocolVersion.x100); for (int pageIndex = 0; pageIndex < 7; pageIndex++) { if (rInfo.Pages[pageIndex] != -1) { page = GetPage(pageIndex); PageNumber pageNumber = PageNumber.P0; if (rInfo.Pages[pageIndex] == 1) pageNumber = PageNumber.P1; if (rInfo.Pages[pageIndex] == 2) pageNumber = PageNumber.P2; if (rInfo.Pages[pageIndex] == 3) pageNumber = PageNumber.P3; if (rInfo.Pages[pageIndex] == 4) pageNumber = PageNumber.P4; if (rInfo.Pages[pageIndex] == 5) pageNumber = PageNumber.P5; if (rInfo.Pages[pageIndex] == 6) pageNumber = PageNumber.P6; if (rInfo.Pages[pageIndex] == 7) pageNumber = PageNumber.P7; for (int lineIndex = 0; lineIndex < 16; lineIndex++) { int offset = lineIndex * 16; string command = protocol.CreateCommand(rInfo.Device, Command.Read, pageNumber, offset, 16, string.Empty); bool needNext = true; ResultOperation result = ResultOperation.Default; for (int attempts = 0; attempts <= rInfo.NumberOfDataChecks; attempts++) { if (!needNext) break; result = ChekerToReadEprom(new Packet(command, DateTime.Now, null)); switch (result) { case ResultOperation.Succes: Datas.Add(protocol.GetData(data)); data = CheckDatas(Datas); if (data != string.Empty) { Invoke(incer, 1); if (data.Length != 32) { MessageBox.Show("Поступившие данные не корректны.", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < data.Length / 2; i++) { page[i, lineIndex].Value = data.Substring(i * 2, 2); } Datas.Clear(); needNext = false; } break; case ResultOperation.Timeout: MessageBox.Show("Превышен лимит времени ожидания", "Сообщение", MessageBoxButtons.OK); return; case ResultOperation.MorePopit: MessageBox.Show("Превышен лимит попыток чтения/записи", "Сообщение", MessageBoxButtons.OK); return; default: break; } Thread.Sleep(rInfo.TimeoutBetweenRead); } } } } } finally { workHandle.operation = Operation.Default; } }
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { TabControl tab = sender as TabControl; switch (tab.SelectedIndex) { case 0: page = PageNumber.P1; break; case 1: page = PageNumber.P2; break; case 2: page = PageNumber.P3; break; case 3: page = PageNumber.P4; break; case 4: page = PageNumber.P5; break; case 5: page = PageNumber.P6; break; case 6: page = PageNumber.P7; break; default: break; } }
private string GetFooterReferenceId(PageNumber pageNumber) { return(this.GetReferenceId(_footers, pageNumber)); }
public int CompareTo(SelectionMarker other) { return(PageNumber == other.PageNumber ? Index.CompareTo(other.Index) : PageNumber.CompareTo(other.PageNumber)); }
private string GetHeaderReferenceId(PageNumber pageNumber) { return(this.GetReferenceId(_headers, pageNumber)); }
public IRendererPage GetPage(PageNumber pageNumber) => this.GetPage(pageNumber, Point.Zero);
public BorderLine(PageNumber pageNumber, Point start, Point end) { this.PageNumber = pageNumber; this.Start = start; this.End = end; }
/// <summary> /// Returns true if BarcodeInfo instances are equal /// </summary> /// <param name="input">Instance of BarcodeInfo to be compared</param> /// <returns>Boolean</returns> public bool Equals(BarcodeInfo input) { if (input == null) { return(false); } return (( Type == input.Type || Type.Equals(input.Type) ) && ( Barcode1DSymbology == input.Barcode1DSymbology || Barcode1DSymbology.Equals(input.Barcode1DSymbology) ) && ( Data == input.Data || (Data != null && Data.Equals(input.Data)) ) && ( X1 == input.X1 || X1.Equals(input.X1) ) && ( X2 == input.X2 || X2.Equals(input.X2) ) && ( X3 == input.X3 || X3.Equals(input.X3) ) && ( X4 == input.X4 || X4.Equals(input.X4) ) && ( Y1 == input.Y1 || Y1.Equals(input.Y1) ) && ( Y2 == input.Y2 || Y2.Equals(input.Y2) ) && ( Y3 == input.Y3 || Y3.Equals(input.Y3) ) && ( Y4 == input.Y4 || Y4.Equals(input.Y4) ) && ( BboxLeftInches == input.BboxLeftInches || BboxLeftInches.Equals(input.BboxLeftInches) ) && ( BboxTopInches == input.BboxTopInches || BboxTopInches.Equals(input.BboxTopInches) ) && ( BboxWidthInches == input.BboxWidthInches || BboxWidthInches.Equals(input.BboxWidthInches) ) && ( BboxHeightInches == input.BboxHeightInches || BboxHeightInches.Equals(input.BboxHeightInches) ) && ( PageNumber == input.PageNumber || PageNumber.Equals(input.PageNumber) ) && ( PagePixelWidth == input.PagePixelWidth || PagePixelWidth.Equals(input.PagePixelWidth) ) && ( PagePixelHeight == input.PagePixelHeight || PagePixelHeight.Equals(input.PagePixelHeight) ) && ( PageHorizontalResolution == input.PageHorizontalResolution || PageHorizontalResolution.Equals(input.PageHorizontalResolution) ) && ( PageVerticalResolution == input.PageVerticalResolution || PageVerticalResolution.Equals(input.PageVerticalResolution) )); }
void ReleaseDesignerOutlets() { if (AnnotationButton != null) { AnnotationButton.Dispose(); AnnotationButton = null; } if (AnnotationView != null) { AnnotationView.Dispose(); AnnotationView = null; } if (BackgroudView != null) { BackgroudView.Dispose(); BackgroudView = null; } if (BookContentView != null) { BookContentView.Dispose(); BookContentView = null; } if (ContentButton != null) { ContentButton.Dispose(); ContentButton = null; } if (FunctionButtonView != null) { FunctionButtonView.Dispose(); FunctionButtonView = null; } if (HistoryButton != null) { HistoryButton.Dispose(); HistoryButton = null; } if (IndexButton != null) { IndexButton.Dispose(); IndexButton = null; } if (IndexCustomView != null) { IndexCustomView.Dispose(); IndexCustomView = null; } if (IndexViewController != null) { IndexViewController.Dispose(); IndexViewController = null; } if (InfoButton != null) { InfoButton.Dispose(); InfoButton = null; } if (LeftButton != null) { LeftButton.Dispose(); LeftButton = null; } if (PageNumber != null) { PageNumber.Dispose(); PageNumber = null; } if (PageViewController != null) { PageViewController.Dispose(); PageViewController = null; } if (RightButton != null) { RightButton.Dispose(); RightButton = null; } if (SearchField != null) { SearchField.Dispose(); SearchField = null; } if (SegmentContol != null) { SegmentContol.Dispose(); SegmentContol = null; } if (ShareButton != null) { ShareButton.Dispose(); ShareButton = null; } if (SplitSwithButton != null) { SplitSwithButton.Dispose(); SplitSwithButton = null; } if (TitleTField != null) { TitleTField.Dispose(); TitleTField = null; } if (TocCustomView != null) { TocCustomView.Dispose(); TocCustomView = null; } if (TOCViewController != null) { TOCViewController.Dispose(); TOCViewController = null; } if (GotoButton != null) { GotoButton.Dispose(); GotoButton = null; } }