ShowTrxListFueling - Copy.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 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. if (Main.CurrentEpsTrx != null)
  17. {
  18. Main.DebugLogger.Add("Main.CurrentEpsTrx not null");
  19. var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  20. Main.GetAllNozzlesOnThisSide(),
  21. ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
  22. Main.DebugLogger);
  23. Main.ActiveTrx = validTrx;
  24. //Main.CurrentEpsTrx.Model.AvailableNozzleGrade = Main.GetAvailableNozzleInfo();
  25. var nozzleIdGradeNameDic = Main.Eps.NozzleMappingGradeName();
  26. if (nozzleIdGradeNameDic != null)
  27. {
  28. Main.DebugLogger.Add("nozzleIdGradeNameDic not null");
  29. foreach (var trx in validTrx)
  30. {
  31. if (trx.id == Main.CurrentEpsTrx.Model.id)
  32. {
  33. trx.nozzleSelected = Main.CurrentEpsTrx.Model.nozzleSelected;
  34. Main.DebugLogger.Add("trx.nozzleSelected set");
  35. }
  36. if (trx.trx_status == EpsTrxStatus.BeforeFueling || trx.trx_status == EpsTrxStatus.Fueling)
  37. {
  38. trx.AvailableNozzleGrade = nozzleIdGradeNameDic;
  39. Main.DebugLogger.Add("trx.AvailableNozzleGrade set");
  40. }
  41. }
  42. }
  43. var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 1);
  44. if (Main.Eps.CarPlateHandler != null)
  45. {
  46. Main.DebugLogger.Add("Abby" + text);
  47. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  48. if (!Main.ContainsRequestId(requestId))
  49. Main.AddRequestId(requestId);
  50. }
  51. }
  52. else
  53. {
  54. DebugLog("Unable to show the fueling transactions list");
  55. transition = new Transition(this, TransitionType.Done);
  56. }
  57. }
  58. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  59. {
  60. if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived))
  61. {
  62. var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
  63. if (e != null && e.EventArgs != null)
  64. {
  65. if (requestId == e.EventArgs.DispResponse.RequestId)
  66. {
  67. e.Handled = true;
  68. if (Main.ContainsRequestId(requestId))
  69. Main.RemoveRequestId(requestId);
  70. transition = new Transition(this, TransitionType.Done);
  71. }
  72. }
  73. }
  74. }
  75. protected override void Timeout(ref Transition transition)
  76. {
  77. transition = new Transition(this, TransitionType.Timeout);
  78. }
  79. protected override int TimeoutInterval =>
  80. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_ShowTrxListFueling, 10);
  81. }
  82. }