修改读取逻辑

This commit is contained in:
gongxh
2022-05-06 15:23:30 +08:00
parent 0e459f231a
commit 64238fee13
8 changed files with 199 additions and 121 deletions

View File

@@ -32,6 +32,8 @@
<add key="ParityMsg" value="2"/>
<add key="ModbusPattern" value="0" />
<add key="SlaveAddress" value="1" />
<!--托盘序列号前缀-->
<add key="PalletIndexPrefix" value="Pallet"/>
<!--托盘序列号生成日期-->

View File

@@ -78,9 +78,9 @@ namespace CleanMachineHMI.FrmUserControl
{
try
{
if (Global.PlcItemMd_X_List != null && Global.PlcItemMd_X_List.Count > 0)
if (PlcOperationHelper.Instance.PlcItemMd_X_List != null && PlcOperationHelper.Instance.PlcItemMd_X_List.Count > 0)
{
List<PlcItem> tempLst = Global.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
foreach (PlcItem item in tempLst)
{
BeginInvoke(new Action(() =>
@@ -95,9 +95,9 @@ namespace CleanMachineHMI.FrmUserControl
}
}
if (Global.PlcItemMd_Y_List != null && Global.PlcItemMd_Y_List.Count > 0)
if (PlcOperationHelper.Instance.PlcItemMd_Y_List != null && PlcOperationHelper.Instance.PlcItemMd_Y_List.Count > 0)
{
List<PlcItem> tempLst = Global.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
foreach (PlcItem item in tempLst)
{
BeginInvoke(new Action(() =>

View File

@@ -149,11 +149,11 @@ namespace CleanMachineHMI.FrmUserControl
List<PlcItem> tmpMdList;
if (!string.IsNullOrEmpty(ktb_plcMsg.Text.Trim()))
{
tmpMdList = Global.PlcItemMdList.FindAll(x => x.PlcItemCode.Contains(ktb_plcMsg.Text.Trim()) || x.PlcItemName.Contains(ktb_plcMsg.Text.Trim()));
tmpMdList = PlcOperationHelper.Instance. PlcItemMdList.FindAll(x => x.PlcItemCode.Contains(ktb_plcMsg.Text.Trim()) || x.PlcItemName.Contains(ktb_plcMsg.Text.Trim()));
}
else
{
tmpMdList = Global.PlcItemMdList;
tmpMdList = PlcOperationHelper.Instance.PlcItemMdList;
}
if (tmpMdList != null && tmpMdList.Count > 0)
{

View File

@@ -117,14 +117,14 @@ namespace CleanMachineHMI
/// <summary>
///
/// </summary>
public static List<PlcItem> PlcItemMdList { get; set; } = new List<PlcItem>();
public static List<PlcItem> PlcItemMd_D_List { get; set; } = new List<PlcItem>();
//public static List<PlcItem> PlcItemMdList { get; set; } = new List<PlcItem>();
//public static List<PlcItem> PlcItemMd_D_List { get; set; } = new List<PlcItem>();
public static List<PlcItem> PlcItemMd_M_List { get; set; }=new List<PlcItem>();
//public static List<PlcItem> PlcItemMd_M_List { get; set; }=new List<PlcItem>();
public static List<PlcItem> PlcItemMd_X_List { get; set; }=new List<PlcItem>();
//public static List<PlcItem> PlcItemMd_X_List { get; set; }=new List<PlcItem>();
public static List<PlcItem> PlcItemMd_Y_List { get; set; }=new List<PlcItem>();
//public static List<PlcItem> PlcItemMd_Y_List { get; set; }=new List<PlcItem>();
public static List<Warning> BasWarningMd_List { get; set; }

View File

@@ -24,6 +24,7 @@ using System.Diagnostics;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace CleanMachineHMI
@@ -60,7 +61,7 @@ namespace CleanMachineHMI
private byte slaveAddress = 1;
private byte slaveAddress = byte.Parse(ConfigurationManager.AppSettings["SlaveAddress"]);
private bool _isConn = false;
@@ -85,13 +86,77 @@ namespace CleanMachineHMI
#else
private static SerialPort port;
#endif
public List<PlcItem> PlcItemMdList { get; set; } = new List<PlcItem>();
public List<PlcItem> PlcItemMd_D_List { get; set; } = new List<PlcItem>();
public List<PlcItem> PlcItemMd_M_List { get; set; } = new List<PlcItem>();
public List<PlcItem> PlcItemMd_X_List { get; set; } = new List<PlcItem>();
public List<PlcItem> PlcItemMd_Y_List { get; set; } = new List<PlcItem>();
public void StartRead()
{
Thread th = new Thread(RefreshPlcItem)
{
IsBackground = true
};
th.Start();
}
private void RefreshPlcItem()
{
while (Global.SysThIsRunFlag)
{
RefreshPlcItem_M();
Instance.RefreshPlcItem_D();
Instance.RefreshPlcItem_X();
Instance.RefreshPlcItem_Y();
// ShowWarningMsg();
Thread.Sleep(100);
}
}
/// <summary>
/// 初始化PLC
/// </summary>
/// <returns></returns>
public bool PlcInit()
public bool PlcInit(IEnumerable<PlcItem> items)
{
foreach (var plcitem in items)
{
switch (plcitem.PlcItemDataType)
{
case 0:
PlcItemMd_M_List.Add(plcitem);
break;
case 1:
PlcItemMd_D_List.Add(plcitem);
break;
case 2:
PlcItemMd_X_List.Add(plcitem);
break;
case 3:
PlcItemMd_Y_List.Add(plcitem);
break;
}
PlcItemMdList.Add(plcitem);
}
try
{
@@ -103,6 +168,7 @@ namespace CleanMachineHMI
Parity paritymsg = (Parity)int.Parse(ConfigurationManager.AppSettings["ParityMsg"]);
int modbusPattern = int.Parse(ConfigurationManager.AppSettings["ModbusPattern"]);
//string portname = GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'PortName'")[0]["PARAMETER_VALUE"].ToString();
//int baudrate = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'BaudRate'")[0]["PARAMETER_VALUE"]);
//int databits = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'DataBits'")[0]["PARAMETER_VALUE"]);
@@ -176,9 +242,9 @@ namespace CleanMachineHMI
bool[] readBytArr_M1 = master.ReadCoils(slaveAddress, 2048, 50);
if (readBytArr_M.Length > 0 && readBytArr_M1.Length > 0)
{
if (Global.PlcItemMd_M_List != null && Global.PlcItemMd_M_List.Count > 0)
if (PlcItemMd_M_List != null && PlcItemMd_M_List.Count > 0)
{
foreach (PlcItem item in Global.PlcItemMd_M_List)
foreach (PlcItem item in PlcItemMd_M_List)
{
if (Convert.ToInt32(item.PlcItemPriAddress) >= 200)
{
@@ -223,9 +289,9 @@ namespace CleanMachineHMI
ushort[] readBytArr_D = master.ReadHoldingRegisters(slaveAddress, 4505, 50);
if (readBytArr_D.Length > 0 && tmpReadAlarmBytArr_D.Length > 0)
{
if (Global.PlcItemMd_D_List != null && Global.PlcItemMd_D_List.Count > 0)
if (PlcItemMd_D_List != null && PlcItemMd_D_List.Count > 0)
{
foreach (PlcItem item in Global.PlcItemMd_D_List)
foreach (PlcItem item in PlcItemMd_D_List)
{
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
{
@@ -239,6 +305,7 @@ namespace CleanMachineHMI
}
else
{
if (item.PlcItemDataLength == 2)
{
ushort[] tmp_1 = new ushort[] { readBytArr_D[plcItemDeviationAddress], readBytArr_D[plcItemDeviationAddress + 1] };
@@ -627,9 +694,9 @@ namespace CleanMachineHMI
if (readBytArr_X.Length > 0)
//if(true)
{
if (Global.PlcItemMd_X_List != null && Global.PlcItemMd_X_List.Count > 0)
if (PlcItemMd_X_List != null && PlcItemMd_X_List.Count > 0)
{
foreach (PlcItem item in Global.PlcItemMd_X_List)
foreach (PlcItem item in PlcItemMd_X_List)
{
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
{
@@ -666,9 +733,9 @@ namespace CleanMachineHMI
if (readBytArr_Y.Length > 0)
//if(true)
{
if (Global.PlcItemMd_Y_List != null && Global.PlcItemMd_Y_List.Count > 0)
if (PlcItemMd_Y_List != null && PlcItemMd_Y_List.Count > 0)
{
foreach (PlcItem item in Global.PlcItemMd_Y_List)
foreach (PlcItem item in PlcItemMd_Y_List)
{
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
{
@@ -696,9 +763,11 @@ namespace CleanMachineHMI
}
public object ReadPlcItem(string plcItemCode)
{
PlcItem item = Global.PlcItemMdList.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item = PlcItemMdList.Find(x => x.PlcItemCode == plcItemCode);
if (item == null)
{
return null;
@@ -744,7 +813,7 @@ namespace CleanMachineHMI
{
case PlcItemTypeDesc.M:
PlcItem item_M = Global.PlcItemMd_M_List.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item_M = PlcItemMd_M_List.Find(x => x.PlcItemCode == plcItemCode);
if (item_M == null)
{
return null;
@@ -759,7 +828,7 @@ namespace CleanMachineHMI
}
break;
case PlcItemTypeDesc.D:
PlcItem item_D = Global.PlcItemMd_D_List.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item_D = PlcItemMd_D_List.Find(x => x.PlcItemCode == plcItemCode);
if (item_D == null)
{
return null;
@@ -774,7 +843,7 @@ namespace CleanMachineHMI
}
break;
case PlcItemTypeDesc.X:
PlcItem item_X = Global.PlcItemMd_X_List.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item_X = PlcItemMd_X_List.Find(x => x.PlcItemCode == plcItemCode);
if (item_X == null)
{
return null;
@@ -789,7 +858,7 @@ namespace CleanMachineHMI
}
break;
case PlcItemTypeDesc.Y:
PlcItem item_Y = Global.PlcItemMd_Y_List.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item_Y = PlcItemMd_Y_List.Find(x => x.PlcItemCode == plcItemCode);
if (item_Y == null)
{
return null;
@@ -828,7 +897,7 @@ namespace CleanMachineHMI
switch (itemType)
{
case PlcItemTypeDesc.M:
PlcItem item_M = Global.PlcItemMd_M_List.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item_M = PlcItemMd_M_List.Find(x => x.PlcItemCode == plcItemCode);
if (item_M == null)
{
return false;
@@ -836,7 +905,7 @@ namespace CleanMachineHMI
master.WriteSingleCoil(slaveAddress, Convert.ToUInt16(item_M.PlcItemModbusAddress), bool.Parse(writeValue));
return true;
case PlcItemTypeDesc.Y:
PlcItem item_Y = Global.PlcItemMd_Y_List.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item_Y = PlcItemMd_Y_List.Find(x => x.PlcItemCode == plcItemCode);
if (item_Y == null)
{
return false;
@@ -844,7 +913,7 @@ namespace CleanMachineHMI
master.WriteSingleCoil(slaveAddress, Convert.ToUInt16(item_Y.PlcItemModbusAddress), bool.Parse(writeValue));
return true;
case PlcItemTypeDesc.D:
PlcItem item_D = Global.PlcItemMd_D_List.Find(x => x.PlcItemCode == plcItemCode);
PlcItem item_D = PlcItemMd_D_List.Find(x => x.PlcItemCode == plcItemCode);
if (item_D == null)
{
return false;

View File

@@ -146,10 +146,10 @@ namespace CleanMachineHMI
lstMoitor_Y.Clear();
#region PLC X数据类型变量
if (Global.PlcItemMd_X_List != null && Global.PlcItemMd_X_List.Count > 0)
if (PlcOperationHelper.Instance.PlcItemMd_X_List != null && PlcOperationHelper.Instance.PlcItemMd_X_List.Count > 0)
{
//List<BasPlcItemMd> tempLst = AppConfig.PlcItemMd_X_List.FindAll(x => x.PlcItemName != "备用").OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = Global.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
int dataSum = tempLst.Count;
int rowNum;
if (dataSum % 2 == 0)
@@ -262,10 +262,10 @@ namespace CleanMachineHMI
#endregion
#region PLC Y数据类型变量
if (Global.PlcItemMd_Y_List != null && Global.PlcItemMd_Y_List.Count > 0)
if (PlcOperationHelper.Instance.PlcItemMd_Y_List != null && PlcOperationHelper.Instance.PlcItemMd_Y_List.Count > 0)
{
//List<BasPlcItemMd> tempLst = AppConfig.PlcItemMd_Y_List.FindAll(x => x.PlcItemName != "备用").OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = Global.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
int dataSum = tempLst.Count;
//int dataSum = AppConfig.PlcItemMd_Y_List.Count;
int rowNum;

View File

@@ -166,9 +166,9 @@ namespace CleanMachineHMI
{
try
{
if (Global.PlcItemMd_X_List != null && Global.PlcItemMd_X_List.Count > 0)
if (PlcOperationHelper.Instance.PlcItemMd_X_List != null && PlcOperationHelper.Instance.PlcItemMd_X_List.Count > 0)
{
List<PlcItem> tempLst = Global.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_X_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
foreach (PlcItem item in tempLst)
{
Invoke(new Action(() =>
@@ -183,9 +183,9 @@ namespace CleanMachineHMI
}
}
if (Global.PlcItemMd_Y_List != null && Global.PlcItemMd_Y_List.Count > 0)
if (PlcOperationHelper.Instance.PlcItemMd_Y_List != null && PlcOperationHelper.Instance.PlcItemMd_Y_List.Count > 0)
{
List<PlcItem> tempLst = Global.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
List<PlcItem> tempLst = PlcOperationHelper.Instance.PlcItemMd_Y_List.OrderBy(x => Convert.ToInt32(x.PlcItemPriAddress)).ToList();
foreach (PlcItem item in tempLst)
{
Invoke(new Action(() =>
@@ -220,7 +220,7 @@ namespace CleanMachineHMI
string plcItemNameAddress = pic.Name.Replace("picb_", "");
if (plcItemNameAddress.StartsWith("M"))
{
PlcItem tmpPlc = Global.PlcItemMd_M_List.First(x => x.PlcItemPriAddress == plcItemNameAddress.Replace("M", ""));
PlcItem tmpPlc = PlcOperationHelper.Instance.PlcItemMd_M_List.First(x => x.PlcItemPriAddress == plcItemNameAddress.Replace("M", ""));
if (tmpPlc != null)
{
ttp.SetToolTip(pic, tmpPlc.PlcItemName);
@@ -228,7 +228,7 @@ namespace CleanMachineHMI
}
else
{
PlcItem tmpPlc = Global.PlcItemMd_X_List.First(x => x.PlcItemPriAddress == Convert.ToInt32(plcItemNameAddress.Replace("X", ""), 10).ToString());
PlcItem tmpPlc = PlcOperationHelper.Instance.PlcItemMd_X_List.First(x => x.PlcItemPriAddress == Convert.ToInt32(plcItemNameAddress.Replace("X", ""), 10).ToString());
if (tmpPlc != null)
{
ttp.SetToolTip(pic, tmpPlc.PlcItemName);

View File

@@ -152,26 +152,26 @@ namespace CleanMachineHMI
SwitchFrmMenu = new dlgSwitchFrmMenu(AddFrmMenuPage);
var plcitems = new CleanMachine.BLL.BAS.PlcItemBLL().GetList("");
foreach (var plcitem in plcitems)
{
switch (plcitem.PlcItemDataType)
{
case 0:
Global.PlcItemMd_M_List.Add(plcitem);
break;
//foreach (var plcitem in plcitems)
//{
// switch (plcitem.PlcItemDataType)
// {
// case 0:
// Global.PlcItemMd_M_List.Add(plcitem);
// break;
case 1:
Global.PlcItemMd_D_List.Add(plcitem);
break;
case 2:
Global.PlcItemMd_X_List.Add(plcitem);
break;
case 3:
Global.PlcItemMd_Y_List.Add(plcitem);
break;
}
Global.PlcItemMdList.Add(plcitem);
}
// case 1:
// Global.PlcItemMd_D_List.Add(plcitem);
// break;
// case 2:
// Global.PlcItemMd_X_List.Add(plcitem);
// break;
// case 3:
// Global.PlcItemMd_Y_List.Add(plcitem);
// break;
// }
// Global.PlcItemMdList.Add(plcitem);
//}
@@ -211,7 +211,10 @@ namespace CleanMachineHMI
//GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_Y_List);
//}
InitWarningMsg();
bool isInitStatus = PlcOperationHelper.Instance.PlcInit();
bool isInitStatus = PlcOperationHelper.Instance.PlcInit(plcitems);
if (isInitStatus)
{
label3Professional.Text = this.T("串口打开成功,PLC连接成功!", "label3Professional_Success");
@@ -219,11 +222,14 @@ namespace CleanMachineHMI
isPlcConnStatus = true;
Global.SysThIsRunFlag = true;
Thread th = new Thread(RefreshPlcItem)
{
IsBackground = true
};
th.Start();
PlcOperationHelper.Instance.StartRead();
//Thread th = new Thread(RefreshPlcItem)
//{
// IsBackground = true
//};
//th.Start();
//Thread th = new Thread(RefreshPlcItem_M)
@@ -250,11 +256,11 @@ namespace CleanMachineHMI
//};
//th3.Start();
//Thread th4 = new Thread(MainThRunFunc)
//{
// IsBackground = true
//};
//th4.Start();
Thread th4 = new Thread(MainThRunFunc)
{
IsBackground = true
};
th4.Start();
LogHelper.WriteLog($"串口打开成功,PLC连接成功!", LogTypeEum.Run);
}
@@ -292,7 +298,7 @@ namespace CleanMachineHMI
private void ShowWarningMsg()
{
PlcItem item = Global.PlcItemMd_D_List.FirstOrDefault(x => x.PlcItemCode == "AlarmPopUpMsg");
PlcItem item = PlcOperationHelper.Instance.PlcItemMd_D_List.FirstOrDefault(x => x.PlcItemCode == "AlarmPopUpMsg");
char[] tmpCharArr = Convert.ToString(Convert.ToInt32(item.PlcItemValue), 2).PadLeft(16, '0').Reverse().ToArray();
if (tmpCharArr.Contains('1'))
{
@@ -397,56 +403,56 @@ namespace CleanMachineHMI
LeadDbHelperSQLite.ExecuteSql(sql2);
}
}
private void SetPlcItem(List<PlcItem> PlcItemMdList, DataRow item)
{
if (PlcItemMdList != null)
{
PlcItem md = PlcItemMdList.Find(x => x.PlcItemCode == item["PLC_ITEM_CODE"].ToString());
if (md != null)
{
md.PlcItemId = int.Parse(item["PLC_ITEM_ID"].ToString());
md.PlcItemCode = item["PLC_ITEM_CODE"].ToString();
md.PlcItemName = item["PLC_ITEM_NAME"].ToString();
md.PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString());
md.PlcItemDataType = Convert.ToInt32(item["PLC_ITEM_DATA_TYPE"].ToString());
md.PlcItemPriAddress = item["PLC_ITEM_PRI_ADDRESS"].ToString();
md.PlcItemModbusAddress = item["PLC_ITEM_MODBUS_ADDRESS"].ToString();
md.PlcItemDeviationAddress = item["PLC_ITEM_DEVIATION_ADDRESS"] == null ? "" : item["PLC_ITEM_DEVIATION_ADDRESS"].ToString();
md.PlcItemDataLength = Convert.ToInt32(item["PLC_ITEM_DATA_LENGTH"]);
}
else
{
PlcItemMdList.Add(new PlcItem
{
PlcItemId = int.Parse(item["PLC_ITEM_ID"].ToString()),
PlcItemCode = item["PLC_ITEM_CODE"].ToString(),
PlcItemName = item["PLC_ITEM_NAME"].ToString(),
PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString()),
PlcItemDataType = Convert.ToInt32(item["PLC_ITEM_DATA_TYPE"].ToString()),
PlcItemPriAddress = item["PLC_ITEM_PRI_ADDRESS"].ToString(),
PlcItemModbusAddress = item["PLC_ITEM_MODBUS_ADDRESS"].ToString(),
PlcItemDeviationAddress = item["PLC_ITEM_DEVIATION_ADDRESS"] == null ? "" : item["PLC_ITEM_DEVIATION_ADDRESS"].ToString(),
PlcItemDataLength = Convert.ToInt32(item["PLC_ITEM_DATA_LENGTH"]),
});
}
}
else
{
PlcItemMdList = new List<PlcItem>();
PlcItemMdList.Add(new PlcItem
{
PlcItemId = int.Parse(item["PLC_ITEM_ID"].ToString()),
PlcItemCode = item["PLC_ITEM_CODE"].ToString(),
PlcItemName = item["PLC_ITEM_NAME"].ToString(),
PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString()),
PlcItemDataType = Convert.ToInt32(item["PLC_ITEM_DATA_TYPE"].ToString()),
PlcItemPriAddress = item["PLC_ITEM_PRI_ADDRESS"].ToString(),
PlcItemModbusAddress = item["PLC_ITEM_MODBUS_ADDRESS"].ToString(),
PlcItemDeviationAddress = item["PLC_ITEM_DEVIATION_ADDRESS"] == null ? "" : item["PLC_ITEM_DEVIATION_ADDRESS"].ToString(),
PlcItemDataLength = Convert.ToInt32(item["PLC_ITEM_DATA_LENGTH"]),
});
}
}
//private void SetPlcItem(List<PlcItem> PlcItemMdList, DataRow item)
//{
// if (PlcItemMdList != null)
// {
// PlcItem md = PlcItemMdList.Find(x => x.PlcItemCode == item["PLC_ITEM_CODE"].ToString());
// if (md != null)
// {
// md.PlcItemId = int.Parse(item["PLC_ITEM_ID"].ToString());
// md.PlcItemCode = item["PLC_ITEM_CODE"].ToString();
// md.PlcItemName = item["PLC_ITEM_NAME"].ToString();
// md.PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString());
// md.PlcItemDataType = Convert.ToInt32(item["PLC_ITEM_DATA_TYPE"].ToString());
// md.PlcItemPriAddress = item["PLC_ITEM_PRI_ADDRESS"].ToString();
// md.PlcItemModbusAddress = item["PLC_ITEM_MODBUS_ADDRESS"].ToString();
// md.PlcItemDeviationAddress = item["PLC_ITEM_DEVIATION_ADDRESS"] == null ? "" : item["PLC_ITEM_DEVIATION_ADDRESS"].ToString();
// md.PlcItemDataLength = Convert.ToInt32(item["PLC_ITEM_DATA_LENGTH"]);
// }
// else
// {
// PlcItemMdList.Add(new PlcItem
// {
// PlcItemId = int.Parse(item["PLC_ITEM_ID"].ToString()),
// PlcItemCode = item["PLC_ITEM_CODE"].ToString(),
// PlcItemName = item["PLC_ITEM_NAME"].ToString(),
// PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString()),
// PlcItemDataType = Convert.ToInt32(item["PLC_ITEM_DATA_TYPE"].ToString()),
// PlcItemPriAddress = item["PLC_ITEM_PRI_ADDRESS"].ToString(),
// PlcItemModbusAddress = item["PLC_ITEM_MODBUS_ADDRESS"].ToString(),
// PlcItemDeviationAddress = item["PLC_ITEM_DEVIATION_ADDRESS"] == null ? "" : item["PLC_ITEM_DEVIATION_ADDRESS"].ToString(),
// PlcItemDataLength = Convert.ToInt32(item["PLC_ITEM_DATA_LENGTH"]),
// });
// }
// }
// else
// {
// PlcItemMdList = new List<PlcItem>();
// PlcItemMdList.Add(new PlcItem
// {
// PlcItemId = int.Parse(item["PLC_ITEM_ID"].ToString()),
// PlcItemCode = item["PLC_ITEM_CODE"].ToString(),
// PlcItemName = item["PLC_ITEM_NAME"].ToString(),
// PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString()),
// PlcItemDataType = Convert.ToInt32(item["PLC_ITEM_DATA_TYPE"].ToString()),
// PlcItemPriAddress = item["PLC_ITEM_PRI_ADDRESS"].ToString(),
// PlcItemModbusAddress = item["PLC_ITEM_MODBUS_ADDRESS"].ToString(),
// PlcItemDeviationAddress = item["PLC_ITEM_DEVIATION_ADDRESS"] == null ? "" : item["PLC_ITEM_DEVIATION_ADDRESS"].ToString(),
// PlcItemDataLength = Convert.ToInt32(item["PLC_ITEM_DATA_LENGTH"]),
// });
// }
//}
private void timer_Tick(object sender, EventArgs e)
{
try
@@ -675,6 +681,7 @@ namespace CleanMachineHMI
#endregion
PlcOperationHelper.Instance.HeartbeatDetection();
ShowWarningMsg();
#endregion
#if RELEASE
}