2021-06-05 14:17:30 +08:00
|
|
|
|
using CleanMachineHMI.Domain.Enums;
|
|
|
|
|
|
using CleanMachineHMI.Utils;
|
2021-12-26 21:30:02 +08:00
|
|
|
|
using Krypton.Toolkit;
|
2021-06-05 14:17:30 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CleanMachineHMI.FrmUserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
//[FormType(EnumFormType.IoMonitor)]
|
|
|
|
|
|
public partial class frmIOMonitor : UserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public frmIOMonitor()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
_InfoLanguageTextList = this.GetInfoLanguageText(GlobalHelper.LanguageCode, "Label");
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 页面信息语言文本列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private DataTable _InfoLanguageTextList;
|
|
|
|
|
|
private void frmIOMonitorNew_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
initControl();
|
|
|
|
|
|
GlobalHelper.OnShowX_Y_Status += Show_X_Y_Status;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void Show_X_Y_Status(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
BasPlcItemMd item = sender as BasPlcItemMd;
|
|
|
|
|
|
Invoke(new Action(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.PlcItemDataType == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.Controls.Find("cbt_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
CircleButton ctn = this.Controls.Find("cbt_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as CircleButton;
|
|
|
|
|
|
if (string.IsNullOrEmpty(item.PlcItemValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
ctn.BackColor = Color.FromArgb(191, 219, 255);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (bool.Parse(item.PlcItemValue.ToString()))
|
|
|
|
|
|
{
|
|
|
|
|
|
ctn.BackColor = Color.Lime;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ctn.BackColor = Color.Red;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.Controls.Find("cbt_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
CircleButton ctn = this.Controls.Find("cbt_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as CircleButton;
|
|
|
|
|
|
if (string.IsNullOrEmpty(item.PlcItemValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
ctn.BackColor = Color.FromArgb(191, 219, 255);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (bool.Parse(item.PlcItemValue.ToString()))
|
|
|
|
|
|
{
|
|
|
|
|
|
ctn.BackColor = Color.Lime;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ctn.BackColor = Color.Red;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
private void initControl()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GlobalHelper.PlcItemMd_X_List != null && GlobalHelper.PlcItemMd_X_List.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<BasPlcItemMd> tempLst = GlobalHelper.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
|
|
|
|
|
|
foreach (BasPlcItemMd item in tempLst)
|
|
|
|
|
|
{
|
|
|
|
|
|
Invoke(new Action(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.Controls.Find("klb_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
KryptonLabel label1 = this.Controls.Find("klb_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as KryptonLabel;
|
|
|
|
|
|
|
|
|
|
|
|
label1.Text = _InfoLanguageTextList.GetInfoText_1(item.PlcItemName.Replace("(I/O监控)", ""), item.PlcItemCode, "Label");
|
|
|
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GlobalHelper.PlcItemMd_Y_List != null && GlobalHelper.PlcItemMd_Y_List.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<BasPlcItemMd> tempLst = GlobalHelper.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
|
|
|
|
|
|
foreach (BasPlcItemMd item in tempLst)
|
|
|
|
|
|
{
|
|
|
|
|
|
Invoke(new Action(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.Controls.Find("klb_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true).Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
KryptonLabel label1 = this.Controls.Find("klb_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true)[0] as KryptonLabel;
|
|
|
|
|
|
|
|
|
|
|
|
label1.Text = _InfoLanguageTextList.GetInfoText_1(item.PlcItemName.Replace("(I/O监控)", ""), item.PlcItemCode, "Label");
|
|
|
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
KryptonMessageBox.Show(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|