Esempio n. 1
0
        private async void readFlashButton_Click(object sender, EventArgs e)
        {
            string[] filename;
            if (!(_saveFileDialogFlash.FileName == String.Empty))
            {
                filename = _saveFileDialogFlash.FileName.Split('\\');
                _saveFileDialogFlash.FileName = filename[filename.Length - 1];
            }
            else
            {
                _saveFileDialogFlash.FileName = String.Empty;
            }

            if (this._saveFileDialogFlash.ShowDialog() == DialogResult.OK)
            {
                ModuleWritterController controller = new ModuleWritterController(this._moduleInformation, TypeOfMemory.BOOT_FLASH, DevicesManager.DeviceNumber,
                                                                                 (ushort)Convert.ToUInt16(_startReadPage.Text), (ushort)Convert.ToUInt16(_countReadPage.Text));
                try
                {
                    byte[] result = await controller.ReadPage(progressFlash);

                    Common.SwapArrayItems(ref result);
                    File.WriteAllBytes(this._saveFileDialogFlash.FileName, result);
                    MessageBox.Show("Файл успешно сохранен");
                }
                catch (Exception exception)
                {
                    MessageErrorBox messageErrorBox = new MessageErrorBox(exception.Message, "Неудалось прочитать файл Flash");
                    messageErrorBox.ShowErrorMessageForm();
                }
            }
        }
Esempio n. 2
0
        private async void _readDiscretRelayButton1_Click(object sender, EventArgs e)
        {
            string[] filename;
            if (!(_saveFileDialogRelayDiscret.FileName == String.Empty))
            {
                filename = _saveFileDialogRelayDiscret.FileName.Split('\\');
                _saveFileDialogRelayDiscret.FileName = filename[filename.Length - 1];
            }
            else
            {
                _saveFileDialogRelayDiscret.FileName = String.Empty;
            }

            if (this._saveFileDialogRelayDiscret.ShowDialog() == DialogResult.OK)
            {
                this._relayDiscretCheckBox.Text = this._saveFileDialogRelayDiscret.FileName;
                ModuleWritterController controller = new ModuleWritterController(this._moduleInformation, TypeOfMemory.RALAY_DISCRET, DevicesManager.DeviceNumber);
                try
                {
                    byte[] result = await controller.ReadPage(progressRelay);

                    Common.SwapArrayItems(ref result);
                    File.WriteAllBytes(this._saveFileDialogRelayDiscret.FileName, result);
                    MessageBox.Show("Файл успешно сохранен");
                }
                catch (Exception exception)
                {
                    MessageErrorBox messageErrorBox = new MessageErrorBox(exception.Message, "Неудалось прочитать файл");
                    messageErrorBox.ShowErrorMessageForm();
                }
            }
        }
Esempio n. 3
0
        public async Task SetLoader(ModuleWritterController moduleWritterController)
        {
            try
            {
                _moduleWritterController = moduleWritterController;
                byte[] result = await _moduleWritterController.ReadPage(_progress);

                _config = new AllConfig(result);
            }
            catch (Exception e)
            {
                MessageErrorBox me  = new MessageErrorBox(e.Message, "Создать конфигурацию по умолчанию?");
                bool            res = me.ShowErrorMessageForm();
                if (res)
                {
                    _config = new AllConfig();
                }
            }

            ShowRelay();
            ShowDiscret();
            ShowDiode();
            ShowSystemDiode();
        }