WaitForMacData.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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.ICCardMode
  9. {
  10. public class WaitForMacData : TimeoutState<FuelingPoint>
  11. {
  12. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  13. {
  14. if (stateEngineEvent.Type.Equals(EventType.DataSigned))
  15. {
  16. var @event = stateEngineEvent as GenericEvent<SignedDataEventArgs>;
  17. if (@event != null && @event.EventArgs != null)
  18. {
  19. @event.Handled = true;
  20. Main.SignedData = @event.EventArgs.SignedDataResponse;
  21. Main.CurrentEpsTrx.Model.mac = Main.SignedData.MacValue;
  22. transition = new Transition(this, TransitionType.Done);
  23. }
  24. }
  25. }
  26. protected override void Timeout(ref Transition transition)
  27. {
  28. DebugLog("WaitForMacData timed out, fatal error!!!");
  29. transition = new Transition(this, TransitionType.Timeout);
  30. }
  31. protected override int TimeoutInterval =>
  32. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.ICCardMode_WaitForMacData, 10);
  33. }
  34. }