修改
This commit is contained in:
@@ -337,7 +337,7 @@ namespace CleanMachineHMI
|
|||||||
{
|
{
|
||||||
if (PlcItemMd_M_List != null && PlcItemMd_M_List.Count > 0)
|
if (PlcItemMd_M_List != null && PlcItemMd_M_List.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (PlcItem item in PlcItemMd_M_List)
|
foreach (PlcItem item in PlcItemMd_M_List.Values)
|
||||||
{
|
{
|
||||||
string value = "";
|
string value = "";
|
||||||
if (Convert.ToInt32(item.PlcItemPriAddress) >= 200)
|
if (Convert.ToInt32(item.PlcItemPriAddress) >= 200)
|
||||||
@@ -398,7 +398,7 @@ namespace CleanMachineHMI
|
|||||||
{
|
{
|
||||||
if (PlcItemMd_D_List != null && PlcItemMd_D_List.Count > 0)
|
if (PlcItemMd_D_List != null && PlcItemMd_D_List.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (PlcItem item in PlcItemMd_D_List)
|
foreach (PlcItem item in PlcItemMd_D_List.Values)
|
||||||
{
|
{
|
||||||
var value = "";
|
var value = "";
|
||||||
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
||||||
@@ -892,33 +892,33 @@ namespace CleanMachineHMI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
List<PlcItem> changeItems = new List<PlcItem>();
|
List<PlcItem> changeItems = new List<PlcItem>();
|
||||||
bool[] readBytArr_X = master.ReadInputs(slaveAddress, 1024, 50);
|
bool[] readBytArr_X = master.ReadInputs(slaveAddress, 1024, 50);
|
||||||
if (readBytArr_X.Length > 0)
|
if (readBytArr_X.Length > 0)
|
||||||
//if(true)
|
//if(true)
|
||||||
{
|
|
||||||
if (PlcItemMd_X_List != null && PlcItemMd_X_List.Count > 0)
|
|
||||||
{
|
{
|
||||||
foreach (PlcItem item in PlcItemMd_X_List)
|
if (PlcItemMd_X_List != null && PlcItemMd_X_List.Count > 0)
|
||||||
{
|
{
|
||||||
string value = "";
|
foreach (PlcItem item in PlcItemMd_X_List.Values)
|
||||||
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
|
||||||
{
|
{
|
||||||
string PlcItemId = item.PlcItemId.ToString();
|
string value = "";
|
||||||
string plcdatatype = item.PlcItemDataType.ToString();
|
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
||||||
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
|
||||||
value = readBytArr_X[plcItemDeviationAddress].ToString();
|
|
||||||
if (value != null)
|
|
||||||
{
|
{
|
||||||
if (item.PlcItemValue != value)
|
string PlcItemId = item.PlcItemId.ToString();
|
||||||
|
string plcdatatype = item.PlcItemDataType.ToString();
|
||||||
|
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
||||||
|
value = readBytArr_X[plcItemDeviationAddress].ToString();
|
||||||
|
if (value != null)
|
||||||
{
|
{
|
||||||
haschange = true;
|
if (item.PlcItemValue != value)
|
||||||
item.PlcItemValue = value;
|
{
|
||||||
// this.DoShowX_Y_Status(item);
|
haschange = true;
|
||||||
changeItems.Add(item);
|
item.PlcItemValue = value;
|
||||||
// Global.ShowX_Y_Status(item, new EventArgs());
|
// this.DoShowX_Y_Status(item);
|
||||||
Global.ShowSensorStatus(item, new EventArgs());
|
changeItems.Add(item);
|
||||||
}
|
// Global.ShowX_Y_Status(item, new EventArgs());
|
||||||
|
Global.ShowSensorStatus(item, new EventArgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -953,22 +953,22 @@ namespace CleanMachineHMI
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
List<PlcItem> changeItems = new List<PlcItem>();
|
List<PlcItem> changeItems = new List<PlcItem>();
|
||||||
bool[] readBytArr_Y = master.ReadCoils(slaveAddress, 1280, 50);
|
bool[] readBytArr_Y = master.ReadCoils(slaveAddress, 1280, 50);
|
||||||
if (readBytArr_Y.Length > 0)
|
if (readBytArr_Y.Length > 0)
|
||||||
//if(true)
|
//if(true)
|
||||||
{
|
|
||||||
if (PlcItemMd_Y_List != null && PlcItemMd_Y_List.Count > 0)
|
|
||||||
{
|
{
|
||||||
foreach (PlcItem item in PlcItemMd_Y_List)
|
if (PlcItemMd_Y_List != null && PlcItemMd_Y_List.Count > 0)
|
||||||
{
|
{
|
||||||
string value = "";
|
foreach (PlcItem item in PlcItemMd_Y_List.Values)
|
||||||
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
|
||||||
{
|
{
|
||||||
string PlcItemId = item.PlcItemId.ToString();
|
string value = "";
|
||||||
string plcdatatype = item.PlcItemDataType.ToString();
|
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
||||||
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
{
|
||||||
value = readBytArr_Y[plcItemDeviationAddress].ToString();
|
string PlcItemId = item.PlcItemId.ToString();
|
||||||
|
string plcdatatype = item.PlcItemDataType.ToString();
|
||||||
|
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
||||||
|
value = readBytArr_Y[plcItemDeviationAddress].ToString();
|
||||||
|
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
@@ -1061,79 +1061,82 @@ namespace CleanMachineHMI
|
|||||||
switch (itemType)
|
switch (itemType)
|
||||||
{
|
{
|
||||||
case PlcItemTypeDesc.M:
|
case PlcItemTypeDesc.M:
|
||||||
|
PlcItemMd_M_List.TryGetValue(plcItemCode, out var item_M);
|
||||||
|
|
||||||
PlcItem item_M = PlcItemMd_M_List.Find(x => x.PlcItemCode == plcItemCode);
|
if (item_M == null)
|
||||||
if (item_M == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(item_M.PlcItemValue))
|
|
||||||
{
|
|
||||||
retObj = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retObj = bool.Parse(item_M.PlcItemValue);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PlcItemTypeDesc.D:
|
|
||||||
PlcItem item_D = PlcItemMd_D_List.Find(x => x.PlcItemCode == plcItemCode);
|
|
||||||
if (item_D == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(item_D.PlcItemValue))
|
|
||||||
{
|
|
||||||
retObj = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (item_D.PlcItemDataLength == 2)
|
|
||||||
{
|
{
|
||||||
retObj = int.Parse(item_D.PlcItemValue);
|
return null;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(item_M.PlcItemValue))
|
||||||
|
{
|
||||||
|
retObj = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retObj = short.Parse(item_D.PlcItemValue);
|
retObj = bool.Parse(item_M.PlcItemValue);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case PlcItemTypeDesc.D:
|
||||||
|
PlcItemMd_D_List.TryGetValue(plcItemCode, out var item_D);
|
||||||
|
// PlcItem item_D = PlcItemMd_D_List.Find(x => x.PlcItemCode == plcItemCode);
|
||||||
|
if (item_D == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(item_D.PlcItemValue))
|
||||||
|
{
|
||||||
|
retObj = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (item_D.PlcItemDataLength == 2)
|
||||||
|
{
|
||||||
|
retObj = int.Parse(item_D.PlcItemValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retObj = short.Parse(item_D.PlcItemValue);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PlcItemTypeDesc.X:
|
case PlcItemTypeDesc.X:
|
||||||
PlcItem item_X = PlcItemMd_X_List.Find(x => x.PlcItemCode == plcItemCode);
|
PlcItemMd_X_List.TryGetValue(plcItemCode, out var item_X);
|
||||||
if (item_X == null)
|
//PlcItem item_X = PlcItemMd_X_List.Find(x => x.PlcItemCode == plcItemCode);
|
||||||
{
|
if (item_X == null)
|
||||||
return null;
|
{
|
||||||
}
|
return null;
|
||||||
if (string.IsNullOrEmpty(item_X.PlcItemValue))
|
}
|
||||||
{
|
if (string.IsNullOrEmpty(item_X.PlcItemValue))
|
||||||
retObj = false;
|
{
|
||||||
}
|
retObj = false;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
retObj = bool.Parse(item_X.PlcItemValue);
|
{
|
||||||
}
|
retObj = bool.Parse(item_X.PlcItemValue);
|
||||||
break;
|
}
|
||||||
case PlcItemTypeDesc.Y:
|
break;
|
||||||
PlcItem item_Y = PlcItemMd_Y_List.Find(x => x.PlcItemCode == plcItemCode);
|
case PlcItemTypeDesc.Y:
|
||||||
if (item_Y == null)
|
PlcItemMd_Y_List.TryGetValue(plcItemCode, out var item_Y);
|
||||||
{
|
// PlcItem item_Y = PlcItemMd_Y_List.Find(x => x.PlcItemCode == plcItemCode);
|
||||||
return null;
|
if (item_Y == null)
|
||||||
}
|
{
|
||||||
if (string.IsNullOrEmpty(item_Y.PlcItemValue))
|
return null;
|
||||||
{
|
}
|
||||||
retObj = false;
|
if (string.IsNullOrEmpty(item_Y.PlcItemValue))
|
||||||
}
|
{
|
||||||
else
|
retObj = false;
|
||||||
{
|
}
|
||||||
retObj = bool.Parse(item_Y.PlcItemValue);
|
else
|
||||||
}
|
{
|
||||||
break;
|
retObj = bool.Parse(item_Y.PlcItemValue);
|
||||||
default:
|
}
|
||||||
retObj = null;
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
retObj = null;
|
||||||
return retObj;
|
break;
|
||||||
|
}
|
||||||
|
return retObj;
|
||||||
#if RELEASE
|
#if RELEASE
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1151,30 +1154,31 @@ namespace CleanMachineHMI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
switch (itemType)
|
switch (itemType)
|
||||||
{
|
{
|
||||||
case PlcItemTypeDesc.M:
|
case PlcItemTypeDesc.M:
|
||||||
PlcItem item_M = PlcItemMd_M_List.Find(x => x.PlcItemCode == plcItemCode);
|
PlcItemMd_M_List.TryGetValue(plcItemCode, out var item_M);
|
||||||
if (item_M == null)
|
if (item_M == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
master.WriteSingleCoil(slaveAddress, Convert.ToUInt16(item_M.PlcItemModbusAddress), bool.Parse(writeValue));
|
master.WriteSingleCoil(slaveAddress, Convert.ToUInt16(item_M.PlcItemModbusAddress), bool.Parse(writeValue));
|
||||||
return true;
|
return true;
|
||||||
case PlcItemTypeDesc.Y:
|
case PlcItemTypeDesc.Y:
|
||||||
PlcItem item_Y = PlcItemMd_Y_List.Find(x => x.PlcItemCode == plcItemCode);
|
PlcItemMd_Y_List.TryGetValue(plcItemCode, out var item_Y);
|
||||||
if (item_Y == null)
|
|
||||||
{
|
if (item_Y == null)
|
||||||
return false;
|
{
|
||||||
}
|
return false;
|
||||||
master.WriteSingleCoil(slaveAddress, Convert.ToUInt16(item_Y.PlcItemModbusAddress), bool.Parse(writeValue));
|
}
|
||||||
return true;
|
master.WriteSingleCoil(slaveAddress, Convert.ToUInt16(item_Y.PlcItemModbusAddress), bool.Parse(writeValue));
|
||||||
case PlcItemTypeDesc.D:
|
return true;
|
||||||
PlcItem item_D = PlcItemMd_D_List.Find(x => x.PlcItemCode == plcItemCode);
|
case PlcItemTypeDesc.D:
|
||||||
if (item_D == null)
|
PlcItemMd_D_List.TryGetValue(plcItemCode, out var item_D);
|
||||||
{
|
if (item_D == null)
|
||||||
return false;
|
{
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (item_D.PlcItemDataLength == 2)
|
if (item_D.PlcItemDataLength == 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user