按照MP新增RTK界面
This commit is contained in:
parent
b554a1f4ae
commit
dd8888efc2
@ -41,6 +41,12 @@
|
|||||||
<cnv:BooleanToResourceConverter x:Key="CheckSignConverter2"
|
<cnv:BooleanToResourceConverter x:Key="CheckSignConverter2"
|
||||||
FalseKey="CloseIcon"
|
FalseKey="CloseIcon"
|
||||||
TrueKey="CheckIcon" />
|
TrueKey="CheckIcon" />
|
||||||
|
<cnv:BooleanToStringConverter x:Key="ColorConverter"
|
||||||
|
False="Red"
|
||||||
|
True="Green" />
|
||||||
|
<cnv:BooleanToStringConverter x:Key="SendConverter"
|
||||||
|
False="发送"
|
||||||
|
True="关闭" />
|
||||||
<lcnv:HeartbeatCountToBrushConverter x:Key="HeartbeatCountToBrushConverter" />
|
<lcnv:HeartbeatCountToBrushConverter x:Key="HeartbeatCountToBrushConverter" />
|
||||||
<lcnv:AppModeToVisibilityConverter x:Key="AppModeToVisibilityConverter" />
|
<lcnv:AppModeToVisibilityConverter x:Key="AppModeToVisibilityConverter" />
|
||||||
<lcnv:FlightTaskStatusToFillConverter x:Key="FlightTaskStatusToFillConverter" />
|
<lcnv:FlightTaskStatusToFillConverter x:Key="FlightTaskStatusToFillConverter" />
|
||||||
|
@ -120,6 +120,8 @@ namespace Plane.FormationCreator
|
|||||||
|
|
||||||
MainWindow = new MainWindow();
|
MainWindow = new MainWindow();
|
||||||
MainWindow.Show();
|
MainWindow.Show();
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* by panxu tcp 不使用了 --使用TCP监听在自动获取IP的情况下,刚开始会导致界面无响应,过一会就好
|
/* by panxu tcp 不使用了 --使用TCP监听在自动获取IP的情况下,刚开始会导致界面无响应,过一会就好
|
||||||
|
@ -425,13 +425,13 @@ namespace Plane.FormationCreator.Formation
|
|||||||
foreach (string line in lines)
|
foreach (string line in lines)
|
||||||
{
|
{
|
||||||
string[] parameters = line.Split(' ');
|
string[] parameters = line.Split(' ');
|
||||||
string id = parameters[0];
|
int id = Convert.ToInt32(parameters[0])+1;
|
||||||
string frame = parameters[1];
|
string frame = parameters[1];
|
||||||
string[] point = new string[3];
|
string[] point = new string[3];
|
||||||
point[0] = parameters[2]; //左右 经度
|
point[0] = parameters[2]; //左右 经度
|
||||||
point[1] = parameters[3]; //上下 高度
|
point[1] = parameters[3]; //上下 高度
|
||||||
point[2] = parameters[4]; //前后 纬度
|
point[2] = parameters[4]; //前后 纬度
|
||||||
PointDic.Add(Convert.ToInt32(id), point);
|
PointDic.Add(id, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
432
Plane.FormationCreator/Formation/RtcmManager.cs
Normal file
432
Plane.FormationCreator/Formation/RtcmManager.cs
Normal file
@ -0,0 +1,432 @@
|
|||||||
|
using GalaSoft.MvvmLight;
|
||||||
|
using Microsoft.Practices.ServiceLocation;
|
||||||
|
using Plane.CommunicationManagement;
|
||||||
|
using Plane.Util;
|
||||||
|
using Plane.Windows.IniHelper;
|
||||||
|
using Plane.Windows.Messages;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
|
namespace Plane.FormationCreator.Formation
|
||||||
|
{
|
||||||
|
public class RtcmManager: ObservableObject
|
||||||
|
{
|
||||||
|
private rtcm3 rtcm = new rtcm3();
|
||||||
|
private Hashtable msgseen = new Hashtable();
|
||||||
|
|
||||||
|
private ICommsSerial comPort;
|
||||||
|
private CommModuleManager _commModuleManager = CommModuleManager.Instance;
|
||||||
|
public ObservableCollection<RtcmInfo> rtcmInfoList { get; } = new ObservableCollection<RtcmInfo>();
|
||||||
|
|
||||||
|
private bool _rtcmthreadrun = false;
|
||||||
|
public bool Rtcmthreadrun
|
||||||
|
{
|
||||||
|
get { return _rtcmthreadrun; }
|
||||||
|
set { Set(nameof(Rtcmthreadrun), ref _rtcmthreadrun, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private int bps;
|
||||||
|
private int bpsusefull;
|
||||||
|
|
||||||
|
private int _bps = 0;
|
||||||
|
public int Bps
|
||||||
|
{
|
||||||
|
get { return _bps; }
|
||||||
|
set { Set(nameof(Bps), ref _bps, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _bpsusefull = 0;
|
||||||
|
public int Bpsusefull
|
||||||
|
{
|
||||||
|
get { return _bpsusefull; }
|
||||||
|
set { Set(nameof(Bpsusefull), ref _bpsusefull, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _messages_seen = "";
|
||||||
|
public string Messages_seen
|
||||||
|
{
|
||||||
|
get { return _messages_seen; }
|
||||||
|
set { Set(nameof(Messages_seen), ref _messages_seen, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private DateTime baseTime = DateTime.Now;
|
||||||
|
private DateTime gpsTime = DateTime.Now;
|
||||||
|
private DateTime glonassTime = DateTime.Now;
|
||||||
|
private DateTime beidouTime = DateTime.Now;
|
||||||
|
|
||||||
|
private bool _baseState = false;
|
||||||
|
public bool BaseState
|
||||||
|
{
|
||||||
|
get { return _baseState; }
|
||||||
|
set { Set(nameof(BaseState), ref _baseState, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _gpsState = false;
|
||||||
|
public bool GpsState
|
||||||
|
{
|
||||||
|
get { return _gpsState; }
|
||||||
|
set { Set(nameof(GpsState), ref _gpsState, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _glonassState = false;
|
||||||
|
public bool GlonassState
|
||||||
|
{
|
||||||
|
get { return _glonassState; }
|
||||||
|
set { Set(nameof(GlonassState), ref _glonassState, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _beidouState = false;
|
||||||
|
public bool BeidouState
|
||||||
|
{
|
||||||
|
get { return _beidouState; }
|
||||||
|
set { Set(nameof(BeidouState), ref _beidouState, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _stationLat;
|
||||||
|
public double StationLat
|
||||||
|
{
|
||||||
|
get { return _stationLat; }
|
||||||
|
set { Set(nameof(StationLat), ref _stationLat, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _stationLng;
|
||||||
|
public double StationLng
|
||||||
|
{
|
||||||
|
get { return _stationLng; }
|
||||||
|
set { Set(nameof(StationLng), ref _stationLng, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _stationAlt;
|
||||||
|
public double StationAlt
|
||||||
|
{
|
||||||
|
get { return _stationAlt; }
|
||||||
|
set { Set(nameof(StationAlt), ref _stationAlt, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _stationTime;
|
||||||
|
public string StationTime
|
||||||
|
{
|
||||||
|
get { return _stationTime; }
|
||||||
|
set { Set(nameof(StationTime), ref _stationTime, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private DispatcherTimer dispatcherTimer = null;
|
||||||
|
public RtcmManager()
|
||||||
|
{
|
||||||
|
rtcm.ObsMessage += Rtcm_ObsMessage;
|
||||||
|
dispatcherTimer = new DispatcherTimer();
|
||||||
|
dispatcherTimer.Tick += new EventHandler(OnTimedEvent);
|
||||||
|
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
|
||||||
|
dispatcherTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTimedEvent(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
BaseState = baseTime > DateTime.Now;
|
||||||
|
GpsState = gpsTime > DateTime.Now;
|
||||||
|
GlonassState = glonassTime > DateTime.Now;
|
||||||
|
BeidouState = beidouTime > DateTime.Now;
|
||||||
|
|
||||||
|
Bps = bps;
|
||||||
|
Bpsusefull = bpsusefull;
|
||||||
|
bps = 0;
|
||||||
|
bpsusefull = 0;
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var item in msgseen.Keys)
|
||||||
|
{
|
||||||
|
sb.Append(item + "=" + msgseen[item] + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{}
|
||||||
|
Messages_seen = sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Rtcm_ObsMessage(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
List<rtcm3.ob> obs = sender as List<rtcm3.ob>;
|
||||||
|
if (obs.Count == 0) return;
|
||||||
|
|
||||||
|
List<RtcmInfo> partRtcmInfos;
|
||||||
|
partRtcmInfos = rtcmInfoList.Where(o => o.Sys == obs[0].sys).ToList();
|
||||||
|
while (partRtcmInfos.Count() < obs.Count)
|
||||||
|
{
|
||||||
|
RtcmInfo newInfo = new RtcmInfo();
|
||||||
|
rtcmInfoList.Add(newInfo);
|
||||||
|
partRtcmInfos.Add(newInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
while (partRtcmInfos.Count() > obs.Count)
|
||||||
|
{
|
||||||
|
RtcmInfo lastInfo = partRtcmInfos[partRtcmInfos.Count - 1];
|
||||||
|
rtcmInfoList.Remove(lastInfo);
|
||||||
|
partRtcmInfos.Remove(lastInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (partRtcmInfos.Count() == obs.Count)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < obs.Count; i++)
|
||||||
|
{
|
||||||
|
partRtcmInfos[i].Sys = obs[i].sys;
|
||||||
|
partRtcmInfos[i].Prn = obs[i].prn;
|
||||||
|
partRtcmInfos[i].Snr = obs[i].snr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] GetPortNames()
|
||||||
|
{
|
||||||
|
return SerialPort.GetPortNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Open(string CMB_serialport)
|
||||||
|
{
|
||||||
|
if (CMB_serialport == "") return;
|
||||||
|
|
||||||
|
switch(CMB_serialport)
|
||||||
|
{
|
||||||
|
case "千寻":
|
||||||
|
//检测原点
|
||||||
|
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
||||||
|
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
|
||||||
|
{
|
||||||
|
Alert.Show("作为参照的原点未设置,无法发送RTCM!", "提示");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//千寻账号
|
||||||
|
string messagetips = "格式:http://差分账号:差分密码@域名:端口/坐标系\r\n例如:http://account:password@rtk.ntrip.qxwz.com:8002/RTCM32_GGB";
|
||||||
|
string url = "";
|
||||||
|
IniFiles inifilse = new IniFiles();
|
||||||
|
url = inifilse.IniReadvalue("Default", "RTKurl");
|
||||||
|
if (PlaneMessageBox.OnShow(messagetips, "发送RTK", ref url) == false) return;
|
||||||
|
inifilse.IniWritevalue("Default", "RTKurl", url);
|
||||||
|
|
||||||
|
//构造
|
||||||
|
comPort = new CommsNTRIP(url, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
comPort = new SerialPort();
|
||||||
|
comPort.PortName = CMB_serialport;
|
||||||
|
comPort.BaudRate = 57600;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
msgseen.Clear();
|
||||||
|
comPort.Open();
|
||||||
|
if (comPort.IsOpen)
|
||||||
|
{
|
||||||
|
Rtcmthreadrun = true;
|
||||||
|
await RtcmLoop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Close()
|
||||||
|
{
|
||||||
|
Rtcmthreadrun = false;
|
||||||
|
comPort.Close();
|
||||||
|
await Task.Delay(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RtcmLoop()
|
||||||
|
{
|
||||||
|
int reconnecttimeout = 10;
|
||||||
|
DateTime lastrecv = DateTime.MinValue;
|
||||||
|
while (Rtcmthreadrun)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((DateTime.Now - lastrecv).TotalSeconds > reconnecttimeout || !comPort.IsOpen)
|
||||||
|
{
|
||||||
|
if (comPort is CommsNTRIP)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
comPort.Close();
|
||||||
|
comPort.Open();
|
||||||
|
}
|
||||||
|
// reset timer
|
||||||
|
lastrecv = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
if (!comPort.IsOpen)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//rtcm size=180
|
||||||
|
byte[] buffer = new byte[180];
|
||||||
|
|
||||||
|
int read = comPort.Read(buffer, 0, Math.Min(buffer.Length, comPort.BytesToRead));
|
||||||
|
if (read > 0)
|
||||||
|
lastrecv = DateTime.Now;
|
||||||
|
|
||||||
|
bps += read;
|
||||||
|
for (int a = 0; a < read; a++)
|
||||||
|
{
|
||||||
|
int seenmsg = -1;
|
||||||
|
// rtcm
|
||||||
|
if ((seenmsg = rtcm.Read(buffer[a])) > 0)
|
||||||
|
{
|
||||||
|
bpsusefull += rtcm.length;
|
||||||
|
Message.Show($"{DateTime.Now.ToString("HH-mm-ss:fff")} rtcm.length = {rtcm.length}");
|
||||||
|
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm.packet, rtcm.length);
|
||||||
|
|
||||||
|
string msgname = "Rtcm" + seenmsg;
|
||||||
|
|
||||||
|
if (!msgseen.ContainsKey(msgname))
|
||||||
|
msgseen[msgname] = 0;
|
||||||
|
msgseen[msgname] = (int)msgseen[msgname] + 1;
|
||||||
|
|
||||||
|
await ExtractBasePos(seenmsg);
|
||||||
|
//await seenRTCM(seenmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Task.Delay(10);
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Message.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task ExtractBasePos(int seen)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (seen == 1005)
|
||||||
|
{
|
||||||
|
var basepos = new rtcm3.type1005();
|
||||||
|
basepos.Read(rtcm.packet);
|
||||||
|
var pos = basepos.ecefposition;
|
||||||
|
double[] baseposllh = new double[3];
|
||||||
|
rtcm3.ecef2pos(pos, ref baseposllh);
|
||||||
|
|
||||||
|
|
||||||
|
StationLat = baseposllh[0] * rtcm3.R2D;
|
||||||
|
StationLng = baseposllh[1] * rtcm3.R2D;
|
||||||
|
StationAlt = baseposllh[2];
|
||||||
|
StationTime = DateTime.Now.ToString("HH:mm:ss");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (seen == 1006)
|
||||||
|
{
|
||||||
|
var basepos = new rtcm3.type1006();
|
||||||
|
basepos.Read(rtcm.packet);
|
||||||
|
var pos = basepos.ecefposition;
|
||||||
|
double[] baseposllh = new double[3];
|
||||||
|
rtcm3.ecef2pos(pos, ref baseposllh);
|
||||||
|
|
||||||
|
StationLat = baseposllh[0] * rtcm3.R2D;
|
||||||
|
StationLng = baseposllh[1] * rtcm3.R2D;
|
||||||
|
StationAlt = baseposllh[2];
|
||||||
|
StationTime = DateTime.Now.ToString("HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (seen)
|
||||||
|
{
|
||||||
|
case 1001:
|
||||||
|
case 1002:
|
||||||
|
case 1003:
|
||||||
|
case 1004:
|
||||||
|
case 1071:
|
||||||
|
case 1072:
|
||||||
|
case 1073:
|
||||||
|
case 1074:
|
||||||
|
case 1075:
|
||||||
|
case 1076:
|
||||||
|
case 1077:
|
||||||
|
gpsTime = DateTime.Now.AddSeconds(5);
|
||||||
|
break;
|
||||||
|
case 1005:
|
||||||
|
case 1006:
|
||||||
|
case 4072: // ublox moving base
|
||||||
|
baseTime = DateTime.Now.AddSeconds(20);
|
||||||
|
break;
|
||||||
|
case 1009:
|
||||||
|
case 1010:
|
||||||
|
case 1011:
|
||||||
|
case 1012:
|
||||||
|
case 1081:
|
||||||
|
case 1082:
|
||||||
|
case 1083:
|
||||||
|
case 1084:
|
||||||
|
case 1085:
|
||||||
|
case 1086:
|
||||||
|
case 1087:
|
||||||
|
glonassTime = DateTime.Now.AddSeconds(5);
|
||||||
|
break;
|
||||||
|
case 1121:
|
||||||
|
case 1122:
|
||||||
|
case 1123:
|
||||||
|
case 1124:
|
||||||
|
case 1125:
|
||||||
|
case 1126:
|
||||||
|
case 1127:
|
||||||
|
beidouTime = DateTime.Now.AddSeconds(5);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Message.Show(ex.Message);
|
||||||
|
}
|
||||||
|
await Task.Delay(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RtcmInfo: ObservableObject
|
||||||
|
{
|
||||||
|
private char sys;
|
||||||
|
private byte prn;
|
||||||
|
private byte snr;
|
||||||
|
|
||||||
|
public RtcmInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public char Sys
|
||||||
|
{
|
||||||
|
get { return sys; }
|
||||||
|
set { Set(nameof(Sys), ref sys, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte Prn
|
||||||
|
{
|
||||||
|
get { return prn; }
|
||||||
|
set { Set(nameof(Prn), ref prn, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte Snr
|
||||||
|
{
|
||||||
|
get { return snr; }
|
||||||
|
set { Set(nameof(Snr), ref snr, value); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,13 @@ namespace Plane.FormationCreator
|
|||||||
|
|
||||||
this.DataContext = ServiceLocator.Current.GetInstance<MainViewModel>();
|
this.DataContext = ServiceLocator.Current.GetInstance<MainViewModel>();
|
||||||
|
|
||||||
|
DateTime dateTimeClose = DateTime.Parse("2019-12-7");
|
||||||
|
if (DateTime.UtcNow > dateTimeClose)
|
||||||
|
{
|
||||||
|
MessageBox.Show("软件过旧,请更新!");
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
//ShowConnectDialog();
|
//ShowConnectDialog();
|
||||||
//if (_copterManager.CoptersForControlling.Count <= 0)
|
//if (_copterManager.CoptersForControlling.Count <= 0)
|
||||||
//{
|
//{
|
||||||
|
@ -182,6 +182,7 @@
|
|||||||
<Compile Include="Formation\FlightTaskManager.cs" />
|
<Compile Include="Formation\FlightTaskManager.cs" />
|
||||||
<Compile Include="Formation\PropertyChangedEventArgs.cs" />
|
<Compile Include="Formation\PropertyChangedEventArgs.cs" />
|
||||||
<Compile Include="Formation\FlightTask_TakeOff.cs" />
|
<Compile Include="Formation\FlightTask_TakeOff.cs" />
|
||||||
|
<Compile Include="Formation\RtcmManager.cs" />
|
||||||
<Compile Include="Formation\View3DManager.cs" />
|
<Compile Include="Formation\View3DManager.cs" />
|
||||||
<Compile Include="GMap.cs" />
|
<Compile Include="GMap.cs" />
|
||||||
<Compile Include="Maps\MapConverter.cs" />
|
<Compile Include="Maps\MapConverter.cs" />
|
||||||
@ -195,6 +196,10 @@
|
|||||||
<Compile Include="Test.cs" />
|
<Compile Include="Test.cs" />
|
||||||
<Compile Include="CalculationLogLatDistance.cs" />
|
<Compile Include="CalculationLogLatDistance.cs" />
|
||||||
<Compile Include="Util\CommNTRIP.cs" />
|
<Compile Include="Util\CommNTRIP.cs" />
|
||||||
|
<Compile Include="Util\CommsSerialPort.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Util\ICommsSerial.cs" />
|
||||||
<Compile Include="Util\ICorrections.cs" />
|
<Compile Include="Util\ICorrections.cs" />
|
||||||
<Compile Include="Util\ParamFile.cs" />
|
<Compile Include="Util\ParamFile.cs" />
|
||||||
<Compile Include="Util\rtcm3.cs" />
|
<Compile Include="Util\rtcm3.cs" />
|
||||||
@ -208,6 +213,7 @@
|
|||||||
<Compile Include="ViewModels\MapViewModel.cs" />
|
<Compile Include="ViewModels\MapViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ModifyTaskViewModel.cs" />
|
<Compile Include="ViewModels\ModifyTaskViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ModiLEDModel.cs" />
|
<Compile Include="ViewModels\ModiLEDModel.cs" />
|
||||||
|
<Compile Include="ViewModels\RtcmInfoViewModel.cs" />
|
||||||
<Compile Include="ViewModels\TaskBarViewModel.cs" />
|
<Compile Include="ViewModels\TaskBarViewModel.cs" />
|
||||||
<Compile Include="ViewModels\View3DViewModel.cs" />
|
<Compile Include="ViewModels\View3DViewModel.cs" />
|
||||||
<Compile Include="Views\CalibrationWindow.xaml.cs">
|
<Compile Include="Views\CalibrationWindow.xaml.cs">
|
||||||
@ -241,6 +247,9 @@
|
|||||||
<Compile Include="Views\ModifyTaskView.xaml.cs">
|
<Compile Include="Views\ModifyTaskView.xaml.cs">
|
||||||
<DependentUpon>ModifyTaskView.xaml</DependentUpon>
|
<DependentUpon>ModifyTaskView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\RtcmInfoView.xaml.cs">
|
||||||
|
<DependentUpon>RtcmInfoView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\SetCoptersPutView.xaml.cs">
|
<Compile Include="Views\SetCoptersPutView.xaml.cs">
|
||||||
<DependentUpon>SetCoptersPutView.xaml</DependentUpon>
|
<DependentUpon>SetCoptersPutView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -375,6 +384,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\RtcmInfoView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\SetCoptersPutView.xaml">
|
<Page Include="Views\SetCoptersPutView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
Title="PlaneMessageBox" Height="200" Width="600"
|
Title="PlaneMessageBox" Height="200" Width="600"
|
||||||
MinHeight="200" MinWidth="600"
|
MinHeight="200" MinWidth="600"
|
||||||
MaxHeight="200" MaxWidth="600"
|
MaxHeight="200" MaxWidth="600"
|
||||||
WindowStyle="ToolWindow" Visibility="Visible" ShowMinButton="False" ShowMaxRestoreButton="False" ShowCloseButton="False" IsCloseButtonEnabled="False" IsMinButtonEnabled="False" IsMaxRestoreButtonEnabled="False" IsWindowDraggable="False"
|
WindowStyle="ToolWindow" Visibility="Visible" ShowMinButton="False" ShowMaxRestoreButton="False" ShowCloseButton="False" IsCloseButtonEnabled="False" IsMinButtonEnabled="False" IsMaxRestoreButtonEnabled="False" IsWindowDraggable="True" Background="#FF2D2D2D" BorderBrush="#FF099EF3"
|
||||||
>
|
>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
@ -35,6 +35,7 @@ namespace Plane.FormationCreator
|
|||||||
_container.Register<ModifyTaskViewModel>();
|
_container.Register<ModifyTaskViewModel>();
|
||||||
_container.Register<CalibrationViewModel>();
|
_container.Register<CalibrationViewModel>();
|
||||||
_container.Register<GroupsViewModel>();
|
_container.Register<GroupsViewModel>();
|
||||||
|
_container.Register<RtcmInfoViewModel>();
|
||||||
|
|
||||||
_container.Register<ILogger>(() => new LocalFileLogger(new DebugLogger()));
|
_container.Register<ILogger>(() => new LocalFileLogger(new DebugLogger()));
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ namespace Plane.FormationCreator
|
|||||||
_container.Register<FlightTaskManager>();
|
_container.Register<FlightTaskManager>();
|
||||||
|
|
||||||
_container.Register<FormationController>();
|
_container.Register<FormationController>();
|
||||||
|
_container.Register<RtcmManager>();
|
||||||
|
|
||||||
_container.Register<AppConfig>();
|
_container.Register<AppConfig>();
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,141 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.Reflection;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.IO.Ports;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Net; // dns, ip address
|
||||||
|
using System.Net.Sockets; // tcplistner
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Plane.Util
|
namespace Plane.Util
|
||||||
{
|
{
|
||||||
public class CommNTRIP: IDisposable
|
public class CommsNTRIP : ICommsSerial, IDisposable
|
||||||
{
|
{
|
||||||
public TcpClient client = new TcpClient();
|
public TcpClient client = new TcpClient();
|
||||||
|
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
|
||||||
private Uri remoteUri;
|
private Uri remoteUri;
|
||||||
double Lat = 40.0910757034397;
|
|
||||||
double Lng = 116.27734627295;
|
public double lat = 0;
|
||||||
double alt = 0;
|
public double lng = 0;
|
||||||
|
public double alt = 0;
|
||||||
|
|
||||||
int retrys = 3;
|
int retrys = 3;
|
||||||
DateTime _lastnmea = DateTime.MinValue;
|
|
||||||
public string Port { get; set; }
|
|
||||||
|
|
||||||
private string host;
|
private string host;
|
||||||
|
|
||||||
|
public int WriteBufferSize { get; set; }
|
||||||
|
public int WriteTimeout { get; set; }
|
||||||
|
public bool RtsEnable { get; set; }
|
||||||
|
private string url;
|
||||||
|
|
||||||
|
public Stream BaseStream
|
||||||
private static int bytes = 0;
|
|
||||||
private static int bps = 0;
|
|
||||||
public int ReadTimeout
|
|
||||||
{
|
{
|
||||||
get;
|
get { return client.GetStream(); }
|
||||||
set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommNTRIP(string url, double lat, double lng)
|
public CommsNTRIP(string url, double lat, double lng)
|
||||||
{
|
{
|
||||||
remoteUri = new Uri(url);
|
this.url = url;
|
||||||
this.Lat = lat;
|
this.lat = lat;
|
||||||
this.Lng = lng;
|
this.lng = lng;
|
||||||
ReadTimeout = 500;
|
ReadTimeout = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doConnect()
|
public void toggleDTR()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Port { get; set; }
|
||||||
|
|
||||||
|
public int ReadTimeout
|
||||||
|
{
|
||||||
|
get; // { return client.ReceiveTimeout; }
|
||||||
|
set; // { client.ReceiveTimeout = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReadBufferSize { get; set; }
|
||||||
|
|
||||||
|
public int BaudRate { get; set; }
|
||||||
|
public StopBits StopBits { get; set; }
|
||||||
|
public Parity Parity { get; set; }
|
||||||
|
public int DataBits { get; set; }
|
||||||
|
|
||||||
|
public string PortName { get; set; }
|
||||||
|
|
||||||
|
public int BytesToRead
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
/*Console.WriteLine(DateTime.Now.Millisecond + " tcp btr " + (client.Available + rbuffer.Length - rbufferread));*/
|
||||||
|
SendNMEA();
|
||||||
|
return (int)client.Available;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BytesToWrite
|
||||||
|
{
|
||||||
|
get { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsOpen
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return client.Client.Connected;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DtrEnable { get; set; }
|
||||||
|
|
||||||
|
public void Open()
|
||||||
|
{
|
||||||
|
if (client.Client.Connected)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*string url = "";*/
|
||||||
|
|
||||||
|
|
||||||
|
int count = url.Split('@').Length - 1;
|
||||||
|
|
||||||
|
if (count > 1)
|
||||||
|
{
|
||||||
|
var regex = new Regex("@");
|
||||||
|
url = regex.Replace(url, "%40", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
url = url.Replace("ntrip://", "http://");
|
||||||
|
|
||||||
|
remoteUri = new Uri(url);
|
||||||
|
|
||||||
|
doConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] TcpKeepAlive(bool On_Off, uint KeepaLiveTime, uint KeepaLiveInterval)
|
||||||
|
{
|
||||||
|
byte[] InValue = new byte[12];
|
||||||
|
|
||||||
|
Array.ConstrainedCopy(BitConverter.GetBytes(Convert.ToUInt32(On_Off)), 0, InValue, 0, 4);
|
||||||
|
Array.ConstrainedCopy(BitConverter.GetBytes(KeepaLiveTime), 0, InValue, 4, 4);
|
||||||
|
Array.ConstrainedCopy(BitConverter.GetBytes(KeepaLiveInterval), 0, InValue, 8, 4);
|
||||||
|
|
||||||
|
return InValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doConnect()
|
||||||
{
|
{
|
||||||
string usernamePassword = remoteUri.UserInfo;
|
string usernamePassword = remoteUri.UserInfo;
|
||||||
string userpass2 = Uri.UnescapeDataString(usernamePassword);
|
string userpass2 = Uri.UnescapeDataString(usernamePassword);
|
||||||
@ -67,133 +162,54 @@ namespace Plane.Util
|
|||||||
+ "Connection: close\r\n\r\n";
|
+ "Connection: close\r\n\r\n";
|
||||||
|
|
||||||
sw.Write(line);
|
sw.Write(line);
|
||||||
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
|
|
||||||
line = sr.ReadLine();
|
line = sr.ReadLine();
|
||||||
|
|
||||||
Console.WriteLine(line);
|
|
||||||
if (!line.Contains("200"))
|
if (!line.Contains("200"))
|
||||||
{
|
{
|
||||||
client.Dispose();
|
client.Dispose();
|
||||||
|
|
||||||
client = new TcpClient();
|
client = new TcpClient();
|
||||||
|
|
||||||
throw new Exception("Bad ntrip Responce\n\n" + line);
|
throw new Exception("Bad ntrip Responce\n\n" + line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vrs may take up to 60+ seconds to respond
|
||||||
SendNMEA();
|
SendNMEA();
|
||||||
|
|
||||||
VerifyConnected();
|
VerifyConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Read(byte[] readto, int offset, int length)
|
DateTime _lastnmea = DateTime.MinValue;
|
||||||
{
|
|
||||||
VerifyConnected();
|
|
||||||
|
|
||||||
SendNMEA();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (length < 1) { return 0; }
|
|
||||||
|
|
||||||
return client.Client.Receive(readto, offset, length, SocketFlags.Partial);
|
|
||||||
}
|
|
||||||
catch { throw new Exception("ntrip Socket Closed"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void SendNMEA()
|
private void SendNMEA()
|
||||||
{
|
{
|
||||||
if (Lat != 0 || Lng != 0)
|
if (lat != 0 || lng != 0)
|
||||||
{
|
{
|
||||||
if (_lastnmea.AddSeconds(30) < DateTime.Now)
|
if (_lastnmea.AddSeconds(30) < DateTime.Now)
|
||||||
{
|
{
|
||||||
double latdms = (int)Lat + ((Lat - (int)Lat) * .6f);
|
double latdms = (int)lat + ((lat - (int)lat) * .6f);
|
||||||
double lngdms = (int)Lng + ((Lng - (int)Lng) * .6f);
|
double lngdms = (int)lng + ((lng - (int)lng) * .6f);
|
||||||
|
|
||||||
var line = string.Format(System.Globalization.CultureInfo.InvariantCulture,
|
var line = string.Format(System.Globalization.CultureInfo.InvariantCulture,
|
||||||
"$GP{0},{1:HHmmss.ff},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}", "GGA",
|
"$GP{0},{1:HHmmss.ff},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}", "GGA",
|
||||||
DateTime.Now.ToUniversalTime(), Math.Abs(latdms * 100).ToString("0000.00"), Lat < 0 ? "S" : "N",
|
DateTime.Now.ToUniversalTime(), Math.Abs(latdms * 100).ToString("0000.00"), lat < 0 ? "S" : "N",
|
||||||
Math.Abs(lngdms * 100).ToString("00000.00"), Lng < 0 ? "W" : "E", 1, 10,
|
Math.Abs(lngdms * 100).ToString("00000.00"), lng < 0 ? "W" : "E", 1, 10,
|
||||||
1, alt.ToString("0.00"), "M", 0, "M", "0.0", "0");
|
1, alt.ToString("0.00"), "M", 0, "M", "0.0", "0");
|
||||||
|
|
||||||
string checksum = GetChecksum(line);
|
string checksum = GetChecksum(line);
|
||||||
WriteLine(line + "*" + checksum);
|
WriteLine(line + "*" + checksum);
|
||||||
|
|
||||||
|
|
||||||
_lastnmea = DateTime.Now;
|
_lastnmea = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int BytesToRead
|
// Calculates the checksum for a sentence
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
/*Console.WriteLine(DateTime.Now.Millisecond + " tcp btr " + (client.Available + rbuffer.Length - rbufferread));*/
|
|
||||||
SendNMEA();
|
|
||||||
return (int)client.Available;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void VerifyConnected()
|
|
||||||
{
|
|
||||||
if (!IsOpen)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
client.Dispose();
|
|
||||||
client = new TcpClient();
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
// this should only happen if we have established a connection in the first place
|
|
||||||
if (client != null && retrys > 0)
|
|
||||||
{
|
|
||||||
doConnect();
|
|
||||||
retrys--;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception("The ntrip is closed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsOpen
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return client.Client.Connected;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteLine(string line)
|
|
||||||
{
|
|
||||||
VerifyConnected();
|
|
||||||
line = line + "\r\n";
|
|
||||||
Write(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(string line)
|
|
||||||
{
|
|
||||||
VerifyConnected();
|
|
||||||
byte[] data = new System.Text.ASCIIEncoding().GetBytes(line);
|
|
||||||
Write(data, 0, data.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(byte[] write, int offset, int length)
|
|
||||||
{
|
|
||||||
VerifyConnected();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
client.Client.Send(write, length, SocketFlags.None);
|
|
||||||
}
|
|
||||||
catch { }//throw new Exception("Comport / Socket Closed"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
string GetChecksum(string sentence)
|
string GetChecksum(string sentence)
|
||||||
{
|
{
|
||||||
// Loop through all chars to get a checksum
|
// Loop through all chars to get a checksum
|
||||||
@ -227,30 +243,151 @@ namespace Plane.Util
|
|||||||
return Checksum.ToString("X2");
|
return Checksum.ToString("X2");
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] TcpKeepAlive(bool On_Off, uint KeepaLiveTime, uint KeepaLiveInterval)
|
void VerifyConnected()
|
||||||
{
|
{
|
||||||
byte[] InValue = new byte[12];
|
if (!IsOpen)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.Dispose();
|
||||||
|
client = new TcpClient();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
Array.ConstrainedCopy(BitConverter.GetBytes(Convert.ToUInt32(On_Off)), 0, InValue, 0, 4);
|
// this should only happen if we have established a connection in the first place
|
||||||
Array.ConstrainedCopy(BitConverter.GetBytes(KeepaLiveTime), 0, InValue, 4, 4);
|
if (client != null && retrys > 0)
|
||||||
Array.ConstrainedCopy(BitConverter.GetBytes(KeepaLiveInterval), 0, InValue, 8, 4);
|
{
|
||||||
|
doConnect();
|
||||||
return InValue;
|
retrys--;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
throw new Exception("The ntrip is closed");
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
this.Close();
|
|
||||||
client = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public int Read(byte[] readto, int offset, int length)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
VerifyConnected();
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
|
SendNMEA();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (length < 1) { return 0; }
|
||||||
|
|
||||||
|
return client.Client.Receive(readto, offset, length, SocketFlags.Partial);
|
||||||
|
/*
|
||||||
|
byte[] temp = new byte[length];
|
||||||
|
clientbuf.Read(temp, 0, length);
|
||||||
|
|
||||||
|
temp.CopyTo(readto, offset);
|
||||||
|
|
||||||
|
return length;*/
|
||||||
|
}
|
||||||
|
catch { throw new Exception("ntrip Socket Closed"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReadByte()
|
||||||
|
{
|
||||||
|
VerifyConnected();
|
||||||
|
int count = 0;
|
||||||
|
while (this.BytesToRead == 0)
|
||||||
|
{
|
||||||
|
System.Threading.Thread.Sleep(1);
|
||||||
|
if (count > ReadTimeout)
|
||||||
|
throw new Exception("ntrip Timeout on read");
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
byte[] buffer = new byte[1];
|
||||||
|
Read(buffer, 0, 1);
|
||||||
|
return buffer[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReadChar()
|
||||||
|
{
|
||||||
|
return ReadByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ReadExisting()
|
||||||
|
{
|
||||||
|
VerifyConnected();
|
||||||
|
byte[] data = new byte[client.Available];
|
||||||
|
if (data.Length > 0)
|
||||||
|
Read(data, 0, data.Length);
|
||||||
|
|
||||||
|
string line = Encoding.ASCII.GetString(data, 0, data.Length);
|
||||||
|
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteLine(string line)
|
||||||
|
{
|
||||||
|
VerifyConnected();
|
||||||
|
line = line + "\r\n";
|
||||||
|
Write(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Write(string line)
|
||||||
|
{
|
||||||
|
VerifyConnected();
|
||||||
|
byte[] data = new System.Text.ASCIIEncoding().GetBytes(line);
|
||||||
|
Write(data, 0, data.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Write(byte[] write, int offset, int length)
|
||||||
|
{
|
||||||
|
VerifyConnected();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.Client.Send(write, length, SocketFlags.None);
|
||||||
|
}
|
||||||
|
catch { }//throw new Exception("Comport / Socket Closed"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DiscardInBuffer()
|
||||||
|
{
|
||||||
|
VerifyConnected();
|
||||||
|
int size = (int)client.Available;
|
||||||
|
byte[] crap = new byte[size];
|
||||||
|
Read(crap, 0, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ReadLine()
|
||||||
|
{
|
||||||
|
byte[] temp = new byte[4000];
|
||||||
|
int count = 0;
|
||||||
|
int timeout = 0;
|
||||||
|
|
||||||
|
while (timeout <= 100)
|
||||||
|
{
|
||||||
|
if (!this.IsOpen) { break; }
|
||||||
|
if (this.BytesToRead > 0)
|
||||||
|
{
|
||||||
|
byte letter = (byte)this.ReadByte();
|
||||||
|
|
||||||
|
temp[count] = letter;
|
||||||
|
|
||||||
|
if (letter == '\n') // normal line
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
count++;
|
||||||
|
if (count == temp.Length)
|
||||||
|
break;
|
||||||
|
timeout = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeout++;
|
||||||
|
System.Threading.Thread.Sleep(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Array.Resize<byte>(ref temp, count + 1);
|
||||||
|
|
||||||
|
return Encoding.ASCII.GetString(temp, 0, temp.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
@ -273,5 +410,22 @@ namespace Plane.Util
|
|||||||
|
|
||||||
client = new TcpClient();
|
client = new TcpClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
// dispose managed resources
|
||||||
|
this.Close();
|
||||||
|
client = null;
|
||||||
|
}
|
||||||
|
// free native resources
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
59
Plane.FormationCreator/Util/ICommsSerial.cs
Normal file
59
Plane.FormationCreator/Util/ICommsSerial.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO.Ports;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Plane.Util
|
||||||
|
{
|
||||||
|
|
||||||
|
public interface ICommsSerial
|
||||||
|
{
|
||||||
|
// from serialport class
|
||||||
|
// Methods
|
||||||
|
void Close();
|
||||||
|
void DiscardInBuffer();
|
||||||
|
//void DiscardOutBuffer();
|
||||||
|
void Open();
|
||||||
|
int Read(byte[] buffer, int offset, int count);
|
||||||
|
//int Read(char[] buffer, int offset, int count);
|
||||||
|
int ReadByte();
|
||||||
|
int ReadChar();
|
||||||
|
string ReadExisting();
|
||||||
|
string ReadLine();
|
||||||
|
//string ReadTo(string value);
|
||||||
|
void Write(string text);
|
||||||
|
void Write(byte[] buffer, int offset, int count);
|
||||||
|
//void Write(char[] buffer, int offset, int count);
|
||||||
|
void WriteLine(string text);
|
||||||
|
|
||||||
|
void toggleDTR();
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
Stream BaseStream { get; }
|
||||||
|
int BaudRate { get; set; }
|
||||||
|
//bool BreakState { get; set; }
|
||||||
|
int BytesToRead { get; }
|
||||||
|
int BytesToWrite { get; }
|
||||||
|
//bool CDHolding { get; }
|
||||||
|
//bool CtsHolding { get; }
|
||||||
|
int DataBits { get; set; }
|
||||||
|
//bool DiscardNull { get; set; }
|
||||||
|
//bool DsrHolding { get; }
|
||||||
|
bool DtrEnable { get; set; }
|
||||||
|
//Encoding Encoding { get; set; }
|
||||||
|
//Handshake Handshake { get; set; }
|
||||||
|
bool IsOpen { get; }
|
||||||
|
//string NewLine { get; set; }
|
||||||
|
Parity Parity { get; set; }
|
||||||
|
//byte ParityReplace { get; set; }
|
||||||
|
string PortName { get; set; }
|
||||||
|
int ReadBufferSize { get; set; }
|
||||||
|
int ReadTimeout { get; set; }
|
||||||
|
bool RtsEnable { get; set; }
|
||||||
|
StopBits StopBits { get; set; }
|
||||||
|
int WriteBufferSize { get; set; }
|
||||||
|
int WriteTimeout { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -864,8 +864,10 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
RTKState = "RTK数据发送中";
|
RTKState = "RTK数据发送中";
|
||||||
RTKbtntxt = "停止RTK";
|
RTKbtntxt = "停止RTK";
|
||||||
await SaveRTKcomvalue();
|
await SaveRTKcomvalue();
|
||||||
|
await _commModuleManager.StartRtcmLoop();
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
Message.Show("RTK数据开始发送");
|
||||||
//读取RTK数据循环
|
//读取RTK数据循环
|
||||||
rtcm3 rtcm3 = new rtcm3();
|
rtcm3 rtcm3 = new rtcm3();
|
||||||
while (trkthreadrun)
|
while (trkthreadrun)
|
||||||
@ -873,7 +875,6 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
//读入RTK数据
|
//读入RTK数据
|
||||||
var packet = await ReadRTKPacketAsync().ConfigureAwait(false);
|
var packet = await ReadRTKPacketAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
||||||
if (packet != null && packet.Length > 0)
|
if (packet != null && packet.Length > 0)
|
||||||
{
|
{
|
||||||
//Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---packet.length = {packet.Length}");
|
//Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---packet.length = {packet.Length}");
|
||||||
@ -886,8 +887,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
// rtcm
|
// rtcm
|
||||||
if ((seenmsg = rtcm3.Read(packet[a])) > 0)
|
if ((seenmsg = rtcm3.Read(packet[a])) > 0)
|
||||||
{
|
{
|
||||||
//Console.WriteLine($"{DateTime.Now.ToLongTimeString()}---rtcm3.length = {rtcm3.length}");
|
Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---rtcm3.length = {rtcm3.length}");
|
||||||
//Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---rtcm3.length = {rtcm3.length}");
|
|
||||||
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
|
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -941,15 +941,14 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
NTRIPbtntxt = "停止RTCM";
|
NTRIPbtntxt = "停止RTCM";
|
||||||
Alert.Show("RTCM数据开始发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
Alert.Show("RTCM数据开始发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
|
||||||
|
await _commModuleManager.StartRtcmLoop();
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
Message.Show("RTK数据开始发送");
|
||||||
|
|
||||||
|
|
||||||
//string url = "http://qxarpz003:1dc880b@rtk.ntrip.qxwz.com:8002/RTCM32_GGB";
|
//string url = "http://qxarpz003:1dc880b@rtk.ntrip.qxwz.com:8002/RTCM32_GGB";
|
||||||
CommNTRIP commNTRIP = new CommNTRIP(url, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng);
|
CommsNTRIP commNTRIP = new CommsNTRIP(url, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng);
|
||||||
rtcm3 rtcm3 = new rtcm3();
|
rtcm3 rtcm3 = new rtcm3();
|
||||||
commNTRIP.doConnect();
|
commNTRIP.Open();
|
||||||
//读取RTK数据循环
|
//读取RTK数据循环
|
||||||
while (rtcmthreadrun)
|
while (rtcmthreadrun)
|
||||||
{
|
{
|
||||||
@ -967,7 +966,9 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
// rtcm
|
// rtcm
|
||||||
if ((seenmsg = rtcm3.Read(buffer[a])) > 0)
|
if ((seenmsg = rtcm3.Read(buffer[a])) > 0)
|
||||||
{
|
{
|
||||||
//Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---rtcm3.length = {rtcm3.length}");
|
//rtcmDatas.Add(rtcm3.packet);
|
||||||
|
//await SendRtcmData();
|
||||||
|
Message.Show($"{DateTime.Now.ToString("HH:mm:ss fff")}---rtcm3.length = {rtcm3.length}");
|
||||||
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
|
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -984,6 +985,25 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RtcmInfoView rtcmInfoView;
|
||||||
|
private ICommand _OpenRtcmManageCommand;
|
||||||
|
public ICommand OpenRtcmManageCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _OpenRtcmManageCommand ?? (_OpenRtcmManageCommand = new RelayCommand(() =>
|
||||||
|
{
|
||||||
|
RtcmInfoView.GetInstance().Show();
|
||||||
|
RtcmInfoView.GetInstance().Activate();
|
||||||
|
// if (rtcmInfoView == null)
|
||||||
|
// {
|
||||||
|
// rtcmInfoView = new RtcmInfoView();
|
||||||
|
// }
|
||||||
|
// rtcmInfoView.Show();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rtcm3 rtcm3 = new rtcm3();
|
rtcm3 rtcm3 = new rtcm3();
|
||||||
private async Task AnalysisRendRrcmData(byte[] buffer, int length)
|
private async Task AnalysisRendRrcmData(byte[] buffer, int length)
|
||||||
{
|
{
|
||||||
@ -1000,9 +1020,6 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private ICommand _LandCommand;
|
private ICommand _LandCommand;
|
||||||
public ICommand LandCommand
|
public ICommand LandCommand
|
||||||
{
|
{
|
||||||
@ -1401,18 +1418,6 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
return missions;
|
return missions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private ICommand _FlagCommand;
|
private ICommand _FlagCommand;
|
||||||
public ICommand FlagCommand
|
public ICommand FlagCommand
|
||||||
{
|
{
|
||||||
|
87
Plane.FormationCreator/ViewModels/RtcmInfoViewModel.cs
Normal file
87
Plane.FormationCreator/ViewModels/RtcmInfoViewModel.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using GalaSoft.MvvmLight;
|
||||||
|
using GalaSoft.MvvmLight.Command;
|
||||||
|
using Plane.FormationCreator.Formation;
|
||||||
|
using Plane.Windows.Messages;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace Plane.FormationCreator.ViewModels
|
||||||
|
{
|
||||||
|
public class RtcmInfoViewModel: ViewModelBase
|
||||||
|
{
|
||||||
|
private RtcmManager _rtcmManager;
|
||||||
|
|
||||||
|
public RtcmManager RtcmManager { get { return _rtcmManager; } }
|
||||||
|
|
||||||
|
public ObservableCollection<string> serialPorts { get; } = new ObservableCollection<string>();
|
||||||
|
|
||||||
|
private string _serialPortsSelectdValue;
|
||||||
|
public string SerialPortsSelectdValue
|
||||||
|
{
|
||||||
|
|
||||||
|
get { return _serialPortsSelectdValue; }
|
||||||
|
set { Set(nameof(SerialPortsSelectdValue), ref _serialPortsSelectdValue, value); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RtcmInfoViewModel(RtcmManager rtcmManager)
|
||||||
|
{
|
||||||
|
_rtcmManager = rtcmManager;
|
||||||
|
string[] commports = _rtcmManager.GetPortNames();
|
||||||
|
foreach (var item in commports)
|
||||||
|
{
|
||||||
|
serialPorts.Add(item);
|
||||||
|
}
|
||||||
|
serialPorts.Add("千寻");
|
||||||
|
SerialPortsSelectdValue = serialPorts[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void RefreshPorts()
|
||||||
|
{
|
||||||
|
string lastSelectValue = SerialPortsSelectdValue;
|
||||||
|
serialPorts.Clear();
|
||||||
|
string[] commports = _rtcmManager.GetPortNames();
|
||||||
|
foreach (var item in commports)
|
||||||
|
{
|
||||||
|
serialPorts.Add(item);
|
||||||
|
}
|
||||||
|
serialPorts.Add("千寻");
|
||||||
|
if (serialPorts.Contains(lastSelectValue))
|
||||||
|
SerialPortsSelectdValue = lastSelectValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICommand _ConnectRtcmCommand;
|
||||||
|
public ICommand ConnectRtcmCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _ConnectRtcmCommand ?? (_ConnectRtcmCommand = new RelayCommand(async() =>
|
||||||
|
{
|
||||||
|
if (!_rtcmManager.Rtcmthreadrun)
|
||||||
|
await _rtcmManager.Open(SerialPortsSelectdValue);
|
||||||
|
else
|
||||||
|
await _rtcmManager.Close();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICommand _ClearRtcmCommand;
|
||||||
|
public ICommand ClearRtcmCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _ClearRtcmCommand ?? (_ClearRtcmCommand = new RelayCommand(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(1);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -142,8 +142,10 @@
|
|||||||
Command="{Binding SendRTKCommand}" />
|
Command="{Binding SendRTKCommand}" />
|
||||||
|
|
||||||
<Button Content="{Binding Path=NTRIPbtntxt}"
|
<Button Content="{Binding Path=NTRIPbtntxt}"
|
||||||
Command="{Binding SendRTCMCommand}"
|
Command="{Binding SendRTCMCommand}"/>
|
||||||
/>
|
|
||||||
|
<Button Content="RTK" Command="{Binding OpenRtcmManageCommand}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="5,5,5,5"
|
Margin="5,5,5,5"
|
||||||
Text="{Binding Path=RTKState}"
|
Text="{Binding Path=RTKState}"
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
<Button Content="优化路线" Command="{Binding OptimizeRouteCommand}"
|
<Button Content="优化路线" Command="{Binding OptimizeRouteCommand}"
|
||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed"/>
|
||||||
<Button Content="导入航点" Command="{Binding ImportBlenderWayPointCommand}"
|
<Button Content="导入航点" Command="{Binding ImportBlenderWayPointCommand}"
|
||||||
Visibility="Collapsed"/>
|
/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Separator Margin="0,1"/>
|
<Separator Margin="0,1"/>
|
||||||
|
119
Plane.FormationCreator/Views/RtcmInfoView.xaml
Normal file
119
Plane.FormationCreator/Views/RtcmInfoView.xaml
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<c:MetroWindow x:Class="Plane.FormationCreator.Views.RtcmInfoView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:Plane.FormationCreator.Views"
|
||||||
|
xmlns:c="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="800"
|
||||||
|
Height="350" Width="1500" WindowStartupLocation="CenterScreen" Background="#FF2D2D2D" BorderBrush="#FF039AF0">
|
||||||
|
<Grid Margin="0,0,0,0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<StackPanel Margin="5" Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
|
<ComboBox Width="120" Height="25" Foreground="White" SelectedIndex="0"
|
||||||
|
ItemsSource="{Binding serialPorts, Mode=OneWay}"
|
||||||
|
SelectedValue="{Binding SerialPortsSelectdValue}"
|
||||||
|
DropDownOpened="ComboBox_DropDownOpened"/>
|
||||||
|
<Button Margin="6" Width="80" Height="28"
|
||||||
|
Content="{Binding RtcmManager.Rtcmthreadrun,Converter={StaticResource SendConverter}}"
|
||||||
|
Command="{Binding ConnectRtcmCommand}"/>
|
||||||
|
<Label Margin="6,6,0,6" Height="28" Content="总数:"/>
|
||||||
|
<Label Margin="0,6,6,6" Height="28" Content="{Binding RtcmManager.rtcmInfoList.Count,UpdateSourceTrigger=PropertyChanged}"></Label>
|
||||||
|
|
||||||
|
<Border Margin="10,5" BorderBrush="#FFB9B8B8" BorderThickness="1">
|
||||||
|
<StackPanel Margin="5" Orientation="Vertical">
|
||||||
|
<StackPanel Margin="5" Orientation="Horizontal">
|
||||||
|
<TextBlock Text="Input data rate "/>
|
||||||
|
<TextBlock TextAlignment="Right" Width="30"
|
||||||
|
Text="{Binding RtcmManager.Bps}"/>
|
||||||
|
<TextBlock Text=" bps: put data rate "/>
|
||||||
|
<TextBlock TextAlignment="Right" Width="30"
|
||||||
|
Text="{Binding RtcmManager.Bpsusefull}"/>
|
||||||
|
<TextBlock Text=" bps sent"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Margin="5" Orientation="Horizontal">
|
||||||
|
<TextBlock Text="Messages seen "/>
|
||||||
|
<TextBlock Text="{Binding RtcmManager.Messages_seen}"
|
||||||
|
/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<Border Margin="10,5" BorderBrush="#FFB9B8B8" BorderThickness="1">
|
||||||
|
<StackPanel Margin="5" Width="488">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Margin="5" Text="Base"/>
|
||||||
|
<Rectangle Margin="0,0,15,0" Width="20" Height="20"
|
||||||
|
Fill="{Binding RtcmManager.BaseState,Converter={StaticResource ColorConverter}}"/>
|
||||||
|
<TextBlock Margin="5" Text="Gps"/>
|
||||||
|
<Rectangle Margin="0,0,15,0" Width="20" Height="20"
|
||||||
|
Fill="{Binding RtcmManager.GlonassState,Converter={StaticResource ColorConverter}}"/>
|
||||||
|
<TextBlock Margin="5" Text="Glonass"/>
|
||||||
|
<Rectangle Margin="0,0,15,0" Width="20" Height="20"
|
||||||
|
Fill="{Binding RtcmManager.GpsState,Converter={StaticResource ColorConverter}}"/>
|
||||||
|
<TextBlock Margin="5" Text="Beidou"/>
|
||||||
|
<Rectangle Margin="0,0,15,0" Width="20" Height="20"
|
||||||
|
Fill="{Binding RtcmManager.BeidouState,Converter={StaticResource ColorConverter}}"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" >
|
||||||
|
<TextBlock Margin="5" Text="RTCM Base"/>
|
||||||
|
<TextBlock Margin="2,5" Text="{Binding RtcmManager.StationLat}"/>
|
||||||
|
<TextBlock Margin="2,5" Text="{Binding RtcmManager.StationLng}"/>
|
||||||
|
<TextBlock Margin="2,5" Text="{Binding RtcmManager.StationAlt}"/>
|
||||||
|
<TextBlock Margin="2,5" Text="-"/>
|
||||||
|
<TextBlock Margin="2,5" Text="{Binding RtcmManager.StationTime}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<ItemsControl Grid.Row="1"
|
||||||
|
ItemsSource="{Binding Path = RtcmManager.rtcmInfoList}"
|
||||||
|
>
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<UniformGrid Rows="1"></UniformGrid>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid >
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="15*" />
|
||||||
|
<RowDefinition Height="15*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<ProgressBar Margin="0.5"
|
||||||
|
Orientation="Vertical"
|
||||||
|
Minimum="25"
|
||||||
|
Maximum="55"
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
Value="{Binding Snr, UpdateSourceTrigger=PropertyChanged}"/>
|
||||||
|
<StackPanel Orientation ="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||||
|
<StackPanel Orientation ="Horizontal">
|
||||||
|
<TextBlock Text="{Binding Sys,UpdateSourceTrigger=PropertyChanged}" Foreground="Black"></TextBlock>
|
||||||
|
<TextBlock Text="{Binding Prn,UpdateSourceTrigger=PropertyChanged}" Foreground="Black"></TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock Margin="0,20,0,0" Text="{Binding Snr,UpdateSourceTrigger=PropertyChanged}" Foreground="Black"></TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="1" Orientation ="Vertical" HorizontalAlignment="Center">
|
||||||
|
<Line Stroke="Red" X2="1000" StrokeThickness="3" />
|
||||||
|
<TextBlock Text="40" Foreground="Black"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
|
||||||
|
</ItemsControl>
|
||||||
|
</Grid>
|
||||||
|
</c:MetroWindow>
|
56
Plane.FormationCreator/Views/RtcmInfoView.xaml.cs
Normal file
56
Plane.FormationCreator/Views/RtcmInfoView.xaml.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using MahApps.Metro.Controls;
|
||||||
|
using Microsoft.Practices.ServiceLocation;
|
||||||
|
using Plane.FormationCreator.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace Plane.FormationCreator.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// RtcmInfoView.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class RtcmInfoView : MetroWindow
|
||||||
|
{
|
||||||
|
private static RtcmInfoView staticInstance = null;
|
||||||
|
public static RtcmInfoView GetInstance()
|
||||||
|
{
|
||||||
|
if (staticInstance == null)
|
||||||
|
{
|
||||||
|
staticInstance = new RtcmInfoView();
|
||||||
|
}
|
||||||
|
return staticInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RtcmInfoViewModel _rtcmInfoViewModel = ServiceLocator.Current.GetInstance<RtcmInfoViewModel>();
|
||||||
|
public RtcmInfoView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.DataContext = _rtcmInfoViewModel;
|
||||||
|
this.Closed += WindowOnClosed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComboBox_DropDownOpened(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_rtcmInfoViewModel.RefreshPorts();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WindowOnClosed(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
staticInstance = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user