123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using Wayne.Lib.StateEngine;
- using WayneChina_IcCardReader_SinoChem.MessageEntity;
- using WayneChina_IcCardReader_SinoChem.MessageEntity.Outgoing;
- namespace SinochemInternetPlusApp.States.ICCardMode
- {
- public class SendCalculateMacRequest : SendCardReaderCommandBase
- {
- protected override void Enter(StateEntry stateEntry, ref Transition transition)
- {
- base.Enter(stateEntry, ref transition);
- CreateCommand();
- transition = new Transition(this, TransitionType.Done); //Transition out directly, WT30.
- }
- protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
- {
- //First step, an ACK expected.
- var e = stateEngineEvent as GenericEvent<CardReaderAckEventArgs>;
- if (e != null && e.EventArgs != null)
- {
- if (e.EventArgs.Ack.MessageSeqNumber == sqNo)
- {
- e.Handled = true;
- transition = new Transition(this, TransitionType.Done);
- }
- else
- {
- DebugLog($"SqNo not matched, Sent: {sqNo}, Received: {e.EventArgs.Ack.MessageSeqNumber}");
- e.Handled = true;
- transition = new Transition(this, TransitionType.Done);
- }
- }
- }
- protected override IcCardReaderMessageBase CreateCommand()
- {
- byte[] targetBytes = Main.GetMAC(Main.CurrentEpsTrx.Model);
- return new SignDataRequest(targetBytes);
- }
- protected override int TimeoutInterval =>
- TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.ICCardMode_SendCalculateMacRequest, 10);
- }
- }
|