dep_yangw
我叫锄头 11 months ago
parent fee1a5639d
commit b71c61c333

@ -746,12 +746,6 @@ namespace ProductionSystem.Forms
// if(txtProductCode)
//ClearMiddleData
if (txtProductCode.Text.Contains("暂无条码") || txtProductCode.Text== "12345889" || txtProductCode.Text=="")
{
CleanMiddleData("BZ1");
return;
}
var d1300Value = GetPlcValue("D1300");
@ -1576,6 +1570,24 @@ namespace ProductionSystem.Forms
{
while (!cancellationTokenSource.IsCancellationRequested)
{
string tiaoma = txtProductCode.Text.Replace("\r", "").Replace("\n", "");
if (tiaoma.Contains("暂无条码") || tiaoma == "")
{
for (int i = 1; i < 9; i++)
{
CleanMiddleData("BZ"+i);
CleanMiddleDataDB($"BZ{i}_DB");
}
}
else
{
GetPlc(Program.BZ1, "BZ1");
GetPlc(Program.BZ2, "BZ2");
GetPlc(Program.BZ3, "BZ3");
@ -1586,14 +1598,6 @@ namespace ProductionSystem.Forms
GetPlc(Program.BZ8, "BZ8");
// count++;
// if (count == 1)
// {
//
// count = 0;
//
// }
Collect("BZ1");
Collect("BZ2");
Collect("BZ3");
@ -1611,6 +1615,7 @@ namespace ProductionSystem.Forms
SetMiddleData("BZ6_DB");
SetMiddleData("BZ7_DB");
SetMiddleData("BZ8_DB");
}
Thread.Sleep(Program.ReadPlcRate);
}
@ -1865,23 +1870,7 @@ namespace ProductionSystem.Forms
//}
#region 中间控件PLC值采集
/// <summary>
/// 空载
/// </summary>
//private void GetIdlingPointsVal()
//{
// //responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M261");
// //for (int i = 0; i < Program.idlingPoints.Count; i++)
// //{
// // var idlingReadResult = OmronHelper.GetPlcVal(Program.idlingPoints[i].DataType, Program.idlingPoints[i].Address);
// // Program.idlingPoints[i].Val = idlingReadResult.val;
// //}
// //var idlingStatus = Program.idlingPoints.FirstOrDefault(m => m.Key == "M84").Val;
// //if (idlingStatus == "1.000" || idlingStatus == "2.000")
// //{
// // SetMiddleData(Program.idlingPoints, "Idling", responsePoint, 3);
// //}
//}
@ -2218,6 +2207,48 @@ namespace ProductionSystem.Forms
}
private void CleanMiddleDataDB(string paraCategory)
{
try
{
var groupControls = middleFlowLayoutPanel.Controls.OfType<GroupControl>().FirstOrDefault(m => m.Tag.ToString().Contains(paraCategory));
//如果有GroupControl控件
if (groupControls != null)
{
var layOutControl = groupControls.Controls.OfType<LayoutControl>().FirstOrDefault(m => m.Name.Contains(paraCategory));
if (layOutControl != null)
{
var middleMyTestResultControls = layOutControl.Controls.OfType<MyTestResultControl>().ToList();
if (middleMyTestResultControls.Any())
{
for (int j = 0; j < middleMyTestResultControls.Count; j++)
{
if (middleMyTestResultControls[j].IsHandleCreated && !middleMyTestResultControls[j].IsDisposed)
{
this.Invoke(new Action(() =>
{
SetColor(middleMyTestResultControls[j], -1, "0.000");
}));
}
}
}
}
}
}
catch (Exception ex)
{
LogHelper.Error(ex, $"给中间部分控件赋值时异常!");
}
}
/// <summary>
/// 清空中间控件的数据
/// </summary>

Loading…
Cancel
Save