ShowTrxListFillingPaid.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.Shared
  9. {
  10. public class ShowTrxListFillingPaid : 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. //Don't need send rquest to BigScreen
  17. if (!Main.HasBigSreen())
  18. {
  19. transition = new Transition(this, TransitionType.Done);
  20. return;
  21. }
  22. if (Main.CurrentEpsTrx != null)
  23. {
  24. var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  25. Main.GetAllNozzlesOnThisSide(),
  26. ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
  27. Main.DebugLogger);
  28. if (Main.Eps.NozzleMappingGradeName() != null)
  29. {
  30. foreach (var trx in validTrx)
  31. {
  32. if (trx.trx_status == EpsTrxStatus.BeforeFueling || trx.trx_status == EpsTrxStatus.Fueling)
  33. {
  34. trx.AvailableNozzleGrade = Main.GetAvailableNozzleInfo();
  35. }
  36. }
  37. }
  38. var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 3);
  39. if (Main.Eps.CarPlateHandler != null)
  40. {
  41. DebugLog(text);
  42. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  43. if (!Main.ContainsRequestId(requestId))
  44. Main.AddRequestId(requestId);
  45. }
  46. else
  47. transition = new Transition(this, TransitionType.Done);
  48. }
  49. else
  50. transition = new Transition(this, TransitionType.Done);
  51. }
  52. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  53. {
  54. if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived))
  55. {
  56. var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
  57. if (e != null && e.EventArgs != null)
  58. {
  59. if (requestId == e.EventArgs.DispResponse.RequestId)
  60. {
  61. e.Handled = true;
  62. if (Main.ContainsRequestId(requestId))
  63. Main.RemoveRequestId(requestId);
  64. transition = new Transition(this, TransitionType.Done);
  65. }
  66. }
  67. }
  68. }
  69. protected override void Timeout(ref Transition transition)
  70. {
  71. transition = new Transition(this, TransitionType.Timeout);
  72. }
  73. protected override int TimeoutInterval =>
  74. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_SendTrxListFillingPaid, 10);
  75. }
  76. }