ClientData.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 bool IsAC { set; get; }
  24. #region Billing
  25. public List<ChargingPrice> ChargingPrices { set; get; }
  26. /// <summary>
  27. /// 電樁顯示費率
  28. /// </summary>
  29. public string DisplayPrice { set; get; }
  30. /// <summary>
  31. /// 充電費率 以小時計費
  32. /// </summary>
  33. public decimal ChargingFeebyHour { set; get; }
  34. /// <summary>
  35. /// 停車費率 以小時計費
  36. /// </summary>
  37. public decimal ParkingFee { set; get; }
  38. /// <summary>
  39. /// 電樁是否計費
  40. /// </summary>
  41. public bool IsBilling { set; get; }
  42. /// <summary>
  43. /// 收費方式 1: 以度計費 2:以小時計費
  44. /// </summary>
  45. public int BillingMethod { set; get; }
  46. /// <summary>
  47. /// 電樁適用幣別
  48. /// </summary>
  49. public string Currency { get; internal set; }
  50. #endregion
  51. public string CustomerName { get; set; }
  52. public string StationName { set; get; }
  53. public string StationLocation { set; get; }
  54. public delegate void OCPPClientDataEventHandler<ClientData, String>(ClientData clientdata, String msg);
  55. public event OCPPClientDataEventHandler<ClientData, String> m_ReceiveData;
  56. public ClientData()
  57. {
  58. IsAC = true;
  59. IsPending = false;
  60. IsCheckIn = false;
  61. ChargeBoxId = SessionID;
  62. MachineId = SessionID;
  63. }
  64. /// <summary>
  65. /// Sends the raw binary data to client.
  66. /// </summary>
  67. /// <param name="data">The data.</param>
  68. /// <param name="offset">The offset.</param>
  69. /// <param name="length">The length.</param>
  70. public void SendRawData(byte[] data, int offset, int length)
  71. {
  72. base.Send(data, offset, length);
  73. }
  74. //receive data event trigger
  75. public void ReceiveData(ClientData clientdata, string msg)
  76. {
  77. if (m_ReceiveData != null)
  78. m_ReceiveData(clientdata, msg);
  79. }
  80. /// <summary>
  81. /// Called when [session closed].
  82. /// </summary>
  83. /// <param name="reason">The reason.</param>
  84. protected override void OnSessionClosed(CloseReason reason)
  85. {
  86. }
  87. }
  88. }