ClientData.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. 
  2. using EVCB_OCPP.Packet.Messages.Basic;
  3. using EVCB_OCPP.WSServer.Dto;
  4. using SuperSocket.SocketBase;
  5. using SuperWebSocket;
  6. using System;
  7. using System.Collections.Generic;
  8. namespace OCPPServer.Protocol
  9. {
  10. public class ClientData : WebSocketSession<ClientData>
  11. { /// <summary>
  12. /// 根據unique id來儲存.取出OCPP Request
  13. /// </summary>
  14. public Queue queue = new Queue();
  15. public EVCB_OCPP20.Packet.Messages.Basic.Queue queue20 = new EVCB_OCPP20.Packet.Messages.Basic.Queue();
  16. public bool IsPending { set; get; }
  17. public bool IsCheckIn { set; get; }
  18. public string ChargeBoxId { set; get; }
  19. public Guid CustomerId { get; set; }
  20. public string MachineId { set; get; }
  21. public bool ISOCPP20 { set; get; }
  22. public bool ResetSecurityProfile { set; get; }
  23. public List<ChargingPrice> ChargingPrices { set; get; }
  24. /// <summary>
  25. /// 電樁顯示費率
  26. /// </summary>
  27. public string DisplayPrice { set; get; }
  28. /// <summary>
  29. /// 以小時計費
  30. /// </summary>
  31. public decimal HRPrice { set; get; }
  32. /// <summary>
  33. /// 電樁是否計費
  34. /// </summary>
  35. public bool IsBilling { set; get; }
  36. /// <summary>
  37. /// 1:以度數計費 2:以小時計費
  38. /// </summary>
  39. public int? BillingMethod { set; get; }
  40. public string CustomerName { get; set; }
  41. /// <summary>
  42. /// 電樁適用幣別
  43. /// </summary>
  44. public string Currency { get; internal set; }
  45. public delegate void OCPPClientDataEventHandler<ClientData, String>(ClientData clientdata, String msg);
  46. public event OCPPClientDataEventHandler<ClientData, String> m_ReceiveData;
  47. public ClientData()
  48. {
  49. IsPending = false;
  50. IsCheckIn = false;
  51. ChargeBoxId = SessionID;
  52. MachineId = SessionID;
  53. }
  54. /// <summary>
  55. /// Sends the raw binary data to client.
  56. /// </summary>
  57. /// <param name="data">The data.</param>
  58. /// <param name="offset">The offset.</param>
  59. /// <param name="length">The length.</param>
  60. public void SendRawData(byte[] data, int offset, int length)
  61. {
  62. base.Send(data, offset, length);
  63. }
  64. //receive data event trigger
  65. public void ReceiveData(ClientData clientdata, string msg)
  66. {
  67. if (m_ReceiveData != null)
  68. m_ReceiveData(clientdata, msg);
  69. }
  70. /// <summary>
  71. /// Called when [session closed].
  72. /// </summary>
  73. /// <param name="reason">The reason.</param>
  74. protected override void OnSessionClosed(CloseReason reason)
  75. {
  76. }
  77. }
  78. }