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