using System; using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using ITC81DB_0H.DialogForms; using ITC81DB_0H.Forms; using ITC81DB_0H_ImageDll; namespace ITC81DB_0H.Controls { public partial class ControlCenterSystemCalibration : UserControl { #region Field private FormMenu m_ParentForm; private Color NormalColor; private Color FinishColor; // 중량 조정이 완료 되었는지 확인하는 Flag private bool IsCalibrationFinish; #endregion #region Constructor public ControlCenterSystemCalibration(FormMenu parent) { InitializeComponent(); this.ParentForm = parent; this.InitializeDesign(); this.DefaultSetting(); } #endregion #region Property public FormMenu ParentForm { get { return this.m_ParentForm; } private set { this.m_ParentForm = value; } } #endregion #region Method public void InitializeDesign() { Class1 images = new Class1(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundCalibration)); this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationCancelDisable)); this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationCancelDown)); this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationCancelUp)); this.buttonStart.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationStartDisable)); this.buttonStart.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationStartDown)); this.buttonStart.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationStartUp)); this.buttonZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationZeroDisable)); this.buttonZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationZeroDown)); this.buttonZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.engCalibrationZeroUp)); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundCalibration)); this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationCancelDisable)); this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationCancelDown)); this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationCancelUp)); this.buttonStart.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationStartDisable)); this.buttonStart.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationStartDown)); this.buttonStart.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationStartUp)); this.buttonZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationZeroDisable)); this.buttonZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationZeroDown)); this.buttonZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.chnCalibrationZeroUp)); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.rusBackgroundCalibration)); this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationCancelDisable)); this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationCancelDown)); this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationCancelUp)); this.buttonStart.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationStartDisable)); this.buttonStart.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationStartDown)); this.buttonStart.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationStartUp)); this.buttonZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationZeroDisable)); this.buttonZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationZeroDown)); this.buttonZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.rusCalibrationZeroUp)); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundCalibration)); this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationCancelDisable)); this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationCancelDown)); this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationCancelUp)); this.buttonStart.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationStartDisable)); this.buttonStart.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationStartDown)); this.buttonStart.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationStartUp)); this.buttonZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationZeroDisable)); this.buttonZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationZeroDown)); this.buttonZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.gerCalibrationZeroUp)); } else { this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundCalibration)); this.buttonCancel.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationCancelDisable)); this.buttonCancel.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationCancelDown)); this.buttonCancel.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationCancelUp)); this.buttonStart.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationStartDisable)); this.buttonStart.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationStartDown)); this.buttonStart.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationStartUp)); this.buttonZero.DisableImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationZeroDisable)); this.buttonZero.DownImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationZeroDown)); this.buttonZero.UpImage = new Bitmap(images.GetImage(Class1.ButtonImages.korCalibrationZeroUp)); } } private void DefaultSetting() { this.NormalColor = Color.White; this.FinishColor = Color.Lime; } private void CalibrationButtonEnable(bool btStart, bool btBalance, bool btCcancel) { this.buttonStart.Enabled = btStart; this.buttonBalance.Enabled = btBalance; this.buttonCancel.Enabled = btCcancel; } private void CalibrationPictureBoxVisible(bool step1, bool step2, bool step3) { if (step1 == true) { this.pictureBoxStep1.Visible = true; this.pictureBoxStep2.Visible = false; this.pictureBoxStep3.Visible = false; } else if (step2 == true) { this.pictureBoxStep1.Visible = false; this.pictureBoxStep2.Visible = true; this.pictureBoxStep3.Visible = false; } else if(step3 == true) { this.pictureBoxStep1.Visible = false; this.pictureBoxStep2.Visible = false; this.pictureBoxStep3.Visible = true; } else { this.pictureBoxStep1.Visible = true; this.pictureBoxStep2.Visible = false; this.pictureBoxStep3.Visible = false; } } private void UpdateControlsDisplay() { this.listBoxHelp.ClearAll(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.listBoxHelp.AddItem("Push the start button."); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.listBoxHelp.AddItem("需要重量调节,请点击开始按钮"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.listBoxHelp.AddItem("Нажмите кнопку [Старт],"); this.listBoxHelp.AddItem("чтобы начать калибровку"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.listBoxHelp.AddItem("Drücken Sie die Taste [Start],"); this.listBoxHelp.AddItem("um die Kalibrierung zu starten"); } else { this.listBoxHelp.AddItem("중량조정을 하시려면"); this.listBoxHelp.AddItem("시작 버튼을 누르세요"); } this.CalibrationButtonEnable(true, false, false); this.CalibrationPictureBoxVisible(true, false, false); this.radioButtonDecimalPlaces1.Click -= new EventHandler(this.radioButtonDecimalPlaces_Click); this.radioButtonDecimalPlaces2.Click -= new EventHandler(this.radioButtonDecimalPlaces_Click); if (this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces == 1) { if (this.radioButtonDecimalPlaces1.Checked != true) this.radioButtonDecimalPlaces1.Checked = true; } else { if (this.radioButtonDecimalPlaces2.Checked != true) this.radioButtonDecimalPlaces2.Checked = true; } this.radioButtonDecimalPlaces1.Click += new EventHandler(this.radioButtonDecimalPlaces_Click); this.radioButtonDecimalPlaces2.Click += new EventHandler(this.radioButtonDecimalPlaces_Click); //if (this.labelWeightUnit.Text != this.ParentForm.ParentForm.SystemConfig1.Unit) // this.labelWeightUnit.Text = this.ParentForm.ParentForm.SystemConfig1.Unit; } public void UpdateWeightDisplay(DataStore.EquipmentStatus status, WeightData data) { switch (data.Status) { case DataStore.WeightStatus.CalNomal: this.labelWeight.Text = Helper.DoubleToString(data.Weight, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces); this.labelWeight.ForeColor = this.NormalColor; this.CalibrationButtonEnable(true, false, false); this.CalibrationPictureBoxVisible(true, false, false); break; case DataStore.WeightStatus.CalWait: // 분동중량 표시 this.IsCalibrationFinish = false; if (this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces == 1) this.labelWeight.Text = "-500.0"; else this.labelWeight.Text = "-500.00"; this.labelWeight.ForeColor = this.NormalColor; break; case DataStore.WeightStatus.CalStandby: //// 분동중량 표시 //this.IsCalibrationFinish = false; //if(this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces == 1) // this.labelWeight.Text = "-500.0"; //else // this.labelWeight.Text = "-500.00"; //this.labelWeight.ForeColor = this.NormalColor; this.listBoxHelp.ClearAll(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.listBoxHelp.AddItem("Put the balance weight."); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.listBoxHelp.AddItem("请放上砝码"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.listBoxHelp.AddItem("Утаноите весы"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.listBoxHelp.AddItem("Gewicht auf den Förderer legen"); } else { this.listBoxHelp.AddItem("분동을 올려주세요"); } this.CalibrationButtonEnable(false, true, true); this.CalibrationPictureBoxVisible(false, true, false); break; case DataStore.WeightStatus.CalBalans: // 분동중량표시 if (this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces == 1) this.labelWeight.Text = "-500.0"; else this.labelWeight.Text = "-500.00"; this.labelWeight.ForeColor = this.NormalColor; this.CalibrationButtonEnable(false, false, true); this.CalibrationPictureBoxVisible(false, false, true); break; case DataStore.WeightStatus.CalFinish: this.listBoxHelp.ClearAll(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.listBoxHelp.AddItem("Finish the calibration"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.listBoxHelp.AddItem("重量调节已完成"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.listBoxHelp.AddItem("Завершение калибровки"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.listBoxHelp.AddItem("Die Kalibrierung ist abgeschlossen."); } else { this.listBoxHelp.AddItem("중량조정이 완료 되었습니다"); } this.CalibrationButtonEnable(true, false, false); this.CalibrationPictureBoxVisible(true, false, false); this.labelWeight.Text = Helper.DoubleToString(data.Weight, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces); this.labelWeight.ForeColor = this.FinishColor; if (this.IsCalibrationFinish == false) { this.IsCalibrationFinish = true; this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead3901, ""); } break; case DataStore.WeightStatus.CalError: this.listBoxHelp.ClearAll(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.listBoxHelp.AddItem("Calibration error"); this.listBoxHelp.AddItem("Please try again."); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.listBoxHelp.AddItem("错误发生,重试"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.listBoxHelp.AddItem("Произошла ошибка"); this.listBoxHelp.AddItem("Попробуйте еще раз"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.listBoxHelp.AddItem("Fehler!"); this.listBoxHelp.AddItem("Bitte noch einmal versuchen"); } else { this.listBoxHelp.AddItem("중량조정 에러"); this.listBoxHelp.AddItem("다시 시도해 주세요."); } this.CalibrationButtonEnable(true, false, false); this.CalibrationPictureBoxVisible(true, false, false); this.labelWeight.Text = Helper.DoubleToString(data.Weight, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces); this.labelWeight.ForeColor = this.NormalColor; break; default: break; } } public void DisplayRefresh(SystemStatus status) { this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.SystemCalibration; this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Calibration); this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus); this.UpdateControlsDisplay(); this.Refresh(); } #endregion #region Event Handler private void buttonZero_Click(object sender, EventArgs e) { this.ParentForm.ParentForm.TransferData(CommunicationCommand.Zero, CommunicationID.SubBoard1); } private void buttonStart_Click(object sender, EventArgs e) { this.listBoxHelp.ClearAll(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.listBoxHelp.AddItem("Calibration start"); this.listBoxHelp.AddItem("Wait a minute."); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.listBoxHelp.AddItem("校准开始按钮"); this.listBoxHelp.AddItem("请等待"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.listBoxHelp.AddItem("Начало калибровки"); this.listBoxHelp.AddItem("Подождите"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.listBoxHelp.AddItem("Kalibrierungsstart"); this.listBoxHelp.AddItem("bitte warten"); } else { this.listBoxHelp.AddItem("중량조정을 시작합니다"); this.listBoxHelp.AddItem("잠시만 기다리세요"); } this.ParentForm.ParentForm.TransferData(CommunicationCommand.CalibrationStart, CommunicationID.SubBoard1); this.CalibrationButtonEnable(false, false, false); } private void buttonBalance_Click(object sender, EventArgs e) { this.listBoxHelp.ClearAll(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.listBoxHelp.AddItem("Caculating..."); this.listBoxHelp.AddItem("Wait a minute."); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.listBoxHelp.AddItem("测量砝码中"); this.listBoxHelp.AddItem("请等待"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.listBoxHelp.AddItem("Имерение…"); this.listBoxHelp.AddItem("Ожидайте"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.listBoxHelp.AddItem("Rechnen..."); this.listBoxHelp.AddItem("bitte warten."); } else { this.listBoxHelp.AddItem("분동 계산중 입니다"); this.listBoxHelp.AddItem("잠시만 기다리세요"); } this.ParentForm.ParentForm.TransferData(CommunicationCommand.CalibrationBalance, CommunicationID.SubBoard1); this.CalibrationButtonEnable(false, false, true); } private void buttonCancel_Click(object sender, EventArgs e) { this.listBoxHelp.ClearAll(); if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English) { this.listBoxHelp.AddItem("Cancel the calibration"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese) { this.listBoxHelp.AddItem("取消重量调节"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian) { this.listBoxHelp.AddItem("Отменить калибровку"); } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German) { this.listBoxHelp.AddItem("Brechen Sie die Kalibrierung ab"); } else { this.listBoxHelp.AddItem("중량조정을 취소합니다"); } this.ParentForm.ParentForm.TransferData(CommunicationCommand.CalibrationCancel, CommunicationID.SubBoard1); this.CalibrationButtonEnable(true, false, false); } private void radioButtonDecimalPlaces_Click(object sender, EventArgs e) { string value = ""; //this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.ParameterRead3901, ""); this.ParentForm.ParentForm.OpenSmartFileIO(); if (this.ParentForm.ParentForm.SystemConfig2.IsUsingRandomMode == true) { int currentDecimalPlaces = this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces; bool radioButtonCompare = false; if (this.radioButtonDecimalPlaces1.Checked == true) { if (currentDecimalPlaces != 1) radioButtonCompare = true; } else if (this.radioButtonDecimalPlaces2.Checked == true) { if (currentDecimalPlaces != 2) radioButtonCompare = true; } if (radioButtonCompare == true) { DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.ParentForm.SystemConfig1.Language, 24); if (myDlg.ShowDialog() == DialogResult.Yes) { if (this.radioButtonDecimalPlaces1.Checked == true) { this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces = 1; } else if (this.radioButtonDecimalPlaces2.Checked == true) { this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces = 2; } this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1); } } } else { if (this.radioButtonDecimalPlaces1.Checked == true) { this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces = 1; } else if (this.radioButtonDecimalPlaces2.Checked == true) { this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces = 2; } this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1); } this.ParentForm.ParentForm.CloseSmartFileIO(); value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces.ToString()); this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.DecimalPlaces, value); this.ParentForm.ParentForm.ReLoadProductFile(); this.ParentForm.ParentForm.TransferRandomMode(); } #endregion } }