public async Task Start(UGV ugv) { Device = ugv; Device.Light("Open", 0); await Task.Delay(10000); Device.Light("Close", 0); }
/// <summary> /// 接收服务器消息并处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NetClient_OnBufferReceived(object sender, ESocketModule.BufferSendManage.Delegates.BufferReceivedEventArgs e) { switch (e.Buffer.BufferName) { case "Move": int speed = Convert.ToInt32(e.Buffer.UserParameters["Speed"]); Device?.Move(e.Buffer.UserParameters["Direction"], speed); break; case "Light": int id = Convert.ToInt32(e.Buffer.UserParameters["ID"]); Device?.Light(e.Buffer.UserParameters["State"], id); break; case "Servo": int angle = Convert.ToInt32(e.Buffer.UserParameters["Angle"]); Device?.Steering(angle); break; case "Sensor": var para = Device?.GetSensorInfo(e.Buffer.UserParameters["Type"]); para.Add("Type", e.Buffer.UserParameters["Type"]); NetClient.SendBuffer(null, e.Buffer.BufferName, para, ESocketModule.BufferSendManage.Buffer.SendPriority.Normal); break; } }