NotifyPOS.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using Wayne.Lib;
  4. using Wayne.Lib.StateEngine;
  5. using Wayne.Lib.StateEngine.Generic;
  6. namespace SinochemInternetPlusApp.States.Shared
  7. {
  8. class NotifyPOS : TimeoutState<FuelingPoint>
  9. {
  10. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  11. {
  12. base.Enter(stateEntry, ref transition);
  13. Main.NotifyPosAync();
  14. }
  15. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  16. {
  17. if (stateEngineEvent.Type is EventType)
  18. {
  19. switch ((EventType)stateEngineEvent.Type)
  20. {
  21. case EventType.PosNotifyOk:
  22. Main.CurrentEpsTrx.UpdateNotifyPosFlagToDb(NotifyPosFlag.NotifyOk);
  23. transition = new Transition(this, TransitionType.PosNotifyOk);
  24. stateEngineEvent.Handled = true;
  25. break;
  26. case EventType.PosNotifyFailed:
  27. transition = HandleFailedNotify();
  28. stateEngineEvent.Handled = true;
  29. break;
  30. }
  31. }
  32. }
  33. private Transition HandleFailedNotify()
  34. {
  35. DebugLog(string.Format("Notify pos failed!!! jihao: {0}, fuelSeq: {1}",
  36. Main.CurrentEpsTrx.Model.jihao,
  37. Main.CurrentEpsTrx.Model.liushuino));
  38. Main.CurrentEpsTrx.UpdateNotifyPosFlagToDb(NotifyPosFlag.NotifyFailed);
  39. Transition transition = new Transition(this, TransitionType.PosNotifyFailed);
  40. return transition;
  41. }
  42. protected override void Timeout(ref Transition transition)
  43. {
  44. transition = HandleFailedNotify();
  45. }
  46. protected override int TimeoutInterval =>
  47. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.Shared_NotifyPOS, 10);
  48. }
  49. }