SendTrxDoneToCardReader.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Wayne.Lib.StateEngine;
  7. using Wayne.Lib.StateEngine.Generic;
  8. namespace SinochemInternetPlusApp.States.CarPlateManualMode
  9. {
  10. public class SendTrxDoneToCardReader : TimeoutState<FuelingPoint>
  11. {
  12. private byte sqNo;
  13. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  14. {
  15. base.Enter(stateEntry, ref transition);
  16. Main.NotifyCardReaderTrxDone(out sqNo);
  17. }
  18. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  19. {
  20. GenericEvent<CardReaderAckEventArgs> ackEvent = stateEngineEvent as GenericEvent<CardReaderAckEventArgs>;
  21. if (ackEvent != null && ackEvent.EventArgs != null)
  22. {
  23. if (ackEvent.EventArgs.Ack.MessageSeqNumber == sqNo)
  24. {
  25. ackEvent.Handled = true;
  26. Main.CardReaderDisabled = false;
  27. transition = new Transition(this, TransitionType.Done);
  28. }
  29. }
  30. }
  31. protected override void Timeout(ref Transition transition)
  32. {
  33. transition = new Transition(this, TransitionType.Timeout);
  34. }
  35. protected override int TimeoutInterval =>
  36. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_SendTrxDoneToCardReader, 10);
  37. }
  38. }