|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Drawing; |
| 4 | +using System.IO; |
4 | 5 | using System.IO.Ports; |
5 | 6 | using System.Threading; |
6 | 7 | using System.Windows.Forms; |
@@ -90,7 +91,7 @@ private static readonly (Mat Departure, Mat Destination) IconOrder = ( |
90 | 91 | /// <summary> |
91 | 92 | /// The length of the buffer for serial ports. |
92 | 93 | /// </summary> |
93 | | - private const int SerialPortBufferLength = 1024; |
| 94 | + private const int SerialPortBufferLength = 1048576; |
94 | 95 |
|
95 | 96 | #endregion |
96 | 97 |
|
@@ -170,6 +171,7 @@ public Dictionary<CampType, SerialPort> SerialPortDict |
170 | 171 | private CoordinateConverter _coordinateConverter; |
171 | 172 | private Game _game = new Game(); |
172 | 173 | private Dictionary<CampType, Locator> _locatorDict = new Dictionary<CampType, Locator>(); |
| 174 | + private Logger _logger = new(Path.Combine(Directory.GetCurrentDirectory(), "Logs", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".log")); |
173 | 175 | private Point2f[] _monitorCorners = new Point2f[4]; |
174 | 176 | private OpenCvSharp.Size _monitorFrameSize; |
175 | 177 | private List<Order> _orderToTransmitList = new List<Order>(); |
@@ -378,6 +380,11 @@ private void Communicate() |
378 | 380 | { |
379 | 381 | foreach (var camp in MainWindow.AllCampList) |
380 | 382 | { |
| 383 | + if (this._game.Camp != camp) |
| 384 | + { |
| 385 | + continue; |
| 386 | + } |
| 387 | + |
381 | 388 | if ( |
382 | 389 | this._serialPortDict[camp] == null || |
383 | 390 | !this._serialPortDict[camp].IsOpen |
@@ -461,6 +468,7 @@ private void Communicate() |
461 | 468 | ownChargingPiles: ownChargingPiles, |
462 | 469 | opponentChargingPiles: opponentChargingPiles |
463 | 470 | ); |
| 471 | + _logger.Debug($"{DateTime.Now.ToString("HH:mm:ss")} [0x01 {camp}] {Convert.ToHexString(gameInfoPacket.GetBytes())}"); |
464 | 472 | var bytesToWrite = gameInfoPacket.GetBytes(); |
465 | 473 | try |
466 | 474 | { |
@@ -540,6 +548,7 @@ private void Communicate() |
540 | 548 | orderInDeliveryList: orderInDeliveryList, |
541 | 549 | latestPendingOrder: latestPendingOrder |
542 | 550 | ); |
| 551 | + _logger.Debug($"{DateTime.Now.ToString("HH:mm:ss")} [0x05 {camp}] {Convert.ToHexString(packet.GetBytes())}"); |
543 | 552 |
|
544 | 553 | var bytesToWrite = packet.GetBytes(); |
545 | 554 |
|
|
0 commit comments