|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace NearCardAttendance.Service.TcpServer.Protocol
- {
- public class ProtocolWrapper
- {
- private string Length { get; }
-
- private string FuncNo { get; }
- private string SeqNo { get; }
-
- private string Data { get; }
-
-
- public ProtocolWrapper(string funcNo,string seqNo,string data)
- {
-
- FuncNo =funcNo;
- SeqNo=seqNo;
- Data=data;
- Length = CalculateMessageLength();
- }
-
- private string CalculateMessageLength()
- {
- return string.Format("{0:D4}", GenerateProtocolString().Length + 4);
- }
-
- public string GenerateProtocolString()
- {
- return $"{Length}{FuncNo}{SeqNo}{Data}";
- }
- }
-
- }
|