From a419289c914e59d674c149c4804888c69d8455c5 Mon Sep 17 00:00:00 2001 From: zxd Date: Sat, 11 Aug 2018 12:14:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=80=9A=E4=BF=A1=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=89=8D=E7=9A=84=E6=8F=90=E4=BA=A4=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=80=9F=E5=BA=A6=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs | 5 +++++ .../PlaneGcsSdk_Private_NET46.csproj | 4 ++++ PlaneGcsSdk_Shared/Communication/TcpConnection.cs | 1 + PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs | 6 +++++- PlaneGcsSdk_Shared/Copters/Mission.cs | 8 ++++++++ PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems | 1 + 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs b/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs index f6f5887..f7689bf 100644 --- a/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs +++ b/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs @@ -35,6 +35,11 @@ /// TakeOff = 22, + /// + /// 命令飞行器改变速度 + /// + ChangeSpeed = 178, + /// /// 命令LED颜色改变 /// diff --git a/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj b/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj index 4625ca5..0569a3e 100644 --- a/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj +++ b/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj @@ -57,6 +57,10 @@ + + {413C18E2-235F-4E15-B5C1-633657DE5D7A} + Plane.Windows.Messages + {47141894-ece3-48ca-8dcf-ca751bda231e} PlaneGcsSdk.Contract_Private diff --git a/PlaneGcsSdk_Shared/Communication/TcpConnection.cs b/PlaneGcsSdk_Shared/Communication/TcpConnection.cs index 1879629..58c086f 100644 --- a/PlaneGcsSdk_Shared/Communication/TcpConnection.cs +++ b/PlaneGcsSdk_Shared/Communication/TcpConnection.cs @@ -44,6 +44,7 @@ namespace Plane.Communication } _isBroken = false; } + _stream = _client.GetStream(); } diff --git a/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs b/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs index 208443a..c1e7231 100644 --- a/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs +++ b/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs @@ -24,7 +24,10 @@ namespace Plane.Communication { try { - return _client.Available; + if (_client.Connected) + return _client.Available; + else + return 0; } catch (ObjectDisposedException ex) { @@ -89,6 +92,7 @@ namespace Plane.Communication { while (Available < count) { + if (!IsOpen) return 0; await Task.Delay(5).ConfigureAwait(false); } return await _stream.ReadAsync(buffer, offset, count); diff --git a/PlaneGcsSdk_Shared/Copters/Mission.cs b/PlaneGcsSdk_Shared/Copters/Mission.cs index da36bb8..5d5a8f8 100644 --- a/PlaneGcsSdk_Shared/Copters/Mission.cs +++ b/PlaneGcsSdk_Shared/Copters/Mission.cs @@ -198,5 +198,13 @@ namespace Plane.Copters G = green, //Green B = blue //Blue }; + + public static IMission CreateChangeSpeedMission(float levelSpeed, float upSpeed, float downSpeed) => new Mission + { + Command = FlightCommand.ChangeSpeed, + Param1 = levelSpeed, //水平速度 + Param2 = upSpeed, //上升速度 + Param3 = downSpeed, //下降速度 + }; } } diff --git a/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems b/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems index c18897f..eb29cd0 100644 --- a/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems +++ b/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems @@ -10,6 +10,7 @@ +