ITC81DB_V8/ITC81DB/Controls/Etc/ControlConfiOptionBoard2.cs

350 lines
16 KiB
C#
Raw Normal View History

2023-07-11 01:56:01 +00:00
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_ImageDll;
using ITC81DB.DialogForms;
using ITC81DB.Forms;
namespace ITC81DB.Controls
{
public partial class ControlConfiOptionBoard2 : UserControl
{
#region Field
private FormMenu m_ParentForm;
#endregion
#region Constructor
public ControlConfiOptionBoard2(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.engBackgroundDispenser));
this.labelTitleDelayTime1.Font = this.labelTitleDelayTime2.Font = new Font("새굴림", 12, FontStyle.Bold);
this.labelTitleDelayTime1.Text = "Delay 1 time";
this.labelTitleDelayTime2.Text = "Delay 2 time";
this.radioButtonPortNone.Text = "None";
this.radioButtonPort56.Text = "Output port 5, 6";
this.radioButtonPort78.Text = "Output port 7, 8";
this.labelHelp1.Text = "1. A : The object enters.";
this.labelHelp2.Text = "2. B : The object enters into the range of dispenser sensor.";
this.labelHelp3.Text = "3. C : After 'Delay 1 time', stick 'Dispenser 1' out.";
this.labelHelp4.Text = "4. D : At the same time, 'Dispenser 2' descend.";
this.labelHelp5.Text = "5. After 'Delay 2 time', come back to A.";
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundDispenser));
this.labelTitleDelayTime1.Font = this.labelTitleDelayTime2.Font = new Font("새굴림", 12, FontStyle.Bold);
this.labelTitleDelayTime1.Text = "延迟1时间";
this.labelTitleDelayTime2.Text = "延迟2时间";
this.radioButtonPortNone.Text = "不使用";
this.radioButtonPort56.Text = "输出 5, 6";
this.radioButtonPort78.Text = "输出 7, 8";
this.labelHelp1.Text = "1. A : 被测量物体进入";
this.labelHelp2.Text = "2. B : 被测量物体进入感应器检测范围";
this.labelHelp3.Text = "3. C : 延迟1时间后分配器1上升";
this.labelHelp4.Text = "4. D : 分配器1上升的同时分配器2下降";
this.labelHelp5.Text = "5. 延迟2时间后重新回到A状态";
}
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.rusBackgroundDispenser));
this.labelTitleDelayTime1.Font = this.labelTitleDelayTime2.Font = new Font("새굴림", 10, FontStyle.Bold);
this.labelTitleDelayTime1.Text = "Время задержки 1";
this.labelTitleDelayTime2.Text = "Время задержки 2";
this.radioButtonPortNone.Text = "Нет";
this.radioButtonPort56.Text = "Порт выхода 5, 6";
this.radioButtonPort78.Text = "Порт выхода 7, 8";
this.labelHelp1.Text = "1. A : Входит измеряемый объект";
this.labelHelp2.Text = "2. B : Объект входит в зону действия датчика дозатора";
this.labelHelp3.Text = "3. C : После «Задержки 1» отключите «Вход дозатора1»";
this.labelHelp4.Text = "4. D : В то же время, «Вход дозатора 2» опустится";
this.labelHelp5.Text = "5. Через 2 часа вернитесь в состояние A";
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundDispenser));
this.labelTitleDelayTime1.Font = this.labelTitleDelayTime2.Font = new Font("새굴림", 12, FontStyle.Bold);
this.labelTitleDelayTime1.Text = "Vezögerung 1";
this.labelTitleDelayTime2.Text = "Vezögerung 2";
this.radioButtonPortNone.Text = "Keiner";
this.radioButtonPort56.Text = "Ausgangsport 5, 6";
this.radioButtonPort78.Text = "Ausgangsport 7, 8";
this.labelHelp1.Text = "1. A : Das Objekt tritt ein.";
this.labelHelp2.Text = "2. B : Das Objekt gelangt in den Bereich des Spenders sensors.";
this.labelHelp3.Text = "3. C : Nach 'Verzögerung 1' stecken Sie 'Dispenser 1' heraus.";
this.labelHelp4.Text = "4. D : Gleichzeitig senkt 'Dispenser 2' ab.";
this.labelHelp5.Text = "5. Nach 2 Stunden Verspätung kehren wir wieder in den A-Zustand zurück.";
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundDispenser));
this.labelTitleDelayTime1.Font = this.labelTitleDelayTime2.Font = new Font("새굴림", 10, FontStyle.Bold);
this.labelTitleDelayTime1.Text = "1 Tiempo de retardo";
this.labelTitleDelayTime2.Text = "2 Tiempo de retardo";
this.radioButtonPortNone.Text = "Ninguna";
this.radioButtonPort56.Text = "Puerto de salida 5, 6";
this.radioButtonPort78.Text = "Puerto de salida 7, 8";
this.labelHelp1.Text = "1. A : El objeto entra.";
this.labelHelp2.Text = "2. B : El objeto entra en el rango de sensor de dispensador.";
this.labelHelp3.Text = "3. C : Después de 'Tiempo de retraso 1', Stick 'Dispenser 1' Out";
this.labelHelp4.Text = "4. D : Al mismo tiempo, 'Dispenser 2' desciende.";
this.labelHelp5.Text = "5. Después de 'retraso 2' tiempo, vuelve a un.";
}
else
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundDispenser));
this.labelTitleDelayTime1.Font = this.labelTitleDelayTime2.Font = new Font("새굴림", 12, FontStyle.Bold);
this.labelTitleDelayTime1.Text = "지연시간 1";
this.labelTitleDelayTime2.Text = "지연시간 2";
this.radioButtonPortNone.Text = "None";
this.radioButtonPort56.Text = "Output port 5, 6";
this.radioButtonPort78.Text = "Output port 7, 8";
this.labelHelp1.Text = "1. A : 피계량물이 진입한다.";
this.labelHelp2.Text = "2. B : 피계량물이 Dispenser sensor 범위 안에 진입한다.";
this.labelHelp3.Text = "3. C : '지연시간1'만큼 지난 후, Dispenser1이 올라온다.";
this.labelHelp4.Text = "4. D : Dispenser1이 올라옴과 동시에 Dispenser2가 내려간다.";
this.labelHelp5.Text = "5. '지연시간2'만큼 지난 후, 다시 A 상태로 돌아온다.";
}
}
private void DefaultSetting()
{
this.UpdateCurrentProductDisplay(this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.CurrentSystemParameter1, this.ParentForm.ParentForm.CurrentSystemParameter2);
}
public void UpdateCurrentProductDisplay(ProductItem product, SystemParameter1 parameter1, SystemParameter2 parameter2)
{
string value = "";
value = product.Number.ToString();
if (this.buttonItemNo.Text != value)
this.buttonItemNo.Text = value;
this.UpdateDelayTime(product);
this.UpdateDisplay(parameter1, parameter2);
}
private void UpdateDelayTime(ProductItem product)
{
string sValue = "";
sValue = product.DispenserDelayTime1;
if (this.labelDelayTime1.Text != sValue)
this.labelDelayTime1.Text = sValue;
sValue = product.DispenserDelayTime2;
if (this.labelDelayTime2.Text != sValue)
this.labelDelayTime2.Text = sValue;
}
private void UpdateDisplay(SystemParameter1 parameter1, SystemParameter2 parameter2)
{
int iValue = 0;
string sValue = "";
try
{
iValue = int.Parse(parameter2.OPT2Port);
}
catch
{
iValue = 0;
}
this.radioButtonPortNone.Click -= new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort56.Click -= new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort78.Click -= new EventHandler(this.radioButtonPort_Click);
if (iValue == 1)
{
this.radioButtonPortNone.Checked = false;
this.radioButtonPort78.Checked = false;
this.radioButtonPort56.Checked = true;
}
else if (iValue == 2)
{
this.radioButtonPortNone.Checked = false;
this.radioButtonPort56.Checked = false;
this.radioButtonPort78.Checked = true;
}
else
{
this.radioButtonPortNone.Checked = true;
this.radioButtonPort56.Checked = false;
this.radioButtonPort78.Checked = false;
}
this.radioButtonPortNone.Click += new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort56.Click += new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort78.Click += new EventHandler(this.radioButtonPort_Click);
}
public void DisplayRefresh(SystemStatus status)
{
this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.ConfiOptionBoard2;
// 로그
if (this.ParentForm.ParentForm.IsCommunicationLogOpen == true)
this.ParentForm.ParentForm.smartFileCommunicationLog.WriteString(string.Format("Current Product ({0:yyyy-MM-dd HH:mm:ss}): {1}", DateTime.Now, this.ParentForm.ParentForm.SystemConfig1.ProductNumber.ToString()));
this.UpdateCurrentProductDisplay(this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.CurrentSystemParameter1, this.ParentForm.ParentForm.CurrentSystemParameter2);
}
#endregion
#region Event Handler
private void labelDelayTime1_Click(object sender, EventArgs e)
{
string value = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelDelayTime1.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language);
myMsg.ShowDialog();
}
else
{
this.labelDelayTime1.Text = myKeyPad.StringValue;
value = Helper.StringZeroFillDigits4(this.labelDelayTime1.Text);
this.ParentForm.ParentForm.CurrentProductItem.DispenserDelayTime1 = myKeyPad.StringValue;
this.ParentForm.ParentForm.SaveProductFile(this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig1.ProductNumber - 1);
}
}
}
private void labelDelayTime2_Click(object sender, EventArgs e)
{
string value = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelDelayTime2.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 0 || myKeyPad.doubleValue > 9999)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language);
myMsg.ShowDialog();
}
else
{
this.labelDelayTime2.Text = myKeyPad.StringValue;
value = Helper.StringZeroFillDigits4(this.labelDelayTime2.Text);
this.ParentForm.ParentForm.CurrentProductItem.DispenserDelayTime2 = myKeyPad.StringValue;
this.ParentForm.ParentForm.SaveProductFile(this.ParentForm.ParentForm.CurrentProductItem, this.ParentForm.ParentForm.SystemConfig1.ProductNumber - 1);
}
}
}
private void radioButtonPort_Click(object sender, EventArgs e)
{
string value = "";
this.radioButtonPortNone.Click -= new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort56.Click -= new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort78.Click -= new EventHandler(this.radioButtonPort_Click);
if (this.radioButtonPortNone.Checked == true)
{
value = "0000";
this.radioButtonPort56.Checked = false;
this.radioButtonPort78.Checked = false;
}
else if (this.radioButtonPort56.Checked == true)
{
value = "0001";
this.radioButtonPortNone.Checked = false;
this.radioButtonPort78.Checked = false;
}
else
{
value = "0002";
this.radioButtonPortNone.Checked = false;
this.radioButtonPort56.Checked = false;
}
this.radioButtonPortNone.Click += new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort56.Click += new EventHandler(this.radioButtonPort_Click);
this.radioButtonPort78.Click += new EventHandler(this.radioButtonPort_Click);
this.ParentForm.ParentForm.CurrentSystemParameter2.OPT2Port = value;
this.ParentForm.ParentForm.SaveSystemParameter2File(this.ParentForm.ParentForm.CurrentSystemParameter2);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.OPT2Port, value);
}
private void buttonItemNo_Click(object sender, EventArgs e)
{
string message = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.buttonItemNo.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 1 || myKeyPad.doubleValue > this.ParentForm.ParentForm.ProductCount)
{
// 입력범위를 확인하세요
message = string.Format("1 ~ {0}", this.ParentForm.ParentForm.ProductCount);
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, message);
myMsg.ShowDialog();
}
else
{
this.buttonItemNo.Text = myKeyPad.StringValue;
this.buttonItemNo.Text = "**";
this.ParentForm.ParentForm.TransferProductParameter(myKeyPad.IntValue);
}
}
}
#endregion
}
}