12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Rdh.SocketServer.Client.Models
- {
- public class LocationRequestProtocol : EleMedKitProtocol
- {
- public LocationRequestProtocol()
- {
- base.Command = EleMedKitCommand.RequestLocation;
- MinLines = base.MinLines + 1;
- }
- /// <summary>
- /// 获取或设置基站编号
- /// </summary>
- public string? StationCode { get; set; }
- /// <summary>
- /// 获取或设置药箱到基站的距离(厘米)
- /// </summary>
- public float? Distance { get; set; }
- public override string GetContent()
- {
- return base.GetContent()
- + AddLineContent(StationCode + AddBlockContent(Distance.ToString()))
- + AddLineContent(CountFlag);
- }
- public override bool ParseContent(string[] lines)
- {
- if (!base.ParseContent(lines)
- || lines.Length < MinLines)
- {
- return false;
- }
- string[] stationInfo = EleMedKitProtocolHelper.GetContentBlocks(lines[2]);
- if (stationInfo == null || stationInfo.Length < 2)
- {
- return false;
- }
- StationCode = stationInfo[0];
- float tempDistance;
- float.TryParse(stationInfo[1], out tempDistance);
- Distance = tempDistance;
- return true;
- }
- }
- }
|