diff --git a/Plane.FormationCreator/Formation/RtcmManager.cs b/Plane.FormationCreator/Formation/RtcmManager.cs index d2a3ff2..c66f8dd 100644 --- a/Plane.FormationCreator/Formation/RtcmManager.cs +++ b/Plane.FormationCreator/Formation/RtcmManager.cs @@ -101,33 +101,13 @@ namespace Plane.FormationCreator.Formation return typename; } - private void SetRTKStatestr() - { - string rtksstr= ""; - // ResendToCom - if (Rtcmthreadrun) - { - rtksstr = "RTK发送中 "; - - if (SmallRtcmData) - rtksstr += ",低带宽模式 "; - if (ResendToCom) - rtksstr += ",双通道发送 "; - rtksstr += "..."; - } - else - rtksstr = "RTK未发送"; - - ControlPanelVM.RTKState = rtksstr; - - } - public bool Rtcmthreadrun { get { return _rtcmthreadrun; } set { Set(nameof(Rtcmthreadrun), ref _rtcmthreadrun, value); - SetRTKStatestr(); + var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance(); + _RtcmInfoViewModel.SetRTKStatestr(); } } @@ -137,7 +117,8 @@ namespace Plane.FormationCreator.Formation set { Set(nameof(SmallRtcmData), ref _smallrtcmdata, value); - SetRTKStatestr(); + var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance(); + _RtcmInfoViewModel.SetRTKStatestr(); } } @@ -234,7 +215,8 @@ namespace Plane.FormationCreator.Formation get { return _sesendtocom; } set { Set(nameof(ResendToCom), ref _sesendtocom, value); - SetRTKStatestr(); + var _RtcmInfoViewModel = ServiceLocator.Current.GetInstance(); + _RtcmInfoViewModel.SetRTKStatestr(); } } diff --git a/Plane.FormationCreator/ViewModels/ConnectViewModel.cs b/Plane.FormationCreator/ViewModels/ConnectViewModel.cs index 961c927..e570af4 100644 --- a/Plane.FormationCreator/ViewModels/ConnectViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ConnectViewModel.cs @@ -114,26 +114,28 @@ namespace Plane.FormationCreator.ViewModels { if (_commModuleManager.Recomisopen) { - //当前是否使用了广播端口 - if (_rtcmInfoViewModel.ResendToComMK) + //关闭广播端口 + //正在发送rtcm数据并且使用了广播端口 + if (_rtcmInfoViewModel.RtcmManager.Rtcmthreadrun&& _rtcmInfoViewModel.ResendToComMK) { - if (Alert.Show("将同时关闭双通道发送RTK数据,继续吗?", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning) + if (Alert.Show("正在使用广播端口发送RTCM数据,关闭后广播端口将停止发送,继续吗?", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) { - _rtcmInfoViewModel.ResendToComMK = false; + // _rtcmInfoViewModel.ResendToComMK = false; } else { return; } } - _commModuleManager.CloseResendRtcmserial(); + //关闭同时清除广播端口,这样就不会重试打开 + _commModuleManager.CloseResendRtcmserial(true); btnBoardPortStr = "打开广播端口"; BoardPortStatusStr = _commModuleManager.BoardPortStatusStr; Message.BoardOpen(false); } else - { + { //打开广播端口 if ((SerialPortResend != null)) { @@ -155,6 +157,7 @@ namespace Plane.FormationCreator.ViewModels return; } } + _rtcmInfoViewModel.SetRTKStatestr(); } )); } @@ -231,7 +234,7 @@ namespace Plane.FormationCreator.ViewModels set { Set(nameof(CopterColor), ref _CopterColor, value); } } - private string _BoardPortStatusStr = "端口未打开"; + private string _BoardPortStatusStr = "广播端口未打开"; public string BoardPortStatusStr { get { return _BoardPortStatusStr; } diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs index 7b5d56d..48e0849 100644 --- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs @@ -409,6 +409,14 @@ namespace Plane.FormationCreator.ViewModels })); } } + /// + /// 紧急返航:计算当前图案中心点,起飞图案中心点,图案距离起飞图案中心点最近距离 + /// 条件:任务已经开始,且飞行器已经飞行 + /// 可用于模拟和实际飞行, + /// 1首先需要导入最后的飞行任务文件, + /// 2实际飞机需要执行解锁和开始任务 + /// 3模拟任务需要开始任务并且暂停任务才能计算 + /// private ICommand _EmergencyRetCommand; public ICommand EmergencyRetCommand { @@ -427,7 +435,7 @@ namespace Plane.FormationCreator.ViewModels if ((_flightTaskManager.TaskState_real == TasksStatus.Stop) &&((_flightTaskManager.IsPaused ?? false) == false)) { - Alert.Show("先暂停任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); + Alert.Show("没有开始真实任务,模拟紧急返航需要先暂停模拟任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } //if (Alert.Show("您确定要紧急返航吗?紧急返航可能导致飞行器碰撞!!!!", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning) diff --git a/Plane.FormationCreator/ViewModels/RtcmInfoViewModel.cs b/Plane.FormationCreator/ViewModels/RtcmInfoViewModel.cs index 1334c81..e66f11d 100644 --- a/Plane.FormationCreator/ViewModels/RtcmInfoViewModel.cs +++ b/Plane.FormationCreator/ViewModels/RtcmInfoViewModel.cs @@ -1,5 +1,6 @@ using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; +using Microsoft.Practices.ServiceLocation; using Plane.CommunicationManagement; using Plane.FormationCreator.Formation; using Plane.Windows.Messages; @@ -31,7 +32,27 @@ namespace Plane.FormationCreator.ViewModels return _commModuleManager.BoardPortStatusStr; } } + private ControlPanelViewModel ControlPanelVM = ServiceLocator.Current.GetInstance(); + public void SetRTKStatestr() + { + string rtksstr = ""; + // ResendToCom + if (_rtcmManager.Rtcmthreadrun) + { + rtksstr = "RTK发送中 "; + if (_rtcmManager.SmallRtcmData) + rtksstr += ",低带宽模式 "; + if (_rtcmManager.ResendToCom && _commModuleManager.Recomisopen) + rtksstr += ",双通道模式 "; + rtksstr += "..."; + } + else + rtksstr = "RTK未发送"; + + ControlPanelVM.RTKState = rtksstr; + + } private string _serialPortsSelectdValue; @@ -56,7 +77,7 @@ namespace Plane.FormationCreator.ViewModels } } - private bool _resendtocommk; + private bool _resendtocommk=true; public bool ResendToComMK { get { return _resendtocommk; } @@ -67,8 +88,7 @@ namespace Plane.FormationCreator.ViewModels { //发送 if (!_commModuleManager.Recomisopen) { - Alert.Show($"请在设置里面打开广播端口", "提示", MessageBoxButton.OK, MessageBoxImage.Information); - return; + Alert.Show($"请先在设置里面打开广播端口,否则无法发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } } diff --git a/Plane.FormationCreator/Views/ConnectWindow.xaml b/Plane.FormationCreator/Views/ConnectWindow.xaml index 5f60a4b..81c3715 100644 --- a/Plane.FormationCreator/Views/ConnectWindow.xaml +++ b/Plane.FormationCreator/Views/ConnectWindow.xaml @@ -70,7 +70,7 @@ ItemsSource="{Binding serialRePorts, Mode=OneWay}" SelectedValue="{Binding SerialPortResend}" DropDownOpened="ComboBox_DropDownOpened"/> - + diff --git a/Plane.FormationCreator/Views/RtcmInfoView.xaml b/Plane.FormationCreator/Views/RtcmInfoView.xaml index b9b2928..3233c63 100644 --- a/Plane.FormationCreator/Views/RtcmInfoView.xaml +++ b/Plane.FormationCreator/Views/RtcmInfoView.xaml @@ -26,15 +26,20 @@