SendTrxListPendingFueling.cs 3.5 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
  9. {
  10. public class ShowTrxListPendingFueling : 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. Main.NewEpsTrx.UpdateTrxStatusToDb(EpsTrxStatus.BeforeFueling);
  17. //Main.CurrentEpsTrx.UpdateTrxStatusToDb(EpsTrxStatus.BeforeFueling);
  18. if (!Main.HasBigSreen())
  19. {
  20. Main.DebugLogger.Add("No screen configured");
  21. transition = new Transition(this, TransitionType.Done);
  22. return;
  23. }
  24. var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  25. Main.GetAllNozzlesOnThisSide(),
  26. ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
  27. Main.DebugLogger);
  28. Main.ActiveTrx = validTrx;
  29. //Main.NewEpsTrx.Model.AvailableNozzleGrade = Main.GetAvailableNozzleInfo();
  30. var nozzleIdGradeNameDic = Main.GetAvailableNozzleInfo();
  31. if (nozzleIdGradeNameDic != null)
  32. {
  33. foreach (var trx in validTrx)
  34. {
  35. if (trx.trx_status == EpsTrxStatus.BeforeFueling || trx.trx_status == EpsTrxStatus.Fueling)
  36. {
  37. trx.AvailableNozzleGrade = nozzleIdGradeNameDic;
  38. }
  39. }
  40. }
  41. var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 0);
  42. if (Main.Eps.CarPlateHandler != null)
  43. {
  44. DebugLog(text);
  45. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  46. Main.DebugLogger.Add("request Id: " + requestId);
  47. if (!Main.ContainsRequestId(requestId))
  48. {
  49. Main.AddRequestId(requestId);
  50. }
  51. }
  52. }
  53. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  54. {
  55. if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived))
  56. {
  57. var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
  58. if (e != null && e.EventArgs != null)
  59. {
  60. Main.DebugLogger.Add("request Id: " + requestId + " incoming event request Id:" + e.EventArgs.DispResponse.RequestId);
  61. if (requestId == e.EventArgs.DispResponse.RequestId)
  62. {
  63. e.Handled = true;
  64. if (Main.ContainsRequestId(requestId))
  65. Main.RemoveRequestId(requestId);
  66. transition = new Transition(this, TransitionType.Done);
  67. }
  68. }
  69. }
  70. else if (stateEngineEvent.Type.Equals(EventType.NozzleLifted))
  71. {
  72. transition = new Transition(this, TransitionType.Done);
  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_ShowTrxListPendingFueling, 60);
  81. }
  82. }