修改
This commit is contained in:
@@ -59,7 +59,7 @@ namespace CleanMachineHMI
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
//UserControl objFrm = GlobalHelper.FrmModelList.Where(s => s.FormType == enumFormType).FirstOrDefault().Form;
|
||||
Type frmType = GlobalHelper.FrmModelList.Where(s => s.FormType == enumFormType).FirstOrDefault().Form;
|
||||
Type frmType = Global.FrmModelList.Where(s => s.FormType == enumFormType).FirstOrDefault().Form;
|
||||
if (isDefaultPage)
|
||||
{
|
||||
kryptonNavigator1.Pages[0].Controls.Clear();
|
||||
@@ -150,41 +150,66 @@ namespace CleanMachineHMI
|
||||
{
|
||||
this.SetFormControlText();
|
||||
SwitchFrmMenu = new dlgSwitchFrmMenu(AddFrmMenuPage);
|
||||
|
||||
string sql1 = $@" SELECT * FROM BAS_PLC_ITEM ";
|
||||
DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
|
||||
if (dt1 != null && dt1.Rows.Count > 0)
|
||||
{
|
||||
GlobalHelper.PlcItemMd_M_List = new List<PlcItem>();
|
||||
GlobalHelper.PlcItemMd_D_List = new List<PlcItem>();
|
||||
GlobalHelper.PlcItemMd_X_List = new List<PlcItem>();
|
||||
GlobalHelper.PlcItemMd_Y_List = new List<PlcItem>();
|
||||
|
||||
foreach (DataRow item in dt1.Rows)
|
||||
var plcitems = new CleanMachine.BLL.BAS.PlcItemBLL().GetList("");
|
||||
foreach (var plcitem in plcitems)
|
||||
{
|
||||
switch (plcitem.PlcItemDataType)
|
||||
{
|
||||
if (item["PLC_ITEM_DATA_TYPE"].ToString() == "0")
|
||||
{
|
||||
SetPlcItem(GlobalHelper.PlcItemMd_M_List, item);
|
||||
}
|
||||
else if (item["PLC_ITEM_DATA_TYPE"].ToString() == "1")
|
||||
{
|
||||
SetPlcItem(GlobalHelper.PlcItemMd_D_List, item);
|
||||
}
|
||||
else if (item["PLC_ITEM_DATA_TYPE"].ToString() == "2")
|
||||
{
|
||||
SetPlcItem(GlobalHelper.PlcItemMd_X_List, item);
|
||||
}
|
||||
else if (item["PLC_ITEM_DATA_TYPE"].ToString() == "3")
|
||||
{
|
||||
SetPlcItem(GlobalHelper.PlcItemMd_Y_List, item);
|
||||
}
|
||||
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;
|
||||
}
|
||||
GlobalHelper.PlcItemMdList = new List<PlcItem>();
|
||||
GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_M_List);
|
||||
GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_D_List);
|
||||
GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_X_List);
|
||||
GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_Y_List);
|
||||
Global.PlcItemMdList.Add(plcitem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//string sql1 = $@" SELECT * FROM BAS_PLC_ITEM ";
|
||||
//DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
|
||||
//if (dt1 != null && dt1.Rows.Count > 0)
|
||||
//{
|
||||
//GlobalHelper.PlcItemMd_M_List = new List<PlcItem>();
|
||||
//GlobalHelper.PlcItemMd_D_List = new List<PlcItem>();
|
||||
//GlobalHelper.PlcItemMd_X_List = new List<PlcItem>();
|
||||
//GlobalHelper.PlcItemMd_Y_List = new List<PlcItem>();
|
||||
|
||||
//foreach (DataRow item in dt1.Rows)
|
||||
//{
|
||||
// if (item["PLC_ITEM_DATA_TYPE"].ToString() == "0")
|
||||
// {
|
||||
// SetPlcItem(GlobalHelper.PlcItemMd_M_List, item);
|
||||
// }
|
||||
// else if (item["PLC_ITEM_DATA_TYPE"].ToString() == "1")
|
||||
// {
|
||||
// SetPlcItem(GlobalHelper.PlcItemMd_D_List, item);
|
||||
// }
|
||||
// else if (item["PLC_ITEM_DATA_TYPE"].ToString() == "2")
|
||||
// {
|
||||
// SetPlcItem(GlobalHelper.PlcItemMd_X_List, item);
|
||||
// }
|
||||
// else if (item["PLC_ITEM_DATA_TYPE"].ToString() == "3")
|
||||
// {
|
||||
// SetPlcItem(GlobalHelper.PlcItemMd_Y_List, item);
|
||||
// }
|
||||
//}
|
||||
//GlobalHelper.PlcItemMdList = new List<PlcItem>();
|
||||
//GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_M_List);
|
||||
//GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_D_List);
|
||||
//GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_X_List);
|
||||
//GlobalHelper.PlcItemMdList.AddRange(GlobalHelper.PlcItemMd_Y_List);
|
||||
//}
|
||||
InitWarningMsg();
|
||||
bool isInitStatus = PlcOperationHelper.Instance.PlcInit();
|
||||
if (isInitStatus)
|
||||
@@ -193,43 +218,43 @@ namespace CleanMachineHMI
|
||||
label3Professional.BackColor = Color.Lime;
|
||||
isPlcConnStatus = true;
|
||||
|
||||
GlobalHelper.SysThIsRunFlag = true;
|
||||
//Thread th = new Thread(RefreshPlcItem)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th.Start();
|
||||
|
||||
|
||||
Thread th = new Thread(RefreshPlcItem_M)
|
||||
Global.SysThIsRunFlag = true;
|
||||
Thread th = new Thread(RefreshPlcItem)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th.Start();
|
||||
|
||||
Thread th1 = new Thread(RefreshPlcItem_D)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th1.Start();
|
||||
|
||||
Thread th2 = new Thread(RefreshPlcItem_X)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th2.Start();
|
||||
//Thread th = new Thread(RefreshPlcItem_M)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th.Start();
|
||||
|
||||
Thread th3 = new Thread(RefreshPlcItem_Y)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th3.Start();
|
||||
//Thread th1 = new Thread(RefreshPlcItem_D)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th1.Start();
|
||||
|
||||
Thread th4 = new Thread(MainThRunFunc)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th4.Start();
|
||||
//Thread th2 = new Thread(RefreshPlcItem_X)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th2.Start();
|
||||
|
||||
//Thread th3 = new Thread(RefreshPlcItem_Y)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th3.Start();
|
||||
|
||||
//Thread th4 = new Thread(MainThRunFunc)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th4.Start();
|
||||
|
||||
LogHelper.WriteLog($"串口打开成功,PLC连接成功!", LogTypeEum.Run);
|
||||
}
|
||||
@@ -246,7 +271,7 @@ namespace CleanMachineHMI
|
||||
MothedShowMessage = new dlgShowMessage(Test);
|
||||
RefreshFrmHost = new dlgRefreshFrmHost(ShowWorkingPalletFullNumAlarm);
|
||||
//Show_ptb_Alarm = new dlgShow_ptb_Alarm(ShowPicAlarm);
|
||||
GlobalHelper.OnShowMainFrmAlarmMsg += ShowPicAlarm;
|
||||
Global.OnShowMainFrmAlarmMsg += ShowPicAlarm;
|
||||
Show_Plc_Alarm = new dlgShow_Plc_Alarm(ShowPlcAlarm);
|
||||
RemoveMaintainingFlag = new dlgShowMessage(ClearMaintainingFlag);
|
||||
timer.Enabled = true;
|
||||
@@ -267,7 +292,7 @@ namespace CleanMachineHMI
|
||||
|
||||
private void ShowWarningMsg()
|
||||
{
|
||||
PlcItem item = GlobalHelper.PlcItemMd_D_List.FirstOrDefault(x => x.PlcItemCode == "AlarmPopUpMsg");
|
||||
PlcItem item = Global.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'))
|
||||
{
|
||||
@@ -277,7 +302,7 @@ namespace CleanMachineHMI
|
||||
if (tmpCharArr[j] == '1')
|
||||
{
|
||||
string priWarnCode = "bit";
|
||||
Warning tmpMd = GlobalHelper.BasWarningMd_List.Find(x => x.PlcItemCode == $"D12" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1");
|
||||
Warning tmpMd = Global.BasWarningMd_List.Find(x => x.PlcItemCode == $"D12" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1");
|
||||
if (tmpMd != null)
|
||||
{
|
||||
warnLst.Add(tmpMd);
|
||||
@@ -286,14 +311,14 @@ namespace CleanMachineHMI
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (GlobalHelper.PopupWarningMsgForm == null)
|
||||
if (Global.PopupWarningMsgForm == null)
|
||||
{
|
||||
frmPopupWarningMsg frm = new frmPopupWarningMsg();
|
||||
frmPopupWarningMsg.warnLst = warnLst;
|
||||
frm.TopMost = true;
|
||||
frm.Show();
|
||||
frmPopupWarningMsg.RefreshFrmHost();
|
||||
GlobalHelper.PopupWarningMsgForm = frm;
|
||||
Global.PopupWarningMsgForm = frm;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -324,31 +349,34 @@ namespace CleanMachineHMI
|
||||
}
|
||||
private void InitWarningMsg()
|
||||
{
|
||||
string sql = $@"SELECT * FROM BAS_WARNING";
|
||||
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
GlobalHelper.BasWarningMd_List = new List<Warning>();
|
||||
GlobalHelper.CmWarningLogMd_List = new List<WarningLog>();
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
GlobalHelper.BasWarningMd_List.Add(new Warning
|
||||
{
|
||||
WarningCode = item["WARNING_CODE"].ToString(),
|
||||
WarningName = item["WARNING_NAME"].ToString(),
|
||||
PlcItemCode = item["PLC_ITEM_CODE"] == null ? null : item["PLC_ITEM_CODE"].ToString(),
|
||||
WarningType = item["WARNING_TYPE"].ToString(),
|
||||
WarningMessage = item["WARNING_MESSAGE"].ToString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
//string sql = $@"SELECT * FROM BAS_WARNING";
|
||||
//DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
//if (dt != null && dt.Rows.Count > 0)
|
||||
//{
|
||||
// GlobalHelper.BasWarningMd_List = new List<Warning>();
|
||||
|
||||
// foreach (DataRow item in dt.Rows)
|
||||
// {
|
||||
// GlobalHelper.BasWarningMd_List.Add(new Warning
|
||||
// {
|
||||
// WarningCode = item["WARNING_CODE"].ToString(),
|
||||
// WarningName = item["WARNING_NAME"].ToString(),
|
||||
// PlcItemCode = item["PLC_ITEM_CODE"] == null ? null : item["PLC_ITEM_CODE"].ToString(),
|
||||
// WarningType = item["WARNING_TYPE"].ToString(),
|
||||
// WarningMessage = item["WARNING_MESSAGE"].ToString(),
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
Global.BasWarningMd_List = new CleanMachine.BLL.BAS.WarningBLL().GetList("").ToList();
|
||||
Global.CmWarningLogMd_List = new List<WarningLog>();
|
||||
string sql1 = $@"SELECT * FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT =0";
|
||||
DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
|
||||
if (dt1 != null && dt1.Rows.Count > 0)
|
||||
{
|
||||
|
||||
foreach (DataRow item in dt1.Rows)
|
||||
{
|
||||
GlobalHelper.CmWarningLogMd_List.Add(new WarningLog
|
||||
Global.CmWarningLogMd_List.Add(new WarningLog
|
||||
{
|
||||
WarningCode = item["WARNING_CODE"].ToString(),
|
||||
WarningName = item["WARNING_NAME"].ToString(),
|
||||
@@ -376,7 +404,7 @@ namespace CleanMachineHMI
|
||||
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.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());
|
||||
@@ -390,7 +418,7 @@ namespace CleanMachineHMI
|
||||
{
|
||||
PlcItemMdList.Add(new PlcItem
|
||||
{
|
||||
PlcItemId = int.Parse( item["PLC_ITEM_ID"].ToString()),
|
||||
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()),
|
||||
@@ -407,7 +435,7 @@ namespace CleanMachineHMI
|
||||
PlcItemMdList = new List<PlcItem>();
|
||||
PlcItemMdList.Add(new PlcItem
|
||||
{
|
||||
PlcItemId = int.Parse( item["PLC_ITEM_ID"].ToString()),
|
||||
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()),
|
||||
@@ -433,7 +461,7 @@ namespace CleanMachineHMI
|
||||
|
||||
private void RefreshPlcItem()
|
||||
{
|
||||
while (GlobalHelper.SysThIsRunFlag)
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_M();
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_D();
|
||||
@@ -450,7 +478,7 @@ namespace CleanMachineHMI
|
||||
#region 线程执行函数
|
||||
private void RefreshPlcItem_M()
|
||||
{
|
||||
while (GlobalHelper.SysThIsRunFlag)
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_M();
|
||||
Thread.Sleep(100);
|
||||
@@ -458,7 +486,7 @@ namespace CleanMachineHMI
|
||||
}
|
||||
private void RefreshPlcItem_D()
|
||||
{
|
||||
while (GlobalHelper.SysThIsRunFlag)
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_D();
|
||||
ShowWarningMsg();
|
||||
@@ -467,7 +495,7 @@ namespace CleanMachineHMI
|
||||
}
|
||||
private void RefreshPlcItem_X()
|
||||
{
|
||||
while (GlobalHelper.SysThIsRunFlag)
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_X();
|
||||
Thread.Sleep(100);
|
||||
@@ -475,7 +503,7 @@ namespace CleanMachineHMI
|
||||
}
|
||||
private void RefreshPlcItem_Y()
|
||||
{
|
||||
while (GlobalHelper.SysThIsRunFlag)
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_Y();
|
||||
Thread.Sleep(100);
|
||||
@@ -486,7 +514,7 @@ namespace CleanMachineHMI
|
||||
|
||||
|
||||
long lastTick = DateTime.Now.Ticks;
|
||||
while (GlobalHelper.SysThIsRunFlag)
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
@@ -693,11 +721,11 @@ namespace CleanMachineHMI
|
||||
Task.Run(async delegate
|
||||
{
|
||||
timer.Enabled = false;
|
||||
GlobalHelper.SysThIsRunFlag = false;
|
||||
GlobalHelper.eventAlarmLock = true;
|
||||
if (GlobalHelper.CmWarningLogMd_List.Count > 0)
|
||||
Global.SysThIsRunFlag = false;
|
||||
Global.eventAlarmLock = true;
|
||||
if (Global.CmWarningLogMd_List.Count > 0)
|
||||
{
|
||||
foreach (WarningLog item in GlobalHelper.CmWarningLogMd_List)
|
||||
foreach (WarningLog item in Global.CmWarningLogMd_List)
|
||||
{
|
||||
if (item.WaringStatus == 0 && item.WarningHandleResult == 0)
|
||||
{
|
||||
@@ -779,12 +807,12 @@ namespace CleanMachineHMI
|
||||
|
||||
if (isPlcConnStatus)
|
||||
{
|
||||
// 断开PLC连接
|
||||
PlcOperationHelper.Instance.ClosePlcConn();
|
||||
// 断开PLC连接
|
||||
PlcOperationHelper.Instance.ClosePlcConn();
|
||||
isPlcConnStatus = false;
|
||||
}
|
||||
if (GlobalHelper.PopupWarningMsgForm != null)
|
||||
GlobalHelper.PopupWarningMsgForm.Close();
|
||||
if (Global.PopupWarningMsgForm != null)
|
||||
Global.PopupWarningMsgForm.Close();
|
||||
Environment.Exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user