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_0H_ImageDll; using ITC81DB_0H.DialogForms; using ITC81DB_0H.Forms; namespace ITC81DB_0H.Controls { public partial class ControlCenterConfiEthernet : UserControl { #region Field private int m_ModeSTD2; private FormMenu m_ParentForm; public ControlConfiEthernetLocalIP ControlEthernetLocalIP; public ControlConfiSerialHitachi ControlHitachi; public ControlConfiSerialMarkoPrint ControlMarkoprint; #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; } } public int ModeSTD2 { get { return this.m_ModeSTD2; } set { this.m_ModeSTD2 = 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 == DataStore.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 == DataStore.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 == DataStore.LanguageID.Czech) { } else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.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 == DataStore.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.ModeSTD2 = 4; 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("-"); // 모드버스 TCP 22 this.comboBoxEthernetMode.Items.Add("STD2"); // STD2 23 } 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 = "label\\1234.txt,W[6],Unit[1],"; 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)DataStore.EthernetMode.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; 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; } } private void ControlVisible(bool visible) { this.ControlHitachi.Visible = visible; this.ControlMarkoprint.Visible = visible; } private void DisplayBottomSettingMenu() { this.ControlVisible(false); this.buttonTestSend.Enabled = true; if (this.comboBoxEthernetMode.SelectedIndex == 9) { this.ControlHitachi.Visible = true; this.ControlHitachi.BringToFront(); this.ControlHitachi.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu()); } else if (this.comboBoxEthernetMode.SelectedIndex == 11) { this.ControlMarkoprint.Visible = true; this.ControlMarkoprint.BringToFront(); this.ControlMarkoprint.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu()); } else { } } public void DisplayRefresh(SystemStatus status) { this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.ConfiEthernet; this.ParentForm.ParentForm.SetDisplayMode(DataStore.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)DataStore.EthernetMode.f23_STD2) this.comboBoxEthernetMode.SelectedIndex = this.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(); 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(); 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(); DataStore.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(Helper.StringZeroFillDigits6(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(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 == DataStore.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(DataStore.CharValue.ENQ)); } } break; case 2: this.ParentForm.ParentForm.EthernetWeightData(this.ParentForm.ParentForm.SendChar(DataStore.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 == DataStore.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; // 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("" + fileName + "" + @""); 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(""); for (int i = 0; i < bytes.Length; i++) { byteArray[i + length] = bytes[i]; } length = length + bytes.Length; bytes = new UTF8Encoding().GetBytes(""); 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; default: break; } #region 사용안함 //else if (this.comboBoxSerialMode.SelectedIndex == 4) // Barcode //{ // return; //} //else if (this.comboBoxSerialMode.SelectedIndex == 5) // User Define //{ // switch (temp) // { // case DataStore.MenuBottomConfiguration.SerialCOM1: // sb.Append(this.ControlUserDefine.ConvertProtocol((int)DataStore.SerialNumber.SerialCOM1)); // break; // case DataStore.MenuBottomConfiguration.SerialCOM3: // sb.Append(this.ControlUserDefine.ConvertProtocol((int)DataStore.SerialNumber.SerialCOM3)); // break; // case DataStore.MenuBottomConfiguration.SerialCOM4: // sb.Append(this.ControlUserDefine.ConvertProtocol((int)DataStore.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) { try { this.ParentForm.ParentForm.SystemConfig2.EthernetPort = int.Parse(this.labelHostPort.Text); } catch { this.ParentForm.ParentForm.SystemConfig2.EthernetPort = 0; } this.ParentForm.ParentForm.SystemConfig2.EthernetAddress = string.Format("{0}.{1}.{2}.{3}", this.labelHostIP1.Text, this.labelHostIP2.Text, this.labelHostIP3.Text, this.labelHostIP4.Text); this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2); this.ParentForm.ParentForm.EthernetClientDisconnect(); this.buttonSave2.Enabled = false; } 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) { if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 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.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 2) { this.buttonStart.Enabled = true; this.buttonStop.Enabled = true; this.ParentForm.ParentForm.EthernetClientConnect(); } } private void buttonStop_Click(object sender, EventArgs e) { if (this.ParentForm.ParentForm.SystemConfig2.EthernetOperationMode == 1) { 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) { this.ParentForm.ParentForm.EthernetClientDisconnect(); } } private void buttonLocalIP_Click(object sender, EventArgs e) { this.ControlEthernetLocalIP.Visible = true; this.ControlEthernetLocalIP.BringToFront(); this.ControlEthernetLocalIP.DisplayRefresh(); } 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; 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; 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(); 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; this.buttonStart.Enabled = false; this.buttonStop.Enabled = false; this.labelServerStatus.Text = "-"; this.labelClientStatus.Text = "-"; this.labelConnectedIP.Text = "-"; } if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false) { if (this.comboBoxEthernetMode.SelectedIndex == this.ModeSTD2) mode = (int)DataStore.SerialMode.f23_STD2; } else mode = this.comboBoxEthernetMode.SelectedIndex; this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode = mode; this.ParentForm.ParentForm.SaveSystemConfigurationFile2(this.ParentForm.ParentForm.SystemConfig2); this.buttonSave.Enabled = false; } private void buttonAddon_Click(object sender, EventArgs e) { if (this.ControlHitachi.Visible == false && this.ControlMarkoprint.Visible == false) this.DisplayBottomSettingMenu(); else { this.ControlVisible(false); } } #endregion } }