using Message;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Communication
{
class GroundDIsplayCommuncator : Communication.Communicator
{
protected GroundDIsplayCommuncator():base()
{
}
///
/// 单例访问
///
public new static Communicator GetInstance()
{
if (instance == null)
{
lock (lockObj)
{
if (instance == null)
{
instance = new GroundDIsplayCommuncator();
}
}
}
return instance;
}
///
/// 检查消息
///
///
///
public override bool CheckMsg(Base_info header)
{
if (header.HasMsgType && header.HasSender && header.HasTimeoutMs
&& header.MsgType == Message_type.EGroundStatusMsg && header.Sender == Message.Communicator.EGroundMeasurer)
return true;
else
return false;
}
///
/// 检查执行器状态
///
///
///
///
public override CheckExecuterReturn CheckExecuter(Base_info header, DateTime receiveTime)
{
if ((DateTime.Now - receiveTime).Milliseconds > header.TimeoutMs)
return CheckExecuterReturn.MSG_TIMEOUT;
else
return CheckExecuterReturn.EXECUTER_READY;
}
///
/// 执行消息
///
///
///
public override bool ExecuteMsg(MsgStamped msgStamped)
{
Ground_status_msg msg = Ground_status_msg.Parser.ParseFrom(msgStamped.msg);
Console.WriteLine(Ground_status_msg.Parser.ParseJson(msg.ToString()));
return true;
}
}
}