61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using MECF.Framework.Common.Communications;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Temps
|
|
{
|
|
public abstract class SensorTempHandler : HandlerBase
|
|
{
|
|
public SensorTemp Device { get; }
|
|
|
|
protected SensorTempHandler(SensorTemp device, byte[] commandvalue)
|
|
: base(commandvalue)
|
|
{
|
|
Device = device;
|
|
}
|
|
|
|
|
|
public override bool HandleMessage(MessageBase msg, out bool handled)
|
|
{
|
|
var result = msg as BinaryMessage;
|
|
|
|
ResponseMessage = msg;
|
|
handled = true;
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
public class SensorTempQueryHandler : SensorTempHandler
|
|
{
|
|
public SensorTempQueryHandler(SensorTemp device, string name, byte[] commandvalue)
|
|
: base(device, commandvalue)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
public override bool HandleMessage(MessageBase msg, out bool handled)
|
|
{
|
|
var result = msg as BinaryMessage;
|
|
handled = false;
|
|
if (result.IsError)
|
|
{
|
|
Device.ResponseError();
|
|
return false;
|
|
}
|
|
if (!result.IsComplete)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Device.ResponseQuery(Name, result.RawMessage);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|