修改
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user