ClientData.cs 3.4 KB

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