修改
This commit is contained in:
@@ -79,8 +79,31 @@ namespace CleanMachineHMI
|
||||
|
||||
}
|
||||
|
||||
public delegate void ShowX_Y_Status(IEnumerable<PlcItem> plcItem);
|
||||
|
||||
|
||||
public event ShowX_Y_Status OnShowX_Y_Status;
|
||||
|
||||
private void PostShowX_Y_Status(object data)
|
||||
{
|
||||
var _data = data as IEnumerable<PlcItem>;
|
||||
OnShowX_Y_Status?.Invoke(_data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void DoShowX_Y_Status(IEnumerable<PlcItem> plcItem)
|
||||
{
|
||||
|
||||
if (_synchronization != null)
|
||||
{
|
||||
_synchronization.Post(this.PostShowX_Y_Status, plcItem);
|
||||
// OnShowX_Y_Status?.Invoke(plcItem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -98,11 +121,7 @@ namespace CleanMachineHMI
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
|
||||
return this._isConn;
|
||||
|
||||
|
||||
}
|
||||
set { this._isConn = value; }
|
||||
}
|
||||
@@ -144,7 +163,7 @@ namespace CleanMachineHMI
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
var haschange=false;
|
||||
var haschange = false;
|
||||
RefreshPlcItem_M(ref haschange);
|
||||
RefreshPlcItem_D(ref haschange);
|
||||
RefreshPlcItem_X(ref haschange);
|
||||
@@ -176,17 +195,17 @@ namespace CleanMachineHMI
|
||||
{
|
||||
switch (plcitem.PlcItemDataType)
|
||||
{
|
||||
case 0:
|
||||
case PlcItemTypeDesc.M:
|
||||
PlcItemMd_M_List.Add(plcitem);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case PlcItemTypeDesc.D:
|
||||
PlcItemMd_D_List.Add(plcitem);
|
||||
break;
|
||||
case 2:
|
||||
case PlcItemTypeDesc.X:
|
||||
PlcItemMd_X_List.Add(plcitem);
|
||||
break;
|
||||
case 3:
|
||||
case PlcItemTypeDesc.Y:
|
||||
PlcItemMd_Y_List.Add(plcitem);
|
||||
break;
|
||||
}
|
||||
@@ -338,6 +357,7 @@ namespace CleanMachineHMI
|
||||
try
|
||||
{
|
||||
#endif
|
||||
|
||||
ushort[] tmpReadAlarmBytArr_D = master.ReadHoldingRegisters(slaveAddress, 4106, 50);
|
||||
ushort[] readBytArr_D = master.ReadHoldingRegisters(slaveAddress, 4505, 50);
|
||||
if (readBytArr_D.Length > 0 && tmpReadAlarmBytArr_D.Length > 0)
|
||||
@@ -396,8 +416,10 @@ namespace CleanMachineHMI
|
||||
if (item.PlcItemValue != value)
|
||||
{
|
||||
haschange = true;
|
||||
item.PlcItemValue = value;
|
||||
|
||||
}
|
||||
item.PlcItemValue = value;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -789,6 +811,7 @@ namespace CleanMachineHMI
|
||||
try
|
||||
{
|
||||
#endif
|
||||
List<PlcItem> changeItems = new List<PlcItem>();
|
||||
bool[] readBytArr_X = master.ReadInputs(slaveAddress, 1024, 50);
|
||||
if (readBytArr_X.Length > 0)
|
||||
//if(true)
|
||||
@@ -810,7 +833,9 @@ namespace CleanMachineHMI
|
||||
{
|
||||
haschange = true;
|
||||
item.PlcItemValue = value;
|
||||
Global.ShowX_Y_Status(item, new EventArgs());
|
||||
// this.DoShowX_Y_Status(item);
|
||||
changeItems.Add(item);
|
||||
// Global.ShowX_Y_Status(item, new EventArgs());
|
||||
Global.ShowSensorStatus(item, new EventArgs());
|
||||
}
|
||||
|
||||
@@ -826,6 +851,8 @@ namespace CleanMachineHMI
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.DoShowX_Y_Status(changeItems);
|
||||
}
|
||||
}
|
||||
#if RELEASE
|
||||
@@ -843,6 +870,9 @@ namespace CleanMachineHMI
|
||||
try
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
List<PlcItem> changeItems = new List<PlcItem>();
|
||||
bool[] readBytArr_Y = master.ReadCoils(slaveAddress, 1280, 50);
|
||||
if (readBytArr_Y.Length > 0)
|
||||
//if(true)
|
||||
@@ -863,22 +893,19 @@ namespace CleanMachineHMI
|
||||
{
|
||||
if (item.PlcItemValue != value)
|
||||
{
|
||||
haschange=true;
|
||||
haschange = true;
|
||||
item.PlcItemValue = value;
|
||||
Global.ShowX_Y_Status(item, new EventArgs());
|
||||
|
||||
changeItems.Add(item);
|
||||
// this.DoShowX_Y_Status(item);
|
||||
// Global.ShowX_Y_Status(item, new EventArgs());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Random r = new Random();
|
||||
//item.PlcItemValue = r.Next(0, 2) == 0 ? "False" : "True";
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.DoShowX_Y_Status(changeItems);
|
||||
}
|
||||
}
|
||||
#if RELEASE
|
||||
@@ -900,7 +927,7 @@ namespace CleanMachineHMI
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (item.PlcItemDataType == 1)
|
||||
if (item.PlcItemDataType == PlcItemTypeDesc.D)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(item.PlcItemValue))
|
||||
@@ -1157,23 +1184,5 @@ namespace CleanMachineHMI
|
||||
|
||||
|
||||
|
||||
public enum PlcItemTypeDesc
|
||||
{
|
||||
/// <summary>
|
||||
/// M 类型布尔变量
|
||||
/// </summary>
|
||||
M,
|
||||
/// <summary>
|
||||
/// D 类型整数变量
|
||||
/// </summary>
|
||||
D,
|
||||
/// <summary>
|
||||
/// X 类型布尔变量
|
||||
/// </summary>
|
||||
X,
|
||||
/// <summary>
|
||||
/// Y 类型布尔变量
|
||||
/// </summary>
|
||||
Y
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user