This commit is contained in:
gongxh
2022-05-19 15:56:08 +08:00
parent f5190d70ce
commit 2a03e1dba9
7 changed files with 863 additions and 773 deletions

View File

@@ -8,7 +8,7 @@
<!--<add key="GlobalPaletteMode" value="Professionaloffice2003"/>--> <!--<add key="GlobalPaletteMode" value="Professionaloffice2003"/>-->
<add key="LanguageCode" value="zh-CN"/> <add key="LanguageCode" value="en-US"/>
<!--SQLite数据库连接字符串--> <!--SQLite数据库连接字符串-->
<!--<add key="LeadSQLite" value="Data Source=|DataDirectory|\\clearMac.db;Pooling=true;FailIfMissing=false"/>--> <!--<add key="LeadSQLite" value="Data Source=|DataDirectory|\\clearMac.db;Pooling=true;FailIfMissing=false"/>-->
<add key="LeadSQLite" value="Data Source=DataBase/clearMac.db"/> <add key="LeadSQLite" value="Data Source=DataBase/clearMac.db"/>

Binary file not shown.

View File

@@ -109,7 +109,7 @@ namespace CleanMachineHMI.FrmUserControl
private void RefreshPlcData(bool isContainHisData) private void RefreshPlcData(bool isContainHisData)
{ {
List<WarningLog> tmpWarningLogList = new List<WarningLog>(); List<WarningLog> tmpWarningLogList = new List<WarningLog>();
tmpWarningLogList.AddRange(Global.CmWarningLogMd_List); tmpWarningLogList.AddRange(PlcOperationHelper.Instance.CmWarningLogMd_List.Values);
if (isContainHisData) if (isContainHisData)
{ {
string sql = $@"SELECT * FROM CM_WARNING_LOG"; string sql = $@"SELECT * FROM CM_WARNING_LOG";

View File

@@ -210,7 +210,7 @@ namespace CleanMachineHMI
public static List<Warning> BasWarningMd_List { get; set; } public static List<Warning> BasWarningMd_List { get; set; }
public static List<WarningLog> CmWarningLogMd_List { get; set; } // public static Dictionary<string, WarningLog> CmWarningLogMd_List { get; set; } = new Dictionary<string, WarningLog>();
public static List<WarningLog> CmWarningLogMd_List_1 { get; set; } public static List<WarningLog> CmWarningLogMd_List_1 { get; set; }

View File

@@ -6,9 +6,9 @@
#endif #endif
//启用心跳检查 //启用心跳检查
#if RELEASE //#if RELEASE
#define UseHeartbeat //#define UseHeartbeat
#endif //#endif
using CleanMachine.Model; using CleanMachine.Model;
using CleanMachine.Model.BAS; using CleanMachine.Model.BAS;
using CleanMachine.Model.CM; using CleanMachine.Model.CM;
@@ -469,24 +469,59 @@ namespace CleanMachineHMI
string priStr = "D"; string priStr = "D";
int index = 10; int index = 10;
bool alarmChange = false; bool alarmChange = false;
Global.CmWarningLogMd_List.Clear();
//Global.CmWarningLogMd_List.Clear();
for (var i = 0; i < 9; i++) for (var i = 0; i < 9; i++)
{ {
var plcitem = $"{priStr}{index + i}"; var plcitem = $"{priStr}{index + i}";
if (lastAlarm[i] != tmpReadAlarmBytArr_D[i]) if (lastAlarm[i] != tmpReadAlarmBytArr_D[i])
{ {
foreach (var W in CmWarningLogMd_List)
{
if (W.Value.PlcItemCode == plcitem)
{
W.Value.WaringStatus = 1;
}
}
if (tmpReadAlarmBytArr_D[i] != 0) if (tmpReadAlarmBytArr_D[i] != 0)
{ {
var wanglist = Global.CheckWarng(tmpReadAlarmBytArr_D[i], plcitem); var wanglist = Global.CheckWarng(tmpReadAlarmBytArr_D[i], plcitem);
Global.CmWarningLogMd_List.AddRange(wanglist); foreach (var wang in wanglist)
{
if (CmWarningLogMd_List.TryGetValue(wang.PlcItemCode + wang.WarningCode, out var warning))
{
wang.WaringStatus = 0;
}
else
{
//添加
CmWarningLogMd_List.Add(wang.PlcItemCode + wang.WarningCode, wang);
// new CleanMachine.BLL.CM.WarningLogBLL().Add(wang);
}
}
} }
lastAlarm[i] = tmpReadAlarmBytArr_D[i]; lastAlarm[i] = tmpReadAlarmBytArr_D[i];
alarmChange = true; alarmChange = true;
} }
} }
var keys = CmWarningLogMd_List.Keys.ToList();
foreach (var key in keys)
{
if (CmWarningLogMd_List[key].WaringStatus == 1)
{
// new CleanMachine.BLL.CM.WarningLogBLL().Update(Global.CmWarningLogMd_List[key]);
CmWarningLogMd_List.Remove(key);
}
}
if (alarmChange) if (alarmChange)
{ {
@@ -517,6 +552,12 @@ namespace CleanMachineHMI
ushort[] lastAlarm = new ushort[9] { 0, 0, 0, 0, 0, 0, 0, 0, 0, }; ushort[] lastAlarm = new ushort[9] { 0, 0, 0, 0, 0, 0, 0, 0, 0, };
public Dictionary<string, WarningLog> CmWarningLogMd_List { get; set; } = new Dictionary<string, WarningLog>();
@@ -549,230 +590,284 @@ namespace CleanMachineHMI
//报警信息记录 //报警信息记录
private void HandleWaringLog(ushort[] tmpReadAlarmBytArr_D) // private void HandleWaringLog(ushort[] tmpReadAlarmBytArr_D)
{
#if RELEASE
try
{
#endif
int index = 10;
string priStr = "D";
string priWarnCode = "bit";
for (int i = 0; i < tmpReadAlarmBytArr_D.Length; i++)
{
if (i <= 1)
{//D10~D11 报警
char[] tmpCharArr = Convert.ToString(tmpReadAlarmBytArr_D[i], 2).PadLeft(16, '0').Reverse().ToArray();
for (int j = 0; j < tmpCharArr.Length; j++)
{
if (tmpCharArr[j] == '1')
{//当前报警
Warning tmpMd = Global.BasWarningMd_List.Find(x => x.PlcItemCode == $"{priStr + (index + i)}" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1");
if (tmpMd != null)
{
WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.WarningCode == tmpMd.WarningCode && y.PlcItemCode == tmpMd.PlcItemCode);
if (warnLogTmp != null)
{//找到报警项,并增加版本
warnLogTmp.UpdateTime = DateTime.Now;
warnLogTmp.DataVersion += 1;
}
else
{//新报警增加记录
Global.CmWarningLogMd_List.Add(new WarningLog
{
WarningCode = tmpMd.WarningCode,
WarningName = tmpMd.WarningName,
WarningType = tmpMd.WarningType,
WarningMessage = tmpMd.WarningMessage,
WarningTime = DateTime.Now,
PlcItemCode = tmpMd.PlcItemCode,
WaringStatus = 0,
WarningHandleResult = 0,
CreateBy = 1,
CreateTime = DateTime.Now,
UpdateBy = 1,
UpdateTime = DateTime.Now,
DataVersion = 0,
});
}
}
#region 已删除
// string sql = $@"SELECT * FROM BAS_WARNING WHERE PLC_ITEM_CODE = '{priStr + (index + i)}' and WARNING_CODE = '{priWarnCode + i}' and WARNING_TYPE = '1'";
// DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
// if (dt != null && dt.Rows.Count > 0)
// { // {
// string sql1 = $@" //#if RELEASE
// INSERT INTO CM_WARNING_LOG ( // try
// WARNING_CODE, // {
// WARNING_NAME, //#endif
// WARNING_TYPE, // int index = 10;
// WARNING_MESSAGE, // string priStr = "D";
// WARNING_TIME, // string priWarnCode = "bit";
// PLC_ITEM_CODE, // for (int i = 0; i < tmpReadAlarmBytArr_D.Length; i++)
// WARING_STATUS, // {
// WARNING_HANDLE_RESULT, // if (i <= 1)
// CREATE_BY, // {//D10~D11 报警
// CREATE_TIME, // char[] tmpCharArr = Convert.ToString(tmpReadAlarmBytArr_D[i], 2).PadLeft(16, '0').Reverse().ToArray();
// UPDATE_BY,
// UPDATE_TIME,
// DATA_VERSION
// )
// SELECT
// '{dt.Rows[0]["WARNING_CODE"]}',
// '{dt.Rows[0]["WARNING_NAME"]}',
// '{dt.Rows[0]["WARNING_TYPE"]}',
// '{dt.Rows[0]["WARNING_MESSAGE"]}',
// datetime('now', 'localtime'),
// '{dt.Rows[0]["PLC_ITEM_CODE"]}',
// 0,
// 0,
// 1,
// datetime('now', 'localtime'),
// 1,
// datetime('now', 'localtime'),
// 0
// WHERE NOT EXISTS (SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}')
// ";
// LeadDbHelperSQLite.ExecuteSql(sql1);
// string sql2 = $@"
//UPDATE CM_WARNING_LOG set UPDATE_TIME = datetime('now', 'localtime'),DATA_VERSION = DATA_VERSION + 1
// WHERE EXISTS(SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}') and WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}';
// ";
// LeadDbHelperSQLite.ExecuteSql(sql2);
// }
#endregion
}
else
{//当前报警项没有报警
Warning tmpMd = Global.BasWarningMd_List.Find(x => x.PlcItemCode == $"{priStr + (index + i)}" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1");
if (tmpMd != null)
{//之前有报警,则结束当前报警项
WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.WarningCode == tmpMd.WarningCode && y.PlcItemCode == tmpMd.PlcItemCode);
if (warnLogTmp != null)
{
warnLogTmp.UpdateTime = DateTime.Now;
warnLogTmp.DataVersion += 1;
warnLogTmp.WaringStatus = 1;
warnLogTmp.WarningHandleResult = 1;
warnLogTmp.WarningHandleTime = DateTime.Now;
}
}
#region 已删除
//string sql = $@"SELECT * FROM BAS_WARNING WHERE PLC_ITEM_CODE = '{priStr + (index + i)}' and WARNING_CODE = '{priWarnCode + i}' and WARNING_TYPE = '1'";
//DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
//if (dt != null && dt.Rows.Count > 0)
//{
// string sql2 = $@"
// UPDATE CM_WARNING_LOG
// SET UPDATE_TIME = datetime('now', 'localtime'),
// DATA_VERSION = DATA_VERSION + 1,
// WARING_STATUS = 1,
// WARNING_HANDLE_RESULT = 1,
// WARNING_HANDLE_TIME = datetime('now', 'localtime')
// WHERE
// EXISTS ( SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT = 0 AND WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' AND PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}' )
// AND WARING_STATUS = 0
// AND WARNING_HANDLE_RESULT = 0
// AND WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}'
// AND PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}';
// ";
// LeadDbHelperSQLite.ExecuteSql(sql2);
//}
#endregion
}
}
}
else if (i == 2)
{
//char[] tmpCharArr = Convert.ToString(tmpReadAlarmBytArr_D[i], 2).PadLeft(16, '0').Reverse().ToArray();
//if (tmpCharArr.Contains('1'))
//{
// List<Bas_WarningMd> warnLst = new List<Bas_WarningMd>();
// for (int j = 0; j < tmpCharArr.Length; j++) // for (int j = 0; j < tmpCharArr.Length; j++)
// { // {
// if (tmpCharArr[j] == '1') // if (tmpCharArr[j] == '1')
// { // {//当前报警
// Bas_WarningMd tmpMd = GlobalHelper.BasWarningMd_List.Find(x => x.PlcItemCode == $"{priStr + (index + i)}" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1"); // Warning tmpMd = Global.BasWarningMd_List.Find(x => x.PlcItemCode == $"{priStr + (index + i)}" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1");
// if (tmpMd != null) // if (tmpMd != null)
// { // {
// warnLst.Add(tmpMd); // WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.WarningCode == tmpMd.WarningCode && y.PlcItemCode == tmpMd.PlcItemCode);
// if (warnLogTmp != null)
// {//找到报警项,并增加版本
// warnLogTmp.UpdateTime = DateTime.Now;
// warnLogTmp.DataVersion += 1;
// }
// else
// {//新报警增加记录
// Global.CmWarningLogMd_List.Add(new WarningLog
// {
// WarningCode = tmpMd.WarningCode,
// WarningName = tmpMd.WarningName,
// WarningType = tmpMd.WarningType,
// WarningMessage = tmpMd.WarningMessage,
// WarningTime = DateTime.Now,
// PlcItemCode = tmpMd.PlcItemCode,
// WaringStatus = 0,
// WarningHandleResult = 0,
// CreateBy = 1,
// CreateTime = DateTime.Now,
// UpdateBy = 1,
// UpdateTime = DateTime.Now,
// DataVersion = 0,
// });
// } // }
// } // }
// } // #region 已删除
// GlobalHelper.ShowWarningMsg(warnLst, new EventArgs());
//}
}
else if (i >= 3 && i <= 9)
{//D13~D19报警
if (tmpReadAlarmBytArr_D[i] == 0)
{
WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.PlcItemCode == $"{priStr + (index + i)}");
if (warnLogTmp != null)
{
warnLogTmp.UpdateTime = DateTime.Now;
warnLogTmp.DataVersion += 1;
warnLogTmp.WaringStatus = 1;
warnLogTmp.WarningHandleResult = 1;
warnLogTmp.WarningHandleTime = DateTime.Now;
}
#region 已删除
//string sql2 = $@"
// UPDATE CM_WARNING_LOG
// SET UPDATE_TIME = datetime('now', 'localtime'),
// DATA_VERSION = DATA_VERSION + 1,
// WARING_STATUS = 1,
// WARNING_HANDLE_RESULT = 1,
// WARNING_HANDLE_TIME = datetime('now', 'localtime')
// WHERE
// EXISTS ( SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT = 0 AND WARNING_CODE = '{i}' AND PLC_ITEM_CODE is NULL )
// AND WARING_STATUS = 0
// AND WARNING_HANDLE_RESULT = 0
// AND WARNING_CODE = 'i'
// AND PLC_ITEM_CODE is NULL;
// ";
//LeadDbHelperSQLite.ExecuteSql(sql2);
#endregion
}
else
{//根据报警编码,获取报警信息,根据读取顺序编号,组成PlcItemCode
Warning tmpMd = Global.BasWarningMd_List.Find(x => string.IsNullOrEmpty(x.PlcItemCode) && x.WarningCode == tmpReadAlarmBytArr_D[i].ToString() && x.WarningType == "2");
if (tmpMd != null)
{
WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.WarningCode == tmpMd.WarningCode && y.PlcItemCode == $"{priStr + (index + i)}");
if (warnLogTmp != null)
{
warnLogTmp.UpdateTime = DateTime.Now;
warnLogTmp.DataVersion += 1;
}
else
{
Global.CmWarningLogMd_List.Add(new WarningLog
{
WarningCode = tmpMd.WarningCode,
WarningName = tmpMd.WarningName,
WarningType = tmpMd.WarningType,
WarningMessage = tmpMd.WarningMessage,
WarningTime = DateTime.Now,
PlcItemCode = $"{priStr + (index + i)}",
WaringStatus = 0,
WarningHandleResult = 0,
CreateBy = 1,
CreateTime = DateTime.Now,
UpdateBy = 1,
UpdateTime = DateTime.Now,
DataVersion = 0,
});
}
}
#region 已删除 // // string sql = $@"SELECT * FROM BAS_WARNING WHERE PLC_ITEM_CODE = '{priStr + (index + i)}' and WARNING_CODE = '{priWarnCode + i}' and WARNING_TYPE = '1'";
// // DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
// // if (dt != null && dt.Rows.Count > 0)
// // {
// // string sql1 = $@"
// // INSERT INTO CM_WARNING_LOG (
// // WARNING_CODE,
// // WARNING_NAME,
// // WARNING_TYPE,
// // WARNING_MESSAGE,
// // WARNING_TIME,
// // PLC_ITEM_CODE,
// // WARING_STATUS,
// // WARNING_HANDLE_RESULT,
// // CREATE_BY,
// // CREATE_TIME,
// // UPDATE_BY,
// // UPDATE_TIME,
// // DATA_VERSION
// // )
// // SELECT
// // '{dt.Rows[0]["WARNING_CODE"]}',
// // '{dt.Rows[0]["WARNING_NAME"]}',
// // '{dt.Rows[0]["WARNING_TYPE"]}',
// // '{dt.Rows[0]["WARNING_MESSAGE"]}',
// // datetime('now', 'localtime'),
// // '{dt.Rows[0]["PLC_ITEM_CODE"]}',
// // 0,
// // 0,
// // 1,
// // datetime('now', 'localtime'),
// // 1,
// // datetime('now', 'localtime'),
// // 0
// // WHERE NOT EXISTS (SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}')
// // ";
// // LeadDbHelperSQLite.ExecuteSql(sql1);
// string sql = $@"SELECT * FROM BAS_WARNING WHERE PLC_ITEM_CODE is NULL and WARNING_CODE = '{i}' and WARNING_TYPE = '2'"; // // string sql2 = $@"
// DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0]; // //UPDATE CM_WARNING_LOG set UPDATE_TIME = datetime('now', 'localtime'),DATA_VERSION = DATA_VERSION + 1
// if (dt != null && dt.Rows.Count > 0) // // WHERE EXISTS(SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}') and WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}';
// // ";
// // LeadDbHelperSQLite.ExecuteSql(sql2);
// // }
// #endregion
// }
// else
// {//当前报警项没有报警
// Warning tmpMd = Global.BasWarningMd_List.Find(x => x.PlcItemCode == $"{priStr + (index + i)}" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1");
// if (tmpMd != null)
// {//之前有报警,则结束当前报警项
// WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.WarningCode == tmpMd.WarningCode && y.PlcItemCode == tmpMd.PlcItemCode);
// if (warnLogTmp != null)
// {
// warnLogTmp.UpdateTime = DateTime.Now;
// warnLogTmp.DataVersion += 1;
// warnLogTmp.WaringStatus = 1;
// warnLogTmp.WarningHandleResult = 1;
// warnLogTmp.WarningHandleTime = DateTime.Now;
// }
// }
// #region 已删除
// //string sql = $@"SELECT * FROM BAS_WARNING WHERE PLC_ITEM_CODE = '{priStr + (index + i)}' and WARNING_CODE = '{priWarnCode + i}' and WARNING_TYPE = '1'";
// //DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
// //if (dt != null && dt.Rows.Count > 0)
// //{
// // string sql2 = $@"
// // UPDATE CM_WARNING_LOG
// // SET UPDATE_TIME = datetime('now', 'localtime'),
// // DATA_VERSION = DATA_VERSION + 1,
// // WARING_STATUS = 1,
// // WARNING_HANDLE_RESULT = 1,
// // WARNING_HANDLE_TIME = datetime('now', 'localtime')
// // WHERE
// // EXISTS ( SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT = 0 AND WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' AND PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}' )
// // AND WARING_STATUS = 0
// // AND WARNING_HANDLE_RESULT = 0
// // AND WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}'
// // AND PLC_ITEM_CODE = '{dt.Rows[0]["PLC_ITEM_CODE"]}';
// // ";
// // LeadDbHelperSQLite.ExecuteSql(sql2);
// //}
// #endregion
// }
// }
// }
// else if (i == 2)
// {
// //char[] tmpCharArr = Convert.ToString(tmpReadAlarmBytArr_D[i], 2).PadLeft(16, '0').Reverse().ToArray();
// //if (tmpCharArr.Contains('1'))
// //{
// // List<Bas_WarningMd> warnLst = new List<Bas_WarningMd>();
// // for (int j = 0; j < tmpCharArr.Length; j++)
// // {
// // if (tmpCharArr[j] == '1')
// // {
// // Bas_WarningMd tmpMd = GlobalHelper.BasWarningMd_List.Find(x => x.PlcItemCode == $"{priStr + (index + i)}" && x.WarningCode == $"{priWarnCode + j}" && x.WarningType == "1");
// // if (tmpMd != null)
// // {
// // warnLst.Add(tmpMd);
// // }
// // }
// // }
// // GlobalHelper.ShowWarningMsg(warnLst, new EventArgs());
// //}
// }
// else if (i >= 3 && i <= 9)
// {//D13~D19报警
// if (tmpReadAlarmBytArr_D[i] == 0)
// {
// WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.PlcItemCode == $"{priStr + (index + i)}");
// if (warnLogTmp != null)
// {
// warnLogTmp.UpdateTime = DateTime.Now;
// warnLogTmp.DataVersion += 1;
// warnLogTmp.WaringStatus = 1;
// warnLogTmp.WarningHandleResult = 1;
// warnLogTmp.WarningHandleTime = DateTime.Now;
// }
// #region 已删除
// //string sql2 = $@"
// // UPDATE CM_WARNING_LOG
// // SET UPDATE_TIME = datetime('now', 'localtime'),
// // DATA_VERSION = DATA_VERSION + 1,
// // WARING_STATUS = 1,
// // WARNING_HANDLE_RESULT = 1,
// // WARNING_HANDLE_TIME = datetime('now', 'localtime')
// // WHERE
// // EXISTS ( SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT = 0 AND WARNING_CODE = '{i}' AND PLC_ITEM_CODE is NULL )
// // AND WARING_STATUS = 0
// // AND WARNING_HANDLE_RESULT = 0
// // AND WARNING_CODE = 'i'
// // AND PLC_ITEM_CODE is NULL;
// // ";
// //LeadDbHelperSQLite.ExecuteSql(sql2);
// #endregion
// }
// else
// {//根据报警编码,获取报警信息,根据读取顺序编号,组成PlcItemCode
// Warning tmpMd = Global.BasWarningMd_List.Find(x => string.IsNullOrEmpty(x.PlcItemCode) && x.WarningCode == tmpReadAlarmBytArr_D[i].ToString() && x.WarningType == "2");
// if (tmpMd != null)
// {
// WarningLog warnLogTmp = Global.CmWarningLogMd_List.Find(y => y.WaringStatus == 0 && y.WarningHandleResult == 0 && y.WarningCode == tmpMd.WarningCode && y.PlcItemCode == $"{priStr + (index + i)}");
// if (warnLogTmp != null)
// {
// warnLogTmp.UpdateTime = DateTime.Now;
// warnLogTmp.DataVersion += 1;
// }
// else
// {
// Global.CmWarningLogMd_List.Add(new WarningLog
// {
// WarningCode = tmpMd.WarningCode,
// WarningName = tmpMd.WarningName,
// WarningType = tmpMd.WarningType,
// WarningMessage = tmpMd.WarningMessage,
// WarningTime = DateTime.Now,
// PlcItemCode = $"{priStr + (index + i)}",
// WaringStatus = 0,
// WarningHandleResult = 0,
// CreateBy = 1,
// CreateTime = DateTime.Now,
// UpdateBy = 1,
// UpdateTime = DateTime.Now,
// DataVersion = 0,
// });
// }
// }
// #region 已删除
// // string sql = $@"SELECT * FROM BAS_WARNING WHERE PLC_ITEM_CODE is NULL and WARNING_CODE = '{i}' and WARNING_TYPE = '2'";
// // DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0];
// // if (dt != null && dt.Rows.Count > 0)
// // {
// // string sql1 = $@"
// // INSERT INTO CM_WARNING_LOG (
// // WARNING_CODE,
// // WARNING_NAME,
// // WARNING_TYPE,
// // WARNING_MESSAGE,
// // WARNING_TIME,
// // PLC_ITEM_CODE,
// // WARING_STATUS,
// // WARNING_HANDLE_RESULT,
// // CREATE_BY,
// // CREATE_TIME,
// // UPDATE_BY,
// // UPDATE_TIME,
// // DATA_VERSION
// // )
// // SELECT
// // '{dt.Rows[0]["WARNING_CODE"]}',
// // '{dt.Rows[0]["WARNING_NAME"]}',
// // '{dt.Rows[0]["WARNING_TYPE"]}',
// // '{dt.Rows[0]["WARNING_MESSAGE"]}',
// // datetime('now', 'localtime'),
// // '{dt.Rows[0]["PLC_ITEM_CODE"]}',
// // 0,
// // 0,
// // 1,
// // datetime('now', 'localtime'),
// // 1,
// // datetime('now', 'localtime'),
// // 0
// // WHERE NOT EXISTS (SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE is NULL)
// // ";
// // LeadDbHelperSQLite.ExecuteSql(sql1);
// // string sql2 = $@"
// //UPDATE CM_WARNING_LOG set UPDATE_TIME = datetime('now', 'localtime'),DATA_VERSION = DATA_VERSION + 1
// // WHERE EXISTS(SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE is NULL) and WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and is NULL;
// // ";
// // LeadDbHelperSQLite.ExecuteSql(sql2);
// // }
// #endregion
// }
// }
// else if (i > 9)
// {
// break;
// }
// }
// List<WarningLog> tmpLst = Global.CmWarningLogMd_List.Values.FindAll(x => x.WarningHandleResult == 1 && x.WaringStatus == 1);
// if (tmpLst.Count >= 10)
// {
// foreach (WarningLog item in tmpLst)
// { // {
// string sql1 = $@" // string sql1 = $@"
// INSERT INTO CM_WARNING_LOG ( // INSERT INTO CM_WARNING_LOG (
@@ -784,107 +879,53 @@ namespace CleanMachineHMI
// PLC_ITEM_CODE, // PLC_ITEM_CODE,
// WARING_STATUS, // WARING_STATUS,
// WARNING_HANDLE_RESULT, // WARNING_HANDLE_RESULT,
// WARNING_HANDLE_TIME,
// CREATE_BY, // CREATE_BY,
// CREATE_TIME, // CREATE_TIME,
// UPDATE_BY, // UPDATE_BY,
// UPDATE_TIME, // UPDATE_TIME,
// DATA_VERSION // DATA_VERSION
// ) // )
// SELECT // VALUES (
// '{dt.Rows[0]["WARNING_CODE"]}', // '{item.WarningCode}',
// '{dt.Rows[0]["WARNING_NAME"]}', // '{item.WarningName}',
// '{dt.Rows[0]["WARNING_TYPE"]}', // '{item.WarningType}',
// '{dt.Rows[0]["WARNING_MESSAGE"]}', // '{item.WarningMessage}',
// datetime('now', 'localtime'), // '{item.WarningTime.ToString("yyyy-MM-dd HH:mm:ss")}',
// '{dt.Rows[0]["PLC_ITEM_CODE"]}', // '{item.PlcItemCode}',
// 0, // '{item.WaringStatus}',
// 0, // '{item.WarningHandleResult}',
// 1, // '{item.WarningHandleTime.ToString("yyyy-MM-dd HH:mm:ss")}',
// datetime('now', 'localtime'), // '{item.CreateBy}',
// 1, // '{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
// datetime('now', 'localtime'), // '{item.UpdateBy}',
// 0 // '{item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
// WHERE NOT EXISTS (SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE is NULL) // '{item.DataVersion}'
// );
// "; // ";
// LeadDbHelperSQLite.ExecuteSql(sql1); // LeadDbHelperSQLite.Execute(sql1);
// string sql2 = $@" // }
//UPDATE CM_WARNING_LOG set UPDATE_TIME = datetime('now', 'localtime'),DATA_VERSION = DATA_VERSION + 1 // Global.CmWarningLogMd_List.RemoveAll(x => x.WarningHandleResult == 1 && x.WaringStatus == 1);
// WHERE EXISTS(SELECT 1 FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and PLC_ITEM_CODE is NULL) and WARING_STATUS = 0 and WARNING_HANDLE_RESULT = 0 and WARNING_CODE = '{dt.Rows[0]["WARNING_CODE"]}' and is NULL;
// ";
// LeadDbHelperSQLite.ExecuteSql(sql2);
// } // }
#endregion
} // if (Global.CmWarningLogMd_List.FindAll(x => x.WarningHandleResult == 0 && x.WaringStatus == 0).Count > 0)
} // {
else if (i > 9) // //frmMainNew.Show_ptb_Alarm(true);
{ // ShowMainFrmAlarmMsg();
break; // }
} // else
} // {
// //frmMainNew.Show_ptb_Alarm(false);
List<WarningLog> tmpLst = Global.CmWarningLogMd_List.FindAll(x => x.WarningHandleResult == 1 && x.WaringStatus == 1); // ShowMainFrmAlarmMsg();
if (tmpLst.Count >= 10) // }
{ //#if RELEASE
foreach (WarningLog item in tmpLst) // }
{ // catch (Exception ex)
string sql1 = $@" // {
INSERT INTO CM_WARNING_LOG ( // LogHelper.WriteLog($"处理设备报警信息时发生异常:【{ex.Message}】", LogTypeEum.Err);
WARNING_CODE, // }
WARNING_NAME, //#endif
WARNING_TYPE, // }
WARNING_MESSAGE,
WARNING_TIME,
PLC_ITEM_CODE,
WARING_STATUS,
WARNING_HANDLE_RESULT,
WARNING_HANDLE_TIME,
CREATE_BY,
CREATE_TIME,
UPDATE_BY,
UPDATE_TIME,
DATA_VERSION
)
VALUES (
'{item.WarningCode}',
'{item.WarningName}',
'{item.WarningType}',
'{item.WarningMessage}',
'{item.WarningTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.PlcItemCode}',
'{item.WaringStatus}',
'{item.WarningHandleResult}',
'{item.WarningHandleTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.CreateBy}',
'{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.UpdateBy}',
'{item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.DataVersion}'
);
";
LeadDbHelperSQLite.Execute(sql1);
}
Global.CmWarningLogMd_List.RemoveAll(x => x.WarningHandleResult == 1 && x.WaringStatus == 1);
}
if (Global.CmWarningLogMd_List.FindAll(x => x.WarningHandleResult == 0 && x.WaringStatus == 0).Count > 0)
{
//frmMainNew.Show_ptb_Alarm(true);
ShowMainFrmAlarmMsg();
}
else
{
//frmMainNew.Show_ptb_Alarm(false);
ShowMainFrmAlarmMsg();
}
#if RELEASE
}
catch (Exception ex)
{
LogHelper.WriteLog($"处理设备报警信息时发生异常:【{ex.Message}】", LogTypeEum.Err);
}
#endif
}
public void RefreshPlcItem_X(ref bool haschange) public void RefreshPlcItem_X(ref bool haschange)
{ {

View File

@@ -45,6 +45,7 @@
this.MainDetail = new Krypton.Navigator.KryptonPage(); this.MainDetail = new Krypton.Navigator.KryptonPage();
this.kryptonManager = new Krypton.Toolkit.KryptonManager(this.components); this.kryptonManager = new Krypton.Toolkit.KryptonManager(this.components);
this.timer = new System.Windows.Forms.Timer(this.components); this.timer = new System.Windows.Forms.Timer(this.components);
this.buttonSpecAny1 = new Krypton.Toolkit.ButtonSpecAny();
((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1.Panel)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1.Panel)).BeginInit();
this.kryptonGroupBox1.Panel.SuspendLayout(); this.kryptonGroupBox1.Panel.SuspendLayout();
@@ -59,7 +60,10 @@
// kryptonGroupBox1 // kryptonGroupBox1
// //
this.kryptonGroupBox1.CaptionOverlap = 0D; this.kryptonGroupBox1.CaptionOverlap = 0D;
this.kryptonGroupBox1.CaptionStyle = Krypton.Toolkit.LabelStyle.GroupBoxCaption;
this.kryptonGroupBox1.Dock = System.Windows.Forms.DockStyle.Top; this.kryptonGroupBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.kryptonGroupBox1.GroupBackStyle = Krypton.Toolkit.PaletteBackStyle.ControlGroupBox;
this.kryptonGroupBox1.GroupBorderStyle = Krypton.Toolkit.PaletteBorderStyle.ControlGroupBox;
this.kryptonGroupBox1.Location = new System.Drawing.Point(0, 0); this.kryptonGroupBox1.Location = new System.Drawing.Point(0, 0);
this.kryptonGroupBox1.Name = "kryptonGroupBox1"; this.kryptonGroupBox1.Name = "kryptonGroupBox1";
// //
@@ -135,6 +139,8 @@
this.btnExit.Name = "btnExit"; this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(107, 45); this.btnExit.Size = new System.Drawing.Size(107, 45);
this.btnExit.StateCommon.Content.ShortText.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnExit.StateCommon.Content.ShortText.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnExit.StateCommon.Content.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.btnExit.StateCommon.Content.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.btnExit.TabIndex = 13; this.btnExit.TabIndex = 13;
this.btnExit.Values.Text = "返回"; this.btnExit.Values.Text = "返回";
this.btnExit.Visible = false; this.btnExit.Visible = false;
@@ -148,16 +154,21 @@
this.lbSysAlreadyRunning.Name = "lbSysAlreadyRunning"; this.lbSysAlreadyRunning.Name = "lbSysAlreadyRunning";
this.lbSysAlreadyRunning.Size = new System.Drawing.Size(112, 20); this.lbSysAlreadyRunning.Size = new System.Drawing.Size(112, 20);
this.lbSysAlreadyRunning.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbSysAlreadyRunning.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbSysAlreadyRunning.StateCommon.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.lbSysAlreadyRunning.StateCommon.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.lbSysAlreadyRunning.TabIndex = 8; this.lbSysAlreadyRunning.TabIndex = 8;
this.lbSysAlreadyRunning.Values.Text = "系统运行时间:"; this.lbSysAlreadyRunning.Values.Text = "系统运行时间:";
// //
// label3Professional // label3Professional
// //
this.label3Professional.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label3Professional.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label3Professional.LabelStyle = Krypton.Toolkit.LabelStyle.NormalPanel;
this.label3Professional.Location = new System.Drawing.Point(885, 23); this.label3Professional.Location = new System.Drawing.Point(885, 23);
this.label3Professional.Name = "label3Professional"; this.label3Professional.Name = "label3Professional";
this.label3Professional.Size = new System.Drawing.Size(112, 22); this.label3Professional.Size = new System.Drawing.Size(112, 22);
this.label3Professional.StateCommon.ShortText.Font = new System.Drawing.Font("Verdana", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3Professional.StateCommon.ShortText.Font = new System.Drawing.Font("Verdana", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3Professional.StateCommon.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.label3Professional.StateCommon.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.label3Professional.TabIndex = 7; this.label3Professional.TabIndex = 7;
this.label3Professional.Values.Image = global::CleanMachineHMI.Properties.Resources.conn; this.label3Professional.Values.Image = global::CleanMachineHMI.Properties.Resources.conn;
this.label3Professional.Values.Text = "通讯已连接"; this.label3Professional.Values.Text = "通讯已连接";
@@ -170,63 +181,91 @@
this.lbSysTime.Name = "lbSysTime"; this.lbSysTime.Name = "lbSysTime";
this.lbSysTime.Size = new System.Drawing.Size(83, 20); this.lbSysTime.Size = new System.Drawing.Size(83, 20);
this.lbSysTime.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbSysTime.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbSysTime.StateCommon.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.lbSysTime.StateCommon.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.lbSysTime.TabIndex = 4; this.lbSysTime.TabIndex = 4;
this.lbSysTime.Values.Text = "系统时间:"; this.lbSysTime.Values.Text = "系统时间:";
// //
// kryptonLabel1 // kryptonLabel1
// //
this.kryptonLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.kryptonLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.kryptonLabel1.LabelStyle = Krypton.Toolkit.LabelStyle.NormalPanel;
this.kryptonLabel1.Location = new System.Drawing.Point(829, 47); this.kryptonLabel1.Location = new System.Drawing.Point(829, 47);
this.kryptonLabel1.Name = "kryptonLabel1"; this.kryptonLabel1.Name = "kryptonLabel1";
this.kryptonLabel1.PaletteMode = Krypton.Toolkit.PaletteMode.ProfessionalSystem; this.kryptonLabel1.PaletteMode = Krypton.Toolkit.PaletteMode.ProfessionalSystem;
this.kryptonLabel1.Size = new System.Drawing.Size(82, 23); this.kryptonLabel1.Size = new System.Drawing.Size(82, 23);
this.kryptonLabel1.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.kryptonLabel1.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.kryptonLabel1.StateCommon.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.kryptonLabel1.StateCommon.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.kryptonLabel1.StateNormal.Image.Effect = Krypton.Toolkit.PaletteImageEffect.Inherit;
this.kryptonLabel1.StateNormal.Image.ImageH = Krypton.Toolkit.PaletteRelativeAlign.Far; this.kryptonLabel1.StateNormal.Image.ImageH = Krypton.Toolkit.PaletteRelativeAlign.Far;
this.kryptonLabel1.StateNormal.LongText.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); this.kryptonLabel1.StateNormal.LongText.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.kryptonLabel1.StateNormal.LongText.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.kryptonLabel1.StateNormal.LongText.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.kryptonLabel1.StateNormal.LongText.ColorAngle = 45F; this.kryptonLabel1.StateNormal.LongText.ColorAngle = 45F;
this.kryptonLabel1.StateNormal.LongText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma; this.kryptonLabel1.StateNormal.LongText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma;
this.kryptonLabel1.StateNormal.LongText.Font = new System.Drawing.Font("Verdana", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.kryptonLabel1.StateNormal.LongText.Font = new System.Drawing.Font("Verdana", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.kryptonLabel1.StateNormal.LongText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.kryptonLabel1.StateNormal.LongText.TextH = Krypton.Toolkit.PaletteRelativeAlign.Center; this.kryptonLabel1.StateNormal.LongText.TextH = Krypton.Toolkit.PaletteRelativeAlign.Center;
this.kryptonLabel1.StateNormal.LongText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.kryptonLabel1.StateNormal.ShortText.Color1 = System.Drawing.Color.Blue; this.kryptonLabel1.StateNormal.ShortText.Color1 = System.Drawing.Color.Blue;
this.kryptonLabel1.StateNormal.ShortText.Color2 = System.Drawing.Color.MidnightBlue; this.kryptonLabel1.StateNormal.ShortText.Color2 = System.Drawing.Color.MidnightBlue;
this.kryptonLabel1.StateNormal.ShortText.ColorAngle = 45F; this.kryptonLabel1.StateNormal.ShortText.ColorAngle = 45F;
this.kryptonLabel1.StateNormal.ShortText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma; this.kryptonLabel1.StateNormal.ShortText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma;
this.kryptonLabel1.StateNormal.ShortText.Font = new System.Drawing.Font("Verdana", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.kryptonLabel1.StateNormal.ShortText.Font = new System.Drawing.Font("Verdana", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.kryptonLabel1.StateNormal.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.kryptonLabel1.StateNormal.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.kryptonLabel1.TabIndex = 3; this.kryptonLabel1.TabIndex = 3;
this.kryptonLabel1.Values.Text = "0 Minutes"; this.kryptonLabel1.Values.Text = "0 Minutes";
// //
// lbNow // lbNow
// //
this.lbNow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lbNow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lbNow.LabelStyle = Krypton.Toolkit.LabelStyle.NormalPanel;
this.lbNow.Location = new System.Drawing.Point(804, 1); this.lbNow.Location = new System.Drawing.Point(804, 1);
this.lbNow.Name = "lbNow"; this.lbNow.Name = "lbNow";
this.lbNow.PaletteMode = Krypton.Toolkit.PaletteMode.ProfessionalSystem; this.lbNow.PaletteMode = Krypton.Toolkit.PaletteMode.ProfessionalSystem;
this.lbNow.Size = new System.Drawing.Size(171, 23); this.lbNow.Size = new System.Drawing.Size(171, 23);
this.lbNow.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbNow.StateCommon.ShortText.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lbNow.StateCommon.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.lbNow.StateCommon.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.lbNow.StateNormal.Image.Effect = Krypton.Toolkit.PaletteImageEffect.Inherit;
this.lbNow.StateNormal.Image.ImageH = Krypton.Toolkit.PaletteRelativeAlign.Far; this.lbNow.StateNormal.Image.ImageH = Krypton.Toolkit.PaletteRelativeAlign.Far;
this.lbNow.StateNormal.LongText.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); this.lbNow.StateNormal.LongText.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.lbNow.StateNormal.LongText.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.lbNow.StateNormal.LongText.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.lbNow.StateNormal.LongText.ColorAngle = 45F; this.lbNow.StateNormal.LongText.ColorAngle = 45F;
this.lbNow.StateNormal.LongText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma; this.lbNow.StateNormal.LongText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma;
this.lbNow.StateNormal.LongText.Font = new System.Drawing.Font("Verdana", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbNow.StateNormal.LongText.Font = new System.Drawing.Font("Verdana", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbNow.StateNormal.LongText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.lbNow.StateNormal.LongText.TextH = Krypton.Toolkit.PaletteRelativeAlign.Center; this.lbNow.StateNormal.LongText.TextH = Krypton.Toolkit.PaletteRelativeAlign.Center;
this.lbNow.StateNormal.LongText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.lbNow.StateNormal.ShortText.Color1 = System.Drawing.Color.Blue; this.lbNow.StateNormal.ShortText.Color1 = System.Drawing.Color.Blue;
this.lbNow.StateNormal.ShortText.Color2 = System.Drawing.Color.MidnightBlue; this.lbNow.StateNormal.ShortText.Color2 = System.Drawing.Color.MidnightBlue;
this.lbNow.StateNormal.ShortText.ColorAngle = 45F; this.lbNow.StateNormal.ShortText.ColorAngle = 45F;
this.lbNow.StateNormal.ShortText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma; this.lbNow.StateNormal.ShortText.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Sigma;
this.lbNow.StateNormal.ShortText.Font = new System.Drawing.Font("Verdana", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbNow.StateNormal.ShortText.Font = new System.Drawing.Font("Verdana", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbNow.StateNormal.ShortText.ImageStyle = Krypton.Toolkit.PaletteImageStyle.Inherit;
this.lbNow.StateNormal.ShortText.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near; this.lbNow.StateNormal.ShortText.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near;
this.lbNow.StateNormal.ShortText.Trim = Krypton.Toolkit.PaletteTextTrim.Inherit;
this.lbNow.TabIndex = 3; this.lbNow.TabIndex = 3;
this.lbNow.Values.Text = "2020-02-02 22:00:00\r\n"; this.lbNow.Values.Text = "2020-02-02 22:00:00\r\n";
// //
// kryptonNavigator1 // kryptonNavigator1
// //
this.kryptonNavigator1.Button.ButtonDisplayLogic = Krypton.Navigator.ButtonDisplayLogic.ContextNextPrevious; this.kryptonNavigator1.Button.ButtonDisplayLogic = Krypton.Navigator.ButtonDisplayLogic.ContextNextPrevious;
this.kryptonNavigator1.Button.CloseButtonAction = Krypton.Navigator.CloseButtonAction.RemovePageAndDispose;
this.kryptonNavigator1.Button.CloseButtonDisplay = Krypton.Navigator.ButtonDisplay.Hide; this.kryptonNavigator1.Button.CloseButtonDisplay = Krypton.Navigator.ButtonDisplay.Hide;
this.kryptonNavigator1.Button.ContextButtonAction = Krypton.Navigator.ContextButtonAction.SelectPage;
this.kryptonNavigator1.Button.ContextButtonDisplay = Krypton.Navigator.ButtonDisplay.Logic;
this.kryptonNavigator1.Button.ContextMenuMapImage = Krypton.Navigator.MapKryptonPageImage.Small;
this.kryptonNavigator1.Button.ContextMenuMapText = Krypton.Navigator.MapKryptonPageText.TextTitle;
this.kryptonNavigator1.Button.NextButtonAction = Krypton.Navigator.DirectionButtonAction.ModeAppropriateAction;
this.kryptonNavigator1.Button.NextButtonDisplay = Krypton.Navigator.ButtonDisplay.Logic;
this.kryptonNavigator1.Button.PreviousButtonAction = Krypton.Navigator.DirectionButtonAction.ModeAppropriateAction;
this.kryptonNavigator1.Button.PreviousButtonDisplay = Krypton.Navigator.ButtonDisplay.Logic;
this.kryptonNavigator1.Dock = System.Windows.Forms.DockStyle.Fill; this.kryptonNavigator1.Dock = System.Windows.Forms.DockStyle.Fill;
this.kryptonNavigator1.Location = new System.Drawing.Point(0, 79); this.kryptonNavigator1.Location = new System.Drawing.Point(0, 79);
this.kryptonNavigator1.Name = "kryptonNavigator1"; this.kryptonNavigator1.Name = "kryptonNavigator1";
this.kryptonNavigator1.NavigatorMode = Krypton.Navigator.NavigatorMode.BarTabGroup;
this.kryptonNavigator1.Pages.AddRange(new Krypton.Navigator.KryptonPage[] { this.kryptonNavigator1.Pages.AddRange(new Krypton.Navigator.KryptonPage[] {
this.MainDetail}); this.MainDetail});
this.kryptonNavigator1.SelectedIndex = 0; this.kryptonNavigator1.SelectedIndex = 0;
@@ -237,11 +276,13 @@
// MainDetail // MainDetail
// //
this.MainDetail.AutoHiddenSlideSize = new System.Drawing.Size(200, 200); this.MainDetail.AutoHiddenSlideSize = new System.Drawing.Size(200, 200);
this.MainDetail.ButtonSpecs.AddRange(new Krypton.Toolkit.ButtonSpecAny[] {
((Krypton.Toolkit.ButtonSpecAny)(this.buttonSpecAny1))});
this.MainDetail.Flags = 65534; this.MainDetail.Flags = 65534;
this.MainDetail.LastVisibleSet = true; this.MainDetail.LastVisibleSet = true;
this.MainDetail.MinimumSize = new System.Drawing.Size(50, 50); this.MainDetail.MinimumSize = new System.Drawing.Size(50, 50);
this.MainDetail.Name = "MainDetail"; this.MainDetail.Name = "MainDetail";
this.MainDetail.Size = new System.Drawing.Size(1006, 623); this.MainDetail.Size = new System.Drawing.Size(1006, 615);
this.MainDetail.Text = "MainDetail"; this.MainDetail.Text = "MainDetail";
this.MainDetail.ToolTipTitle = "Page ToolTip"; this.MainDetail.ToolTipTitle = "Page ToolTip";
this.MainDetail.UniqueName = "0E1DA5225D8D4CFC70A2EFA8667116CC"; this.MainDetail.UniqueName = "0E1DA5225D8D4CFC70A2EFA8667116CC";
@@ -255,6 +296,13 @@
this.timer.Interval = 1000; this.timer.Interval = 1000;
this.timer.Tick += new System.EventHandler(this.timer_Tick); this.timer.Tick += new System.EventHandler(this.timer_Tick);
// //
// buttonSpecAny1
//
this.buttonSpecAny1.Enabled = Krypton.Toolkit.ButtonEnabled.False;
this.buttonSpecAny1.Style = Krypton.Toolkit.PaletteButtonStyle.FormClose;
this.buttonSpecAny1.Type = Krypton.Toolkit.PaletteButtonSpecStyle.FormClose;
this.buttonSpecAny1.UniqueName = "b98969b28fc84ecca8db41d2f99b165b";
//
// frmMainNew // frmMainNew
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -300,5 +348,6 @@
private Krypton.Navigator.KryptonNavigator kryptonNavigator1; private Krypton.Navigator.KryptonNavigator kryptonNavigator1;
private Krypton.Navigator.KryptonPage MainDetail; private Krypton.Navigator.KryptonPage MainDetail;
public Krypton.Toolkit.KryptonLabel kryptonLabel1; public Krypton.Toolkit.KryptonLabel kryptonLabel1;
private Krypton.Toolkit.ButtonSpecAny buttonSpecAny1;
} }
} }

View File

@@ -383,7 +383,7 @@ namespace CleanMachineHMI
private void ShowPicAlarm() private void ShowPicAlarm()
{ {
ptb_Alarm.Visible = Global.CmWarningLogMd_List.Count > 0; ptb_Alarm.Visible = PlcOperationHelper.Instance.CmWarningLogMd_List.Count > 0;
//Invoke(new Action(() => //Invoke(new Action(() =>
//{ //{
@@ -416,34 +416,34 @@ namespace CleanMachineHMI
// } // }
//} //}
Global.BasWarningMd_List = new CleanMachine.BLL.BAS.WarningBLL().GetList("").ToList(); Global.BasWarningMd_List = new CleanMachine.BLL.BAS.WarningBLL().GetList("").ToList();
Global.CmWarningLogMd_List = new List<WarningLog>(); //Global.CmWarningLogMd_List = new Dictionary<string, WarningLog>();
string sql1 = $@"SELECT * FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT =0"; //string sql1 = $@"SELECT * FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT =0";
DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0]; //DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
if (dt1 != null && dt1.Rows.Count > 0) //if (dt1 != null && dt1.Rows.Count > 0)
{ //{
foreach (DataRow item in dt1.Rows) // foreach (DataRow item in dt1.Rows)
{ // {
Global.CmWarningLogMd_List.Add(new WarningLog // Global.CmWarningLogMd_List.Add(,new WarningLog
{ // {
WarningCode = item["WARNING_CODE"].ToString(), // WarningCode = item["WARNING_CODE"].ToString(),
WarningName = item["WARNING_NAME"].ToString(), // WarningName = item["WARNING_NAME"].ToString(),
WarningType = item["WARNING_TYPE"].ToString(), // WarningType = item["WARNING_TYPE"].ToString(),
WarningMessage = item["WARNING_MESSAGE"].ToString(), // WarningMessage = item["WARNING_MESSAGE"].ToString(),
WarningTime = Convert.ToDateTime(item["WARNING_TIME"]), // WarningTime = Convert.ToDateTime(item["WARNING_TIME"]),
PlcItemCode = item["PLC_ITEM_CODE"].ToString(), // PlcItemCode = item["PLC_ITEM_CODE"].ToString(),
WaringStatus = 0, // WaringStatus = 0,
WarningHandleResult = 0, // WarningHandleResult = 0,
CreateBy = Convert.ToInt32(item["CREATE_BY"]), // CreateBy = Convert.ToInt32(item["CREATE_BY"]),
CreateTime = Convert.ToDateTime(item["CREATE_TIME"]), // CreateTime = Convert.ToDateTime(item["CREATE_TIME"]),
UpdateBy = Convert.ToInt32(item["UPDATE_BY"]), // UpdateBy = Convert.ToInt32(item["UPDATE_BY"]),
UpdateTime = Convert.ToDateTime(item["UPDATE_TIME"]), // UpdateTime = Convert.ToDateTime(item["UPDATE_TIME"]),
DataVersion = Convert.ToInt32(item["DATA_VERSION"]), // DataVersion = Convert.ToInt32(item["DATA_VERSION"]),
}); // });
} // }
string sql2 = $@"DELETE FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT =0"; // string sql2 = $@"DELETE FROM CM_WARNING_LOG WHERE WARING_STATUS = 0 AND WARNING_HANDLE_RESULT =0";
LeadDbHelperSQLite.Execute(sql2); // LeadDbHelperSQLite.Execute(sql2);
} //}
} }
//private void SetPlcItem(List<PlcItem> PlcItemMdList, DataRow item) //private void SetPlcItem(List<PlcItem> PlcItemMdList, DataRow item)
//{ //{
@@ -825,86 +825,86 @@ namespace CleanMachineHMI
timer.Enabled = false; timer.Enabled = false;
Global.SysThIsRunFlag = false; Global.SysThIsRunFlag = false;
PlcOperationHelper.Instance.eventAlarmLock = true; PlcOperationHelper.Instance.eventAlarmLock = true;
if (Global.CmWarningLogMd_List.Count > 0) //if (Global.CmWarningLogMd_List.Count > 0)
{ //{
foreach (WarningLog item in Global.CmWarningLogMd_List) // foreach (WarningLog item in Global.CmWarningLogMd_List.Values)
{ // {
if (item.WaringStatus == 0 && item.WarningHandleResult == 0) // if (item.WaringStatus == 0 && item.WarningHandleResult == 0)
{ // {
string sql1 = $@" // string sql1 = $@"
INSERT INTO CM_WARNING_LOG ( // INSERT INTO CM_WARNING_LOG (
WARNING_CODE, // WARNING_CODE,
WARNING_NAME, // WARNING_NAME,
WARNING_TYPE, // WARNING_TYPE,
WARNING_MESSAGE, // WARNING_MESSAGE,
WARNING_TIME, // WARNING_TIME,
PLC_ITEM_CODE, // PLC_ITEM_CODE,
WARING_STATUS, // WARING_STATUS,
WARNING_HANDLE_RESULT, // WARNING_HANDLE_RESULT,
CREATE_BY, // CREATE_BY,
CREATE_TIME, // CREATE_TIME,
UPDATE_BY, // UPDATE_BY,
UPDATE_TIME, // UPDATE_TIME,
DATA_VERSION // DATA_VERSION
) // )
VALUES ( // VALUES (
'{item.WarningCode}', // '{item.WarningCode}',
'{item.WarningName}', // '{item.WarningName}',
'{item.WarningType}', // '{item.WarningType}',
'{item.WarningMessage}', // '{item.WarningMessage}',
'{item.WarningTime.ToString("yyyy-MM-dd HH:mm:ss")}', // '{item.WarningTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.PlcItemCode}', // '{item.PlcItemCode}',
'{item.WaringStatus}', // '{item.WaringStatus}',
'{item.WarningHandleResult}', // '{item.WarningHandleResult}',
'{item.CreateBy}', // '{item.CreateBy}',
'{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}', // '{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.UpdateBy}', // '{item.UpdateBy}',
'{item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}', // '{item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.DataVersion}' // '{item.DataVersion}'
); // );
"; // ";
LeadDbHelperSQLite.Execute(sql1); // LeadDbHelperSQLite.Execute(sql1);
} // }
else // else
{ // {
string sql1 = $@" // string sql1 = $@"
INSERT INTO CM_WARNING_LOG ( // INSERT INTO CM_WARNING_LOG (
WARNING_CODE, // WARNING_CODE,
WARNING_NAME, // WARNING_NAME,
WARNING_TYPE, // WARNING_TYPE,
WARNING_MESSAGE, // WARNING_MESSAGE,
WARNING_TIME, // WARNING_TIME,
PLC_ITEM_CODE, // PLC_ITEM_CODE,
WARING_STATUS, // WARING_STATUS,
WARNING_HANDLE_RESULT, // WARNING_HANDLE_RESULT,
WARNING_HANDLE_TIME, // WARNING_HANDLE_TIME,
CREATE_BY, // CREATE_BY,
CREATE_TIME, // CREATE_TIME,
UPDATE_BY, // UPDATE_BY,
UPDATE_TIME, // UPDATE_TIME,
DATA_VERSION // DATA_VERSION
) // )
VALUES ( // VALUES (
'{item.WarningCode}', // '{item.WarningCode}',
'{item.WarningName}', // '{item.WarningName}',
'{item.WarningType}', // '{item.WarningType}',
'{item.WarningMessage}', // '{item.WarningMessage}',
'{item.WarningTime.ToString("yyyy-MM-dd HH:mm:ss")}', // '{item.WarningTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.PlcItemCode}', // '{item.PlcItemCode}',
'{item.WaringStatus}', // '{item.WaringStatus}',
'{item.WarningHandleResult}', // '{item.WarningHandleResult}',
'{item.WarningHandleTime.ToString("yyyy-MM-dd HH:mm:ss")}', // '{item.WarningHandleTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.CreateBy}', // '{item.CreateBy}',
'{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}', // '{item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.UpdateBy}', // '{item.UpdateBy}',
'{item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}', // '{item.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss")}',
'{item.DataVersion}' // '{item.DataVersion}'
); // );
"; // ";
LeadDbHelperSQLite.Execute(sql1); // LeadDbHelperSQLite.Execute(sql1);
} // }
} // }
} // }
await Task.Delay(300); await Task.Delay(300);
if (isPlcConnStatus) if (isPlcConnStatus)