ShowTrxListFueling.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.CarPlateMode
  9. {
  10. public class ShowTrxListFueling : TimeoutState<FuelingPoint>
  11. {
  12. private int requestId;
  13. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  14. {
  15. base.Enter(stateEntry, ref transition);
  16. var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  17. Main.GetAllNozzlesOnThisSide(),
  18. ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
  19. Main.DebugLogger);
  20. var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 1);
  21. if (Main.Eps.CarPlateHandler != null)
  22. {
  23. DebugLog(text);
  24. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  25. if (!Main.ContainsRequestId(requestId))
  26. Main.AddRequestId(requestId);
  27. }
  28. }
  29. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  30. {
  31. if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived))
  32. {
  33. var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
  34. if (e != null && e.EventArgs != null)
  35. {
  36. if (requestId == e.EventArgs.DispResponse.RequestId)
  37. {
  38. e.Handled = true;
  39. if (Main.ContainsRequestId(requestId))
  40. Main.RemoveRequestId(requestId);
  41. transition = new Transition(this, TransitionType.Done);
  42. }
  43. }
  44. }
  45. }
  46. protected override void Timeout(ref Transition transition)
  47. {
  48. transition = new Transition(this, TransitionType.Timeout);
  49. }
  50. protected override int TimeoutInterval =>
  51. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_ShowTrxListFueling, 10);
  52. }
  53. }