LL18-25063001:得辉达定制增加MES过站检测功能
This commit is contained in:
@@ -20,6 +20,8 @@ using NPOI.SS.UserModel;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
|
||||
using System.Runtime.InteropServices;
|
||||
using DHDMesApi;
|
||||
using DHDMesApi.Data;
|
||||
|
||||
namespace C_Windows_1
|
||||
{
|
||||
@@ -66,6 +68,13 @@ namespace C_Windows_1
|
||||
public bool checkINI; //选中ini导出
|
||||
public bool checkTxt; //选中txt导出
|
||||
|
||||
//得辉达MES信息
|
||||
public string strURL = "http://192.168.1.21:8080/PlMesRf/RfEntry.jws?wsdl"; //MES服务器地址
|
||||
public string productionOrder = ""; //生产工单
|
||||
public string lineNumber = ""; //产线编号
|
||||
public string processNumber = ""; //工序号
|
||||
public string tester = ""; //测试员
|
||||
public string machineNumber = ""; //测试设备编号
|
||||
public Form1()
|
||||
{
|
||||
f1 = this;
|
||||
@@ -937,7 +946,6 @@ namespace C_Windows_1
|
||||
button2.BackColor = Color.White;
|
||||
button3.BackColor = Color.White;
|
||||
button4.BackColor = Color.White;
|
||||
checkBox1.Checked = true;
|
||||
pictureBox1.BackColor = Color.Green;
|
||||
//Scancode.Checked = true;
|
||||
//修改密码ToolStripMenuItem.Enabled = false;
|
||||
@@ -1714,22 +1722,18 @@ namespace C_Windows_1
|
||||
//启动仪器
|
||||
private void BtnStart_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool bStart = true;
|
||||
try
|
||||
{
|
||||
//if (string.IsNullOrEmpty(Form1.f1.CodeLength.Text))
|
||||
//{
|
||||
// MessageBox.Show("请设定条码长度", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
|
||||
//}
|
||||
//if (Convert.ToInt32(Form1.f1.CodeLength.Text) <= 2)
|
||||
//{
|
||||
// MessageBox.Show("条码长度设置错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
|
||||
//}
|
||||
|
||||
//Code.Focus();
|
||||
workstation = (int)yiqi.start;
|
||||
|
||||
|
||||
|
||||
//检测设备是否已过站
|
||||
if (checkBox2.Checked)
|
||||
{
|
||||
bStart = MesCheck(Code.Text);
|
||||
}
|
||||
if (bStart)
|
||||
{
|
||||
workstation = (int)yiqi.start;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -2598,6 +2602,25 @@ namespace C_Windows_1
|
||||
checkBox1.Checked = Convert.ToBoolean(regName.GetValue("codelengthcheck"));
|
||||
}
|
||||
|
||||
if (regName.GetValue("codeRepeatCheck") is null)
|
||||
{
|
||||
checkCodeRepeat.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
checkCodeRepeat.Checked = Convert.ToBoolean(regName.GetValue("codeRepeatCheck"));
|
||||
}
|
||||
|
||||
if (regName.GetValue("codeTestCheck") is null)
|
||||
{
|
||||
checkBox2.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
checkBox2.Checked = Convert.ToBoolean(regName.GetValue("codeTestCheck"));
|
||||
}
|
||||
|
||||
|
||||
if (regName.GetValue("Baudrate") is null)
|
||||
{
|
||||
Baudrate.Text = "9600";
|
||||
@@ -2764,6 +2787,38 @@ namespace C_Windows_1
|
||||
{
|
||||
CeckScanning.Checked = Convert.ToBoolean(regName.GetValue("CeckScanning").ToString());
|
||||
}
|
||||
|
||||
//读取MES信息
|
||||
var regVal = regName.GetValue("productionOrder");
|
||||
if (regVal != null)
|
||||
{
|
||||
productionOrder = regVal.ToString();
|
||||
}
|
||||
regVal = regName.GetValue("processNumber");
|
||||
if (regVal != null)
|
||||
{
|
||||
processNumber = regVal.ToString();
|
||||
}
|
||||
regVal = regName.GetValue("machineNumber");
|
||||
if (regVal != null)
|
||||
{
|
||||
machineNumber = regVal.ToString();
|
||||
}
|
||||
regVal = regName.GetValue("lineNumber");
|
||||
if (regVal != null)
|
||||
{
|
||||
lineNumber = regVal.ToString();
|
||||
}
|
||||
regVal = regName.GetValue("tester");
|
||||
if (regVal != null)
|
||||
{
|
||||
tester = regVal.ToString();
|
||||
}
|
||||
regVal = regName.GetValue("URL");
|
||||
if (regVal != null)
|
||||
{
|
||||
strURL = regVal.ToString();
|
||||
}
|
||||
regName.Close();
|
||||
}
|
||||
|
||||
@@ -2782,24 +2837,21 @@ namespace C_Windows_1
|
||||
//}
|
||||
return encode.GetString(_bytes);
|
||||
}
|
||||
|
||||
|
||||
private void SetcheckBox1(bool check)
|
||||
/// <summary>
|
||||
/// 打开注册表 SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set
|
||||
/// </summary>
|
||||
private RegistryKey openRegedit()
|
||||
{
|
||||
RegistryKey regName;
|
||||
|
||||
regName = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set", true);
|
||||
|
||||
if (regName is null)
|
||||
{
|
||||
regName = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\PMD\\1.0\\User-LL18-Set");
|
||||
}
|
||||
|
||||
regName.SetValue("codelengthcheck", check);
|
||||
regName.Close();
|
||||
return regName;
|
||||
}
|
||||
|
||||
|
||||
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
//if (checkBox1.Checked)
|
||||
@@ -2809,14 +2861,12 @@ namespace C_Windows_1
|
||||
// Code.ResetText();
|
||||
// Code.Focus();
|
||||
// }
|
||||
if (checkBox1.Checked)
|
||||
{
|
||||
SetcheckBox1(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetcheckBox1(false);
|
||||
}
|
||||
RegistryKey regName;
|
||||
|
||||
regName = openRegedit();
|
||||
|
||||
regName.SetValue("codelengthcheck", checkBox1.Checked);
|
||||
regName.Close();
|
||||
}
|
||||
private void Setcodecheck()
|
||||
{
|
||||
@@ -2956,6 +3006,13 @@ namespace C_Windows_1
|
||||
{
|
||||
pictureBox1.BackColor = Color.Red;
|
||||
}
|
||||
|
||||
RegistryKey regName;
|
||||
|
||||
regName = openRegedit();
|
||||
|
||||
regName.SetValue("codeTestCheck", checkBox2.Checked);
|
||||
regName.Close();
|
||||
}
|
||||
|
||||
private void strlinename_TextChanged(object sender, EventArgs e)
|
||||
@@ -3002,32 +3059,27 @@ namespace C_Windows_1
|
||||
{
|
||||
this.codecheck.Text = "21";
|
||||
}
|
||||
bool flag2 = this.Code.TextLength > 0;
|
||||
if (flag2)
|
||||
//条码长度检测
|
||||
if (checkBox1.Checked && this.Code.TextLength != int.Parse(this.CodeLength.Text))
|
||||
{
|
||||
MessageBox.Show(string.Format("条形码长度错误!当前条码长度:{0},设置长度为:{1}", this.Code.Text.Length, this.CodeLength.Text));
|
||||
this.Code.ResetText();
|
||||
this.Code.Focus();
|
||||
}
|
||||
//条码重复检测
|
||||
if (checkCodeRepeat.Checked)
|
||||
{
|
||||
int Count = BarcodeInfo.QueryBarcodeCount(Code.Text);
|
||||
if (Count > 0)
|
||||
{
|
||||
|
||||
this.Code.ResetText();
|
||||
this.Code.Focus();
|
||||
MessageBox.Show("条形码重码,请检查");
|
||||
}
|
||||
bool flag3 = this.Code.TextLength == int.Parse(this.CodeLength.Text) && this.checkBox1.Checked;
|
||||
if (flag3)
|
||||
if (Code.TextLength == int.Parse(this.CodeLength.Text))
|
||||
{
|
||||
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
BarcodeInfo.InsertBarcodeData(time, Code.Text, "", "", "", "", "", "");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Code.TextLength > 0&& checkBox1.Checked)
|
||||
{
|
||||
MessageBox.Show(string.Format("条形码长度错误!当前条码长度:{0},设置长度为:{1}", this.Code.Text.Length, this.CodeLength.Text));
|
||||
this.Code.ResetText();
|
||||
this.Code.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3044,7 +3096,7 @@ namespace C_Windows_1
|
||||
string text4;
|
||||
string text5;
|
||||
|
||||
text = this.PreCode1.Text;
|
||||
text = this.Code.Text;
|
||||
text2 = this.strstation.Text;
|
||||
text3 = this.strlocation.Text;
|
||||
text4 = this.strbatch.Text;
|
||||
@@ -3175,23 +3227,34 @@ namespace C_Windows_1
|
||||
|
||||
private void Form1_Activated(object sender, EventArgs e)
|
||||
{
|
||||
//PreCode1.Focus();
|
||||
Code.Focus();
|
||||
}
|
||||
|
||||
private void PreCode1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (PreCode1.Text.Length > 0)
|
||||
{
|
||||
timerCH1.Stop();
|
||||
timerCH1.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void label33_Click(object sender, EventArgs e)
|
||||
{
|
||||
//CreateFile();
|
||||
}
|
||||
private void checkCodeRepeat_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
RegistryKey regName;
|
||||
|
||||
regName = openRegedit();
|
||||
|
||||
regName.SetValue("codeRepeatCheck", checkCodeRepeat.Checked);
|
||||
regName.Close();
|
||||
}
|
||||
|
||||
private void mESSetToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
MESConfig mes = new MESConfig();
|
||||
mes.productionOrder.Text = productionOrder;
|
||||
mes.processNumber.Text = processNumber;
|
||||
mes.machineNumber.Text = machineNumber;
|
||||
mes.lineNumber.Text = lineNumber;
|
||||
mes.tester.Text = tester;
|
||||
mes.URL.Text = strURL;
|
||||
OpenForm(mes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 16进制格式字符串转字节数组
|
||||
@@ -3213,5 +3276,30 @@ namespace C_Windows_1
|
||||
|
||||
return returnBytes;
|
||||
}
|
||||
|
||||
//过站检测
|
||||
private bool MesCheck(string sCode)
|
||||
{
|
||||
//string sData = processNumber + "@" + lineNumber + "@" + processNumber + "@" +
|
||||
// tester + "@" + machineNumber + "@" + sCode;
|
||||
|
||||
//string sResponse = MESInfo.HttpPost(strURL, sData);
|
||||
|
||||
string sResponse = "";
|
||||
|
||||
try
|
||||
{
|
||||
sResponse = DHDMes_IFLYTEK_Data.GetAllData(sCode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
sResponse = e.Message;
|
||||
}
|
||||
|
||||
textBox3.Text = sResponse;
|
||||
|
||||
return sResponse.Contains("OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user