tbf/TestBenchFramework/BenchControl/Modbus/TankSelector/SetQuidoBitOp.cs

58 lines
1.3 KiB
C#

namespace TBF.BenchControl.Modbus.TankSelector
{
public class SetQuidoBitOp : IOperation
{
public enum OpSpecifier
{
None,
SelectTank,
UnselectTank, /// tankNo is ignored, the selected tank is unselected
}
readonly TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS;
readonly ushort bitMask;
readonly bool set; /// true = set, false = reset
readonly Event eventDone;
public SetQuidoBitOp(TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS, TankSelector.QuidoOutputs bitMask, bool set)
: this(quidoRS, (ushort)bitMask, set, Event.ConditionMet)
{
}
public SetQuidoBitOp(TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS, ushort bitMask, bool set)
: this(quidoRS, bitMask, set, Event.ConditionMet)
{
}
public SetQuidoBitOp(TBF.BenchControl.Modbus.QuidoRS.QuidoRS quidoRS, ushort bitMask, bool set, Event eventDone)
{
this.quidoRS = quidoRS;
this.bitMask = bitMask;
this.set = set;
this.eventDone = eventDone;
}
/// <summary>Start this operation</summary>
public void Start()
{
if (set)
quidoRS.SetBit(bitMask);
else
quidoRS.ResetBit(bitMask);
}
/// <summary>Run this operation</summary>
public Event Run()
{
return eventDone;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}