using OpcData; using System; using SystemFramework; using System.Threading; using System.Collections; using System.Collections.Specialized; using MisDataFunction; namespace MisDataName { //public partial class ___ { } public partial class MisData { public delegate void ShowMessagePLCInvoke(OpcData.CustomeEvetnArgs msg); /// /// 异步方式显示工位号 /// public ShowMessagePLCInvoke showMessagePLCInvoke; int richTextBox_Length = 0; /// /// 展示信号变化 /// /// private void ShowMessagePLC(OpcData.CustomeEvetnArgs e) { try { //判断工位PLC消息显示方式(显示所有) string opname = e.OpName.ToString(); string TagValue; string TagType = e.TagType.ToString(); int TagKey = Convert.ToInt32(e.TagKey); switch (Convert.ToInt32(e.TagValueType)) { case 11: TagValue = (Convert.ToInt32(e.TagValue)).ToString(); break; default: TagValue = e.TagValue.ToString(); break; } string msg = "MIS|" + TagType + "|" + opname + "|" + TagValue + "|" + TagKey; if ((opname == WorkStationNum_Now || radioButton_AllStation.Checked)&& !radioButton_Pause.Checked) { Action ActionDe = (x) => { richTextBox_MessagePLC.Text = x + "\r\n" + richTextBox_MessagePLC.Text; }; richTextBox_MessagePLC.Invoke(ActionDe, msg); richTextBox_Length++; if (richTextBox_Length > 3000) { Action RichClear = () => { richTextBox_MessagePLC.Text = ""; }; richTextBox_MessagePLC.Invoke(RichClear); richTextBox_Length = 0; // richTextBox_MessagePLC.Text = ""; } } TestPlcConnect.HeartBeatChange(opname,Convert .ToInt32 (TagType)); //只显示当前工位 if (opname == WorkStationNum_Now && Cbx_StatusDisplay.Checked) { //更改按钮显示状态 RefreshBtnColor_Thread(Convert.ToInt32(TagType), TagValue); RefreshStationStatus_Thread(Convert.ToInt32(TagType), TagValue); //更新工位状态栏 //允许保存、工作完成时,刷新质量数据 if (checkBox_Quality_Display.Checked && TagValue == "1"&&(TagType == "19" || TagType == "59")) { button_ReadData_Click(null ,null );//刷新当前工位数据(质量) } if (TagType == "44" && TagValue == "1" && checkBox_PLCData_Display.Checked) { ReadPLC_ProductInfo(); } if (TagType == "5" && TagValue == "1" && checkBox_MESData_Display.Checked) { ReadMES_ProductInfo(); } } } catch (Exception err) { ApplicationLog.WriteLog(err, err.Message); } } } }