日志重写

This commit is contained in:
a88359121
2025-07-31 11:04:47 +08:00
parent a803360523
commit 941564d8a4
28 changed files with 325 additions and 399 deletions
+8 -7
View File
@@ -31,6 +31,7 @@ namespace JinYuan.ControlCenters
{
public partial class ControlCenter
{
private static LoggerHelp _logger = new LoggerHelp();
/// <summary>
/// 打印日志方法
/// </summary>
@@ -139,7 +140,7 @@ namespace JinYuan.ControlCenters
DicStationFunction = new Dictionary<string, dgStationFunction>();
DicStationFunction.Add("电芯进站", FeedingStation);
//DicStationFunction.Add("NG出站", NGStation);
DicStationFunction.Add("NG出站", NGStation);
DicStationFunction.Add("电芯出站", BlankingStation);
for (int i = 0; i < CommonMethods.ChatLineCount; i++)
@@ -262,14 +263,14 @@ namespace JinYuan.ControlCenters
JYResult<byte[]> resByte = CommonMethods.PlcLink.ReadValue<JYResult<byte[]>>($"{pf.VarList[1].VarAddress}", Data_Type.ArrByte, Convert.ToUInt16(pf.VarList[1].OffsetOrLenght));
sw1.Stop();
CommonMethods.AddDataMonitorLog(0, $"{pf.GroupName},耗时:{sw1.Elapsed.TotalMilliseconds}ms");
LogHelper.Instance.WriteLog( $"读取工位:{pf.GroupName},启动读取字节共耗时:" + sw1.Elapsed.TotalMilliseconds, "循环读取PLC工位");
LoggerHelp.WriteLog("循环读取PLC工位" + $"读取工位:{pf.GroupName},启动读取字节共耗时:" + sw1.Elapsed.TotalMilliseconds);
//置位 PLC-防止重复读取
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 2);//置位,读取进行中的标志
if (resByte == null)
{
CommonMethods.AddDataMonitorLog(0, $"上料工位:{pf.GroupName},起始地址:{pf.VarList[1].VarAddress},得到空字节数组");
LogHelper.Instance.WriteLog( $"读取工位:{pf.GroupName},起始地址:{pf.VarList[1].VarAddress},得到空字节数组", "循环读取PLC上料工位");
LoggerHelp.WriteLog("循环读取PLC上料工位"+$"读取工位:{pf.GroupName},起始地址:{pf.VarList[1].VarAddress},得到空字节数组");
}
else
{
@@ -286,14 +287,14 @@ namespace JinYuan.ControlCenters
// }, null);
//}
//// private Dictionary<string, dgStationFunction> DicStationFunction;
DicStationFunction[pf.GroupName].BeginInvoke(resByte, pf, null, null);//信息解析
DicStationFunction[pf.GroupName].BeginInvoke(resByte, pf, null, null);//信息解析
}
}
}
catch (Exception ex)
{
CommonMethods.AddLog(true, ex.Message);
LogHelper.Instance.WriteEX(ex);
LoggerHelp.WriteEX(ex);
}
}
Thread.Sleep(200);
@@ -1359,7 +1360,7 @@ namespace JinYuan.ControlCenters
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX(ex);
LoggerHelp.WriteEX(ex);
}
}
@@ -1842,7 +1843,7 @@ namespace JinYuan.ControlCenters
catch (Exception ex)
{
CommonMethods.AddLog(true, "设备状态" + ex.Message);
LogHelper.Instance.WriteEX(ex);
LoggerHelp.WriteEX(ex);
}
}
#endregion