77 lines
1.7 KiB
C#
77 lines
1.7 KiB
C#
namespace Common.Hardware.SIRT
|
|
{
|
|
using Common.Hardware.SIRT.Parameters;
|
|
|
|
using System;
|
|
|
|
public partial class SIRTTask
|
|
{
|
|
internal byte[] Start()
|
|
{
|
|
if (this.State != SIRTTaskState.Cancelled)
|
|
{
|
|
this.State = SIRTTaskState.Running;
|
|
|
|
this.timeoutTimer.Stop();
|
|
this.timeoutTimer.Start();
|
|
|
|
return this.ToByteArray();
|
|
}
|
|
|
|
return Array.Empty<byte>();
|
|
}
|
|
|
|
internal class AnswerTask : SIRTTask
|
|
{
|
|
public AnswerTask() : base(0, 3000)
|
|
{
|
|
|
|
}
|
|
|
|
public byte[] Last { get; private set; }
|
|
|
|
protected override void ProcessResponse(SIRTMessage response)
|
|
{
|
|
this.Last = response.Data ?? new byte[] { };
|
|
|
|
base.ProcessResponse(response);
|
|
}
|
|
}
|
|
|
|
internal static readonly AnswerTask ActivateSIRT = new AnswerTask
|
|
{
|
|
Cmd = SIRTMessage.W_REG,
|
|
RequestAddress = 0x20000000,
|
|
P2 = 0x05,
|
|
Data = new byte[]
|
|
{
|
|
new SirtOperating { /* default */ },
|
|
new BluetoothOperating { BtOff = true },
|
|
new RFModuleOperating { RfOff = true },
|
|
new RFModuleOperating { OpMode = OperatingModes.ReceiveF1TransmitSensusRFF3 },
|
|
new PamTimeout { Minutes = 1 }
|
|
}
|
|
};
|
|
|
|
internal static readonly AnswerTask IdentifySIRT = new AnswerTask
|
|
{
|
|
Cmd = SIRTMessage.R_REG,
|
|
RequestAddress = 0x11001820,
|
|
P2 = 0x08
|
|
};
|
|
|
|
internal static readonly AnswerTask ReadPamPool = new AnswerTask
|
|
{
|
|
Cmd = SIRTMessage.R_PAM,
|
|
RequestAddress = 0xFFFFFFFF
|
|
};
|
|
|
|
internal static AnswerTask DeleteFromPamPool(uint address) => new AnswerTask
|
|
{
|
|
Cmd = SIRTMessage.W_PAM,
|
|
P1 = new P811 { DelPamAdr = true },
|
|
RequestAddress = address
|
|
};
|
|
}
|
|
}
|