diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs
index 7a4c4f5..645fc34 100644
--- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs
+++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs
@@ -45,6 +45,22 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(AltP), ref _AltP, value); }
}
+
+ private string _RTKState = "RTK未发送";
+ public string RTKState
+ {
+ get { return _RTKState; }
+ set { Set(nameof(RTKState), ref _RTKState, value); }
+ }
+
+ private string _RTKbtntxt = "发送RTK";
+ public string RTKbtntxt
+ {
+ get { return _RTKbtntxt; }
+ set { Set(nameof(RTKbtntxt), ref _RTKbtntxt, value); }
+ }
+
+
private ICommand _UnlockCommand;
public ICommand UnlockCommand
{
@@ -204,28 +220,36 @@ namespace Plane.FormationCreator.ViewModels
{
return _SendRTKCommand ?? (_SendRTKCommand = new RelayCommand(async () =>
{
- Rtkport = new SerialPortConnection(RTKcomvalue,57600) as IConnection;
- await Rtkport.OpenAsync();
- if (!Rtkport.IsOpen)
+ if (!trkthreadrun)
{
- Alert.Show("无法打开" + RTKcomvalue , "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
- return;
- }
- trkthreadrun = true; //开始运行后台任务
- /* //线程方式后台运行rtk转发任务
- thrtk = new System.Threading.Thread(new System.Threading.ThreadStart(mainloop))
- {
- IsBackground = true,
- Name = "injectgps"
- };
- thrtk.Start();
- */
- //后台任务方式运行rtk转发任务
- await Task.Run(async () =>
+
+
+ Rtkport = new SerialPortConnection(RTKcomvalue, 57600) as IConnection;
+ await Rtkport.OpenAsync();
+ if (!Rtkport.IsOpen)
{
- //读取RTK数据循环
- while (trkthreadrun)
+ Alert.Show("无法打开" + RTKcomvalue, "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ trkthreadrun = true; //开始运行后台任务
+ /* //线程方式后台运行rtk转发任务
+ thrtk = new System.Threading.Thread(new System.Threading.ThreadStart(mainloop))
+ {
+ IsBackground = true,
+ Name = "injectgps"
+ };
+ thrtk.Start();
+ */
+ //后台任务方式运行rtk转发任务
+ Alert.Show("RTK数据开始发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+ RTKState = "RTK数据发送中";
+ RTKbtntxt = "停止RTK";
+
+ await Task.Run(async () =>
{
+ //读取RTK数据循环
+ while (trkthreadrun)
+ {
//读入RTK数据
var packet = await ReadRTKPacketAsync().ConfigureAwait(false);
//分发到每个飞机
@@ -235,10 +259,27 @@ namespace Plane.FormationCreator.ViewModels
}
- await Task.Delay(200).ConfigureAwait(false);
+ await Task.Delay(200).ConfigureAwait(false);
+
+ }
+ }).ConfigureAwait(false);
+ Alert.Show("RTK数据停止发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+
+ }
+ else//停止RTK
+ {
+ trkthreadrun = false;
+ Rtkport.Close();
+ Rtkport = null;
+
+ RTKState = "未发送RTK数据";
+ RTKbtntxt = "发送RTK";
+
+
+
+
+ }
- }
- }).ConfigureAwait(false);
/*
diff --git a/Plane.FormationCreator/Views/ControlPanelView.xaml b/Plane.FormationCreator/Views/ControlPanelView.xaml
index 705cc08..cf615ef 100644
--- a/Plane.FormationCreator/Views/ControlPanelView.xaml
+++ b/Plane.FormationCreator/Views/ControlPanelView.xaml
@@ -67,9 +67,14 @@
HorizontalContentAlignment="Right"
Text="{Binding RTKcomvalue, UpdateSourceTrigger=PropertyChanged}"
/>
-
-
+
+