This commit is contained in:
gongxh
2022-05-10 15:21:13 +08:00
parent 8f9e5a8ee2
commit f9f8e587d1
22 changed files with 1216 additions and 831 deletions

View File

@@ -42,7 +42,7 @@ namespace CleanMachineHMI
await Task.Delay(100);
Invoke(new Action(() =>
{
Global.OnShowX_Y_Status -= Show_X_Y_Status;
PlcOperationHelper.Instance.OnShowX_Y_Status -= Show_X_Y_Status;
Global.OnShowSensorStatus -= ShowSensorStatus;
Global.IoMonitor_2.SuspendLayout();
Global.IoMonitor_2.Hide();
@@ -58,7 +58,7 @@ namespace CleanMachineHMI
private void frmIoMonitorNew_2_Load(object sender, EventArgs e)
{
initControl();
Global.OnShowX_Y_Status += Show_X_Y_Status;
PlcOperationHelper.Instance.OnShowX_Y_Status += Show_X_Y_Status;
Global.OnShowSensorStatus += ShowSensorStatus;
}
private void ShowSensorStatus(object sender, EventArgs e)
@@ -68,7 +68,7 @@ namespace CleanMachineHMI
PlcItem item = sender as PlcItem;
Invoke(new Action(() =>
{
if (item.PlcItemDataType == 2)
if (item.PlcItemDataType == PlcItemTypeDesc.X)
{
Control[] crnLst = this.Controls.Find("picb_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true);
if (crnLst.Length > 0)
@@ -111,55 +111,58 @@ namespace CleanMachineHMI
}));
}
}
private void Show_X_Y_Status(object sender, EventArgs e)
private void Show_X_Y_Status( IEnumerable< PlcItem> items )
{
lock (lockObj)
{
PlcItem item = sender as PlcItem;
Invoke(new Action(() =>
foreach (var item in items)
{
if (item.PlcItemDataType == 2)
Invoke(new Action(() =>
{
Control[] crnLst = this.Controls.Find("cbt_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true);
if (crnLst.Length > 0)
{
CircleButton ctn = crnLst[0] as CircleButton;
if (string.IsNullOrEmpty(item.PlcItemValue))
if (item.PlcItemDataType == PlcItemTypeDesc.X)
{
Control[] crnLst = this.Controls.Find("cbt_X" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true);
if (crnLst.Length > 0)
{
ctn.BackColor = Color.FromArgb(191, 219, 255);
CircleButton ctn = crnLst[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 (bool.Parse(item.PlcItemValue.ToString()))
}
else
{
Control[] crnLst = this.Controls.Find("cbt_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true);
if (crnLst.Length > 0)
{
ctn.BackColor = Color.Lime;
CircleButton ctn = crnLst[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
{
ctn.BackColor = Color.Red;
}
}
}
else
{
Control[] crnLst = this.Controls.Find("cbt_Y" + Convert.ToString(Convert.ToInt32(item.PlcItemPriAddress), 8).PadLeft(2, '0'), true);
if (crnLst.Length > 0)
{
CircleButton ctn = crnLst[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()