WaitForFueling.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Wayne.Lib;
  5. using Wayne.Lib.StateEngine;
  6. using Wayne.Lib.StateEngine.Generic;
  7. namespace SinochemInternetPlusApp.States.CarPlateManualMode
  8. {
  9. public class WaitForFueling : TimeoutState<FuelingPoint>
  10. {
  11. private byte sqNo;
  12. private bool cardReaderBackToIdle = false;
  13. private bool nozzleLifted = false;
  14. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  15. {
  16. base.Enter(stateEntry, ref transition);
  17. //cardReaderBackToIdle = false;
  18. nozzleLifted = false;
  19. //Main.SetICCardReaderToCarPlateIdle(out sqNo);
  20. DebugLog($"Start to set card reader back to CarPlateIdle, SqNo={sqNo}\n Waiting for Ack");
  21. }
  22. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  23. {
  24. //GenericEvent<CardReaderAckEventArgs> ackEvent = stateEngineEvent as GenericEvent<CardReaderAckEventArgs>;
  25. //if (ackEvent != null && ackEvent.EventArgs != null)
  26. //{
  27. // if (ackEvent.EventArgs.Ack.MessageSeqNumber == sqNo)
  28. // {
  29. // DebugLog($" Set CardReader to CarPlateIdle ack'ed, SqNo={sqNo}\n");
  30. // ackEvent.Handled = true;
  31. // cardReaderBackToIdle = true;
  32. // }
  33. //}
  34. //if (stateEngineEvent.Type.Equals(EventType.TrxOpRequest))
  35. //{
  36. // GenericEvent<TransactionOperationEventArgs> trxOpEvent = stateEngineEvent as GenericEvent<TransactionOperationEventArgs>;
  37. // if (trxOpEvent != null && trxOpEvent.EventArgs != null && Main.ActiveTrx != null)
  38. // {
  39. // trxOpEvent.Handled = true;
  40. // if (trxOpEvent.EventArgs.TrxOp.OpType == OpType.Delete)
  41. // {
  42. // int trxId = trxOpEvent.EventArgs.TrxOp.TrxId;
  43. // foreach (var trx in Main.ActiveTrx)
  44. // {
  45. // if ((trx.id == trxId) && (Main.AssociatedNozzles.Contains(trx.jihao)))
  46. // {
  47. // EpsTransaction.RestroeEpsTrxFrom(trx).UpdateTrxStatusToDb(EpsTrxStatus.Removed);
  48. // Main.CurrentEpsTrx = null;
  49. // transition = new Transition(this, TransitionType.FuelingRemoved);
  50. // }
  51. // }
  52. // }
  53. // }
  54. //}
  55. if (nozzleLifted) //&& cardReaderBackToIdle)
  56. {
  57. transition = new Transition(this, TransitionType.NozzleLifted);
  58. }
  59. }
  60. protected override void Timeout(ref Transition transition)
  61. {
  62. transition = new Transition(this, TransitionType.Timeout);
  63. }
  64. protected override int TimeoutInterval =>
  65. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.Shared_WaitForFueling, 30 * 60);
  66. }
  67. }