SendCalculateMacRequest.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Wayne.Lib.StateEngine;
  2. using WayneChina_IcCardReader_SinoChem.MessageEntity;
  3. using WayneChina_IcCardReader_SinoChem.MessageEntity.Outgoing;
  4. namespace SinochemInternetPlusApp.States.ICCardMode
  5. {
  6. public class SendCalculateMacRequest : SendCardReaderCommandBase
  7. {
  8. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  9. {
  10. base.Enter(stateEntry, ref transition);
  11. }
  12. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  13. {
  14. //First step, an ACK expected.
  15. var e = stateEngineEvent as GenericEvent<CardReaderAckEventArgs>;
  16. if (e != null && e.EventArgs != null)
  17. {
  18. if (e.EventArgs.Ack.MessageSeqNumber == sqNo)
  19. {
  20. e.Handled = true;
  21. transition = new Transition(this, TransitionType.Done);
  22. }
  23. }
  24. }
  25. protected override IcCardReaderMessageBase CreateCommand()
  26. {
  27. DebugLog($"Is current Eps trx null? {Main.CurrentEpsTrx == null}");
  28. byte[] targetBytes = Main.GetMAC(Main.CurrentEpsTrx.Model);
  29. return new SignDataRequest(targetBytes);
  30. }
  31. protected override int TimeoutInterval =>
  32. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.ICCardMode_SendCalculateMacRequest, 10);
  33. }
  34. }