1272 lines
64 KiB
C#
1272 lines
64 KiB
C#
using System;
|
||
using System.Linq;
|
||
using System.Collections.ObjectModel;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Net.Sockets;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Windows.Forms;
|
||
|
||
|
||
using ITC81DB_0H.Forms;
|
||
using ITC81DB_2H_ImageDll;
|
||
using ITC81DB_0H.DialogForms;
|
||
|
||
namespace ITC81DB_0H.Controls
|
||
{
|
||
public partial class ControlCenterConfiSerial : UserControl
|
||
{
|
||
#region Field
|
||
private static int ModeSTD2 = 4;
|
||
|
||
private FormMenu m_ParentForm;
|
||
public ControlConfiSerialUserDefine ControlUserDefine;
|
||
public ControlConfiSerialHitachi ControlHitachi;
|
||
public ControlConfiSerialMarkoPrint ControlMarkoprint;
|
||
public ControlConfiSerialBarcode ControlBarcode;
|
||
public ControlConfiModbus ControlModbusRTU;
|
||
#endregion
|
||
|
||
#region Constructor
|
||
public ControlCenterConfiSerial(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.engBackgroundSerialSaparate));
|
||
|
||
this.smartLabel2.Text = "- U : Under range, R : Reference, O : Over range";
|
||
this.smartLabel3.Text = "- G, Grd : Grade, W : Weight, CNT : Count, Chk : Checksum";
|
||
this.labelTitleTransmissionDelayTime.Text = "Transmission delay time(ms)";
|
||
}
|
||
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
|
||
{
|
||
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.chnBackgroundSerialSeparate));
|
||
|
||
this.smartLabel2.Text = "- U : 低于, R : 通过, O : 超过";
|
||
this.smartLabel3.Text = "- G, Grd : 等级, W : 重量, CNT : 计数, Chk : 校验和";
|
||
this.labelTitleTransmissionDelayTime.Text = "传送延迟时间(ms)";
|
||
}
|
||
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.rusBackgroundSerialSaparate));
|
||
|
||
this.smartLabel2.Text = "- U : Мало, R : Норма, O : Много";
|
||
this.smartLabel3.Text = "- G, Grd : Сортировка, W : Вес, CNT : Подсчет, Chk : Контрольная сумма";
|
||
this.labelTitleTransmissionDelayTime.Text = "Время задержки передачи(ms)";
|
||
}
|
||
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
|
||
{
|
||
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.gerBackgroundSerialSaparate));
|
||
|
||
this.smartLabel2.Text = "- U : Min., R : Bestehen, O : Max.";
|
||
this.smartLabel3.Text = "- G, Grd : Grad, W : Gewicht, CNT : Zahl, Chk : Prüfsumme";
|
||
this.labelTitleTransmissionDelayTime.Text = "Übertragungsverzögerungszeit(ms)";
|
||
|
||
//this.comboBoxSerialMode.Items.Clear();
|
||
//this.comboBoxSerialMode.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
//this.comboBoxSerialMode.Items.Add("Keiner");
|
||
//this.comboBoxSerialMode.Items.Add("STD1");
|
||
//this.comboBoxSerialMode.Items.Add("Fernzugriff");
|
||
//this.comboBoxSerialMode.Items.Add("Drucker");
|
||
//this.comboBoxSerialMode.Items.Add("imaje 9410 OPT1"); // 한맥
|
||
//this.comboBoxSerialMode.Items.Add("imaje 9028 OPT1"); // 한맥
|
||
//this.comboBoxSerialMode.Items.Add("OPT0"); // 대주
|
||
//this.comboBoxSerialMode.Items.Add("imaje 9410 OPT2"); // 한맥
|
||
//this.comboBoxSerialMode.Items.Add("imaje 9028 OPT2"); // 한맥
|
||
//this.comboBoxSerialMode.Items.Add("Hitachi"); // 히타치
|
||
//this.comboBoxSerialMode.Items.Add("MACSA Laser"); // MACSA
|
||
//this.comboBoxSerialMode.Items.Add("Markoprint"); // Markoprint
|
||
//this.comboBoxSerialMode.Items.Add("alphaJET"); // alphaJET
|
||
//this.comboBoxSerialMode.Items.Add("Marking(VJ1510)"); // VJ1510
|
||
//this.comboBoxSerialMode.Items.Add("OPT1"); // 금속검출기(액트라 - 안리쯔)
|
||
//this.comboBoxSerialMode.Items.Add("OPT2"); // NOW1(Now PPI에 사용)
|
||
//this.comboBoxSerialMode.Items.Add("OPC"); // 16
|
||
//this.comboBoxSerialMode.Items.Add("OPT3"); // 셀로닉스 요청 17
|
||
//this.comboBoxSerialMode.Items.Add("HP-200"); // HP-200 18
|
||
////this.comboBoxSerialMode.Items.Add("Barcode");
|
||
////this.comboBoxSerialMode.Items.Add("User Define");
|
||
//this.comboBoxSerialMode.SelectedIndex = 0;
|
||
//this.comboBoxSerialMode.SelectedIndexChanged += new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
}
|
||
else
|
||
{
|
||
this.smartGroupBox1.Image = new Bitmap(images.GetImage(Class1.ButtonImages.korBackgroundSerialSeparate));
|
||
|
||
this.smartLabel2.Text = "- U : Under range, R : Reference, O : Over range";
|
||
this.smartLabel3.Text = "- G, Grd : Grade, W : Weight, CNT : Count, Chk : Checksum";
|
||
this.labelTitleTransmissionDelayTime.Text = "전송 지연시간(ms)";
|
||
}
|
||
}
|
||
private void DefaultSetting()
|
||
{
|
||
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.ControlUserDefine = new ControlConfiSerialUserDefine(this.ParentForm);
|
||
this.Controls.Add(this.ControlUserDefine);
|
||
this.ControlUserDefine.Location = new Point(0, 217);
|
||
|
||
this.ControlBarcode = new ControlConfiSerialBarcode(this.ParentForm);
|
||
this.Controls.Add(this.ControlBarcode);
|
||
this.ControlBarcode.Location = new Point(0, 217);
|
||
|
||
this.ControlModbusRTU = new ControlConfiModbus(this.ParentForm);
|
||
this.Controls.Add(this.ControlModbusRTU);
|
||
this.ControlModbusRTU.Location = new Point(0, 217);
|
||
|
||
this.ControlVisible(false);
|
||
|
||
this.comboBoxSerialBaudRate.Items.Clear();
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.Items.Add(9600);
|
||
this.comboBoxSerialBaudRate.Items.Add(19200);
|
||
this.comboBoxSerialBaudRate.Items.Add(38400);
|
||
this.comboBoxSerialBaudRate.Items.Add(57600);
|
||
this.comboBoxSerialBaudRate.Items.Add(115200);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 0;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
|
||
this.ChangeCommunicationMode();
|
||
|
||
this.labelFormat.Text = "";
|
||
}
|
||
public void ChangeCommunicationMode()
|
||
{
|
||
this.comboBoxSerialMode.Items.Clear();
|
||
this.comboBoxSerialMode.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == true)
|
||
{
|
||
this.comboBoxSerialMode.Items.Add("None");
|
||
this.comboBoxSerialMode.Items.Add("STD1");
|
||
this.comboBoxSerialMode.Items.Add("Remote");
|
||
this.comboBoxSerialMode.Items.Add("Printer");
|
||
this.comboBoxSerialMode.Items.Add("imaje 9410 OPT1"); // 한맥
|
||
this.comboBoxSerialMode.Items.Add("imaje 9028 OPT1"); // 한맥
|
||
this.comboBoxSerialMode.Items.Add("OPT0"); // 대주
|
||
this.comboBoxSerialMode.Items.Add("imaje 9410 OPT2"); // 한맥
|
||
this.comboBoxSerialMode.Items.Add("imaje 9028 OPT2"); // 한맥
|
||
this.comboBoxSerialMode.Items.Add("Hitachi"); // 히타치
|
||
this.comboBoxSerialMode.Items.Add("MACSA Laser"); // MACSA
|
||
this.comboBoxSerialMode.Items.Add("Markoprint"); // Markoprint
|
||
this.comboBoxSerialMode.Items.Add("alphaJET"); // alphaJET
|
||
this.comboBoxSerialMode.Items.Add("Marking(VJ1510)"); // VJ1510
|
||
this.comboBoxSerialMode.Items.Add("OPT1"); // 금속검출기(액트라 - 안리쯔) 14
|
||
this.comboBoxSerialMode.Items.Add("OPT2"); // NOW1(Now PPI에 사용) 15
|
||
this.comboBoxSerialMode.Items.Add("OPC"); // 16
|
||
this.comboBoxSerialMode.Items.Add("OPT3"); // 셀로닉스 요청 17
|
||
this.comboBoxSerialMode.Items.Add("HP-200"); // HP-200 18
|
||
this.comboBoxSerialMode.Items.Add("Smart Jet"); // Smart Jet 19
|
||
this.comboBoxSerialMode.Items.Add("imaje 9410 OPT3"); // 한맥 20
|
||
this.comboBoxSerialMode.Items.Add("-"); // RFID 21
|
||
this.comboBoxSerialMode.Items.Add("Modbus RTU"); // 모드버스 RTU 22
|
||
this.comboBoxSerialMode.Items.Add("STD2"); // STD2 23
|
||
//this.comboBoxSerialMode.Items.Add("Barcode");
|
||
//this.comboBoxSerialMode.Items.Add("User Define");
|
||
}
|
||
else
|
||
{
|
||
this.comboBoxSerialMode.Items.Add("None");
|
||
this.comboBoxSerialMode.Items.Add("STD1");
|
||
this.comboBoxSerialMode.Items.Add("Remote");
|
||
this.comboBoxSerialMode.Items.Add("Printer");
|
||
this.comboBoxSerialMode.Items.Add("STD2"); // STD2 23
|
||
}
|
||
this.comboBoxSerialMode.SelectedIndexChanged += new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
}
|
||
|
||
private void UpdateLabelFormatDisplay()
|
||
{
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false)
|
||
{
|
||
switch (this.comboBoxSerialMode.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.comboBoxSerialMode.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 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.SerialMode.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;
|
||
}
|
||
}
|
||
}
|
||
private void ControlVisible(bool visible)
|
||
{
|
||
this.ControlUserDefine.Visible = visible;
|
||
this.ControlHitachi.Visible = visible;
|
||
this.ControlMarkoprint.Visible = visible;
|
||
this.ControlModbusRTU.Visible = visible;
|
||
//this.ControlBarcode.Visible = visible;
|
||
}
|
||
private void ButtonAddOnDisplay()
|
||
{
|
||
this.ControlVisible(false);
|
||
this.DisplayBottomSettingMenu();
|
||
|
||
if (this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f9_Hitachi
|
||
|| this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f11_Markoprint
|
||
|| this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f16_OPC
|
||
|| this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f22_Modbus_RTU)
|
||
this.buttonAddon.Visible = true;
|
||
else
|
||
this.buttonAddon.Visible = false;
|
||
}
|
||
|
||
private void UpdateSerialParameterDisplay(SystemConfigurationItem1 item, SystemParameter1 parameter)
|
||
{
|
||
int index = 0;
|
||
string value = "";
|
||
|
||
DataStore.MenuBottomConfiguration temp = this.ParentForm.CurrentConfigurationMenu();
|
||
|
||
this.comboBoxSerialBaudRate.Enabled = true;
|
||
this.comboBoxSerialMode.Enabled = true;
|
||
this.ControlBarcode.Visible = false;
|
||
this.comboBoxSerialMode.Enabled = true;
|
||
|
||
switch (temp)
|
||
{
|
||
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
||
#region COM1 Load
|
||
// BaudRate
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = item.SerialCOM1BaudRate;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
|
||
// Mode
|
||
this.comboBoxSerialMode.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false)
|
||
{
|
||
if (item.SerialCOM1Mode == (int)DataStore.SerialMode.f23_STD2)
|
||
this.comboBoxSerialMode.SelectedIndex = ModeSTD2;
|
||
else if (item.SerialCOM1Mode > this.comboBoxSerialMode.Items.Count - 1)
|
||
this.comboBoxSerialMode.SelectedIndex = 0;
|
||
else
|
||
this.comboBoxSerialMode.SelectedIndex = item.SerialCOM1Mode;
|
||
|
||
this.SaveComboBox(this.comboBoxSerialBaudRate.SelectedIndex, this.comboBoxSerialMode.SelectedIndex);
|
||
}
|
||
else
|
||
this.comboBoxSerialMode.SelectedIndex = item.SerialCOM1Mode;
|
||
this.comboBoxSerialMode.SelectedIndexChanged += new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
|
||
this.labelTransmissionDelayTime.Text = item.TransmissionDelayTimeCOM1.ToString();
|
||
|
||
if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode == (int)DataStore.SerialMode.f16_OPC)
|
||
{
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
this.ControlModbusRTU.OPCSettings();
|
||
}
|
||
else if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode == (int)DataStore.SerialMode.f22_Modbus_RTU)
|
||
this.ControlModbusRTU.ModbusRTUDefaultSettings();
|
||
else
|
||
this.ControlModbusRTU.SerialDefaultSettings();
|
||
#endregion
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
||
#region COM3 Load
|
||
if (this.ParentForm.ParentForm.SystemConfig2.Barcode != 0)
|
||
{
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialMode.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
switch (this.ParentForm.ParentForm.SystemConfig2.Barcode)
|
||
{
|
||
case 1:
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 0;
|
||
this.comboBoxSerialMode.SelectedIndex = 0;
|
||
|
||
this.ControlBarcode.Visible = true;
|
||
this.ControlBarcode.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
|
||
this.ControlBarcode.BringToFront();
|
||
break;
|
||
case 2:
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 4;
|
||
this.comboBoxSerialMode.SelectedIndex = 0;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialMode.SelectedIndexChanged += new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
|
||
this.labelTransmissionDelayTime.Text = "0";
|
||
|
||
/////////////////////
|
||
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
this.comboBoxSerialMode.Enabled = false;
|
||
}
|
||
else
|
||
{
|
||
// BaudRate
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = item.SerialCOM3BaudRate;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
|
||
// Mode
|
||
this.comboBoxSerialMode.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false)
|
||
{
|
||
if (item.SerialCOM3Mode == (int)DataStore.SerialMode.f23_STD2)
|
||
this.comboBoxSerialMode.SelectedIndex = ModeSTD2;
|
||
else if (item.SerialCOM3Mode > this.comboBoxSerialMode.Items.Count - 1)
|
||
this.comboBoxSerialMode.SelectedIndex = 0;
|
||
else
|
||
this.comboBoxSerialMode.SelectedIndex = item.SerialCOM3Mode;
|
||
|
||
this.SaveComboBox(this.comboBoxSerialBaudRate.SelectedIndex, this.comboBoxSerialMode.SelectedIndex);
|
||
}
|
||
else
|
||
this.comboBoxSerialMode.SelectedIndex = item.SerialCOM3Mode;
|
||
this.comboBoxSerialMode.SelectedIndexChanged += new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
|
||
this.labelTransmissionDelayTime.Text = this.ParentForm.ParentForm.SystemConfig1.TransmissionDelayTimeCOM3.ToString();
|
||
|
||
if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode == (int)DataStore.SerialMode.f16_OPC) // OPC
|
||
{
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
this.ControlModbusRTU.OPCSettings();
|
||
}
|
||
else if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode == (int)DataStore.SerialMode.f22_Modbus_RTU)
|
||
this.ControlModbusRTU.ModbusRTUDefaultSettings();
|
||
else
|
||
this.ControlModbusRTU.SerialDefaultSettings();
|
||
}
|
||
#endregion
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
||
#region COM4 Load
|
||
// BaudRate
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = item.SerialCOM4BaudRate;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
|
||
// Mode
|
||
this.comboBoxSerialMode.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false)
|
||
{
|
||
if (item.SerialCOM4Mode == (int)DataStore.SerialMode.f23_STD2)
|
||
this.comboBoxSerialMode.SelectedIndex = ModeSTD2;
|
||
else if (item.SerialCOM4Mode > this.comboBoxSerialMode.Items.Count - 1)
|
||
this.comboBoxSerialMode.SelectedIndex = 0;
|
||
else
|
||
this.comboBoxSerialMode.SelectedIndex = item.SerialCOM4Mode;
|
||
|
||
this.SaveComboBox(this.comboBoxSerialBaudRate.SelectedIndex, this.comboBoxSerialMode.SelectedIndex);
|
||
}
|
||
else
|
||
this.comboBoxSerialMode.SelectedIndex = item.SerialCOM4Mode;
|
||
this.comboBoxSerialMode.SelectedIndexChanged += new EventHandler(this.comboBoxSerialMode_SelectedIndexChanged);
|
||
|
||
this.labelTransmissionDelayTime.Text = item.TransmissionDelayTimeCOM4.ToString();
|
||
|
||
if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode == (int)DataStore.SerialMode.f16_OPC) // OPC
|
||
{
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
this.ControlModbusRTU.OPCSettings();
|
||
}
|
||
else if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode == (int)DataStore.SerialMode.f22_Modbus_RTU)
|
||
this.ControlModbusRTU.ModbusRTUDefaultSettings();
|
||
else
|
||
this.ControlModbusRTU.SerialDefaultSettings();
|
||
#endregion
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (this.comboBoxSerialMode.SelectedIndex != 0)
|
||
this.buttonTestSend.Enabled = true;
|
||
else
|
||
this.buttonTestSend.Enabled = false;
|
||
|
||
this.DisplayReceive("");
|
||
this.ButtonAddOnDisplay();
|
||
this.UpdateLabelFormatDisplay();
|
||
}
|
||
private void SaveComboBox(int baudrate, int mode)
|
||
{
|
||
DataStore.MenuBottomConfiguration temp = this.ParentForm.CurrentConfigurationMenu();
|
||
|
||
this.ParentForm.ParentForm.ChangeSerialCOM3FrameBufferSize(1024);
|
||
this.ParentForm.ParentForm.ChangeSerialCOM3ReceiveDetect(SmartX.SmartSerialPort.RECEIVEDETECTTYPE.EVENT_QUEUE);
|
||
|
||
if (this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f16_OPC)
|
||
{
|
||
this.ControlModbusRTU.OPCSettings();
|
||
|
||
#region OPC
|
||
switch (temp)
|
||
{
|
||
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
||
this.ParentForm.ParentForm.CloseSerialCOM1();
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM1BaudRate = 0;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 0;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode = (int)DataStore.SerialMode.f16_OPC;
|
||
this.ParentForm.ParentForm.OpenSerialCOM1();
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
||
this.ParentForm.ParentForm.CloseSerialCOM3();
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate = 0;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 0;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = (int)DataStore.SerialMode.f16_OPC;
|
||
this.ParentForm.ParentForm.OpenSerialCOM3();
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
||
this.ParentForm.ParentForm.CloseSerialCOM4();
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM4BaudRate = 0;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 0;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode = (int)DataStore.SerialMode.f16_OPC;
|
||
this.ParentForm.ParentForm.OpenSerialCOM4();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
#endregion
|
||
}
|
||
else if (this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f21_Impinj_Speedway_R420)
|
||
{
|
||
#region RFID Speedway R420
|
||
switch (temp)
|
||
{
|
||
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
||
this.ParentForm.ParentForm.CloseSerialCOM1();
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 4;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM1BaudRate = 4;
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode = (int)DataStore.SerialMode.f21_Impinj_Speedway_R420;
|
||
this.ParentForm.ParentForm.ChangeSerialCOM1FrameSeparateType(DataStore.SeparateType.ETXONLY);
|
||
this.ParentForm.ParentForm.OpenSerialCOM1();
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
||
this.ParentForm.ParentForm.CloseSerialCOM3();
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 4;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate = 4;
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = (int)DataStore.SerialMode.f21_Impinj_Speedway_R420;
|
||
this.ParentForm.ParentForm.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.ETXONLY);
|
||
this.ParentForm.ParentForm.OpenSerialCOM3();
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
||
this.ParentForm.ParentForm.CloseSerialCOM4();
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged -= new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.comboBoxSerialBaudRate.SelectedIndex = 4;
|
||
this.comboBoxSerialBaudRate.SelectedIndexChanged += new EventHandler(this.comboBoxSerialBaudRate_SelectedIndexChanged);
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM4BaudRate = 4;
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode = (int)DataStore.SerialMode.f21_Impinj_Speedway_R420;
|
||
this.ParentForm.ParentForm.ChangeSerialCOM4FrameSeparateType(DataStore.SeparateType.ETXONLY);
|
||
this.ParentForm.ParentForm.OpenSerialCOM4();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
#endregion
|
||
}
|
||
else
|
||
{
|
||
this.ControlModbusRTU.SerialDefaultSettings();
|
||
|
||
switch (temp)
|
||
{
|
||
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
||
this.ParentForm.ParentForm.CloseSerialCOM1();
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM1BaudRate = baudrate;
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false && mode == ModeSTD2)
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode = (int)DataStore.SerialMode.f23_STD2;
|
||
else
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode = mode;
|
||
this.ParentForm.ParentForm.ChangeSerialCOM1FrameSeparateType(DataStore.SeparateType.STXANDETX);
|
||
this.ParentForm.ParentForm.OpenSerialCOM1();
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
||
this.ParentForm.ParentForm.CloseSerialCOM3();
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM3BaudRate = baudrate;
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false && mode == ModeSTD2)
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = (int)DataStore.SerialMode.f23_STD2;
|
||
else
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode = mode;
|
||
this.ParentForm.ParentForm.ChangeSerialCOM3FrameSeparateType(DataStore.SeparateType.STXANDETX);
|
||
this.ParentForm.ParentForm.OpenSerialCOM3();
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
||
this.ParentForm.ParentForm.CloseSerialCOM4();
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM4BaudRate = baudrate;
|
||
if (this.ParentForm.ParentForm.SystemConfig2.IsCommunicationOption == false && mode == ModeSTD2)
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode = (int)DataStore.SerialMode.f23_STD2;
|
||
else
|
||
this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode = mode;
|
||
this.ParentForm.ParentForm.ChangeSerialCOM4FrameSeparateType(DataStore.SeparateType.STXANDETX);
|
||
this.ParentForm.ParentForm.OpenSerialCOM4();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (this.ParentForm.ParentForm.SystemConfig1.SerialCOM1Mode == (int)DataStore.SerialMode.f22_Modbus_RTU
|
||
|| this.ParentForm.ParentForm.SystemConfig1.SerialCOM3Mode == (int)DataStore.SerialMode.f22_Modbus_RTU
|
||
|| this.ParentForm.ParentForm.SystemConfig1.SerialCOM4Mode == (int)DataStore.SerialMode.f22_Modbus_RTU
|
||
|| this.ParentForm.ParentForm.SystemConfig2.EthernetCommMode == (int)DataStore.EthernetMode.f22_Modbus_TCP)
|
||
this.ParentForm.ParentForm.ChildFormMainDisplay.MainBottomModbusIconAdd(true);
|
||
else
|
||
this.ParentForm.ParentForm.ChildFormMainDisplay.MainBottomModbusIconAdd(false);
|
||
}
|
||
|
||
this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
|
||
}
|
||
|
||
public void DisplayRefresh(SystemStatus status)
|
||
{
|
||
this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.ConfiSerial;
|
||
this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
|
||
this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);
|
||
|
||
this.buttonSave.Enabled = false;
|
||
|
||
this.UpdateSerialParameterDisplay(this.ParentForm.ParentForm.SystemConfig1, this.ParentForm.ParentForm.CurrentSystemParameter1);
|
||
}
|
||
|
||
public void DisplayReceive(string value)
|
||
{
|
||
this.labelReceive.Text = value;
|
||
}
|
||
private void DisplayBottomSettingMenu()
|
||
{
|
||
this.ControlVisible(false);
|
||
|
||
this.buttonTestSend.Enabled = true;
|
||
|
||
if (this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f9_Hitachi)
|
||
{
|
||
this.ControlHitachi.Visible = true;
|
||
this.ControlHitachi.BringToFront();
|
||
this.ControlHitachi.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
|
||
}
|
||
else if (this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f11_Markoprint)
|
||
{
|
||
this.ControlMarkoprint.Visible = true;
|
||
this.ControlMarkoprint.BringToFront();
|
||
this.ControlMarkoprint.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
|
||
}
|
||
else if (this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f22_Modbus_RTU
|
||
|| this.comboBoxSerialMode.SelectedIndex == (int)DataStore.SerialMode.f16_OPC)
|
||
{
|
||
this.ControlModbusRTU.Visible = true;
|
||
this.ControlModbusRTU.BringToFront();
|
||
this.ControlModbusRTU.DisplayRefresh(this.ParentForm.CurrentConfigurationMenu());
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region Event Handler
|
||
private void buttonAddon_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.ControlUserDefine.Visible == false && this.ControlHitachi.Visible == false && this.ControlMarkoprint.Visible == false
|
||
&& this.ControlBarcode.Visible == false && this.ControlModbusRTU.Visible == false)
|
||
this.DisplayBottomSettingMenu();
|
||
else
|
||
{
|
||
this.ControlVisible(false);
|
||
}
|
||
}
|
||
|
||
private void buttonTestSend_Click(object sender, EventArgs e)
|
||
{
|
||
int tempStringLength = 0;
|
||
string tempString = "";
|
||
string str = "";
|
||
bool isTest = true;
|
||
|
||
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.comboBoxSerialMode.SelectedIndex == 0)
|
||
return;
|
||
|
||
switch (this.comboBoxSerialMode.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 == 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 (temp)
|
||
{
|
||
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
||
this.ParentForm.ParentForm.TransferSerialCOM1(this.ParentForm.ParentForm.SendChar(DataStore.CharValue.ENQ));
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
||
this.ParentForm.ParentForm.TransferSerialCOM3(this.ParentForm.ParentForm.SendChar(DataStore.CharValue.ENQ));
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
||
this.ParentForm.ParentForm.TransferSerialCOM4(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; // <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 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 DataStore.MenuBottomConfiguration.SerialCOM1:
|
||
this.ParentForm.ParentForm.TransferSerialCOM1(sb.ToString());
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
||
this.ParentForm.ParentForm.TransferSerialCOM3(sb.ToString());
|
||
break;
|
||
case DataStore.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(" 123");
|
||
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:
|
||
isTest = false;
|
||
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 (temp)
|
||
{
|
||
case DataStore.MenuBottomConfiguration.SerialCOM1:
|
||
if (isTest == true && this.ParentForm.ParentForm.CheckOpenCOM1() == true)
|
||
{
|
||
if (sb.ToString() == "")
|
||
this.ParentForm.ParentForm.TransferDirectSerialCOM1(byteArray);
|
||
else
|
||
this.ParentForm.ParentForm.TransferDirectSerialCOM1(sb.ToString());
|
||
}
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM3:
|
||
if (isTest == true && this.ParentForm.ParentForm.CheckOpenCOM3() == true)
|
||
{
|
||
if (sb.ToString() == "")
|
||
this.ParentForm.ParentForm.TransferDirectSerialCOM3(byteArray);
|
||
else
|
||
this.ParentForm.ParentForm.TransferDirectSerialCOM3(sb.ToString());
|
||
}
|
||
break;
|
||
case DataStore.MenuBottomConfiguration.SerialCOM4:
|
||
if (isTest == true && this.ParentForm.ParentForm.CheckOpenCOM4() == true)
|
||
{
|
||
if (sb.ToString() == "")
|
||
this.ParentForm.ParentForm.TransferDirectSerialCOM4(byteArray);
|
||
else
|
||
this.ParentForm.ParentForm.TransferDirectSerialCOM4(sb.ToString());
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void buttonSave_Click(object sender, EventArgs e)
|
||
{
|
||
DataStore.MenuBottomConfiguration temp = this.ParentForm.CurrentConfigurationMenu();
|
||
|
||
if (this.comboBoxSerialMode.SelectedIndex != 0)
|
||
this.buttonTestSend.Enabled = true;
|
||
else
|
||
this.buttonTestSend.Enabled = false;
|
||
|
||
this.SaveComboBox(this.comboBoxSerialBaudRate.SelectedIndex, this.comboBoxSerialMode.SelectedIndex);
|
||
|
||
this.ButtonAddOnDisplay();
|
||
this.buttonSave.Enabled = false;
|
||
}
|
||
|
||
private void comboBoxSerialBaudRate_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
this.buttonSave.Enabled = true;
|
||
}
|
||
private void comboBoxSerialMode_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
if(this.comboBoxSerialMode.SelectedIndex == 16) // OPC
|
||
this.comboBoxSerialBaudRate.Enabled = false;
|
||
else
|
||
this.comboBoxSerialBaudRate.Enabled = true;
|
||
|
||
this.buttonSave.Enabled = true;
|
||
|
||
this.UpdateLabelFormatDisplay();
|
||
}
|
||
|
||
private void labelTransmissionDelayTime_Click(object sender, EventArgs e)
|
||
{
|
||
string value = "";
|
||
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelTransmissionDelayTime.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.labelTransmissionDelayTime.Text = myKeyPad.StringValue;
|
||
|
||
value = Helper.StringZeroFillDigits4(this.labelTransmissionDelayTime.Text);
|
||
|
||
DataStore.MenuBottomConfiguration temp = this.ParentForm.CurrentConfigurationMenu();
|
||
if (temp == DataStore.MenuBottomConfiguration.SerialCOM1)
|
||
this.ParentForm.ParentForm.SystemConfig1.TransmissionDelayTimeCOM1 = myKeyPad.IntValue;
|
||
else if(temp == DataStore.MenuBottomConfiguration.SerialCOM3)
|
||
this.ParentForm.ParentForm.SystemConfig1.TransmissionDelayTimeCOM3 = myKeyPad.IntValue;
|
||
else if(temp == DataStore.MenuBottomConfiguration.SerialCOM4)
|
||
this.ParentForm.ParentForm.SystemConfig1.TransmissionDelayTimeCOM4 = myKeyPad.IntValue;
|
||
|
||
this.ParentForm.ParentForm.SaveSystemConfigurationFile1(this.ParentForm.ParentForm.SystemConfig1);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|