64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using MECF.Framework.Common.Communications;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.HwAligner
|
|
{
|
|
public abstract class HwAlignerGuideHandler : HandlerBase
|
|
{
|
|
public HwAlignerGuide Device { get; }
|
|
|
|
protected HwAlignerGuideHandler(HwAlignerGuide device, string commandvalue)
|
|
: base(BuildMessage(commandvalue))
|
|
{
|
|
Device = device;
|
|
}
|
|
|
|
private static byte[] BuildMessage(string commandvalue)
|
|
{
|
|
List<byte> liCmd = Encoding.ASCII.GetBytes(commandvalue).ToList<byte>();
|
|
liCmd.Add(0x0d); //CR
|
|
liCmd.Add(0x0a); //LF 不可颠倒
|
|
|
|
return liCmd.ToArray();
|
|
}
|
|
|
|
public override bool HandleMessage(MessageBase msg, out bool handled)
|
|
{
|
|
var result = msg as HwAlignerGuideMessage;
|
|
|
|
ResponseMessage = msg;
|
|
handled = true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public class HwAlignerGuideSetAHandler : HwAlignerGuideHandler
|
|
{
|
|
public HwAlignerGuideSetAHandler(HwAlignerGuide device, string name, string commandvalue, int timeout = 30)
|
|
: base(device, commandvalue)
|
|
{
|
|
AckTimeout = TimeSpan.FromSeconds(timeout);
|
|
CompleteTimeout = TimeSpan.FromSeconds(timeout);
|
|
Name = name;
|
|
}
|
|
|
|
public override bool HandleMessage(MessageBase msg, out bool handled)
|
|
{
|
|
var result = msg as HwAlignerGuideMessage;
|
|
if (!result.IsResponse)
|
|
{
|
|
handled = true;
|
|
return false;
|
|
}
|
|
|
|
handled = Device.PraseDataA(Name, result.Data,out bool returnIfo);
|
|
return returnIfo;
|
|
}
|
|
}
|
|
|
|
|
|
}
|