har error 和日志更新

This commit is contained in:
Admin
2025-04-29 15:22:54 +08:00
parent 95bc9ce3b3
commit 6c1d86619e
5 changed files with 44 additions and 27 deletions

View File

@ -627,11 +627,22 @@ namespace DH.Devices.PLC
public void NewPieces(int axisIndex, uint pieceNumber)
{
_taskFactory.StartNew(() =>
{
Thread.CurrentThread.Priority = ThreadPriority.Highest;
//_taskFactory.StartNew(() =>
//{
// Thread.CurrentThread.Priority = ThreadPriority.Highest;
// OnNewPieces?.Invoke(axisIndex, pieceNumber);
//});
Task.Run(() =>
{
try
{
Thread.CurrentThread.Priority = ThreadPriority.Highest;
OnNewPieces?.Invoke(axisIndex, pieceNumber);
}
catch (Exception ex) { /* 记录异常 */ }
OnNewPieces?.Invoke(axisIndex, pieceNumber);
});
}
public async Task HeartbeatAsync1()
@ -697,14 +708,14 @@ namespace DH.Devices.PLC
//while (CurrentState != DeviceState.DSClose && CurrentState != DeviceState.DSExcept && CurrentState != DeviceState.DSUninit)
while (Connected)
{
Stopwatch sw = new Stopwatch();
// Stopwatch sw = new Stopwatch();
uint tmpPieceNumber = 0;
sw.Start();
// sw.Start();
// var ret = TcpNet.ReadUInt16("D1016");
var ret = TcpNet.ReadUInt32(Count);
sw.Stop();
//sw.Stop();
if (ret.IsSuccess)
{
tmpPieceNumber = ret.Content;
@ -712,7 +723,7 @@ namespace DH.Devices.PLC
if (ret.IsSuccess && ret.Content > piecesCount)
{
sw.Start();
// sw.Start();
// Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")} 板卡{station}产品入列触发{tmpPieceNumber}");
//LogAsync(DateTime.Now, LogLevel.Information, $"转盘{0}产品入列 {piecesCountDic[0]} size:{sum}");
if (tmpPieceNumber != piecesCount + 1)
@ -724,8 +735,8 @@ namespace DH.Devices.PLC
piecesCount = tmpPieceNumber;
//NewPieces(ai, piecesCountDic[station]);
NewPieces(1, piecesCount);
sw.Stop();
startTime = DateTime.Now;
// sw.Stop();
// startTime = DateTime.Now;
//if (idalarm)
//{
// idalarm = false;