修改
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<!--<add key="LeadSQLite" value="Data Source=|DataDirectory|\\clearMac.db;Pooling=true;FailIfMissing=false"/>-->
|
||||
<add key="LeadSQLite" value="Data Source=DataBase/clearMac.db"/>
|
||||
<!--串口名称-->
|
||||
<add key="PortName" value="COM2"/>
|
||||
<add key="PortName" value="COM3"/>
|
||||
<!--串口波特率-->
|
||||
<add key="BaudRate" value="9600"/>
|
||||
<!--串口数据位-->
|
||||
|
||||
@@ -171,6 +171,7 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
}
|
||||
//加载当前工作信息
|
||||
LoadCurrentWorkingTray();
|
||||
|
||||
Thread th1 = new Thread(MainDtlRunTh)
|
||||
{
|
||||
IsBackground = true
|
||||
@@ -630,6 +631,7 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
kcmb_SheetType.SelectedIndex = 0;
|
||||
ktb_IR.Text = "";
|
||||
kdtp_RecordDate.Text = "";
|
||||
|
||||
kdtp_RecordDate.Checked = false;
|
||||
|
||||
ktb_CompleteNum.Text = "0";
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace CleanMachineHMI
|
||||
|
||||
}
|
||||
|
||||
public static bool CheckRole(string FormName )
|
||||
public static bool CheckRole(string FormName)
|
||||
{
|
||||
//DataRow[] drs = GlobalHelper.RoleMenuPermission.Select($" MENU_URL = '{this.Name}' AND MENU_PID = '-1'");
|
||||
//DataRow[] drs1 = GlobalHelper.RoleMenuPermission.Select($" MENU_URL = '{item.Name}' AND MENU_PID = '{drs[0]["MENU_ID"]}'");
|
||||
@@ -126,6 +126,46 @@ namespace CleanMachineHMI
|
||||
|
||||
//public static List<PlcItem> PlcItemMd_Y_List { get; set; }=new List<PlcItem>();
|
||||
|
||||
|
||||
|
||||
public static List<WarningLog> CheckWarng(ushort id, string PlcItem)
|
||||
{
|
||||
var result = new List<WarningLog>();
|
||||
var list = BasWarningMd_List.FindAll(m => m.PlcItemCode == PlcItem);
|
||||
foreach (var wag in list)
|
||||
{
|
||||
if ((id & wag.bitCode) > 0)
|
||||
{
|
||||
result.Add(new WarningLog()
|
||||
{
|
||||
|
||||
WarningCode = wag.WarningCode,
|
||||
WarningName = wag.WarningName,
|
||||
WarningType = wag.WarningType,
|
||||
WarningMessage = wag.WarningMessage,
|
||||
WarningTime = DateTime.Now,
|
||||
PlcItemCode = PlcItem,
|
||||
WaringStatus = 0,
|
||||
WarningHandleResult = 0,
|
||||
CreateBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
UpdateBy = 1,
|
||||
UpdateTime = DateTime.Now,
|
||||
DataVersion = 0,
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<Warning> BasWarningMd_List { get; set; }
|
||||
|
||||
public static List<WarningLog> CmWarningLogMd_List { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#if DEBUG
|
||||
|
||||
//#define USE_LOCAL_TCP_DEBUG
|
||||
#define USE_LOCAL_TCP_DEBUG
|
||||
#endif
|
||||
//启用心跳检查
|
||||
|
||||
@@ -60,6 +60,15 @@ namespace CleanMachineHMI
|
||||
#endregion
|
||||
|
||||
|
||||
private PlcOperationHelper()
|
||||
{
|
||||
_synchronization = SynchronizationContext.Current;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private SynchronizationContext _synchronization;
|
||||
|
||||
|
||||
private byte slaveAddress = byte.Parse(ConfigurationManager.AppSettings["SlaveAddress"]);
|
||||
|
||||
@@ -89,7 +98,7 @@ namespace CleanMachineHMI
|
||||
|
||||
|
||||
|
||||
public List<PlcItem> PlcItemMdList { get; set; } = new List<PlcItem>();
|
||||
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>();
|
||||
@@ -99,24 +108,29 @@ namespace CleanMachineHMI
|
||||
public List<PlcItem> PlcItemMd_Y_List { get; set; } = new List<PlcItem>();
|
||||
|
||||
|
||||
public void StartRead()
|
||||
{
|
||||
Thread th = new Thread(RefreshPlcItem)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th.Start();
|
||||
//public void StartRead()
|
||||
//{
|
||||
// Thread th = new Thread(RefreshPlcItem)
|
||||
// {
|
||||
// IsBackground = true
|
||||
// };
|
||||
// th.Start();
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// public System.Threading.AutoResetEvent thEvent = new System.Threading.AutoResetEvent(false);
|
||||
|
||||
private void RefreshPlcItem()
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
RefreshPlcItem_M();
|
||||
Instance.RefreshPlcItem_D();
|
||||
Instance.RefreshPlcItem_X();
|
||||
Instance.RefreshPlcItem_Y();
|
||||
RefreshPlcItem_D();
|
||||
RefreshPlcItem_X();
|
||||
RefreshPlcItem_Y();
|
||||
// thEvent.Set();
|
||||
// ShowWarningMsg();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@@ -305,10 +319,10 @@ namespace CleanMachineHMI
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
if (item.PlcItemDataLength == 2)
|
||||
{
|
||||
ushort[] tmp_1 = new ushort[] { readBytArr_D[plcItemDeviationAddress], readBytArr_D[plcItemDeviationAddress + 1] };
|
||||
// ushort[] tmp_1 = new ushort[] { readBytArr_D[plcItemDeviationAddress], readBytArr_D[plcItemDeviationAddress + 1] };
|
||||
|
||||
#region 方法一 :Short数组转换为int数据 20201014 孙亚龙
|
||||
////低位 short 的字节数组。
|
||||
@@ -335,7 +349,32 @@ namespace CleanMachineHMI
|
||||
}
|
||||
}
|
||||
}
|
||||
HandleWaringLog(tmpReadAlarmBytArr_D);
|
||||
string priStr = "D";
|
||||
int index = 10;
|
||||
Global.CmWarningLogMd_List.Clear();
|
||||
for (var i = 0; i < 9; i++)
|
||||
{
|
||||
var plcitem = $"{priStr}{index + i}";
|
||||
|
||||
if (tmpReadAlarmBytArr_D[i] != 0)
|
||||
{
|
||||
var wanglist = Global.CheckWarng(tmpReadAlarmBytArr_D[i], plcitem);
|
||||
Global.CmWarningLogMd_List.AddRange(wanglist);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (Global.CmWarningLogMd_List.Count() > 0)
|
||||
{
|
||||
Global.ShowMainFrmAlarmMsg(true, EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.ShowMainFrmAlarmMsg(false, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
// HandleWaringLog(tmpReadAlarmBytArr_D);
|
||||
}
|
||||
#if RELEASE
|
||||
}
|
||||
@@ -346,6 +385,11 @@ namespace CleanMachineHMI
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//报警信息记录
|
||||
private void HandleWaringLog(ushort[] tmpReadAlarmBytArr_D)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace CleanMachineHMI.frmChild
|
||||
public static List<Warning> warnLst = new List<Warning>();
|
||||
private void frmPopupWarningMsg_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
private void SetDataGridView()
|
||||
{
|
||||
@@ -73,7 +73,7 @@ namespace CleanMachineHMI.frmChild
|
||||
}
|
||||
|
||||
private void frmPopupWarningMsg_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
{
|
||||
//if (PlcOperationHelper.Instance.WritePlcItem("AlarmPopUpMsg", "0", PlcItemTypeDesc.D))
|
||||
//{
|
||||
// LogHelper.WriteLog($"清空PLC报警提示变量成功!", LogTypeEum.Run);
|
||||
@@ -84,17 +84,17 @@ namespace CleanMachineHMI.frmChild
|
||||
{
|
||||
kryptonButton1.Enabled = false;
|
||||
try
|
||||
{
|
||||
Task.Run(async delegate
|
||||
{
|
||||
//Task.Run(async delegate
|
||||
//{
|
||||
if (PlcOperationHelper.Instance.WritePlcItem("AlarmPopUpMsg", "0", PlcItemTypeDesc.D))
|
||||
{
|
||||
if (PlcOperationHelper.Instance.WritePlcItem("AlarmPopUpMsg", "0", PlcItemTypeDesc.D))
|
||||
{
|
||||
LogHelper.WriteLog($"清空PLC报警提示变量成功!", LogTypeEum.Run);
|
||||
}
|
||||
await Task.Delay(500);
|
||||
Global.PopupWarningMsgForm = null;
|
||||
this.Close();
|
||||
});
|
||||
LogHelper.WriteLog($"清空PLC报警提示变量成功!", LogTypeEum.Run);
|
||||
}
|
||||
// await Task.Delay(500);
|
||||
Global.PopupWarningMsgForm = null;
|
||||
this.Close();
|
||||
//});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -222,14 +222,14 @@ namespace CleanMachineHMI
|
||||
isPlcConnStatus = true;
|
||||
|
||||
Global.SysThIsRunFlag = true;
|
||||
PlcOperationHelper.Instance.StartRead();
|
||||
// PlcOperationHelper.Instance.StartRead();
|
||||
|
||||
|
||||
//Thread th = new Thread(RefreshPlcItem)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th.Start();
|
||||
Thread th = new Thread(RefreshPlcItem)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th.Start();
|
||||
|
||||
|
||||
//Thread th = new Thread(RefreshPlcItem_M)
|
||||
@@ -597,49 +597,49 @@ namespace CleanMachineHMI
|
||||
}
|
||||
else if (sysRuningTimeLen >= maintainAlarmTime && sysRuningTimeLen < maintainQuitTime)
|
||||
{
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
pictureBox1.Visible = true;
|
||||
if (!sysAlarmFrmShowFlag)
|
||||
{
|
||||
sysAlarmFrmShowFlag = true;
|
||||
frmSysExitAlarm frm = new frmSysExitAlarm();
|
||||
//frm.showMsg = "机器即将于" + (maintainQuitTime - sysRuningTimeLen) + "分钟后退出。";
|
||||
frm.showMsg = $"The machine will exit in {(maintainQuitTime - sysRuningTimeLen)} minutes.";
|
||||
frm.TopLevel = true;
|
||||
frm.ShowDialog();
|
||||
}
|
||||
}));
|
||||
//BeginInvoke(new Action(() =>
|
||||
//{
|
||||
// pictureBox1.Visible = true;
|
||||
// if (!sysAlarmFrmShowFlag)
|
||||
// {
|
||||
// sysAlarmFrmShowFlag = true;
|
||||
// frmSysExitAlarm frm = new frmSysExitAlarm();
|
||||
// //frm.showMsg = "机器即将于" + (maintainQuitTime - sysRuningTimeLen) + "分钟后退出。";
|
||||
// frm.showMsg = $"The machine will exit in {(maintainQuitTime - sysRuningTimeLen)} minutes.";
|
||||
// frm.TopLevel = true;
|
||||
// frm.ShowDialog();
|
||||
// }
|
||||
//}));
|
||||
}
|
||||
else if (sysRuningTimeLen >= maintainQuitTime)
|
||||
{
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
pictureBox1.Visible = true;
|
||||
string sql = "SELECT 1 FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
|
||||
DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
if (!sysAlarmFrmShowFlag)
|
||||
{
|
||||
sysAlarmFrmShowFlag = true;
|
||||
frmSysExitAlarm frm = new frmSysExitAlarm();
|
||||
frm.showMsg = $"The machine maintenance time has exceeded: [{(maintainQuitTime - sysRuningTimeLen)}] minutes, please complete the current operation tray as soon as possible, and carry out equipment maintenance !!!!!!";
|
||||
frm.TopLevel = true;
|
||||
frm.ShowDialog();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string sqlUpdateParam = $@"update SYS_PARAMETER set PARAMETER_VALUE = '1' WHERE PARAMETER_CODE = 'MaintainFlag'";
|
||||
LeadDbHelperSQLite.ExecuteSql(sqlUpdateParam);
|
||||
PlcOperationHelper.Instance.WritePlcItem("StopSys", "True", PlcItemTypeDesc.M);
|
||||
PlcOperationHelper.Instance.WritePlcItem("StopSys", "False", PlcItemTypeDesc.M);
|
||||
PlcOperationHelper.Instance.WritePlcItem("ResetSys", "True", PlcItemTypeDesc.M);
|
||||
PlcOperationHelper.Instance.WritePlcItem("ResetSys", "False", PlcItemTypeDesc.M);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}));
|
||||
//BeginInvoke(new Action(() =>
|
||||
//{
|
||||
// pictureBox1.Visible = true;
|
||||
// string sql = "SELECT 1 FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
|
||||
// DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
|
||||
// if (dt != null && dt.Rows.Count > 0)
|
||||
// {
|
||||
// if (!sysAlarmFrmShowFlag)
|
||||
// {
|
||||
// sysAlarmFrmShowFlag = true;
|
||||
// frmSysExitAlarm frm = new frmSysExitAlarm();
|
||||
// frm.showMsg = $"The machine maintenance time has exceeded: [{(maintainQuitTime - sysRuningTimeLen)}] minutes, please complete the current operation tray as soon as possible, and carry out equipment maintenance !!!!!!";
|
||||
// frm.TopLevel = true;
|
||||
// frm.ShowDialog();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// string sqlUpdateParam = $@"update SYS_PARAMETER set PARAMETER_VALUE = '1' WHERE PARAMETER_CODE = 'MaintainFlag'";
|
||||
// LeadDbHelperSQLite.ExecuteSql(sqlUpdateParam);
|
||||
// PlcOperationHelper.Instance.WritePlcItem("StopSys", "True", PlcItemTypeDesc.M);
|
||||
// PlcOperationHelper.Instance.WritePlcItem("StopSys", "False", PlcItemTypeDesc.M);
|
||||
// PlcOperationHelper.Instance.WritePlcItem("ResetSys", "True", PlcItemTypeDesc.M);
|
||||
// PlcOperationHelper.Instance.WritePlcItem("ResetSys", "False", PlcItemTypeDesc.M);
|
||||
// Environment.Exit(0);
|
||||
// }
|
||||
//}));
|
||||
}
|
||||
string sqlUpdateRunTimeLen = $@"UPDATE SYS_PARAMETER set PARAMETER_VALUE = '{sysRuningTimeLen}' WHERE PARAMETER_CODE = 'SysRuningTimeLen'";
|
||||
LeadDbHelperSQLite.ExecuteSql(sqlUpdateRunTimeLen);
|
||||
|
||||
Reference in New Issue
Block a user