CalculateMAC.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using SinochemCarplateService.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using Wayne.Lib;
  5. using Wayne.Lib.StateEngine;
  6. using Wayne.Lib.StateEngine.Generic;
  7. namespace SinochemInternetPlusApp.States.CarPlateMode
  8. {
  9. class CalculateMAC : TimeoutState<FuelingPoint>
  10. {
  11. private byte sqNo;
  12. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  13. {
  14. base.Enter(stateEntry, ref transition);
  15. transition = new Transition(this, TransitionType.Done);
  16. return;
  17. DebugLog("Start to calculate MAC");
  18. //Main.GetMAC(new CarPlateTrxRequest()
  19. //{
  20. // amount = 10.00,
  21. // card_No = "08888118001000078417",
  22. // car_Number = "晋A12345",
  23. // gun = "2",
  24. //}, out sqNo);
  25. }
  26. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  27. {
  28. if (stateEngineEvent.Type.Equals(EventType.DataSigned))
  29. {
  30. GenericEvent<SignedDataEventArgs> signDataEvent = stateEngineEvent as GenericEvent<SignedDataEventArgs>;
  31. if (signDataEvent != null && signDataEvent.EventArgs != null)
  32. {
  33. signDataEvent.Handled = true;
  34. DebugLog($" Signed Data arrived\n Mac Value: {signDataEvent.EventArgs.SignedDataResponse.MacValue}\n"); ;
  35. transition = new Transition(this, TransitionType.Done);
  36. }
  37. }
  38. //if (stateEngineEvent.Type is EventType)
  39. //{
  40. // switch ((EventType)stateEngineEvent.Type)
  41. // {
  42. // case EventType.ICCardReaderMACResponse:
  43. // transition = new Transition(this, TransitionType.ICCardReaderMACResponse);
  44. // stateEngineEvent.Handled = true;
  45. // break;
  46. // }
  47. //}
  48. }
  49. protected override void Timeout(ref Transition transition)
  50. {
  51. transition = new Transition(this, TransitionType.Timeout);
  52. }
  53. protected override int TimeoutInterval =>
  54. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_CalculateMAC, 10);
  55. }
  56. }