You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.4 KiB
105 lines
2.4 KiB
|
4 weeks ago
|
using EGFramework;
|
||
|
|
using Newtonsoft.Json;
|
||
|
|
|
||
|
|
//通讯协议类定义
|
||
|
|
public class ResponseControl : IResponse
|
||
|
|
{
|
||
|
|
public int FunctionCode { set; get; }
|
||
|
|
public int Position { set; get; }
|
||
|
|
public bool TrySetData(string protocolData, byte[] protocolBytes)
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
if (!protocolData.StartsWith('{') && !protocolData.StartsWith('['))
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
ResponseControl data = JsonConvert.DeserializeObject<ResponseControl>(protocolData);
|
||
|
|
if (data != null && data.FunctionCode != 0)
|
||
|
|
{
|
||
|
|
this.FunctionCode = data.FunctionCode;
|
||
|
|
this.Position = data.Position;
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (System.Exception)
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
// throw;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//数据返回
|
||
|
|
public class RequestControl : IRequest
|
||
|
|
{
|
||
|
|
public int TargetID { set; get; }
|
||
|
|
public int FunctionCode { set; get; }
|
||
|
|
public bool ExecuteSuccess { set; get; }
|
||
|
|
public int ErrorCode { set; get; }
|
||
|
|
public byte[] ToProtocolByteData()
|
||
|
|
{
|
||
|
|
// throw new NotImplementedException();
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public string ToProtocolData()
|
||
|
|
{
|
||
|
|
return JsonConvert.SerializeObject(this);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//状态查询
|
||
|
|
public class RequestControlStatus : IRequest
|
||
|
|
{
|
||
|
|
public int TargetID { set; get; }
|
||
|
|
public int FunctionCode { set; get; }
|
||
|
|
public bool IsStart { set; get; }
|
||
|
|
public int Position { set; get; }
|
||
|
|
public byte[] ToProtocolByteData()
|
||
|
|
{
|
||
|
|
// throw new NotImplementedException();
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public string ToProtocolData()
|
||
|
|
{
|
||
|
|
return JsonConvert.SerializeObject(this);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//移动状态反馈
|
||
|
|
public class RequestControlMoveStatus : IRequest
|
||
|
|
{
|
||
|
|
public int TargetID { set; get; }
|
||
|
|
public int FunctionCode { set; get; }
|
||
|
|
public int Position { set; get; }
|
||
|
|
public StatusTrack Status { set; get; }
|
||
|
|
|
||
|
|
public byte[] ToProtocolByteData()
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
public string ToProtocolData()
|
||
|
|
{
|
||
|
|
return JsonConvert.SerializeObject(this);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum TypeControlFunction
|
||
|
|
{
|
||
|
|
StartShooting = 201,
|
||
|
|
StopShooting = 200,
|
||
|
|
Status = 100,
|
||
|
|
TargetMessage = 300,
|
||
|
|
TrackMessage = 301,
|
||
|
|
OtherMessage = 302,
|
||
|
|
TrackMove = 401,
|
||
|
|
TrackStop = 400,
|
||
|
|
TrackError = 404
|
||
|
|
}
|