123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using OCPPServer.Protocol;
- using Packet.Cmd;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OCPPServer
- {
- public class ClientData
- {
- public byte[] _buffer = new byte[1024];
- public List<byte> bufferList = new List<byte>();
- public OCPPSession ClientSocket;
- public CmdHelper CmdHelper;
- public bool IsCheckIn { get; set; }
- public DateTime LastAccessDatetime { get; set; }
- /// <summary>
- /// 每個client有他自己的指令序號 2 byte
- /// </summary>
- private ushort _cmdSerNum = 0;
- /// <summary>
- /// 傳送的封包序號 1 byte
- /// </summary>
- private byte _serNum = 0;
- public string MachineId { get; set; }
- public Guid CustomerId { get; set; }
- public string CustomerName { get; set; }
- /// <summary>
- /// 客戶自訂的樁id
- /// </summary>
- public string MachineCustomId
- {
- get; set;
- }
- /// <summary>
- /// Accepted:0, Pending:1, Rejected:2
- /// </summary>
- public bool RegistrationStatus { get; set; }
- /// <summary>
- /// 0: 会员、1: 卡号、2:不识别
- /// </summary>
- public byte StartWith { get; set; }
- /// <summary>
- /// 充電/預約卡號、 36 bytes assic碼、不夠長度補'\0'
- /// </summary>
- public string ReservationCardNum { get; set; }
- /// <summary>
- /// Remote充電
- /// </summary>
- public bool RemoteCharging { get; set; }
- public ClientData()
- {
- MachineCustomId = Guid.NewGuid().ToString();
- IsCheckIn = false;
- RegistrationStatus = false;
- StartWith = 2; /// 0: 会员、1: 卡号、2:不识别
- ReservationCardNum = "";
- RemoteCharging = false; /// Remote充電
- LastAccessDatetime = DateTime.Now;
- }
- public ClientData(OCPPSession clientSocket)
- {
- this.ClientSocket = clientSocket;
- MachineCustomId = Guid.NewGuid().ToString();
- RemoteCharging = false; /// Remote充電
- LastAccessDatetime = DateTime.Now;
- }
- /// <summary>
- /// 取得指令序號 0-65535
- /// </summary>
- /// <returns></returns>
- public ushort GetCmdSerNum()
- {
- if (_cmdSerNum == ushort.MaxValue)
- _cmdSerNum = 0;
- return ++_cmdSerNum;
- }
- /// <summary>
- /// 取得封包序號 1-255
- /// </summary>
- /// <returns></returns>
- public byte GetSerNum()
- {
- if (_serNum == byte.MaxValue)
- {
- _serNum = 0;
- }
- return ++_serNum;
- }
- public bool CheckClient()
- {
- return false;
- }
- }
- }
|