2023-05-10 15:08:06 +08:00
|
|
|
|
using MECF.Framework.Common.Communications;
|
2024-01-22 17:36:25 +08:00
|
|
|
|
using System;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2023-05-10 15:08:06 +08:00
|
|
|
|
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.HiWinAligner
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
public class HwAlignerGuideConnection : SerialPortConnectionBase
|
|
|
|
|
{
|
2023-05-10 15:08:06 +08:00
|
|
|
|
private readonly List<byte> _lstCacheBuffer = new();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
private object _lockerActiveHandler = new object();
|
2024-01-22 17:36:25 +08:00
|
|
|
|
private string _result = "";
|
|
|
|
|
public string Result
|
|
|
|
|
{
|
|
|
|
|
get { return _result; }
|
|
|
|
|
}
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public HwAlignerGuideConnection(string portName)
|
|
|
|
|
: base(portName, 115200, 8, System.IO.Ports.Parity.None, System.IO.Ports.StopBits.One, "\r", false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public override bool SendMessage(byte[] message)
|
|
|
|
|
{
|
|
|
|
|
_lstCacheBuffer.Clear();
|
2024-01-22 17:36:25 +08:00
|
|
|
|
_result = "";
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return base.SendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
protected override MessageBase ParseResponse(byte[] rawMessage)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_lstCacheBuffer.AddRange(rawMessage);
|
2023-05-10 15:08:06 +08:00
|
|
|
|
var temps = _lstCacheBuffer.ToArray();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2024-01-22 17:36:25 +08:00
|
|
|
|
_result += System.Text.Encoding.ASCII.GetString(temps);
|
|
|
|
|
|
|
|
|
|
HwAlignerGuideMessage msg = new HwAlignerGuideMessage();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
msg.IsResponse = false;
|
|
|
|
|
msg.IsAck = false;
|
|
|
|
|
msg.IsComplete = false;
|
|
|
|
|
msg.RawMessage = _lstCacheBuffer.ToArray();
|
|
|
|
|
msg.Data = _lstCacheBuffer.ToArray();
|
|
|
|
|
msg.IsResponse = true;
|
|
|
|
|
msg.IsAck = true;
|
|
|
|
|
msg.IsComplete = true;
|
|
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
2024-01-22 17:36:25 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|