ITC81DB_2H/ITC81DB_0H/Controls/CenterConfiguration/ControlCenterConfiEthernet.cs

1479 lines
69 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using SmartX;
using ITC81DB_2H_ImageDll;
using ITC81DB_0H.DialogForms;
using ITC81DB_0H.Forms;
using ITC81DB_2H.Datastore;
namespace ITC81DB_0H.Controls
{
public partial class ControlCenterConfiEthernet : UserControl
{
#region Field
private static int ModeSTD2 = 4;
private FormMenu m_ParentForm;
public ControlConfiEthernetLocalIP ControlEthernetLocalIP;
public ControlConfiSerialHitachi ControlHitachi;
public ControlConfiSerialMarkoPrint ControlMarkoprint;
public ControlConfiModbus ControlModbusTCP;
public ControlConfiMULTiJET ControlMultiJet;
private delegate void ConnetedIPStatusCallback(string value);
#endregion
#region Constructor
public ControlCenterConfiEthernet(FormMenu parent)
{
InitializeComponent();
this.ParentForm = parent;
this.DefaultSetting();
this.InitializeDesign();
}
#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();
this.labelTitleConnectedIP.Text = "Connceted IP";
this.labelTitleServerPort.Text = "Port";
this.labelTitleClientServerIP.Text = "Server IP";
this.labelTitleClientServerPort.Text = "Server Port";
this.buttonLocalIP.Font = new Font("새굴림", 13, FontStyle.Bold);
this.buttonLocalIP.Text = "Local IP";
this.buttonStart.Text = "Start";
this.buttonStop.Text = "Stop";
if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.English)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.engBackgroundEthernet));
this.comboBoxEthernetOpMode.Items.Clear();
this.comboBoxEthernetOpMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.Items.Add("None");
this.comboBoxEthernetOpMode.Items.Add("Server");
this.comboBoxEthernetOpMode.Items.Add("Client");
this.comboBoxEthernetOpMode.SelectedIndex = 0;
this.comboBoxEthernetOpMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Chinese)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundEthernet));
this.labelTitleConnectedIP.Text = "连接的IP";
this.labelTitleServerPort.Text = "端口";
this.labelTitleClientServerIP.Text = "服务器IP";
this.labelTitleClientServerPort.Text = "服务器端口";
this.buttonLocalIP.Font = new Font("새굴림", 11, FontStyle.Bold);
this.buttonLocalIP.Text = "设备IP地址";
this.buttonStart.Text = "开启";
this.buttonStop.Text = "停止";
this.comboBoxEthernetOpMode.Items.Clear();
this.comboBoxEthernetOpMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.Items.Add("不使用");
this.comboBoxEthernetOpMode.Items.Add("服务器");
this.comboBoxEthernetOpMode.Items.Add("客户端");
this.comboBoxEthernetOpMode.SelectedIndex = 0;
this.comboBoxEthernetOpMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Czech)
{
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.Russian)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.rusBackgroundEthernet));
this.labelTitleConnectedIP.Text = "Подключенный IP";
this.labelTitleServerPort.Text = "Порт";
this.labelTitleClientServerIP.Text = "Сервер IP";
this.labelTitleClientServerPort.Text = "Сервер Порт";
this.buttonLocalIP.Font = new Font("새굴림", 13, FontStyle.Bold);
this.buttonLocalIP.Text = "IP адрес";
this.buttonStart.Text = "Старт";
this.buttonStop.Text = "Стоп";
this.comboBoxEthernetOpMode.Items.Clear();
this.comboBoxEthernetOpMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.Items.Add("Нет");
this.comboBoxEthernetOpMode.Items.Add("Сервер");
this.comboBoxEthernetOpMode.Items.Add("Клиент");
this.comboBoxEthernetOpMode.SelectedIndex = 0;
this.comboBoxEthernetOpMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == Define.E_LanguageID.German)
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundEthernet));
this.comboBoxEthernetOpMode.Items.Clear();
this.comboBoxEthernetOpMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.Items.Add("None");
this.comboBoxEthernetOpMode.Items.Add("Server");
this.comboBoxEthernetOpMode.Items.Add("Client");
this.comboBoxEthernetOpMode.SelectedIndex = 0;
this.comboBoxEthernetOpMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
//this.comboBoxEthernetMode.Items.Clear();
//this.comboBoxEthernetMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetMode_SelectedIndexChanged);
//this.comboBoxEthernetMode.Items.Add("Keiner");
//this.comboBoxEthernetMode.Items.Add("STD1");
//this.comboBoxEthernetMode.Items.Add("Fernzugriff");
//this.comboBoxEthernetMode.Items.Add("Drucker");
//this.comboBoxEthernetMode.Items.Add("imaje 9410 OPT1"); // 한맥 4
//this.comboBoxEthernetMode.Items.Add("imaje 9028 OPT1"); // 한맥 5
//this.comboBoxEthernetMode.Items.Add("OPT3"); // 대주 6
//this.comboBoxEthernetMode.Items.Add("imaje 9410 OPT2"); // 한맥 7
//this.comboBoxEthernetMode.Items.Add("imaje 9028 OPT2"); // 한맥 8
//this.comboBoxEthernetMode.Items.Add("Hitachi"); // 히타치 9
//this.comboBoxEthernetMode.Items.Add("MACSA Laser"); // MACSA 10
//this.comboBoxEthernetMode.Items.Add("Markoprint"); // Markoprint 11
//this.comboBoxEthernetMode.Items.Add("alphaJET"); // alphaJET 12
//this.comboBoxEthernetMode.Items.Add("Marking(VJ1510)"); // VJ1510 13
//this.comboBoxEthernetMode.Items.Add("OPT1"); // 금속검출기(액트라 - 안리쯔) 14
//this.comboBoxEthernetMode.Items.Add("OPT2"); // NOW1(Now PPI에 사용) 15
//this.comboBoxEthernetMode.Items.Add("OPC"); // 16
//this.comboBoxEthernetMode.Items.Add("OPT3"); // 17
//this.comboBoxEthernetMode.Items.Add("HP-200"); // 18
//this.comboBoxEthernetMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetMode_SelectedIndexChanged);
}
else
{
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundEthernet));
this.comboBoxEthernetOpMode.Items.Clear();
this.comboBoxEthernetOpMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.Items.Add("None");
this.comboBoxEthernetOpMode.Items.Add("Server");
this.comboBoxEthernetOpMode.Items.Add("Client");
this.comboBoxEthernetOpMode.SelectedIndex = 0;
this.comboBoxEthernetOpMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
}
}
private void DefaultSetting()
{
string[] sValue;
this.ControlEthernetLocalIP = new ControlConfiEthernetLocalIP(this.ParentForm);
this.Controls.Add(this.ControlEthernetLocalIP);
this.ControlEthernetLocalIP.Location = new Point(0, 217);
this.ControlHitachi = new ControlConfiSerialHitachi(this.ParentForm);
this.Controls.Add(this.ControlHitachi);
this.ControlHitachi.Location = new Point(0, 217);
this.ControlMarkoprint = new ControlConfiSerialMarkoPrint(this.ParentForm);
this.Controls.Add(this.ControlMarkoprint);
this.ControlMarkoprint.Location = new Point(0, 217);
this.ControlModbusTCP = new ControlConfiModbus(this.ParentForm);
this.Controls.Add(this.ControlModbusTCP);
this.ControlModbusTCP.Location = new Point(0, 217);
this.ControlMultiJet = new ControlConfiMULTiJET(this.ParentForm);
this.Controls.Add(this.ControlMultiJet);
this.ControlMultiJet.Location = new Point(0, 217);
this.ControlVisible(false);
if (this.ParentForm.ParentForm.SystemConfig2.IsEthernetEnable == true)
{
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = true;
}
else
{
this.buttonStart.Enabled = false;
this.buttonStop.Enabled = false;
}
this.labelServerStatus.Text = "-";
this.labelClientStatus.Text = "-";
this.labelConnectedIP.Text = "-";
// Host IP
sValue = this.ParentForm.ParentForm.SystemConfig2.EthernetAddress.Split('.');
this.labelHostIP1.Text = sValue[0];
this.labelHostIP2.Text = sValue[1];
this.labelHostIP3.Text = sValue[2];
this.labelHostIP4.Text = sValue[3];
this.labelHostPort.Text = this.ParentForm.ParentForm.SystemConfig2.EthernetPort.ToString();
this.labelLocalPort.Text = this.ParentForm.ParentForm.SystemConfig2.EthernetLocalPort.ToString();
this.ChangeCommunicationMode();
this.buttonSave2.Enabled = false;
}
public void ChangeCommunicationMode()
{
this.comboBoxEthernetMode.Items.Clear();
this.comboBoxEthernetMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetMode_SelectedIndexChanged);
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == true)
{
this.comboBoxEthernetMode.Items.Add("None");
this.comboBoxEthernetMode.Items.Add("STD1");
this.comboBoxEthernetMode.Items.Add("Remote");
this.comboBoxEthernetMode.Items.Add("Printer");
this.comboBoxEthernetMode.Items.Add("imaje 9410 OPT1"); // 한맥 4
this.comboBoxEthernetMode.Items.Add("imaje 9028 OPT1"); // 한맥 5
this.comboBoxEthernetMode.Items.Add("OPT0"); // 대주 6
this.comboBoxEthernetMode.Items.Add("imaje 9410 OPT2"); // 한맥 7
this.comboBoxEthernetMode.Items.Add("imaje 9028 OPT2"); // 한맥 8
this.comboBoxEthernetMode.Items.Add("Hitachi"); // 히타치 9
this.comboBoxEthernetMode.Items.Add("MACSA Laser"); // MACSA 10
this.comboBoxEthernetMode.Items.Add("Markoprint"); // Markoprint 11
this.comboBoxEthernetMode.Items.Add("alphaJET"); // alphaJET 12
this.comboBoxEthernetMode.Items.Add("Marking(VJ1510)"); // VJ1510 13
this.comboBoxEthernetMode.Items.Add("OPT1"); // 금속검출기(액트라 - 안리쯔) 14
this.comboBoxEthernetMode.Items.Add("OPT2"); // NOW1(Now PPI에 사용) 15
this.comboBoxEthernetMode.Items.Add("OPC"); // 16
this.comboBoxEthernetMode.Items.Add("OPT3"); // 17
this.comboBoxEthernetMode.Items.Add("HP-200"); // 18
this.comboBoxEthernetMode.Items.Add("Smart Jet"); // 19
this.comboBoxEthernetMode.Items.Add("imaje 9410 OPT3"); // 한맥 20
this.comboBoxEthernetMode.Items.Add("-"); // Impinj Speedway-R420(RFID) 21
this.comboBoxEthernetMode.Items.Add("Modbus TCP"); // 모드버스 TCP 22
this.comboBoxEthernetMode.Items.Add("STD2"); // STD2 23
this.comboBoxEthernetMode.Items.Add("MULTi-JET"); // MULTi-JET 24
this.comboBoxEthernetMode.Items.Add("DJ(VIDEOJET)"); // DJ VIDEOJET 25
this.comboBoxEthernetMode.Items.Add("LINX8830"); // LINX8830 잉크젯 프린터 26
this.comboBoxEthernetMode.Items.Add("MYJET"); // MYJET 잉크젯 프린터 27
this.comboBoxEthernetMode.Items.Add("OPT4"); // 바코드 값과 함께 전송(Tasco건) 28
}
else
{
this.comboBoxEthernetMode.Items.Add("None");
this.comboBoxEthernetMode.Items.Add("STD1");
this.comboBoxEthernetMode.Items.Add("Remote");
this.comboBoxEthernetMode.Items.Add("Printer");
this.comboBoxEthernetMode.Items.Add("STD2"); // STD2 23
}
this.comboBoxEthernetMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetMode_SelectedIndexChanged);
}
public void UpdateEthernetStatusDisplay(string value)
{
if (this.labelClientStatus.Text != value)
this.labelClientStatus.Text = value;
}
private void UpdateLabelFormatDisplay()
{
this.buttonTestSend.Enabled = true;
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false)
{
switch (this.comboBoxEthernetMode.SelectedIndex)
{
case 0: // None
this.labelFormat.Text = "";
break;
case 1: // STD1
this.labelFormat.Text = "STX[1],ID[5],No[4],U[6],P[6],O[6],Grd[1],Sign[1],Weight[6],ETX[1]";
break;
case 2: // Remote
this.labelFormat.Text = "STX[1],No[2],Grd[1],Weight[6],ETX[1]";
break;
case 3: // Printer
this.labelFormat.Text = "No[4],Grd[8],Weight[10],CNT[10]";
break;
case 4: // STD2
this.labelFormat.Text = "STX[1],ID[5],No[4],U[6],P[6],O[6],UC[7],PC[7],OC[7],ExC[7],TC[9],Grd[1],Sign[1],Weight[6],ETX[1]";
break;
default:
this.labelFormat.Text = "";
break;
}
}
else
{
switch (this.comboBoxEthernetMode.SelectedIndex)
{
case 0: // None
this.labelFormat.Text = "";
break;
case 1: // STD1
this.labelFormat.Text = "STX[1],ID[5],No[4],U[6],P[6],O[6],Grd[1],Sign[1],Weight[6],ETX[1]";
break;
case 2: // Remote
this.labelFormat.Text = "STX[1],No[2],Grd[1],Weight[6],ETX[1]";
break;
case 3: // Printer
this.labelFormat.Text = "No[4],Grd[8],Weight[10],CNT[10]";
break;
case 4: // markem-imaje 9410 OPT1
this.labelFormat.Text = "0xE8,0x00,0x08,0x01,0x00,0x05,W[5],Chksum[1]";
break;
case 5: // markem-imaje 9028 OPT1
this.labelFormat.Text = "0x99,0x00,0x07,0x12,W[5],0x12,Chksum[1]";
break;
case 6: // 노바렉스 대주
this.labelFormat.Text = "0x1B,EW----;1.00I,0x0D,0x1B,P1-0-000000000;A9mm;,W[6],0x0D,0x1B,EX----;,0x0D,0x02,TZ1.00I;13,0x0D,0x03";
break;
case 7: // markem-imaje 9410 OPT2
this.labelFormat.Text = "0xE8,0x00,0x08,0x01,0x00,0x05,W[5],Chksum[1]";
break;
case 8: // markem-imaje 9028 OPT2
this.labelFormat.Text = "0x05/0x99,0x00,0x07,0x12,W[5],0x12,Chksum[1]";
break;
case 9: // Hitachi
this.labelFormat.Text = "STX[1],Length[1],Room Number[1],W[5],ETX[1]";
break;
case 10: // MACSA Laser
this.labelFormat.Text = "STX[1],0xFE,0x41,0x30,0x06,W[6],Chk[1],(Chk[1]&0xff)[1],ETX[1]";
break;
case 11: // Markoprint
this.labelFormat.Text = "STX[1],TZcosmax.;00I;13,0x0D,W[6],Unit[1],0x0D,ETX[1]";
break;
case 12: // alphaJET
this.labelFormat.Text = "<GP><LOADLAB>label\\1234.txt</LOADLAB><DSET><DF aI=''1''>,W[6],Unit[1],</DF></DSET></GP>";
break;
case 13: // Marking(VJ1510)
this.labelFormat.Text = "STX[1],0x55,0x4B,0x0A,W[4],ETX[1]";
break;
case 14: // OPT1
this.labelFormat.Text = "Start:STX[1],12,ETX[1], Stop:STX[1],13,ETX[1], Number change:STX[1],200,No[2],ETX[1]";
break;
case 15:
break;
case 16: // OPC
this.buttonTestSend.Enabled = false;
this.labelFormat.Text = "OPC : opc.tcp://192.168.4.10";
break;
case 17: // OPT3
this.labelFormat.Text = "STX[1],Date[9],Time[9],Count[9],grd[9],W[9],Lot[9],O[9],U[9],P[9],ETX[1]";
break;
case 18: // HP-200
this.labelFormat.Text = "Pass : 02 4a 30 2c W[6] 0d 04 / NG : 02 4a 30 2c 20 20 20 20 20 20 0d 04 -> Screen Update : 02 5a 04";
break;
case 19: // Smart Jet
this.labelFormat.Text = "STX[1], A01, WeightData[6], EOT[1]";
break;
case 20: // markem-imaje 9410 OPT3
this.labelFormat.Text = "0xE8,0x00,0x08,0x01,0x00,0x05,W[5],Chksum[1]";
break;
case (int)Define.E_CommMode.f22_Modbus: // Modbus_TCP
this.labelFormat.Text = "ID, Product No, Under, Pass, Over, Under Count, Pass Count, Over Count, NG Count, ExNG Count, Total Count, Grade, Weight, Status(Run/Stop)";
break;
case (int)Define.E_CommMode.f23_STD2: // STD2
this.labelFormat.Text = "STX[1],ID[5],No[4],U[6],P[6],O[6],UC[7],PC[7],OC[7],ExC[7],TC[9],Grd[1],Sign[1],Weight[6],ETX[1]";
break;
case (int)Define.E_CommMode.f24_MULTi_JET: // Multi-jet
this.labelFormat.Text = "0x1B,0x02,Slave Address[1],0x1D,0x02,0x01,0x0A,Date[10],0x02,0x07,Weight[6],'g',0x1B,0x03,Chksum[1]";
break;
case (int)Define.E_CommMode.f26_LINX8830: // LINX8830
this.labelFormat.Text = "0x1B,0x02,0x1D,0x06,0x00,Weight[6],0x1B,0x03";
break;
case (int)Define.E_CommMode.f27_MYJET: // MYJET
this.labelFormat.Text = "0x1B,0x02,IP[1],0x1D,0x01,0x01,0x06,Weight[6],0x1B,0x03,Checksum[1]";
break;
case (int)Define.E_CommMode.f28_OPT4: // OPT4
this.labelFormat.Text = "0x02,Date[yyyy-MM-dd HH:mm:ss, 19];Grade[1];Weight[6];Data,0x03";
break;
default:
this.buttonTestSend.Enabled = false;
this.labelFormat.Text = "Private use";
break;
}
}
//else if (this.comboBoxSerialMode.SelectedIndex == 15) // OPT2
// this.labelFormat.Text = "STX[1],Length[1],Room Number[1],W[5],ETX[1]";
//else if (this.comboBoxSerialMode.SelectedIndex == 4) // Barcode
// this.labelFormat.Text = "Receive Only";
//else if (this.comboBoxSerialMode.SelectedIndex == 5) // User Define
// this.labelFormat.Text = "User Define";
}
public void DisplayLabelLocalPort(bool bValue)
{
if (bValue == false)
{
this.labelLocalPort.Enabled = false;
this.labelLocalPort.BackColor = Color.Silver;
}
else
{
this.labelLocalPort.Enabled = true;
this.labelLocalPort.BackColor = Color.White;
}
}
public void DisplayHiddenMenu(bool bValue)
{
if (bValue == true)
{
this.buttonDisconnectDetection.Visible = true;
}
else
{
this.buttonDisconnectDetection.Visible = false;
}
}
private void ButtonAddOnDisplay()
{
this.DisplayBottomSettingMenu();
if (this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f9_Hitachi
|| this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f11_Markoprint
|| this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f16_OPC
|| this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f22_Modbus
|| this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f24_MULTi_JET)
this.buttonAddon.Visible = true;
else
this.buttonAddon.Visible = false;
}
private void ControlVisible(bool visible)
{
this.ControlHitachi.Visible = visible;
this.ControlMarkoprint.Visible = visible;
this.ControlModbusTCP.Visible = visible;
this.ControlMultiJet.Visible = visible;
}
private void DisplayBottomSettingMenu()
{
this.ControlVisible(false);
this.buttonTestSend.Enabled = true;
if (this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f9_Hitachi)
{
this.ControlHitachi.Visible = true;
this.ControlHitachi.BringToFront();
this.ControlHitachi.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
}
else if (this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f11_Markoprint)
{
this.ControlMarkoprint.Visible = true;
this.ControlMarkoprint.BringToFront();
this.ControlMarkoprint.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
}
else if (this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f22_Modbus
|| this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f16_OPC)
{
this.ControlModbusTCP.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
this.ControlModbusTCP.Visible = true;
this.ControlModbusTCP.BringToFront();
}
else if (this.comboBoxEthernetMode.SelectedIndex == (int)Define.E_CommMode.f24_MULTi_JET)
{
this.ControlMultiJet.Visible = true;
this.ControlMultiJet.BringToFront();
this.ControlMultiJet.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
}
else
{
}
}
private void ConnectedIPStatusOut(string value)
{
this.labelConnectedIP.Text = value;
}
public void DelegateConnectedIPStatusOut(string value)
{
this.Invoke(new ConnetedIPStatusCallback(this.ConnectedIPStatusOut), value);
}
public void DisplayRefresh(SystemStatus status)
{
this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = Define.E_DisplayStore.ConfiEthernet;
this.ParentForm.ParentForm.SetDisplayMode(Define.E_DisplayMode.Menu);
this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);
this.comboBoxEthernetMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.SelectedIndexChanged -= new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.SelectedIndex = this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode;
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false)
{
if (this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode == (int)Define.E_CommMode.f23_STD2)
this.comboBoxEthernetMode.SelectedIndex = ModeSTD2;
else if (this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode > this.comboBoxEthernetMode.Items.Count - 1)
{
this.comboBoxEthernetMode.SelectedIndex = 0;
this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode = this.comboBoxEthernetMode.SelectedIndex;
this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
}
else
this.comboBoxEthernetMode.SelectedIndex = this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode;
}
else
this.comboBoxEthernetMode.SelectedIndex = this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode;
if (this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode == 16)
this.comboBoxEthernetOpMode.Enabled = false;
this.comboBoxEthernetMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetMode_SelectedIndexChanged);
this.comboBoxEthernetOpMode.SelectedIndexChanged += new EventHandler(this.comboBoxEthernetOpMode_SelectedIndexChanged);
this.UpdateLabelFormatDisplay();
this.DisplayHiddenMenu(false);
if (this.comboBoxEthernetOpMode.SelectedIndex == 1)
{
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = true;
if (string.Compare(this.ParentForm.ParentForm.smartConfigs.IPSettings.DeviceIP, "0.0.0.0") == 0)
{
if (this.labelServerStatus.Text != ">Addr Err")
this.labelServerStatus.Text = ">Addr Err";
this.timerServer.Enabled = false;
}
else
{
this.ParentForm.ParentForm.EthernetServerStart();
if (this.timerServer.Enabled != true)
this.timerServer.Enabled = true;
}
}
else if (this.comboBoxEthernetOpMode.SelectedIndex == 2)
{
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = true;
this.ParentForm.ParentForm.EthernetClientConnect();
}
else
{
this.buttonStart.Enabled = false;
this.buttonStop.Enabled = false;
this.labelServerStatus.Text = "-";
this.labelClientStatus.Text = "-";
this.labelConnectedIP.Text = "-";
}
this.labelLocalPort.Text = this.ParentForm.ParentForm.SystemConfig2.EthernetLocalPort.ToString();
if (this.ParentForm.ParentForm.SystemConfig2.IsDisconnectDetection == true)
{
this.buttonDisconnectDetection.Text = "Disconnect Detection OFF";
this.buttonDisconnectDetection.ButtonDown();
}
else
{
this.buttonDisconnectDetection.Text = "Disconnect Detection ON";
this.buttonDisconnectDetection.ButtonUp();
}
this.ButtonAddOnDisplay();
this.buttonSave.Enabled = false;
}
#endregion
#region Event Handler
private void buttonClientStart_Click(object sender, EventArgs e)
{
this.ParentForm.ParentForm.EthernetClientConnect();
}
private void buttonClientStop_Click(object sender, EventArgs e)
{
this.ParentForm.ParentForm.EthernetClientDisconnect();
}
private void buttonTestSend_Click(object sender, EventArgs e)
{
int tempStringLength = 0;
string tempString = "";
string str = "";
StringBuilder sb = new StringBuilder();
Define.E_MenuBottomConfiguration temp = this.ParentForm.CurrentConfigurationMenu();
byte[] byteArray = new byte[12];
byte[] weightBytes = new byte[4];
byte[] bytes = new byte[100];
if (this.comboBoxEthernetMode.SelectedIndex == 0)
return;
switch (this.comboBoxEthernetMode.SelectedIndex)
{
case 1:
#region STD1
sb.Append((char)0x02);
sb.Append("IN001");
sb.Append("0001");
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces("1000", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces("2000", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces("3000", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append("P");
sb.Append(" ");
sb.Append(string.Format("{0, 6}", Helper.DoubleToString(123.4, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append((char)0x03);
#endregion
break;
case 2:
#region Remote
sb.Append((char)0x02);
sb.Append("01");
sb.Append("P");
sb.Append("0");
sb.Append(Helper.StringToDecimalPlaces("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces));
sb.Append((char)0x03);
#endregion
break;
case 3:
#region Printer
sb.Append("0001");
sb.Append(" Pass");
sb.Append(" " + Helper.StringToDecimalPlaces("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces));
sb.Append("1234567890");
#endregion
break;
case 4:
#region imaje 9410 OPT1
byteArray = new byte[12];
weightBytes = new byte[5];
// 외부변수사용 : 0xE8
byteArray[0] = 0xE8;
// Length : 0x00, 0x08 고정값
byteArray[1] = 0x00;
byteArray[2] = 0x08;
byteArray[3] = 0x01; // 1번 외부변수 번호
byteArray[4] = 0x00;
byteArray[5] = 0x05; // 1번 외부변수 길이
tempString = string.Format("{0,5}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces));
weightBytes = new UTF8Encoding().GetBytes(tempString);
for (int i = 0; i < weightBytes.Length; i++)
{
byteArray[i + 6] = weightBytes[i];
}
byteArray[11] = 0x00;
byteArray[11] = Helper.ChecksumCalculator(byteArray);
#endregion
break;
case 5:
#region imaje 9028 OPT1
byteArray = new byte[11];
weightBytes = new byte[5];
// byteArray[0] ~ byteArray[3]은 고정
byteArray[0] = 0x99;
byteArray[1] = 0x00;
byteArray[2] = 0x07;
byteArray[3] = 0x12;
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0,5}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
for (int i = 0; i < weightBytes.Length; i++)
{
byteArray[i + 4] = weightBytes[i];
}
byteArray[9] = 0x12;
byteArray[10] = 0x00;
byteArray[10] = Helper.ChecksumCalculator(byteArray);
#endregion
break;
case 6:
#region OPT3 - 노바렉스 대주
sb.Append((char)0x1B);
sb.Append("EW----;1.00I");
sb.Append((char)0x0D);
sb.Append((char)0x1B);
sb.Append("P1-0-000000000;A9mm;");
sb.Append(string.Format("{0,6}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append((char)0x0D);
sb.Append((char)0x1B);
sb.Append("EX----;");
sb.Append((char)0x0D);
sb.Append((char)0x02);
sb.Append("TZ1.00I;13");
sb.Append((char)0x0D);
sb.Append((char)0x03);
#endregion
break;
case 7:
#region imaje 9410 OPT2
byteArray = new byte[12];
weightBytes = new byte[5];
// 외부변수사용 : 0xE8
byteArray[0] = 0xE8;
// Length : 0x00, 0x08 고정값
byteArray[1] = 0x00;
byteArray[2] = 0x08;
byteArray[3] = 0x01; // 1번 외부변수 번호
byteArray[4] = 0x00;
byteArray[5] = 0x05; // 1번 외부변수 길이
if (this.ParentForm.ParentForm.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
{
tempString = string.Format("{0,5}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces));
weightBytes = new UTF8Encoding().GetBytes(tempString);
for (int i = 0; i < weightBytes.Length; i++)
{
byteArray[i + 6] = weightBytes[i];
}
}
else
{
for (int i = 0; i < 5; i++)
{
byteArray[i + 6] = 0x20;
}
}
byteArray[11] = 0x00;
byteArray[11] = Helper.ChecksumCalculator(byteArray);
#endregion
break;
case 8:
#region imaje 9028 OPT2
byteArray = new byte[11];
weightBytes = new byte[5];
switch (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode)
{
case 1:
if (this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList != null)
{
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList)
{
this.ParentForm.ParentForm.EthernetServerSendMessage(client, this.ParentForm.ParentForm.SendChar(Define.E_CharValue.ENQ));
}
}
break;
case 2:
this.ParentForm.ParentForm.EthernetWeightData(this.ParentForm.ParentForm.SendChar(Define.E_CharValue.ENQ));
break;
default:
break;
}
Thread.Sleep(30);
// 중량발송 : 0x99
byteArray[0] = 0x99;
// Length : 0x00, 0x02 고정값
byteArray[1] = 0x00;
byteArray[2] = 0x07;
byteArray[3] = 0x12;
if (this.ParentForm.ParentForm.CurrentWeightData.JudgmentStatus == Define.E_JudgmentStatus.Pass)
{
tempString = string.Format("{0,5}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces));
weightBytes = new UTF8Encoding().GetBytes(tempString);
for (int i = 0; i < weightBytes.Length; i++)
{
byteArray[i + 4] = weightBytes[i];
}
}
else
{
for (int i = 0; i < 5; i++)
{
byteArray[i + 4] = 0x20;
}
}
byteArray[9] = 0x12;
byteArray[10] = 0x00;
byteArray[10] = Helper.ChecksumCalculator(byteArray);
#endregion
break;
case 9:
#region Hitachi
sb.Append((char)0x02);
sb.Append((char)0x10);
sb.Append((char)0x31);
sb.Append(string.Format("{0,6}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append((char)0x03);
#endregion
break;
case 10:
#region MACSA Laser
byteArray = new byte[14];
bytes = new byte[6];
byte sum = 0x00;
byteArray[0] = 0x02;
byteArray[1] = 0xFE;
byteArray[2] = 0x41;
byteArray[3] = 0x30;
byteArray[4] = 0x06;
bytes = new UTF8Encoding().GetBytes(string.Format("{0,6}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
for (int i = 0; i < bytes.Length; i++)
{
byteArray[i + 5] = bytes[i];
}
byteArray[11] = byteArray[12] = byteArray[13] = 0x00;
byteArray[11] = Helper.ChecksumCalculator(byteArray);
byteArray[12] = (byte)(byteArray[11] & 0x00ff);
byteArray[13] = 0x03;
#endregion
break;
case 11:
#region Markoprint
byteArray = new byte[50];
bytes = new byte[30];
weightBytes = new byte[30];
string strCosmax = "TZcosmax.00I;13";
string strCosmax2 = "TZcosmax2.00I;13";
string strDate = string.Format("{0:yyyy.MM.dd}", DateTime.Now);
string str2 = "";
byteArray[0] = 0x02; // <STX>
bytes = new UTF8Encoding().GetBytes(strCosmax);
for (int i = 0; i < bytes.Length; i++)
{
byteArray[i + 1] = bytes[i];
}
byteArray[strCosmax.Length + 1] = 0x0D;
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0,6}{1}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces), this.ParentForm.ParentForm.SystemConfig1.Unit));
for (int i = 0; i < weightBytes.Length; i++)
{
byteArray[i + strCosmax.Length + 2] = weightBytes[i];
}
byteArray[strCosmax.Length + weightBytes.Length + 2] = 0x0D;
byteArray[strCosmax.Length + weightBytes.Length + 3] = 0x03;
#endregion
break;
case 12:
#region alphaJET
byteArray = new byte[150];
bytes = new byte[100];
weightBytes = new byte[20];
int length = 0;
string fileName = "label\\1234.txt";
bytes = new UTF8Encoding().GetBytes("<GP><LOADLAB>" + fileName + "</LOADLAB><DSET>" + @"<DF aI=""1"">");
for (int i = 0; i < bytes.Length; i++)
{
byteArray[i] = bytes[i];
}
length = bytes.Length;
///////////////////////////////////////////
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0,6}{1}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces), this.ParentForm.ParentForm.SystemConfig1.Unit));
for (int i = 0; i < weightBytes.Length; i++)
{
byteArray[i + length] = weightBytes[i];
}
length = length + weightBytes.Length;
////////////////////////////////////////////
bytes = new UTF8Encoding().GetBytes("</DF>");
for (int i = 0; i < bytes.Length; i++)
{
byteArray[i + length] = bytes[i];
}
length = length + bytes.Length;
bytes = new UTF8Encoding().GetBytes("</DSET></GP>");
for (int i = 0; i < bytes.Length; i++)
{
byteArray[i + length] = bytes[i];
}
#endregion
break;
case 13:
#region Marking(VJ1510)
byteArray = new byte[9];
weightBytes = new byte[4];
sb.Append((char)0x02);
sb.Append((char)0x55); // U(고정)
sb.Append((char)0x4B); // K(고정)
sb.Append((char)0x0A); // LF(고정)
sb.Append("1234");
sb.Append((char)0x03);
#endregion
break;
case 14:
#region OPT1
sb.Append((char)0x02);
sb.Append("20001");
sb.Append((char)0x03);
#endregion
break;
case 15:
break;
case 16:
break;
case 17:
#region OPT3
string tempValue = "";
DateTime dt = DateTime.Now;
sb.Append((char)0x02);
sb.Append(string.Format(" {0:yyyyMMdd}", dt));
sb.Append(string.Format(" {0:HH:mm:ss}", dt));
sb.Append(" 12345");
sb.Append(" P");
sb.Append(string.Format("{0,9}", 123.4));
if (this.ParentForm.ParentForm.CurrentProductItem.LotNo.Length > 9)
sb.Append(this.ParentForm.ParentForm.CurrentProductItem.LotNo.Substring(0, 9));
else
sb.Append(this.ParentForm.ParentForm.CurrentProductItem.LotNo.PadLeft(9, ' '));
sb.Append((Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem.OverRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)).PadLeft(9));
sb.Append((Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem.UnderRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)).PadLeft(9));
sb.Append((Helper.StringToDecimalPlaces(this.ParentForm.ParentForm.CurrentProductItem.PassRange, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)).PadLeft(9));
sb.Append((char)0x03);
#endregion
break;
case 18:
#region HP-200
sb.Append((char)0x02);
sb.Append((char)0x4a);
sb.Append((char)0x30);
sb.Append((char)0x2c);
sb.Append(" 123.4");
sb.Append((char)0x0d);
sb.Append((char)0x04);
switch (temp)
{
case Define.E_MenuBottomConfiguration.SerialCOM1:
this.ParentForm.ParentForm.TransferSerialCOM1(sb.ToString());
break;
case Define.E_MenuBottomConfiguration.SerialCOM3:
this.ParentForm.ParentForm.TransferSerialCOM3(sb.ToString());
break;
case Define.E_MenuBottomConfiguration.SerialCOM4:
this.ParentForm.ParentForm.TransferSerialCOM4(sb.ToString());
break;
default:
break;
}
sb = new StringBuilder();
sb.Append((char)0x02);
sb.Append((char)0x5a);
sb.Append((char)0x04);
#endregion
break;
case 19:
#region Smart Jet
sb.Append((char)0x02);
sb.Append("A01");
sb.Append(" 12.34");
sb.Append((char)0x04);
#endregion
break;
case 20:
#region imaje 9410 OPT3
byteArray = new byte[12];
weightBytes = new byte[5];
// 외부변수사용 : 0xE8
byteArray[0] = 0xE8;
// Length : 0x00, 0x08 고정값
byteArray[1] = 0x00;
byteArray[2] = 0x08;
byteArray[3] = 0x01; // 1번 외부변수 번호
byteArray[4] = 0x00;
byteArray[5] = 0x05; // 1번 외부변수 길이
weightBytes = new UTF8Encoding().GetBytes(string.Format("{0,5}", Helper.StringToWeight("1234", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
for (int i = 0; i < weightBytes.Length; i++)
{
byteArray[i + 6] = weightBytes[i];
}
byteArray[11] = 0x00;
byteArray[11] = Helper.ChecksumCalculator(byteArray);
#endregion
break;
case 23:
#region STD2
sb.Append((char)0x02);
sb.Append("IN001");
sb.Append("0001");
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces("1000", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces("2000", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append(Helper.StringZeroFillDigits6(Helper.StringToDecimalPlaces("3000", this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append(string.Format("{0:0000000}", 11111));
sb.Append(string.Format("{0:0000000}", 22222));
sb.Append(string.Format("{0:0000000}", 33333));
sb.Append(string.Format("{0:0000000}", 11111));
sb.Append(string.Format("{0:000000000}", 77777));
sb.Append("P");
sb.Append(" ");
sb.Append(string.Format("{0, 6}", Helper.DoubleToString(123.4, this.ParentForm.ParentForm.SystemConfig1.DecimalPlaces)));
sb.Append((char)0x03);
#endregion
break;
default:
break;
}
#region 사용안함
//else if (this.comboBoxSerialMode.SelectedIndex == 4) // Barcode
//{
// return;
//}
//else if (this.comboBoxSerialMode.SelectedIndex == 5) // User Define
//{
// switch (temp)
// {
// case Define.E_MenuBottomConfiguration.SerialCOM1:
// sb.Append(this.ControlUserDefine.ConvertProtocol((int)Define.E_SerialNumber.SerialCOM1));
// break;
// case Define.E_MenuBottomConfiguration.SerialCOM3:
// sb.Append(this.ControlUserDefine.ConvertProtocol((int)Define.E_SerialNumber.SerialCOM3));
// break;
// case Define.E_MenuBottomConfiguration.SerialCOM4:
// sb.Append(this.ControlUserDefine.ConvertProtocol((int)Define.E_SerialNumber.SerialCOM4));
// break;
// default:
// break;
// }
//}
#endregion
switch (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode)
{
case 1:
if (this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList != null)
{
foreach (SmartTCPMultiServer.CLIENTSINFOS client in this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList)
{
if (sb.ToString() == "")
this.ParentForm.ParentForm.EthernetServerSendMessage(client, byteArray);
else
this.ParentForm.ParentForm.EthernetServerSendMessage(client, sb.ToString());
}
}
break;
case 2:
if (sb.ToString() == "")
this.ParentForm.ParentForm.EthernetWeightData(byteArray);
else
this.ParentForm.ParentForm.EthernetWeightData(sb.ToString());
break;
default:
break;
}
}
private void buttonSave2_Click(object sender, EventArgs e)
{
string beforeServerIP = "", afterServerIP = "";
string beforeServerPort = "", afterServerPort = "";
beforeServerIP = this.ParentForm.ParentForm.SystemConfig2.EthernetAddress;
beforeServerPort = this.ParentForm.ParentForm.SystemConfig2.EthernetPort.ToString();
try
{
this.ParentForm.ParentForm.SystemConfig2.EthernetPort = int.Parse(this.labelHostPort.Text);
afterServerPort = this.ParentForm.ParentForm.SystemConfig2.EthernetPort.ToString();
}
catch
{
this.ParentForm.ParentForm.SystemConfig2.EthernetPort = 0;
afterServerPort = "0";
}
this.ParentForm.ParentForm.SystemConfig2.EthernetAddress = string.Format("{0}.{1}.{2}.{3}",
this.labelHostIP1.Text, this.labelHostIP2.Text, this.labelHostIP3.Text, this.labelHostIP4.Text);
afterServerIP = this.ParentForm.ParentForm.SystemConfig2.EthernetAddress;
this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
this.ParentForm.ParentForm.EthernetClientDisconnect();
this.buttonSave2.Enabled = false;
if (beforeServerIP != afterServerIP)
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.TCPServerIPAddress, "", beforeServerIP, afterServerIP);
if (beforeServerPort != afterServerPort)
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.TCPServerPort, "", beforeServerPort, afterServerPort);
}
private void labelHostPort_Click(object sender, EventArgs e)
{
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelHostPort.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
this.labelHostPort.Text = myKeyPad.StringValue;
this.buttonSave2.Enabled = true;
}
}
private void labelHostIP1_Click(object sender, EventArgs e)
{
string temp = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelHostIP1.Text, 3, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue > 255)
{
temp = "0 ~ 255";
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, temp);
myMsg.ShowDialog();
}
else
{
this.labelHostIP1.Text = myKeyPad.StringValue;
this.buttonSave2.Enabled = true;
}
}
}
private void labelHostIP2_Click(object sender, EventArgs e)
{
string temp = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelHostIP2.Text, 3, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue > 255)
{
temp = "0 ~ 255";
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, temp);
myMsg.ShowDialog();
}
else
{
this.labelHostIP2.Text = myKeyPad.StringValue;
this.buttonSave2.Enabled = true;
}
}
}
private void labelHostIP3_Click(object sender, EventArgs e)
{
string temp = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelHostIP3.Text, 3, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue > 255)
{
temp = "0 ~ 255";
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, temp);
myMsg.ShowDialog();
}
else
{
this.labelHostIP3.Text = myKeyPad.StringValue;
this.buttonSave2.Enabled = true;
}
}
}
private void labelHostIP4_Click(object sender, EventArgs e)
{
string temp = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelHostIP4.Text, 3, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue > 255)
{
temp = "0 ~ 255";
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, temp);
myMsg.ShowDialog();
}
else
{
this.labelHostIP4.Text = myKeyPad.StringValue;
this.buttonSave2.Enabled = true;
}
}
}
private void timerServer_Tick(object sender, EventArgs e)
{
if (this.ParentForm.ParentForm.smartTCPMultiServer.IsStart == true)
{
if (this.labelServerStatus.Text != ">Start")
this.labelServerStatus.Text = ">Start";
this.smartListBoxClientList.ClearAll();
this.labelClientCount.Text = "-";
this.labelConnectedIP.Text = "-";
if (this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList != null)
{
for (int i = 0; i < this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList.Length; i++)
{
this.smartListBoxClientList.AddItem(
this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList[i].strID + ", " +
this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList[i].strIPAddress);
}
this.labelClientCount.Text = this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList.Length.ToString();
this.labelConnectedIP.Text = this.ParentForm.ParentForm.smartTCPMultiServer.ClientInfoList[0].strIPAddress;
}
}
else
{
if (this.labelServerStatus.Text != ">Stop")
this.labelServerStatus.Text = ">Stop";
this.smartListBoxClientList.ClearAll();
this.labelClientCount.Text = "-";
}
}
private void labelLocalPort_Click(object sender, EventArgs e)
{
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelLocalPort.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
this.labelLocalPort.Text = myKeyPad.StringValue;
this.ParentForm.ParentForm.SystemConfig2.EthernetLocalPort = myKeyPad.IntValue;
this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
this.ParentForm.ParentForm.smartTCPMultiServer.Port = myKeyPad.IntValue;
}
}
private void buttonStart_Click(object sender, EventArgs e)
{
string detail = "";
if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 1)
{
detail = "Server";
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = true;
if (string.Compare(this.ParentForm.ParentForm.smartConfigs.IPSettings.DeviceIP, "0.0.0.0") == 0)
{
if (this.labelServerStatus.Text != ">Addr Err")
this.labelServerStatus.Text = ">Addr Err";
this.timerServer.Enabled = false;
}
else
{
this.ParentForm.ParentForm.EthernetServerStart();
if (this.timerServer.Enabled != true)
this.timerServer.Enabled = true;
}
}
else if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 2)
{
detail = "Client";
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = true;
this.ParentForm.ParentForm.EthernetClientConnect();
}
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.TryEthernetStart, detail);
}
private void buttonStop_Click(object sender, EventArgs e)
{
string detail = "";
if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 1)
{
detail = "Server";
this.timerServer.Enabled = false;
this.ParentForm.ParentForm.EthernetServerStop();
if (this.labelServerStatus.Text != ">Stop")
this.labelServerStatus.Text = ">Stop";
}
else if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 2)
{
detail = "Client";
this.ParentForm.ParentForm.EthernetClientDisconnect();
}
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingOperation.TryEthernetStop, detail);
}
private void buttonLocalIP_Click(object sender, EventArgs e)
{
this.ControlEthernetLocalIP.Visible = true;
this.ControlEthernetLocalIP.BringToFront();
this.ControlEthernetLocalIP.DisplayRefresh();
}
private void buttonDisconnectDetection_Click(object sender, EventArgs e)
{
if (this.buttonDisconnectDetection.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
{
this.ParentForm.ParentForm.SystemConfig2.IsDisconnectDetection = true;
this.buttonDisconnectDetection.Text = "Disconnect Detection OFF";
this.ParentForm.ParentForm.IsUsingTimerEthernetPing(true);
}
else
{
this.ParentForm.ParentForm.SystemConfig2.IsDisconnectDetection = false;
this.buttonDisconnectDetection.Text = "Disconnect Detection ON";
this.ParentForm.ParentForm.IsUsingTimerEthernetPing(false);
}
this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
}
private void comboBoxEthernetMode_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.comboBoxEthernetMode.SelectedIndex == 16) // OPC
this.comboBoxEthernetOpMode.Enabled = false;
else
this.comboBoxEthernetOpMode.Enabled = true;
this.buttonSave.Enabled = true;
this.UpdateLabelFormatDisplay();
}
private void comboBoxEthernetOpMode_SelectedIndexChanged(object sender, EventArgs e)
{
this.buttonSave.Enabled = true;
}
private void buttonSave_Click(object sender, EventArgs e)
{
int mode = 0;
string beforeLocalPort = "", afterLocalPort = "";
string beforeOpMode = "", afterOpMode = "";
string beforeComMode = "", afterComMode = "";
beforeLocalPort = this.labelLocalPort.Text;
if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 1)
beforeOpMode = "Server";
else if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 2)
beforeOpMode = "Client";
else
beforeOpMode = "None";
beforeComMode = this.ParentForm.ParentForm.ChildFormMenu.CenterConfiSerial.ReturnCommunicationModeName(this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode);
if (this.comboBoxEthernetMode.SelectedIndex == 16) // OPC
{
DialogFormMessage msg = new DialogFormMessage(26, this.ParentForm.ParentForm.SystemConfig1.Language);
msg.ShowDialog();
this.labelLocalPort.Text = "502";
this.ParentForm.ParentForm.SystemConfig2.EthernetLocalPort = 502;
this.ParentForm.ParentForm.smartTCPMultiServer.Port = 502;
this.comboBoxEthernetOpMode.SelectedIndex = 1;
}
if (this.comboBoxEthernetOpMode.SelectedIndex == 1)
{
this.ParentForm.ParentForm.EthernetClientDisconnect();
this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode = 1;
afterOpMode = "Server";
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = true;
}
else if (this.comboBoxEthernetOpMode.SelectedIndex == 2)
{
this.labelServerStatus.Text = "-";
this.timerServer.Enabled = false;
this.ParentForm.ParentForm.EthernetServerStop();
this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode = 2;
this.ParentForm.ParentForm.EthernetClientDisconnect();
afterOpMode = "Client";
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = true;
}
else
{
this.timerServer.Enabled = false;
this.ParentForm.ParentForm.EthernetServerStop();
this.ParentForm.ParentForm.EthernetClientDisconnect();
this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode = 0;
afterOpMode = "None";
this.buttonStart.Enabled = false;
this.buttonStop.Enabled = false;
this.labelServerStatus.Text = "-";
this.labelClientStatus.Text = "-";
this.labelConnectedIP.Text = "-";
}
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false && mode == ModeSTD2)
mode = (int)Define.E_CommMode.f23_STD2;
else
mode = this.comboBoxEthernetMode.SelectedIndex;
this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode = mode;
afterComMode = this.ParentForm.ParentForm.ChildFormMenu.CenterInforSystem3.ReturnCommunicationModeName(mode);
if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode == (int)Define.E_CommMode.f22_Modbus
|| this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode == (int)Define.E_CommMode.f22_Modbus
|| this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode == (int)Define.E_CommMode.f22_Modbus
|| this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode == (int)Define.E_CommMode.f22_Modbus
|| this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode == (int)Define.E_CommMode.f16_OPC
|| this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode == (int)Define.E_CommMode.f16_OPC
|| this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode == (int)Define.E_CommMode.f16_OPC
|| this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode == (int)Define.E_CommMode.f16_OPC)
this.ParentForm.ParentForm.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
else
this.ParentForm.ParentForm.ChildFormMainDisplay.MainBottomModbusIconAdd(false);
this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2);
this.ButtonAddOnDisplay();
this.buttonSave.Enabled = false;
afterLocalPort = this.labelLocalPort.Text;
if (beforeLocalPort != afterLocalPort)
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.TCPLocalPort, "", beforeLocalPort, afterLocalPort);
if (beforeOpMode != afterOpMode)
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.TCPOpMode, "", beforeOpMode, afterOpMode);
if (beforeComMode != afterComMode)
this.ParentForm.ParentForm.SetTrackingHistoryData(Define.E_TrackingParameter.TCPComMode, "", beforeComMode, afterComMode);
}
private void buttonAddon_Click(object sender, EventArgs e)
{
if (this.ControlHitachi.Visible == false && this.ControlMarkoprint.Visible == false && this.ControlModbusTCP.Visible == false)
this.DisplayBottomSettingMenu();
else
{
this.ControlVisible(false);
}
}
#endregion
}
}