Files
01-Siyuan-MesProject/MisData_3.0_2022.08.23.1622.LLX/MisData/MisDataChange/MisData.ShowMessagePLC.cs
2026-05-29 10:07:05 +08:00

99 lines
3.5 KiB
C#

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);
/// <summary>
/// 异步方式显示工位号
/// </summary>
public ShowMessagePLCInvoke showMessagePLCInvoke;
int richTextBox_Length = 0;
/// <summary>
/// 展示信号变化
/// </summary>
/// <param name="msg"></param>
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<string> 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);
}
}
}
}