//---------------------------------------------------------------------------- /// <summary> /// Метод читает все данные из устройства БИ /// </summary> private void DeviceRead() { OperationResult result; DialogResult rslt; this.LockGUI(); // Читаем тип устройства и сверяем его с уже созданным виртуальным. Если // несовпадают, то предлагаем созадать новое виртуальное устройство. Если // виртуальное устройство не создано, то по прочитанному значению создаём... // Если код типа устройства не опредлён, сообщаем об этом пользователю и выходим. TYPE_NGK_DEVICE type; this._MeasuringDevice.Read_IR_TypeOfDevice(ref _Host, out result, out type); if (result.Result != OPERATION_RESULT.OK) { MessageBox.Show(this, String.Format( "Неудалось определить тип устройства. {0}", result.Message), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); this.UnLockGUI(); return; } else { if (_MeasuringDevice != null) { if (_MeasuringDevice.GetDeviceType() != type) { // Тип виртуального и физического устройства не совпадают DialogResult dlg = MessageBox.Show(this, "Тип физического устройства не совпадает с текущим. Удалить текущее устройство и создать новое?", "Внимание!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlg == System.Windows.Forms.DialogResult.OK) { switch (type) { case TYPE_NGK_DEVICE.BI_BATTERY_POWER: { this.DeleteDevice(); this.CreateDevice((IMeasuringDevice)new MeasuringDeviceBatteryPower()); break; } case TYPE_NGK_DEVICE.BI_MAIN_POWERED: { this.DeleteDevice(); this.CreateDevice((IMeasuringDevice)new MeasuringDeviceMainPower()); break; } default: { MessageBox.Show(this, "Невозможно выполнить операцию. Тип физического устройства не поддерживается в данной версии ПО.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); this.UnLockGUI(); return; } } } else { // Ползователь отменил операцию. Выходим this.UnLockGUI(); return; } } } else { // Создаём новое устройство устройство switch (type) { case TYPE_NGK_DEVICE.BI_BATTERY_POWER: { this.DeleteDevice(); this.CreateDevice((IMeasuringDevice)new MeasuringDeviceBatteryPower()); break; } case TYPE_NGK_DEVICE.BI_MAIN_POWERED: { this.DeleteDevice(); this.CreateDevice((IMeasuringDevice)new MeasuringDeviceMainPower()); break; } default: { MessageBox.Show(this, "Невозможно выполнить операцию. Тип физического устройства не поддерживается в данной версии ПО.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); this.UnLockGUI(); return; } } } } // Читаем данные из устройства. NGK.Forms.FormProgressBar frm = new NGK.Forms.FormProgressBar(); frm.progressBar.Value = 0; frm.labelMessage.Text = "Выполняется чтение данных из устройства БИ"; frm.Show(this); //frm.StartPosition = FormStartPosition.CenterScreen; this.Cursor = Cursors.WaitCursor; // Читаем регистры хранения this._MeasuringDevice.Read_HR_BaudRateCAN(ref _Host, out result); frm.progressBar.Value = 3; if (result.Result != OPERATION_RESULT.OK) { if (result.Result != OPERATION_RESULT.INVALID_OPERATION) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } } this._MeasuringDevice.Read_HR_CurrentShuntValue(ref _Host, out result); frm.progressBar.Value = 6; if (result.Result != OPERATION_RESULT.OK) { if (result.Result != OPERATION_RESULT.INVALID_OPERATION) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } } DateTime dt; this._MeasuringDevice.Read_HR_DateTime(ref _Host, out result, out dt); frm.progressBar.Value = 9; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_HR_MeasuringPeriod(ref _Host, out result); frm.progressBar.Value = 12; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_HR_MeasuringVoltagePeriod(ref _Host, out result); frm.progressBar.Value = 15; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_HR_NetAddress(ref _Host, out result); frm.progressBar.Value = 18; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_HR_PollingPeriodBPI(ref _Host, out result); frm.progressBar.Value = 21; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_HR_PollingPeriodChannel1(ref _Host, out result); frm.progressBar.Value = 24; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_HR_PollingPeriodChannel2(ref _Host, out result); frm.progressBar.Value = 27; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_HR_PollingPeriodUSIKPST(ref _Host, out result); frm.progressBar.Value = 30; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } // Читаем реле this._MeasuringDevice.Read_CL_ExtendedModeX10SumPotentialEn(ref _Host, out result); frm.progressBar.Value = 36; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_InducedVoltageEn(ref _Host, out result); frm.progressBar.Value = 39; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_PolarizationPotentialEn(ref _Host, out result); frm.progressBar.Value = 42; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_PolarizationСurrentEn(ref _Host, out result); frm.progressBar.Value = 44; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_ProtectivePotentialEn(ref _Host, out result); frm.progressBar.Value = 46; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_ProtectiveСurrentEn(ref _Host, out result); frm.progressBar.Value = 48; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_SendStatusWordEn(ref _Host, out result); frm.progressBar.Value = 48; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_DcCurrentRefereceElectrodeEn(ref _Host, out result); frm.progressBar.Value = 48; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_CL_AcCurrentRefereceElectrodeEn(ref _Host, out result); frm.progressBar.Value = 48; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } // Читаем состояния дискретных входов this._MeasuringDevice.Read_DI_BattaryVoltageStatus(ref _Host, out result); frm.progressBar.Value = 50; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_DI_CaseOpen(ref _Host, out result); frm.progressBar.Value = 52; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_DI_CorrosionSensor1(ref _Host, out result); frm.progressBar.Value = 54; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_DI_CorrosionSensor2(ref _Host, out result); frm.progressBar.Value = 56; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_DI_CorrosionSensor3(ref _Host, out result); frm.progressBar.Value = 58; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_DI_SupplyVoltageStatus(ref _Host, out result); frm.progressBar.Value = 60; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } // Читаем состояния входных регистров. this._MeasuringDevice.Read_IR_SoftWareVersion(ref _Host, out result); frm.progressBar.Value = 62; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_HardWareVersion(ref _Host, out result); frm.progressBar.Value = 64; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_SerialNumber(ref _Host, out result); frm.progressBar.Value = 66; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_CRC16(ref _Host, out result); frm.progressBar.Value = 68; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_ManufacturerCode(ref _Host, out result); frm.progressBar.Value = 70; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_BattaryVoltage(ref _Host, out result); frm.progressBar.Value = 72; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_Current_Channel_1(ref _Host, out result); frm.progressBar.Value = 74; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_Current_Channel_2(ref _Host, out result); frm.progressBar.Value = 76; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } //this._MeasuringDevice.Read_IR_DateTime(ref _Host, out result); //frm.progressBar.Value = 78; //if ((result.Result != OPERATION_RESULT.OK) && // (result.Result != OPERATION_RESULT.INVALID_OPERATION)) //{ // rslt = MessageBox.Show(this, String.Concat(result.Message, // " Продолжить выполение?"), // "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); // switch (rslt) // { // case System.Windows.Forms.DialogResult.Yes: // { // break; // } // case System.Windows.Forms.DialogResult.No: // { // frm.Close(); // this.Cursor = Cursors.Default; // this.UnLockGUI(); // return; // } // } //} this._MeasuringDevice.Read_IR_DepthOfCorrosionUSIKPST(ref _Host, out result); frm.progressBar.Value = 80; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_InducedVoltage(ref _Host, out result); frm.progressBar.Value = 82; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_InternalTemperatureSensor(ref _Host, out result); frm.progressBar.Value = 84; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_Polarization_current(ref _Host, out result); frm.progressBar.Value = 86; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_Polarization_potential(ref _Host, out result); frm.progressBar.Value = 88; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_Protective_current(ref _Host, out result); frm.progressBar.Value = 90; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_Protective_potential(ref _Host, out result); frm.progressBar.Value = 92; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_SpeedOfCorrosionUSIKPST(ref _Host, out result); frm.progressBar.Value = 94; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_StatusUSIKPST(ref _Host, out result); frm.progressBar.Value = 96; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_SupplyVoltage(ref _Host, out result); frm.progressBar.Value = 98; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_ReferenceElectrodeDCCurrent(ref _Host, out result); frm.progressBar.Value = 98; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Read_IR_ReferenceElectrodeACCurrent(ref _Host, out result); frm.progressBar.Value = 98; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } frm.progressBar.Value = 100; frm.Close(); this.Cursor = Cursors.Default; // Проверяем инициализировано устройство или нет. Если не инициализировано // предлягаем инициализировать //Boolean init; //this.Cursor = Cursors.WaitCursor; //this._MeasuringDevice.Read_HR_VerifyInitDevice( // ref _Host, out init, out result); //this.Cursor = Cursors.Default; //if (!init) //{ // MessageBox.Show(this, // "Устройство не инициализировано", "Внимание", // MessageBoxButtons.OK, MessageBoxIcon.Warning); //} this.UnLockGUI(); return; }
//---------------------------------------------------------------------------- /// <summary> /// Метод записывает все данные в устройство /// </summary> public void DeviceWrite() { OperationResult result; DialogResult rslt; NGK.Forms.FormProgressBar frm = new NGK.Forms.FormProgressBar(); frm.progressBar.Value = 0; frm.labelMessage.Text = "Выполняется запись данных в устройство БИ"; frm.Show(this); frm.StartPosition = FormStartPosition.CenterParent; // Записываем регистры хранения this._MeasuringDevice.Write_HR_BaudRateCAN(ref _Host, out result); frm.progressBar.Value = 5; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_CurrentShuntValue(ref _Host, out result); frm.progressBar.Value = 10; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_DateTime(ref _Host, out result); frm.progressBar.Value = 15; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_MeasuringPeriod(ref _Host, out result); frm.progressBar.Value = 20; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_NetAddress(ref _Host, out result); frm.progressBar.Value = 25; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_PollingPeriodBPI(ref _Host, out result); frm.progressBar.Value = 30; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_PollingPeriodChannel1(ref _Host, out result); frm.progressBar.Value = 35; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_PollingPeriodChannel2(ref _Host, out result); frm.progressBar.Value = 40; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_HR_PollingPeriodUSIKPST(ref _Host, out result); frm.progressBar.Value = 50; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } // Записываем реле this._MeasuringDevice.Write_CL_ExtendedModeX10SumPotentialEn(ref _Host, out result); frm.progressBar.Value = 60; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_InducedVoltageEn(ref _Host, out result); frm.progressBar.Value = 70; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_PolarizationPotentialEn(ref _Host, out result); frm.progressBar.Value = 80; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_PolarizationСurrentEn(ref _Host, out result); frm.progressBar.Value = 85; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_ProtectivePotentialEn(ref _Host, out result); frm.progressBar.Value = 95; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_ProtectiveСurrentEn(ref _Host, out result); frm.progressBar.Value = 100; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_SendStatusWordEn(ref _Host, out result); frm.progressBar.Value = 100; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_DcCurrentRefereceElectrodeEn(ref _Host, out result); frm.progressBar.Value = 100; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } this._MeasuringDevice.Write_CL_AcCurrentRefereceElectrodeEn(ref _Host, out result); frm.progressBar.Value = 100; if ((result.Result != OPERATION_RESULT.OK) && (result.Result != OPERATION_RESULT.INVALID_OPERATION)) { rslt = MessageBox.Show(this, String.Concat(result.Message, " Продолжить выполение?"), "Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (rslt) { case System.Windows.Forms.DialogResult.Yes: { break; } case System.Windows.Forms.DialogResult.No: { frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; } } } frm.Close(); this.Cursor = Cursors.Default; this.UnLockGUI(); return; }