Пример #1
0
        private void readChipStripButton_Click(object sender, EventArgs e)
        {
            this.FormClosing += M24CXXDumpForm_FormClosing;
            if (_programmer.IsBusy || (_programmer == null))
            {
                return;
            }
            MemoryRegionInfo regionInfo = new MemoryRegionInfo();

            regionInfo.Address = 0;
            regionInfo.Type    = 1;
            regionInfo.Size    = (uint)s02512[chipSelectStripComboBox.SelectedItem.ToString()];
            Action <ProgrammingCompleteInfo, MemoryRegion> completed =
                delegate(ProgrammingCompleteInfo pcInfo, MemoryRegion region)
            {
                if (pcInfo.error != null)
                {
                    infoPanel.SetErrorState(pcInfo.error.Message);
                }
                else
                {
                    _dataBytes           = new ByteCollection(region.Data);
                    hexBox1.ByteProvider = new DynamicByteProvider(_dataBytes);


                    hexBox1.ByteProvider.Changed += HexBoxChanged;
                    Text = "M24CXX DUMP " + "It is read from CRUM";
                    infoPanel.SetOkState("Read complete");
                }
                this.FormClosing -= M24CXXDumpForm_FormClosing;
            };


            infoPanel.SetProgressState("Reading");

            _programmer.ReadChip(chipSelectStripComboBox.SelectedItem.ToString(), regionInfo, completed, infoPanel.GetProgressDelegate());
        }
Пример #2
0
        private void M24CXXRead(string subtype, string name)
        {
            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;

            MemoryRegionInfo regionInfo = new MemoryRegionInfo();

            regionInfo.Address = 0;
            regionInfo.Type    = 1;
            regionInfo.Size    = (uint)s02512[subtype];

            Action <ProgrammingCompleteInfo, MemoryRegion> completed =
                delegate(ProgrammingCompleteInfo pcInfo, MemoryRegion region)
            {
                progressBar.Value = progressBar.Minimum;
                if (pcInfo.error == null)
                {
                    Encoding enc     = Encoding.GetEncoding(1251);
                    TextBox  textBox = new TextBox();
                    textBox.Multiline  = true;
                    textBox.ReadOnly   = true;
                    textBox.BackColor  = Color.WhiteSmoke;
                    textBox.ScrollBars = ScrollBars.Vertical;
                    textBox.Size       = new Size(150, 100);
                    List <string> strings = new List <string>();
                    for (int i = 0; i < region.Size; i += 16)
                    {
                        byte[] data = new byte[16];
                        for (int j = 0; j < 16; j++)
                        {
                            data[j] = region.Data[i + j] < (byte)0x20 ? (byte)0x2E : region.Data[i + j];
                        }
                        strings.Add(enc.GetString(data));
                    }
                    textBox.Lines = strings.ToArray();

                    infoLayoutPanel.Controls.Add(textBox);
                    infoLayoutPanel.Controls.SetChildIndex(textBox, 0);
                    SetOkText("Read OK");
                }
                else
                {
                    SetAlarmText(pcInfo.error.Message);
                }

                thisBusy          = false;
                this.FormClosing -= AutoForm_FormClosing;
            };

            prog.ReadChip(subtype, regionInfo, completed, Progress);
        }