3.25 测试

改端子扫码,产线页面,主页
This commit is contained in:
zhougf committed 2025-03-25 21:22:36 +08:00
1 parent bd70f38e1a
commit 083c4ec3ac
16 files changed
+1016 -877

No files matched your search

+80 -15
View File
@@ -24,7 +24,7 @@ namespace WindowsFormsApp1
public ScanForm_DZ()
{
InitializeComponent();
Init.ScanPort.DataReceived += SerialPort_DataReceived;
Init.ScanPort.DataReceived += SerialPort_DataReceived_DZ;
端子1.Text = "";
端子2.Text = "";
端子3.Text = "";
@@ -33,6 +33,18 @@ namespace WindowsFormsApp1
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
//Init.ScanPort.DataReceived -= SerialPort_DataReceived_DZ;
//if (string.IsNullOrEmpty(端子1.Text)
// || string.IsNullOrEmpty(端子2.Text)
// || string.IsNullOrEmpty(端子3.Text))
//{
// //MessageBox.Show($"有端子未扫描!");
// //return;
//}
//else
//{
// this.Close();
//}
this.Close();
}
@@ -54,10 +66,11 @@ namespace WindowsFormsApp1
}
}
public void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
public void SerialPort_DataReceived_DZ(object sender, SerialDataReceivedEventArgs e)
{
try
{
var PlcData = new plcdata();
if (!Init.ScanPort.IsOpen)
{
Init.ScanPort?.Open();
@@ -75,14 +88,15 @@ namespace WindowsFormsApp1
return;
}
SQLiteHelper<t_keyvalue> sQLiteHelper_key = new db.SQLiteHelper<t_keyvalue>();
var key_sqlresult = sQLiteHelper_key.QueryAll();
if (string.IsNullOrWhiteSpace(端子1.Text))
{
this.Invoke(new Action(() =>
{
端子1.Text = barcode;
}));
var result = ApiClient.CallFunctionByName("nowinterface.code", null, new otherdata() { JS_SN = barcode });
var result = ApiClient.CallFunctionByName("SN_FeedingCheck", PlcData, new otherdata() { JS_SN = barcode });
if (result.Success)
{
this.Invoke(new Action(() =>
@@ -90,7 +104,7 @@ namespace WindowsFormsApp1
端子1校验.Text = "校验OK";
}));
//继续调用接口
var result2 = ApiClient.CallFunctionByName("nowinterface.code", null, new otherdata() { JS_SN = barcode });
var result2 = ApiClient.CallFunctionByName("Link_Comp", PlcData, new otherdata() { JS_SN = barcode });
if (result2.Success)
{
this.Invoke(new Action(() =>
@@ -98,6 +112,13 @@ namespace WindowsFormsApp1
端子1结果.Text = "绑定OK";
button1.Visible = false;
}));
// 写数据到 主页的barcode 数据库改,缓存改
var txt = Init.t_Keyvalues.FirstOrDefault(a => a.key == "Barcode1");
txt.value = 端子1.Text;
var code = key_sqlresult.Data.First(x => x.key == txt.key);
code.value = 端子1.Text;
sQLiteHelper_key.Update(code);
}
else
{
@@ -121,7 +142,7 @@ namespace WindowsFormsApp1
{
端子2.Text = barcode;
}));
var result = ApiClient.CallFunctionByName("nowinterface.code", null, new otherdata() { JS_SN = barcode });
var result = ApiClient.CallFunctionByName("SN_FeedingCheck", PlcData, new otherdata() { JS_SN = barcode });
if (result.Success)
{
this.Invoke(new Action(() =>
@@ -130,10 +151,30 @@ namespace WindowsFormsApp1
}));
//继续调用接口
this.Invoke(new Action(() =>
var result2 = ApiClient.CallFunctionByName("Link_Comp", PlcData, new otherdata() { JS_SN = barcode });
if (result2.Success)
{
button2.Visible = false;
}));
this.Invoke(new Action(() =>
{
端子2结果.Text = "绑定OK";
button2.Visible = false;
}));
// 写数据到 主页的barcode 数据库改,缓存改
var txt = Init.t_Keyvalues.FirstOrDefault(a => a.key == "Barcode2");
txt.value = 端子2.Text;
var code = key_sqlresult.Data.First(x => x.key == txt.key);
code.value = 端子2.Text;
sQLiteHelper_key.Update(code);
}
else
{
this.Invoke(new Action(() =>
{
端子2结果.Text = "绑定NG";
}));
}
}
else
{
@@ -149,7 +190,7 @@ namespace WindowsFormsApp1
{
端子3.Text = barcode;
}));
var result = ApiClient.CallFunctionByName("nowinterface.code", null, new otherdata() { JS_SN = barcode });
var result = ApiClient.CallFunctionByName("SN_FeedingCheck", PlcData, new otherdata() { JS_SN = barcode });
if (result.Success)
{
this.Invoke(new Action(() =>
@@ -157,11 +198,30 @@ namespace WindowsFormsApp1
端子3校验.Text = "校验OK";
}));
//继续调用接口
this.Invoke(new Action(() =>
var result2 = ApiClient.CallFunctionByName("Link_Comp", PlcData, new otherdata() { JS_SN = barcode });
if (result2.Success)
{
button3.Visible = false;
}));
this.Invoke(new Action(() =>
{
端子3结果.Text = "绑定OK";
button3.Visible = false;
}));
// 写数据到 主页的barcode 数据库改,缓存改
var txt = Init.t_Keyvalues.FirstOrDefault(a => a.key == "Barcode3");
txt.value = 端子3.Text;
var code = key_sqlresult.Data.First(x => x.key == txt.key);
code.value = 端子3.Text;
sQLiteHelper_key.Update(code);
}
else
{
this.Invoke(new Action(() =>
{
端子3结果.Text = "绑定NG";
}));
}
}
else
{
@@ -169,7 +229,7 @@ namespace WindowsFormsApp1
{
端子3校验.Text = "校验NG";
}));
}
}
@@ -209,5 +269,10 @@ namespace WindowsFormsApp1
{
端子3.Text = "";
}
private void ScanForm_DZ_FormClosed(object sender, FormClosedEventArgs e)
{
FormHelp.RemoveAllEventHandlers(Init.ScanPort, "DataReceived");
}
}
}