RTK加入停止发送和提示

This commit is contained in:
pxzleo 2017-08-04 22:29:20 +08:00
parent d81d8f30ea
commit 86856b6e42
2 changed files with 70 additions and 24 deletions

View File

@ -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,6 +220,10 @@ namespace Plane.FormationCreator.ViewModels
{
return _SendRTKCommand ?? (_SendRTKCommand = new RelayCommand(async () =>
{
if (!trkthreadrun)
{
Rtkport = new SerialPortConnection(RTKcomvalue, 57600) as IConnection;
await Rtkport.OpenAsync();
if (!Rtkport.IsOpen)
@ -221,6 +241,10 @@ namespace Plane.FormationCreator.ViewModels
thrtk.Start();
*/
//后台任务方式运行rtk转发任务
Alert.Show("RTK数据开始发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
RTKState = "RTK数据发送中";
RTKbtntxt = "停止RTK";
await Task.Run(async () =>
{
//读取RTK数据循环
@ -239,6 +263,23 @@ namespace Plane.FormationCreator.ViewModels
}
}).ConfigureAwait(false);
Alert.Show("RTK数据停止发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
else//停止RTK
{
trkthreadrun = false;
Rtkport.Close();
Rtkport = null;
RTKState = "未发送RTK数据";
RTKbtntxt = "发送RTK";
}
/*

View File

@ -67,8 +67,13 @@
HorizontalContentAlignment="Right"
Text="{Binding RTKcomvalue, UpdateSourceTrigger=PropertyChanged}"
/>
<Button Content="发送RTK"
<Button Content="{Binding Path=RTKbtntxt}"
Command="{Binding SendRTKCommand}" />
<TextBlock
Margin="5,5,5,5"
Text="{Binding Path=RTKState}"
/>
</WrapPanel>