Sic.Framework-Nanjing-Baishi/MECF.Framework.RT.Equipment.../HardwareUnits/Aligners/HiWinAligner/HwAlignerGuideConnection.cs

50 lines
1.5 KiB
C#
Raw Normal View History

using MECF.Framework.Common.Communications;
using System;
2023-04-13 11:51:03 +08:00
using System.Collections.Generic;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.HiWinAligner
2023-04-13 11:51:03 +08:00
{
public class HwAlignerGuideConnection : SerialPortConnectionBase
{
private readonly List<byte> _lstCacheBuffer = new();
2023-04-13 11:51:03 +08:00
private object _lockerActiveHandler = new object();
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();
_result = "";
2023-04-13 11:51:03 +08:00
return base.SendMessage(message);
}
protected override MessageBase ParseResponse(byte[] rawMessage)
{
_lstCacheBuffer.AddRange(rawMessage);
var temps = _lstCacheBuffer.ToArray();
2023-04-13 11:51:03 +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;
}
2023-04-13 11:51:03 +08:00
}
}