Files
13-PingZhi126KVGLKG-MesProject/Test/ReadThisStationProductInfo.cs

108 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
//using SystemFramework;
namespace MisDataSaveDate
{
public partial class MisData
{
void ReadPLC_ProductInfo()
{
try
{
foreach (Control Tbx in this.groupBox_PLC.Controls)
{
Thread t = new Thread(new ParameterizedThreadStart(ReadPLC_ProductInfo_Thread));
t.Start(Tbx);
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void ReadPLC_ProductInfo_Thread(object obj)
{
try
{
Control Tbx = (Control)obj;
if (Tbx.Name.Length < 12) return;
if (Tbx.Name.Substring(0, 8) != "Tbx_PLC_") return;
string[] TbxName_Split = Tbx.Name.Split('_');
int TagType = Convert.ToInt32(TbxName_Split[2]);
if (Tbx.InvokeRequired )
{
Action<string> actionDelegate = (x) => { Tbx.Text = x; };
Tbx.BeginInvoke(actionDelegate, DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString());
}
else
{
Tbx.Text = DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString();
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void ReadMES_ProductInfo()
{
try
{
foreach (Control Tbx in this.groupBox_MES.Controls)
{
Thread t = new Thread(new ParameterizedThreadStart(ReadMES_ProductInfo_Thread));
t.Start(Tbx);
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void ReadMES_ProductInfo_Thread(object obj)
{
try
{
Control Tbx = (Control)obj;
if (Tbx.Name.Length < 12) return;
if (Tbx.Name.Substring(0, 8) != "Tbx_MES_") return;
string[] TbxName_Split = Tbx.Name.Split('_');
int TagType = Convert.ToInt32(TbxName_Split[2]);
if (Tbx .InvokeRequired )
{
Action<string> ActionDelegate = (x) => { Tbx.Text = x; };
Tbx.BeginInvoke(ActionDelegate, DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString());
}
else
{
Tbx.Text = DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString();
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
}
}