25103101 加了连续测试及次数,验证ok。
This commit is contained in:
588
SLC1-N/Form1.cs
588
SLC1-N/Form1.cs
@@ -60,6 +60,15 @@ namespace SLC1_N
|
||||
|
||||
ProductionRecord m_production = new ProductionRecord(); // 产能记录
|
||||
|
||||
public bool m_ContinueTest; // 连续测试
|
||||
public int m_ContinueTestCount; // 连续次数
|
||||
|
||||
// 测试次数
|
||||
private int CH1testCount = 0;
|
||||
private int CH2testCount = 0;
|
||||
private int CH3testCount = 0;
|
||||
private int CH4testCount = 0;
|
||||
|
||||
public FileSave filesave; // 保存文件设置
|
||||
public static bool MESswitch = false; // MES开关
|
||||
|
||||
@@ -128,7 +137,7 @@ namespace SLC1_N
|
||||
|
||||
// 发送扫码启动
|
||||
timer_SaomaStart.Interval = 500;
|
||||
timer_SaomaStart.Start();
|
||||
//timer_SaomaStart.Start();
|
||||
|
||||
// 间隔8S清除消息框
|
||||
if (lb_User.Text == "操作员")
|
||||
@@ -265,6 +274,10 @@ namespace SLC1_N
|
||||
mxlLog.Instance.IsWarningEnabled = jsconfig.GetValue<bool>("IsWarningEnabled", false);
|
||||
mxlLog.Instance.IsXXXEnabled = jsconfig.GetValue<bool>("IsXXXEnabled", false);
|
||||
|
||||
// 连续测试/次数
|
||||
m_ContinueTest = jsconfig.GetValue<bool>("chk_ContinueTest", true);
|
||||
m_ContinueTestCount = jsconfig.GetValue<int>("tb_ContinueTestCount", 1);
|
||||
|
||||
// MES开关
|
||||
MESswitch = jsconfig.GetValue<bool>("MESswitch", false);
|
||||
if (MESswitch)
|
||||
@@ -1187,8 +1200,9 @@ namespace SLC1_N
|
||||
|
||||
case (int)yiqi.rst:
|
||||
{
|
||||
pb_CH1progressBar.Value = 0; // 复位进度条置为0
|
||||
SetProgressBar(pb_CH1progressBar, 0); // 复位进度条置为0
|
||||
SetLabelText(lb_CH1_Status, "复位");
|
||||
CH1testCount = 0; // 重置测试次数
|
||||
LL28CH1client.writeCoil("1", true);
|
||||
ch1workstation = (int)yiqi.standby;
|
||||
}
|
||||
@@ -1206,9 +1220,9 @@ namespace SLC1_N
|
||||
+ Convert.ToInt32(LL28CH1client.ArrRegister[9] / 10.0); // 排气时间
|
||||
|
||||
// 配置进度条
|
||||
pb_CH1progressBar.Value = 0;
|
||||
pb_CH1progressBar.Maximum = (CH1progressbar + 1) * 10; // 补偿1秒
|
||||
|
||||
SetProgressBar(pb_CH1progressBar, 0);
|
||||
SetProgressBarMax(pb_CH1progressBar, (CH1progressbar + 1) * 10); // 补偿1秒
|
||||
|
||||
// 设备运行状态
|
||||
//Console.WriteLine($"prepare-设备运行状态: {LL28CH1client.ArrCoil[2]}");
|
||||
if (LL28CH1client.ArrCoil[2])
|
||||
@@ -1285,12 +1299,12 @@ namespace SLC1_N
|
||||
|
||||
// 进度条
|
||||
int pb_value = pb_CH1progressBar.Value + 5;
|
||||
pb_CH1progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH1progressBar, pb_value);
|
||||
|
||||
if (pb_value >= pb_CH1progressBar.Maximum)
|
||||
{
|
||||
pb_value = pb_CH1progressBar.Maximum;
|
||||
pb_CH1progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH1progressBar, pb_value);
|
||||
}
|
||||
|
||||
// 设备运行状态
|
||||
@@ -1321,7 +1335,7 @@ namespace SLC1_N
|
||||
}
|
||||
else
|
||||
{
|
||||
pb_CH1progressBar.Value = 0;
|
||||
SetProgressBar(pb_CH1progressBar, 0);
|
||||
ch1workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
@@ -1360,13 +1374,11 @@ namespace SLC1_N
|
||||
bool result = false;
|
||||
if (testresult == 1)
|
||||
{
|
||||
m_production.AddOK();
|
||||
SetLabelText(lb_CH1_Result, "OK", Color.Green);
|
||||
result = true;
|
||||
}
|
||||
else if (testresult == 2)
|
||||
{
|
||||
m_production.AddNG();
|
||||
SetLabelText(lb_CH1_Result, "NG", Color.Red);
|
||||
result = false;
|
||||
}
|
||||
@@ -1374,56 +1386,91 @@ namespace SLC1_N
|
||||
{
|
||||
SetLabelText(lb_CH1_Result, "");
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
//Console.WriteLine($"finish-结果: {testresult}");
|
||||
|
||||
// 设备运行状态-停止
|
||||
//Console.WriteLine($"finish-设备运行状态: {LL28CH1client.ArrCoil[2]}");
|
||||
if (!LL28CH1client.ArrCoil[2])
|
||||
if (LL28CH1client.ArrCoil[2] == false)
|
||||
{
|
||||
pb_CH1progressBar.Value = pb_CH1progressBar.Maximum;
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(1, lb_CH1Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH1MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH1MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH1MainMessage, $"CH1 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
SetProgressBar(pb_CH1progressBar, pb_CH1progressBar.Maximum);
|
||||
|
||||
// 表格
|
||||
DataGridView1.Invoke(new System.Action<int, bool, string>(Display),
|
||||
1, result, lb_CH1Code.Text);
|
||||
|
||||
// 文件
|
||||
CreateFile(1, result, lb_CH1Code.Text);
|
||||
bool testfinish = false; // 测试结束标志位
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
// 连续测试
|
||||
if (result == false) // NG直接视为本次测试结束
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
testfinish = true;
|
||||
}
|
||||
else if (m_ContinueTest) // 开了连续
|
||||
{
|
||||
CH1testCount++;
|
||||
if (CH1testCount >= m_ContinueTestCount) // 测试次数满足
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(10, 0);
|
||||
mxlLog.Instance.Info($"CH1清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH1清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
testfinish = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(150);
|
||||
ch1workstation = (int)yiqi.start;
|
||||
}
|
||||
}
|
||||
else if (m_ContinueTest == false) // 没开连续测试直接视为本次测试结束
|
||||
{
|
||||
testfinish = true;
|
||||
}
|
||||
|
||||
lb_CH1Code.Text = "";
|
||||
ch1workstation = (int)yiqi.standby;
|
||||
if(testfinish) // 该产品测试完成
|
||||
{
|
||||
if(result)
|
||||
{
|
||||
m_production.AddOK();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_production.AddNG();
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
// 文件
|
||||
CreateFile(1, result, lb_CH1Code.Text);
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(1, lb_CH1Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH1MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH1MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH1MainMessage, $"CH1 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(10, 0);
|
||||
mxlLog.Instance.Info($"CH1清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH1清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CH1testCount = 0; // 重置测试次数
|
||||
lb_CH1Code.Text = "";
|
||||
ch1workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1451,8 +1498,9 @@ namespace SLC1_N
|
||||
|
||||
case (int)yiqi.rst:
|
||||
{
|
||||
pb_CH2progressBar.Value = 0; // 复位进度条置为0
|
||||
SetProgressBar(pb_CH2progressBar, 0); // 复位进度条置为0
|
||||
SetLabelText(lb_CH2_Status, "复位");
|
||||
CH2testCount = 0; // 重置测试次数
|
||||
LL28CH2client.writeCoil("1", true);
|
||||
ch2workstation = (int)yiqi.standby;
|
||||
}
|
||||
@@ -1470,8 +1518,8 @@ namespace SLC1_N
|
||||
+ Convert.ToInt32(LL28CH2client.ArrRegister[9] / 10.0); // 排气时间
|
||||
|
||||
// 配置进度条
|
||||
pb_CH2progressBar.Value = 0;
|
||||
pb_CH2progressBar.Maximum = (CH2progressbar + 1) * 10; // 补偿1秒
|
||||
SetProgressBar(pb_CH2progressBar, 0);
|
||||
SetProgressBarMax(pb_CH2progressBar, (CH2progressbar + 1) * 10); // 补偿1秒
|
||||
|
||||
// 设备运行状态
|
||||
//Console.WriteLine($"prepare-设备运行状态: {LL28CH2client.ArrCoil[2]}");
|
||||
@@ -1549,12 +1597,12 @@ namespace SLC1_N
|
||||
|
||||
// 进度条
|
||||
int pb_value = pb_CH2progressBar.Value + 5;
|
||||
pb_CH2progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH2progressBar, pb_value);
|
||||
|
||||
if (pb_value >= pb_CH2progressBar.Maximum)
|
||||
{
|
||||
pb_value = pb_CH2progressBar.Maximum;
|
||||
pb_CH2progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH2progressBar, pb_value);
|
||||
}
|
||||
|
||||
// 设备运行状态
|
||||
@@ -1585,7 +1633,7 @@ namespace SLC1_N
|
||||
}
|
||||
else
|
||||
{
|
||||
pb_CH2progressBar.Value = 0;
|
||||
SetProgressBar(pb_CH2progressBar, 0);
|
||||
ch2workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
@@ -1624,13 +1672,11 @@ namespace SLC1_N
|
||||
bool result = false;
|
||||
if (testresult == 1)
|
||||
{
|
||||
m_production.AddOK();
|
||||
SetLabelText(lb_CH2_Result, "OK", Color.Green);
|
||||
result = true;
|
||||
}
|
||||
else if (testresult == 2)
|
||||
{
|
||||
m_production.AddNG();
|
||||
SetLabelText(lb_CH2_Result, "NG", Color.Red);
|
||||
result = false;
|
||||
}
|
||||
@@ -1638,56 +1684,93 @@ namespace SLC1_N
|
||||
{
|
||||
SetLabelText(lb_CH2_Result, "");
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
//Console.WriteLine($"finish-结果: {testresult}");
|
||||
|
||||
// 设备运行状态-停止
|
||||
//Console.WriteLine($"finish-设备运行状态: {LL28CH2client.ArrCoil[2]}");
|
||||
if (!LL28CH2client.ArrCoil[2])
|
||||
if (LL28CH2client.ArrCoil[2] == false)
|
||||
{
|
||||
pb_CH2progressBar.Value = pb_CH2progressBar.Maximum;
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(2, lb_CH2Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH2MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH2MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH2MainMessage, $"CH2 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
SetProgressBar(pb_CH2progressBar, pb_CH2progressBar.Maximum);
|
||||
|
||||
// 表格
|
||||
DataGridView2.Invoke(new System.Action<int, bool, string>(Display),
|
||||
2, result, lb_CH2Code.Text);
|
||||
|
||||
// 文件
|
||||
CreateFile(2, result, lb_CH2Code.Text);
|
||||
bool testfinish = false; // 测试结束标志位
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
// 连续测试
|
||||
if (result == false) // NG直接视为本次测试结束
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
testfinish = true;
|
||||
}
|
||||
else if (m_ContinueTest) // 开了连续
|
||||
{
|
||||
CH2testCount++;
|
||||
if (CH2testCount >= m_ContinueTestCount) // 测试次数满足
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(11, 0);
|
||||
mxlLog.Instance.Info($"CH2清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH2清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
testfinish = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(150);
|
||||
ch2workstation = (int)yiqi.start;
|
||||
}
|
||||
}
|
||||
else if (m_ContinueTest == false) // 没开连续测试直接视为本次测试结束
|
||||
{
|
||||
testfinish = true;
|
||||
}
|
||||
|
||||
lb_CH2Code.Text = "";
|
||||
ch2workstation = (int)yiqi.standby;
|
||||
if(testfinish)
|
||||
{
|
||||
if(result)
|
||||
{
|
||||
m_production.AddOK();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_production.AddNG();
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
// 文件
|
||||
CreateFile(2, result, lb_CH2Code.Text);
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(2, lb_CH2Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH2MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH2MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH2MainMessage, $"CH2 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(11, 0);
|
||||
mxlLog.Instance.Info($"CH2清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH2清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CH2testCount = 0; // 重置测试次数
|
||||
lb_CH2Code.Text = "";
|
||||
ch2workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1715,8 +1798,9 @@ namespace SLC1_N
|
||||
|
||||
case (int)yiqi.rst:
|
||||
{
|
||||
pb_CH3progressBar.Value = 0; // 复位进度条置为0
|
||||
SetProgressBar(pb_CH3progressBar, 0); // 复位进度条置为0
|
||||
SetLabelText(lb_CH3_Status, "复位");
|
||||
CH3testCount = 0; // 重置测试次数
|
||||
LL28CH3client.writeCoil("1", true);
|
||||
ch3workstation = (int)yiqi.standby;
|
||||
}
|
||||
@@ -1734,8 +1818,8 @@ namespace SLC1_N
|
||||
+ Convert.ToInt32(LL28CH3client.ArrRegister[9] / 10.0); // 排气时间
|
||||
|
||||
// 配置进度条
|
||||
pb_CH3progressBar.Value = 0;
|
||||
pb_CH3progressBar.Maximum = (CH3progressbar + 1) * 10; // 补偿1秒
|
||||
SetProgressBar(pb_CH3progressBar, 0);
|
||||
SetProgressBarMax(pb_CH3progressBar, (CH3progressbar + 1) * 10); // 补偿1秒
|
||||
|
||||
// 设备运行状态
|
||||
//Console.WriteLine($"prepare-设备运行状态: {LL28CH3client.ArrCoil[2]}");
|
||||
@@ -1813,12 +1897,12 @@ namespace SLC1_N
|
||||
|
||||
// 进度条
|
||||
int pb_value = pb_CH3progressBar.Value + 5;
|
||||
pb_CH3progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH3progressBar, pb_value);
|
||||
|
||||
if (pb_value >= pb_CH3progressBar.Maximum)
|
||||
{
|
||||
pb_value = pb_CH3progressBar.Maximum;
|
||||
pb_CH3progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH3progressBar, pb_value);
|
||||
}
|
||||
|
||||
// 设备运行状态
|
||||
@@ -1849,7 +1933,7 @@ namespace SLC1_N
|
||||
}
|
||||
else
|
||||
{
|
||||
pb_CH3progressBar.Value = 0;
|
||||
SetProgressBar(pb_CH3progressBar, 0);
|
||||
ch3workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
@@ -1888,13 +1972,11 @@ namespace SLC1_N
|
||||
bool result = false;
|
||||
if (testresult == 1)
|
||||
{
|
||||
m_production.AddOK();
|
||||
SetLabelText(lb_CH3_Result, "OK", Color.Green);
|
||||
result = true;
|
||||
}
|
||||
else if (testresult == 2)
|
||||
{
|
||||
m_production.AddNG();
|
||||
SetLabelText(lb_CH3_Result, "NG", Color.Red);
|
||||
result = false;
|
||||
}
|
||||
@@ -1902,56 +1984,92 @@ namespace SLC1_N
|
||||
{
|
||||
SetLabelText(lb_CH3_Result, "");
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
//Console.WriteLine($"finish-结果: {testresult}");
|
||||
|
||||
// 设备运行状态-停止
|
||||
//Console.WriteLine($"finish-设备运行状态: {LL28CH3client.ArrCoil[2]}");
|
||||
if (!LL28CH3client.ArrCoil[2])
|
||||
if (LL28CH3client.ArrCoil[2] == false)
|
||||
{
|
||||
pb_CH3progressBar.Value = pb_CH3progressBar.Maximum;
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(3, lb_CH3Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH3MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH3MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH1MainMessage, $"CH3 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
SetProgressBar(pb_CH3progressBar, pb_CH3progressBar.Maximum);
|
||||
|
||||
// 表格
|
||||
DataGridView1.Invoke(new System.Action<int, bool, string>(Display),
|
||||
3, result, lb_CH3Code.Text);
|
||||
|
||||
// 文件
|
||||
CreateFile(3, result, lb_CH3Code.Text);
|
||||
bool testfinish = false; // 测试结束标志位
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
// 连续测试
|
||||
if (result == false) // NG直接视为本次测试结束
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
testfinish = true;
|
||||
}
|
||||
else if (m_ContinueTest) // 开了连续
|
||||
{
|
||||
CH3testCount++;
|
||||
if (CH3testCount >= m_ContinueTestCount) // 测试次数满足
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(12, 0);
|
||||
mxlLog.Instance.Info($"CH3清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH3清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
testfinish = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(150);
|
||||
ch3workstation = (int)yiqi.start;
|
||||
}
|
||||
}
|
||||
else if (m_ContinueTest == false) // 没开连续测试直接视为本次测试结束
|
||||
{
|
||||
testfinish = true;
|
||||
}
|
||||
|
||||
lb_CH3Code.Text = "";
|
||||
ch3workstation = (int)yiqi.standby;
|
||||
if(testfinish)
|
||||
{
|
||||
if(result)
|
||||
{
|
||||
m_production.AddOK();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_production.AddNG();
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
// 文件
|
||||
CreateFile(3, result, lb_CH3Code.Text);
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(3, lb_CH3Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH3MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH3MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH1MainMessage, $"CH3 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(12, 0);
|
||||
mxlLog.Instance.Info($"CH3清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH3清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CH3testCount = 0; // 重置测试次数
|
||||
lb_CH3Code.Text = "";
|
||||
ch3workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1979,8 +2097,9 @@ namespace SLC1_N
|
||||
|
||||
case (int)yiqi.rst:
|
||||
{
|
||||
pb_CH4progressBar.Value = 0; // 复位进度条置为0
|
||||
SetProgressBar(pb_CH4progressBar, 0); // 复位进度条置为0
|
||||
SetLabelText(lb_CH4_Status, "复位");
|
||||
CH4testCount = 0; // 重置测试次数
|
||||
LL28CH4client.writeCoil("1", true);
|
||||
ch4workstation = (int)yiqi.standby;
|
||||
}
|
||||
@@ -1998,8 +2117,8 @@ namespace SLC1_N
|
||||
+ Convert.ToInt32(LL28CH4client.ArrRegister[9] / 10.0); // 排气时间
|
||||
|
||||
// 配置进度条
|
||||
pb_CH4progressBar.Value = 0;
|
||||
pb_CH4progressBar.Maximum = (CH4progressbar + 1) * 10; // 补偿1秒
|
||||
SetProgressBar(pb_CH4progressBar, 0);
|
||||
SetProgressBarMax(pb_CH4progressBar, (CH4progressbar + 1) * 10); // 补偿1秒
|
||||
|
||||
// 设备运行状态
|
||||
//Console.WriteLine($"prepare-设备运行状态: {LL28CH4client.ArrCoil[2]}");
|
||||
@@ -2077,12 +2196,13 @@ namespace SLC1_N
|
||||
|
||||
// 进度条
|
||||
int pb_value = pb_CH4progressBar.Value + 5;
|
||||
pb_CH4progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH4progressBar, pb_value);
|
||||
|
||||
if (pb_value >= pb_CH4progressBar.Maximum)
|
||||
{
|
||||
pb_value = pb_CH4progressBar.Maximum;
|
||||
pb_CH4progressBar.Value = pb_value;
|
||||
SetProgressBar(pb_CH4progressBar, pb_value);
|
||||
|
||||
}
|
||||
|
||||
// 设备运行状态
|
||||
@@ -2113,7 +2233,7 @@ namespace SLC1_N
|
||||
}
|
||||
else
|
||||
{
|
||||
pb_CH4progressBar.Value = 0;
|
||||
SetProgressBar(pb_CH4progressBar, 0);
|
||||
ch4workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
@@ -2152,13 +2272,11 @@ namespace SLC1_N
|
||||
bool result = false;
|
||||
if (testresult == 1)
|
||||
{
|
||||
m_production.AddOK();
|
||||
SetLabelText(lb_CH4_Result, "OK", Color.Green);
|
||||
result = true;
|
||||
}
|
||||
else if (testresult == 2)
|
||||
{
|
||||
m_production.AddNG();
|
||||
SetLabelText(lb_CH4_Result, "NG", Color.Red);
|
||||
result = false;
|
||||
}
|
||||
@@ -2166,56 +2284,93 @@ namespace SLC1_N
|
||||
{
|
||||
SetLabelText(lb_CH4_Result, "");
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
//Console.WriteLine($"finish-结果: {testresult}");
|
||||
|
||||
// 设备运行状态-停止
|
||||
//Console.WriteLine($"finish-设备运行状态: {LL28CH4client.ArrCoil[2]}");
|
||||
if (!LL28CH4client.ArrCoil[2])
|
||||
if (LL28CH4client.ArrCoil[2] == false)
|
||||
{
|
||||
pb_CH4progressBar.Value = pb_CH4progressBar.Maximum;
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(4, lb_CH4Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH4MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH4MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH2MainMessage, $"CH4 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
SetProgressBar(pb_CH4progressBar, pb_CH4progressBar.Maximum);
|
||||
|
||||
// 表格
|
||||
DataGridView2.Invoke(new System.Action<int, bool, string>(Display),
|
||||
4, result, lb_CH4Code.Text);
|
||||
|
||||
// 文件
|
||||
CreateFile(4, result, lb_CH4Code.Text);
|
||||
bool testfinish = false; // 测试结束标志位
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
// 连续测试
|
||||
if (result == false) // NG直接视为本次测试结束
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
testfinish = true;
|
||||
}
|
||||
else if (m_ContinueTest) // 开了连续
|
||||
{
|
||||
CH4testCount++;
|
||||
if (CH4testCount >= m_ContinueTestCount) // 测试次数满足
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(13, 0);
|
||||
mxlLog.Instance.Info($"CH4清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH4清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
testfinish = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(150);
|
||||
ch4workstation = (int)yiqi.start;
|
||||
}
|
||||
}
|
||||
else if (m_ContinueTest == false) // 没开连续测试直接视为本次测试结束
|
||||
{
|
||||
testfinish = true;
|
||||
}
|
||||
|
||||
lb_CH4Code.Text = "";
|
||||
ch4workstation = (int)yiqi.standby;
|
||||
if(testfinish)
|
||||
{
|
||||
if(result)
|
||||
{
|
||||
m_production.AddOK();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_production.AddNG();
|
||||
}
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
|
||||
// 文件
|
||||
CreateFile(4, result, lb_CH4Code.Text);
|
||||
|
||||
// MES
|
||||
if (MESswitch)
|
||||
{
|
||||
RtValue rdata = chuzhan(4, lb_CH4Code.Text, result);
|
||||
if (rdata.result)
|
||||
{
|
||||
SetLabelText(lb_CH4MES_OUTstatus, "PASS", Color.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLabelText(lb_CH4MES_OUTstatus, "NG", Color.Red);
|
||||
SetUITextBox(tb_CH2MainMessage, $"CH4 出站NG:{rdata.data}");
|
||||
}
|
||||
}
|
||||
|
||||
if (HCPLC_client.Connected)
|
||||
{
|
||||
lock (plcLock) // 加锁
|
||||
{
|
||||
try
|
||||
{
|
||||
HCPLC_client.WriteSingleRegister(13, 0);
|
||||
mxlLog.Instance.Info($"CH4清除PLC信号");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mxlLog.Instance.Error($"CH4清除PLC信号异常 ,行号{ex.StackTrace} ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CH4testCount = 0; // 重置测试次数
|
||||
lb_CH4Code.Text = "";
|
||||
ch4workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3235,6 +3390,75 @@ namespace SLC1_N
|
||||
}
|
||||
}
|
||||
|
||||
// 更新进度条值
|
||||
private void SetProgressBar(Sunny.UI.UIProcessBar progressBar, int value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (progressBar.IsDisposed || cts?.IsCancellationRequested == true)
|
||||
return;
|
||||
|
||||
if (progressBar.InvokeRequired)
|
||||
{
|
||||
progressBar.BeginInvoke((MethodInvoker)delegate
|
||||
{
|
||||
if (!progressBar.IsDisposed)
|
||||
{
|
||||
progressBar.Value = Math.Min(value, progressBar.Maximum);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!progressBar.IsDisposed)
|
||||
{
|
||||
progressBar.Value = Math.Min(value, progressBar.Maximum);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
// 设置进度条最大值
|
||||
private void SetProgressBarMax(Sunny.UI.UIProcessBar progressBar, int maximum)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (progressBar.IsDisposed || cts?.IsCancellationRequested == true)
|
||||
return;
|
||||
|
||||
if (progressBar.InvokeRequired)
|
||||
{
|
||||
progressBar.BeginInvoke((MethodInvoker)delegate
|
||||
{
|
||||
if (!progressBar.IsDisposed)
|
||||
{
|
||||
progressBar.Maximum = maximum;
|
||||
// 确保当前值不超过新的最大值
|
||||
if (progressBar.Value > maximum)
|
||||
progressBar.Value = maximum;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!progressBar.IsDisposed)
|
||||
{
|
||||
progressBar.Maximum = maximum;
|
||||
if (progressBar.Value > maximum)
|
||||
progressBar.Value = maximum;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 串口1接收函数(扫码枪1)
|
||||
//private void CodePort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
|
||||
@@ -3315,8 +3539,18 @@ namespace SLC1_N
|
||||
}
|
||||
if (itemText == "产能清零")
|
||||
{
|
||||
m_production.Clear();
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
DialogResult result = MessageBox.Show(
|
||||
"确定要清零吗?",
|
||||
"确认",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
m_production.Clear();
|
||||
UploadProductionData(m_production.GetTotal(), m_production.GetOK(), m_production.GetNG(), m_production.GetOKRate()); // 更新产能
|
||||
}
|
||||
}
|
||||
//if (itemText == "LIN设置")
|
||||
//{
|
||||
@@ -4633,7 +4867,9 @@ namespace SLC1_N
|
||||
private void timer_SaomaStart_Tick(object sender, EventArgs e)
|
||||
{
|
||||
Slot_SaomaStart(1);
|
||||
//Slot_SaomaStart(2);
|
||||
Slot_SaomaStart(2);
|
||||
Slot_SaomaStart(3);
|
||||
Slot_SaomaStart(4);
|
||||
}
|
||||
|
||||
// 显示时间
|
||||
|
||||
Reference in New Issue
Block a user