using System; using System.Linq; using System.Collections.ObjectModel; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using SmartX; using INT69DB_2A_ImageDll; using INT69DB_2A.Controls; using INT69DB_2A.DialogForms; namespace INT69DB_2A.Forms { public partial class FormConfiguration : Form { #region Field private FormMain m_ParentForm; private ControlConfiguration ChildControl; private string BeforeVariate; private string BeforeDoubleDelay; #endregion #region Constructor public FormConfiguration(FormMain parent) { InitializeComponent(); this.ParentForm = parent; this.InitializeDesign(); this.InitializeControl(); this.DefaultSetting(); } #endregion #region Property public FormMain ParentForm { get { return this.m_ParentForm; } private set { this.m_ParentForm = value; } } #endregion #region Method private void InitializeDesign() { ImageDll images = new ImageDll(); if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean) { } else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English) { this.labelTitle.Text = "Configuration"; this.groupBoxAutoZero.Text = "Auto zero"; this.labelStaticTime.Text = "Time"; this.labelStaticRange.Text = "Range"; this.labelStaticVariable.Text = "Variable"; this.labelStaticMode.Text = "Mode"; this.groupBoxOption.Text = "Option"; this.labelStaticDoubleEntry.Text = "Double entry"; this.labelStaticBuzzerOnTime.Text = "Buzzer ON time"; this.labelStaticRelayOnTime.Text = "Relay ON time"; this.labelStaticBypass.Text = "Bypass"; this.labelStaticChattering.Text = "Chattering"; this.labelStaticDecimalPoint.Text = "Decimal point"; } else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese) { this.labelTitle.Text = "选项"; this.groupBoxAutoZero.Text = "自动零点跟踪"; this.labelStaticTime.Text = "时间"; this.labelStaticRange.Text = "范围"; this.labelStaticVariable.Text = "变化"; this.labelStaticMode.Text = "模式"; this.groupBoxOption.Text = "等等"; this.labelStaticDoubleEntry.Text = "重复进入"; this.labelStaticBuzzerOnTime.Text = "蜂鸣器开启时间"; this.labelStaticRelayOnTime.Text = "继电器接通时间"; this.labelStaticBypass.Text = "旁路"; this.labelStaticChattering.Text = "颤振"; this.labelStaticDecimalPoint.Text = "小数点"; this.buttonDoubleEnter.DownImage = this.buttonBypassMode.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnEnable)); this.buttonDoubleEnter.UpImage = this.buttonBypassMode.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnDisable)); } else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech) { } else { } } private void InitializeControl() { this.ChildControl = new ControlConfiguration(this); this.Controls.Add(this.ChildControl); this.ChildControl.Location = new Point(0, 66); this.ChildControl.BringToFront(); this.ChildControl.Visible = false; this.BeforeVariate = ""; this.BeforeDoubleDelay = ""; this.labelZeroParameterTime.Text = "-"; this.labelZeroParameterRange.Text = "-"; this.labelChattering.Text = "-"; this.labelBuzzerOnTime.Text = "-"; this.labelRelayOnTime.Text = "-"; this.comboBoxZeroParameterVariate.Items.Clear(); this.comboBoxZeroParameterVariate.SelectedIndexChanged -= new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged); this.comboBoxZeroParameterVariate.Items.Add("0.05"); this.comboBoxZeroParameterVariate.Items.Add("0.1"); this.comboBoxZeroParameterVariate.Items.Add("0.2"); this.comboBoxZeroParameterVariate.Items.Add("0.5"); this.comboBoxZeroParameterVariate.Items.Add("1.0"); this.comboBoxZeroParameterVariate.Items.Add("1.2"); this.comboBoxZeroParameterVariate.SelectedIndex = 0; this.comboBoxZeroParameterVariate.SelectedIndexChanged += new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged); this.comboBoxZeroParameterMode.Items.Clear(); this.comboBoxZeroParameterMode.SelectedIndexChanged -= new EventHandler(this.comboBoxZeroParameterMode_SelectedIndexChanged); if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese) { this.comboBoxZeroParameterMode.Items.Add("模式1"); this.comboBoxZeroParameterMode.Items.Add("模式2"); } else { this.comboBoxZeroParameterMode.Items.Add("Mode1"); this.comboBoxZeroParameterMode.Items.Add("Mode2"); } this.comboBoxZeroParameterMode.SelectedIndex = 0; this.comboBoxZeroParameterMode.SelectedIndexChanged += new EventHandler(this.comboBoxZeroParameterMode_SelectedIndexChanged); this.comboBoxDecimalPlaces.Items.Clear(); this.comboBoxDecimalPlaces.SelectedIndexChanged -= new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged); this.comboBoxDecimalPlaces.Items.Add("0"); this.comboBoxDecimalPlaces.Items.Add("0.0"); this.comboBoxDecimalPlaces.Items.Add("0.00"); this.comboBoxDecimalPlaces.SelectedIndex = 0; this.comboBoxDecimalPlaces.SelectedIndexChanged += new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged); } private void DefaultSetting() { this.UpdateDisplay(); } private void UpdateDisplay() { this.comboBoxDecimalPlaces.SelectedIndexChanged -= new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged); this.comboBoxDecimalPlaces.SelectedIndex = this.ParentForm.SystemConfig.DecimalPlaces; this.comboBoxDecimalPlaces.SelectedIndexChanged += new EventHandler(this.comboBoxDecimalPlaces_SelectedIndexChanged); if (this.ParentForm.SystemConfig.IsBypassMode == true) this.buttonBypassMode.ButtonDown(); else this.buttonBypassMode.ButtonUp(); } public void UpdateZeroParameterRangeDisplay(DataStore.EquipmentStatus status, Collection values) { if (values == null || values.Count == 0) return; if (this.ChildControl != null) this.ChildControl.UpdateZeroParameterRangeDisplay(status, values); } public void UpdateZeroParameterTimeDisplay(DataStore.EquipmentStatus status, Collection values) { if (values == null || values.Count == 0) return; if (this.ChildControl != null) this.ChildControl.UpdateZeroParameterTimeDisplay(status, values); } public void UpdateZeroParameterVariateDisplay(DataStore.EquipmentStatus status, Collection values) { if (values == null || values.Count == 0) return; if (this.ChildControl != null) this.ChildControl.UpdateZeroParameterVariateDisplay(status, values); } public void UpdateZeroParameterDisplay(DataStore.EquipmentStatus status, ZeroParameterItem item) { int iValue = 0; string sValue = ""; sValue = item.Time.Trim(); if (this.labelZeroParameterTime.Text != sValue) this.labelZeroParameterTime.Text = sValue; sValue = item.Range.Trim(); if (this.labelZeroParameterRange.Text != sValue) this.labelZeroParameterRange.Text = sValue; iValue = int.Parse(item.Variate.Trim()); this.comboBoxZeroParameterVariate.SelectedIndexChanged -= new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged); this.comboBoxZeroParameterVariate.SelectedIndex = iValue; this.BeforeVariate = this.comboBoxZeroParameterVariate.SelectedItem.ToString(); this.comboBoxZeroParameterVariate.SelectedIndexChanged += new EventHandler(this.comboBoxZeroParameterVariate_SelectedIndexChanged); } public void UpdateOptionParameterDisplay(DataStore.EquipmentStatus status, OptionParameterItem item) { string value = ""; value = item.Chattering.Trim(); if (this.labelChattering.Text != value) this.labelChattering.Text = value; value = item.BuzzerOnTime.Trim(); if (this.labelBuzzerOnTime.Text != value) this.labelBuzzerOnTime.Text = value; value = item.RelayOnTime.Trim(); if (this.labelRelayOnTime.Text != value) this.labelRelayOnTime.Text = value; if (item.DoubleEnter == "1") { this.buttonDoubleEnter.ButtonDown(); this.BeforeDoubleDelay = "ON"; } else { this.buttonDoubleEnter.ButtonUp(); this.BeforeDoubleDelay = "OFF"; } } public void UpdateBalanceWeightDisplay(DataStore.EquipmentStatus status, Collection values) { if (values == null || values.Count == 0) return; if (this.ChildControl != null) this.ChildControl.UpdateBalanceWeightDisplay(status, values); } public void UpdateMaxWeightDisplay(DataStore.EquipmentStatus status, Collection values) { if (values == null || values.Count == 0) return; if (this.ChildControl != null) this.ChildControl.UpdateMaxWeightDisplay(status, values); } public void UpdateDigitDisplay(DataStore.EquipmentStatus status, Collection values) { if (values == null || values.Count == 0) return; if (this.ChildControl != null) this.ChildControl.UpdateDigitDisplay(status, values); } public void UpdateFilterDisplay(DataStore.EquipmentStatus status, Collection values) { if (values == null || values.Count == 0) return; if (this.ChildControl != null) this.ChildControl.UpdateFilterDisplay(status, values); } public void DisplayRefresh() { this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormConfiguration; this.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.SubBoard1, CommunicationAddress._4901_ParameterRead4901, ""); this.UpdateDisplay(); } #endregion #region Event Handler private void buttonBack_Click(object sender, EventArgs e) { if (this.ChildControl.Visible == true) this.ChildControl.Visible = false; this.ParentForm.ChildFormMenu.DisplayRefresh(); ((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu); } private void buttonDoubleEnter_Click(object sender, EventArgs e) { string before = "", after = ""; before = this.BeforeDoubleDelay; if (this.buttonDoubleEnter.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN) { this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6005_DoubleEnter, Helper.StringZeroFillDigits4("1")); after = "ON"; } else { this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6005_DoubleEnter, Helper.StringZeroFillDigits4("0")); after = "OFF"; } if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcDoubleEntry, "", before, after); } private void buttonBypassMode_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); string before = "", after = ""; if (this.ParentForm.SystemConfig.IsBypassMode == true) before = "ON"; else before = "OFF"; if (this.buttonBypassMode.ButtonStatus == SmartButton.BUTSTATUS.DOWN) { for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++) sb.Append("1"); after = "ON"; this.ParentForm.SystemConfig.IsBypassMode = true; this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._1201_Bypass, sb.ToString()); } else { for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++) sb.Append("0"); after = "OFF"; this.ParentForm.SystemConfig.IsBypassMode = false; this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._1201_Bypass, sb.ToString()); } if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcBypass, "", before, after); } private void buttonScreen_Click(object sender, EventArgs e) { if (this.ChildControl.Visible == false) { this.ChildControl.BringToFront(); this.ChildControl.Visible = true; } else this.ChildControl.Visible = false; } private void labelZeroParameterTime_Click(object sender, EventArgs e) { string value = ""; string before = "", after = ""; before = this.labelZeroParameterTime.Text; DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelZeroParameterTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language); myKeyPad.Location = new Point(300, 90); if (myKeyPad.ShowDialog() == DialogResult.OK) { if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999) { // 입력범위를 확인하세요 DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language); myMsg.Location = new Point(167, 207); myMsg.ShowDialog(); } else { after = this.labelZeroParameterTime.Text = myKeyPad.StringValue; value = Helper.StringZeroFillDigits4(this.labelZeroParameterTime.Text); this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4001_ZeroTime, value); if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.AutoZeroTime, "", before, after); } } } private void labelZeroParameterRange_Click(object sender, EventArgs e) { string value = ""; string before = "", after = ""; before = this.labelZeroParameterRange.Text; DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelZeroParameterRange.Text, 4, 0, false, this.ParentForm.SystemConfig.Language); myKeyPad.Location = new Point(300, 90); if (myKeyPad.ShowDialog() == DialogResult.OK) { if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999) { // 입력범위를 확인하세요 DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language); myMsg.Location = new Point(167, 207); myMsg.ShowDialog(); } else { after = this.labelZeroParameterRange.Text = myKeyPad.StringValue; value = Helper.StringZeroFillDigits4(this.labelZeroParameterRange.Text); this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4002_ZeroRange, value); if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.AutoZeroRange, "", before, after); } } } private void labelChattering_Click(object sender, EventArgs e) { string value = ""; string before = "", after = ""; before = this.labelChattering.Text; DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelChattering.Text, 4, 0, false, this.ParentForm.SystemConfig.Language); myKeyPad.Location = new Point(300, 90); if (myKeyPad.ShowDialog() == DialogResult.OK) { if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 500) { // 입력범위를 확인하세요 DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language); myMsg.ShowDialog(); } else { after = this.labelChattering.Text = myKeyPad.StringValue; value = Helper.StringZeroFillDigits4(this.labelChattering.Text); this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6006_Chattering, value); if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcChattering, "", before, after); } } } private void labelBuzzerOnTime_Click(object sender, EventArgs e) { string value = ""; string before = "", after = ""; before = this.labelBuzzerOnTime.Text; DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelBuzzerOnTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language); myKeyPad.Location = new Point(300, 90); if (myKeyPad.ShowDialog() == DialogResult.OK) { if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999) { // 입력범위를 확인하세요 DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language); myMsg.ShowDialog(); } else { after = this.labelBuzzerOnTime.Text = myKeyPad.StringValue; value = Helper.StringZeroFillDigits4(this.labelBuzzerOnTime.Text); this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6001_BuzzerOnTime, value); if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcBuzzerRunTime, "", before, after); } } } private void labelRelayOnTime_Click(object sender, EventArgs e) { string value = ""; string before = "", after = ""; before = this.labelRelayOnTime.Text; DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelRelayOnTime.Text, 4, 0, false, this.ParentForm.SystemConfig.Language); myKeyPad.Location = new Point(300, 90); if (myKeyPad.ShowDialog() == DialogResult.OK) { if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > 9999) { // 입력범위를 확인하세요 DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language); myMsg.ShowDialog(); } else { after = this.labelRelayOnTime.Text = myKeyPad.StringValue; value = Helper.StringZeroFillDigits4(this.labelRelayOnTime.Text); this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._6002_RelayRunTime, value); if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcRelayRunTime, "", before, after); } } } private void comboBoxZeroParameterVariate_SelectedIndexChanged(object sender, EventArgs e) { string value = ""; string before = "", after = ""; before = this.BeforeVariate; this.ParentForm.CurrentZeroParameterItem.Variate = this.comboBoxZeroParameterVariate.SelectedIndex.ToString(); value = Helper.StringZeroFillDigits4(this.comboBoxZeroParameterVariate.SelectedIndex.ToString()); this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.SubBoardAll, CommunicationAddress._4003_ZeroVariate, value); after = this.comboBoxZeroParameterVariate.SelectedItem.ToString(); if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.AutoZeroVariance, "", before, after); } private void comboBoxZeroParameterMode_SelectedIndexChanged(object sender, EventArgs e) { } private void comboBoxDecimalPlaces_SelectedIndexChanged(object sender, EventArgs e) { string before = "", after = ""; before = this.comboBoxDecimalPlaces.Items.IndexOf(this.ParentForm.SystemConfig.DecimalPlaces).ToString(); this.ParentForm.SystemConfig.DecimalPlaces = this.comboBoxDecimalPlaces.SelectedIndex; after = this.comboBoxDecimalPlaces.SelectedItem.ToString(); if (before != after) this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.EtcDecimalpoint, "", before, after); this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig); } #endregion } }