Compare commits

..

No commits in common. "71bbea56a7042bac928d46b24e0c8a3730a31e3c" and "1a845198744ac6bc35ddab3e315794548f9393dd" have entirely different histories.

5 changed files with 26 additions and 43 deletions

View File

@ -85,15 +85,11 @@ namespace DH.Devices.Motion
public void NewPieces(int diskIndex, uint pieceNumber) public void NewPieces(int diskIndex, uint pieceNumber)
{ {
Task.Run(() => _taskFactory.StartNew(() =>
{ {
try { Thread.CurrentThread.Priority = ThreadPriority.Highest;
Thread.CurrentThread.Priority = ThreadPriority.Highest;
OnNewPieces?.Invoke(diskIndex, pieceNumber);
}
catch (Exception ex) { /* 记录异常 */ }
OnNewPieces?.Invoke(diskIndex, pieceNumber);
}); });
} }
public void SetResetFlag(bool isReset) public void SetResetFlag(bool isReset)

View File

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

View File

@ -653,9 +653,9 @@ namespace DHSoftware
detectionConfig.IsEnabled = detection.IsEnabled; detectionConfig.IsEnabled = detection.IsEnabled;
detectionConfig.ImageSaveDirectory = "D://Projects//Images"; detectionConfig.ImageSaveDirectory = "D://Projects//Images";
// 优化后代码 detectionConfig.ShowLocation.X = (i + 1) % 5 + (i + 1) / 5;
detectionConfig.ShowLocation.X = (i % 5) + 1; // X坐标从1开始每行1-5 // detectionConfig.ShowLocation.X = detection.ShowLocation.X;
detectionConfig.ShowLocation.Y = (i / 5) + 1; // Y坐标从1开始每5个换行 detectionConfig.ShowLocation.Y = (i + 1) / 5 + 1;
// detectionConfig.ShowLocation.Y = detection.ShowLocation.Y; // detectionConfig.ShowLocation.Y = detection.ShowLocation.Y;
DetectionConfigs.Add(detectionConfig); DetectionConfigs.Add(detectionConfig);
} }
@ -998,7 +998,8 @@ namespace DHSoftware
// 处理按钮状态变化 // 处理按钮状态变化
if (startPressed) if (startPressed)
{ {
PLC.TurnSpeed(0);
PLC.TurnStart(false);
HandleStartButton(); HandleStartButton();
} }
if (resetPressed) if (resetPressed)
@ -1014,7 +1015,7 @@ namespace DHSoftware
//EmergencyStop(null, null, null); //EmergencyStop(null, null, null);
} }
Thread.Sleep(100); Thread.Sleep(50);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -1393,15 +1394,15 @@ namespace DHSoftware
//转盘2 的物料是不是重新覆盖之前的pDta //转盘2 的物料是不是重新覆盖之前的pDta
if (axisIndex == 1) if (axisIndex == 1)
{ {
ProductData pData = new ProductData(BatchNO, pieceNumber, ProductBaseCount); ProductData pData = new ProductData("", pieceNumber, ProductBaseCount);
_productLists[index][pieceNumber] = pData; _productLists[index][pieceNumber] = pData;
LogAsync(DateTime.Now, LogLevel.Action, $">> 转盘{axisIndex}新产品{pieceNumber}加入队列{index}----计数{PieceCount}"); LogAsync(DateTime.Now, LogLevel.Action, $">> {axisIndex}新产品{pieceNumber}加入队列{index}----板卡计数{PieceCount}");
} }
//DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
//UpdateCT(null, (float)(dtNow - _ctTime).TotalSeconds); UpdateCT(null, (float)(dtNow - _ctTime).TotalSeconds);
// _ctTime = dtNow; _ctTime = dtNow;
} }
public async Task UpdateCT(object objData, float ctTime) public async Task UpdateCT(object objData, float ctTime)

View File

@ -55,7 +55,7 @@
this.tsmiClearLog.Name = "tsmiClearLog"; this.tsmiClearLog.Name = "tsmiClearLog";
this.tsmiClearLog.Size = new System.Drawing.Size(124, 22); this.tsmiClearLog.Size = new System.Drawing.Size(124, 22);
this.tsmiClearLog.Text = "清空日志"; this.tsmiClearLog.Text = "清空日志";
// this.tsmiClearLog.Click += new System.EventHandler(this.tsmiClearLog_Click); this.tsmiClearLog.Click += new System.EventHandler(this.tsmiClearLog_Click);
// //
// menuStrip1 // menuStrip1
// //

View File

@ -30,11 +30,8 @@ namespace DHSoftware.Views
#region #region
private const string SOURCE_PROCESS = "流程"; private const string SOURCE_PROCESS = "流程";
private const int LOG_NUM_LIMIT = 2000; private const int LOG_NUM_LIMIT = 2000;
// private const int BATCH_SIZE = 50; private const int BATCH_SIZE = 50;
// 调整常量配置 private const int PROCESS_INTERVAL = 100;
private const int BATCH_SIZE = 100; // 从50提升到100
private const int PROCESS_INTERVAL = 200; // 从100ms调整到200ms
// private const int PROCESS_INTERVAL = 100;
private const int FIRST_COL_WIDTH = 120; private const int FIRST_COL_WIDTH = 120;
#endregion #endregion