Revert "通信模块协议的添加和修改"
提交了前面版本未add的文件
添加了千寻Rtk发送:NTRIP
添加缺号统计
添加GPS类型统计
限制小武内蒙地区部分地区使用(相关代码已注释)
This reverts commit 725c4b6d71
.
This commit is contained in:
parent
725c4b6d71
commit
3cdecf8703
@ -140,13 +140,12 @@ namespace Plane.FormationCreator
|
||||
UdpServerConnectionManager.Instance.StartReceiving();
|
||||
*/
|
||||
|
||||
//初始化地面站连接
|
||||
CommModuleManager.Instance.CommunicationReceived += CommtionReceivedCopterInfo;
|
||||
CommModuleManager.Instance.CommunicationCopterDisconnect += CommCopterDisconnect;
|
||||
CommModuleManager.Instance.CommunicationConnected += CommCopterconnected;
|
||||
|
||||
|
||||
CommModuleManager.Instance.Connect();
|
||||
//CommModuleManager.Instance.test();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -23,6 +23,8 @@ namespace Plane.FormationCreator.Formation
|
||||
Brush = _brushes[NextBrushIndex()];
|
||||
RecordLat = lat;
|
||||
RecordLng = lng;
|
||||
Latitude = lat;
|
||||
Longitude = lng;
|
||||
//RaiseLocationChangedIfNeeded();
|
||||
}
|
||||
|
||||
|
@ -20,9 +20,13 @@ namespace Plane.FormationCreator.Formation
|
||||
/// <param name="baseSemObjects"></param>
|
||||
public int AddCopter(ICopter entityObject)
|
||||
{
|
||||
|
||||
////给第三方时候限制数量和时间用
|
||||
DateTime dateTime2019 = DateTime.Parse("2019-06-20");
|
||||
DateTime dateTime2019 = DateTime.Parse("2019-09-20");
|
||||
|
||||
//新增飞机区域限制:内蒙
|
||||
// if (entityObject.Latitude < 37.4307185218 || entityObject.Latitude > 45.6754821756
|
||||
// || entityObject.Longitude < 97.3493089056 || entityObject.Longitude > 115.8006783856)
|
||||
// return 0;
|
||||
|
||||
if (DateTime.UtcNow > dateTime2019)
|
||||
{
|
||||
|
@ -1374,13 +1374,19 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
}
|
||||
|
||||
TimeSpan timeSpan;
|
||||
DateTime taskStartTime;
|
||||
public async Task RunTaskAsync()
|
||||
|
||||
{
|
||||
Message.Show("任务开始");
|
||||
taskStartTime = DateTime.Now;
|
||||
Message.Show($"{DateTime.Now.ToString("HH:mm:ss")}:任务开始");
|
||||
await RunAsync();
|
||||
if ((IsPaused ?? false) == false)
|
||||
Message.Show("任务完成");
|
||||
{
|
||||
timeSpan = DateTime.Now - taskStartTime;
|
||||
Message.Show($"{DateTime.Now.ToString("HH:mm:ss")}:任务完成");
|
||||
Message.Show($"总时长 = {timeSpan.Minutes}分{timeSpan.Seconds}秒");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
|
@ -169,7 +169,7 @@ namespace Plane.FormationCreator.Formation
|
||||
if (prevTask.TaskType == FlightTaskType.FlyTo && prevTask.LoiterTime == 0)
|
||||
flyToTime += prevTask.RuningTaskRemaining;
|
||||
}
|
||||
int LEDIndex = 0;
|
||||
|
||||
//while (!info.Copter.ArrivedTarget(info.TargetLat, info.TargetLng, info.TargetAlt)) //按航点飞 :所有Copter到达目标点开始飞下个航点
|
||||
while (ts.TotalMilliseconds < (flyToTime + loiterTime)) //按时间轴飞:当前任务时间到达后自动飞往下个航点
|
||||
{
|
||||
@ -212,21 +212,20 @@ namespace Plane.FormationCreator.Formation
|
||||
double time = 0;
|
||||
for (int i = 0; i < LedControl.Count; i++)
|
||||
{
|
||||
|
||||
var led = LedControl[i];
|
||||
time += led.Delay * 1000;
|
||||
if (ts.TotalMilliseconds >= time)
|
||||
{
|
||||
LEDRGB = info.LEDInfos[i].LEDRGB;
|
||||
LEDIndex = i;
|
||||
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
Message.Show(LEDIndex.ToString());
|
||||
info.Copter.LEDColor = LEDRGB;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (ts.TotalMilliseconds / 10 > sendFlyToTimes) // 每500ms发送一遍指点坐标
|
||||
{
|
||||
sendFlyToTimes++;
|
||||
|
174
Plane.FormationCreator/Formation/GroupManager.cs
Normal file
174
Plane.FormationCreator/Formation/GroupManager.cs
Normal file
@ -0,0 +1,174 @@
|
||||
using Plane.Copters;
|
||||
using GalaSoft.MvvmLight;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Plane.FormationCreator.Util;
|
||||
using System.Windows.Input;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
|
||||
namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
public class GroupManager: ObservableObject
|
||||
{
|
||||
public ObservableCollection<CopterGroup> copterGroups { get; } = new ObservableCollection<CopterGroup>();
|
||||
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||
private string _LastSelectedGroup;
|
||||
public string LastSelectedGroup
|
||||
{
|
||||
get { return _LastSelectedGroup; }
|
||||
set { Set(nameof(LastSelectedGroup), ref _LastSelectedGroup, value); }
|
||||
}
|
||||
public GroupManager()
|
||||
{
|
||||
}
|
||||
|
||||
public void AddGroup(string name = "")
|
||||
{
|
||||
CopterGroup group = new CopterGroup(name);
|
||||
copterGroups.Add(group);
|
||||
group.RemoveGroupEvent += new CopterGroup.RemoveGroupEventHandler(GroupRemove);
|
||||
group.SelectedGroupEvent += new CopterGroup.SelectedGroupEventHandler(SelectedGroup);
|
||||
}
|
||||
|
||||
public void SelectedGroup(object sender)
|
||||
{
|
||||
CopterGroup groups = sender as CopterGroup;
|
||||
LastSelectedGroup = groups.groupName;
|
||||
}
|
||||
|
||||
public void GroupRemove(object sender)
|
||||
{
|
||||
CopterGroup groups = sender as CopterGroup;
|
||||
copterGroups.Remove(groups);
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<object> ExportGroups()
|
||||
{
|
||||
return copterGroups;
|
||||
}
|
||||
|
||||
public void ImportGroupsInfo(dynamic groupsInfo)
|
||||
{
|
||||
copterGroups.Clear();
|
||||
foreach (var group in groupsInfo)
|
||||
{
|
||||
string name = group.groupName;
|
||||
CopterGroup copterGroup = new CopterGroup(name);
|
||||
foreach (var index in group.copterIndexList)
|
||||
{
|
||||
copterGroup.copterIndexList.Add(Convert.ToInt32(index));
|
||||
}
|
||||
copterGroups.Add(copterGroup);
|
||||
copterGroup.RemoveGroupEvent += new CopterGroup.RemoveGroupEventHandler(GroupRemove);
|
||||
copterGroup.SelectedGroupEvent += new CopterGroup.SelectedGroupEventHandler(SelectedGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand _AddGroupsCommand;
|
||||
public ICommand AddGroupsCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AddGroupsCommand ?? (_AddGroupsCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
AddGroup();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class CopterGroup : ObservableObject
|
||||
{
|
||||
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||
public CopterGroup(string name = "")
|
||||
{
|
||||
groupName = name != "" ? name : "新分组";
|
||||
|
||||
}
|
||||
public string groupName { get; set; }
|
||||
public List<int> copterIndexList { get; } = new List<int>();
|
||||
|
||||
public delegate void RemoveGroupEventHandler(object sender);
|
||||
public event RemoveGroupEventHandler RemoveGroupEvent;
|
||||
private ICommand _RemoveGroupCommand;
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public ICommand RemoveGroupCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _RemoveGroupCommand ?? (_RemoveGroupCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
RemoveGroupEvent(this);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public delegate void SelectedGroupEventHandler(object sender);
|
||||
public event SelectedGroupEventHandler SelectedGroupEvent;
|
||||
private ICommand _SelectCoptersCommand;
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public ICommand SelectCoptersCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SelectCoptersCommand ?? (_SelectCoptersCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
_copterManager.Select(null);
|
||||
_copterManager.shiftkeydown = true;
|
||||
foreach (var copterIndex in copterIndexList)
|
||||
{
|
||||
//if (_copterManager.Copters.Count > copterIndex)
|
||||
// {
|
||||
//_copterManager.Select(_copterManager.Copters[copterIndex]);
|
||||
ICopter copter = null;
|
||||
// try
|
||||
// {
|
||||
// copter = _copterManager.Copters.First(o => o.Name == (copterIndex + 1).ToString());
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
copter = _copterManager.Copters.FirstOrDefault(o => o.Name == (copterIndex + 1).ToString());
|
||||
if (copter != null)
|
||||
{
|
||||
_copterManager.Select(copter);
|
||||
}
|
||||
//}
|
||||
}
|
||||
_copterManager.shiftkeydown = false;
|
||||
SelectedGroupEvent(this);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _SetGroupCoptersCommand;
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public ICommand SetGroupCoptersCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SetGroupCoptersCommand ?? (_SetGroupCoptersCommand = new RelayCommand<double>(async =>
|
||||
{
|
||||
copterIndexList.Clear();
|
||||
foreach (var copter in _copterManager.SelectedCopters)
|
||||
{
|
||||
copterIndexList.Add(_copterManager.Copters.IndexOf(copter));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -92,7 +92,7 @@
|
||||
<Button BorderThickness="1" Content="导出任务" Margin="0,8,0,8"
|
||||
Command="{Binding ExportTasksCommand}"/>
|
||||
<CheckBox Content="只导出航点" Grid.Column="1" Margin="0,8,0,8" Foreground="#969696"
|
||||
IsChecked="{Binding OnlyImpotWaypointS}"/>
|
||||
IsChecked="{Binding OnlyImpotWaypointS}" Visibility="Collapsed"/>
|
||||
<Button BorderThickness="1" BorderBrush="#FFFFFF" Content="导入任务" Margin="0,8,0,8" Grid.Row="1"
|
||||
Command="{Binding ImportTasksCommand}"/>
|
||||
<StackPanel VerticalAlignment="Center" Margin="0,8,0,8" Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||
@ -109,7 +109,7 @@
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<Menu Name="otherWindows" Background="Transparent" VerticalAlignment="Center">
|
||||
<Menu Name="otherWindows" Background="Transparent" VerticalAlignment="Center" Visibility="Collapsed">
|
||||
<MenuItem Header="窗口" Margin="0,2,0,0" Foreground="#969696">
|
||||
<CheckBox Content="属性设置" Margin="0,8,0,8" IsChecked="False" Click="btnAttribute_Click"/>
|
||||
<CheckBox Content="分组设置" Margin="0,8,0,8" IsChecked="False" Click="btnGroup_Click"/>
|
||||
|
@ -191,7 +191,10 @@
|
||||
<Compile Include="ServiceLocatorConfigurer.cs" />
|
||||
<Compile Include="Test.cs" />
|
||||
<Compile Include="CalculationLogLatDistance.cs" />
|
||||
<Compile Include="Util\CommNTRIP.cs" />
|
||||
<Compile Include="Util\ICorrections.cs" />
|
||||
<Compile Include="Util\ParamFile.cs" />
|
||||
<Compile Include="Util\rtcm3.cs" />
|
||||
<Compile Include="Util\VersionControl.cs" />
|
||||
<Compile Include="ViewModels\CalibrationViewModel.cs" />
|
||||
<Compile Include="ViewModels\ConnectViewModel.cs" />
|
||||
|
277
Plane.FormationCreator/Util/CommNTRIP.cs
Normal file
277
Plane.FormationCreator/Util/CommNTRIP.cs
Normal file
@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane.Util
|
||||
{
|
||||
public class CommNTRIP: IDisposable
|
||||
{
|
||||
public TcpClient client = new TcpClient();
|
||||
private Uri remoteUri;
|
||||
double Lat = 40.0910757034397;
|
||||
double Lng = 116.27734627295;
|
||||
double alt = 0;
|
||||
int retrys = 3;
|
||||
DateTime _lastnmea = DateTime.MinValue;
|
||||
public string Port { get; set; }
|
||||
|
||||
private string host;
|
||||
|
||||
|
||||
|
||||
private static int bytes = 0;
|
||||
private static int bps = 0;
|
||||
public int ReadTimeout
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public CommNTRIP(string url, double lat, double lng)
|
||||
{
|
||||
remoteUri = new Uri(url);
|
||||
this.Lat = lat;
|
||||
this.Lng = lng;
|
||||
ReadTimeout = 500;
|
||||
}
|
||||
|
||||
public void doConnect()
|
||||
{
|
||||
string usernamePassword = remoteUri.UserInfo;
|
||||
string userpass2 = Uri.UnescapeDataString(usernamePassword);
|
||||
string auth = "Authorization: Basic " +
|
||||
Convert.ToBase64String(new ASCIIEncoding().GetBytes(userpass2)) + "\r\n";
|
||||
|
||||
if (usernamePassword == "")
|
||||
auth = "";
|
||||
|
||||
host = remoteUri.Host;
|
||||
Port = remoteUri.Port.ToString();
|
||||
|
||||
client = new TcpClient(host, int.Parse(Port));
|
||||
client.Client.IOControl(IOControlCode.KeepAliveValues, TcpKeepAlive(true, 36000000, 3000), null);
|
||||
|
||||
NetworkStream ns = client.GetStream();
|
||||
|
||||
StreamWriter sw = new StreamWriter(ns);
|
||||
StreamReader sr = new StreamReader(ns);
|
||||
|
||||
string line = "GET " + remoteUri.PathAndQuery + " HTTP/1.0\r\n"
|
||||
+ "User-Agent: NTRIP MissionPlanner/1.0\r\n"
|
||||
+ auth
|
||||
+ "Connection: close\r\n\r\n";
|
||||
|
||||
sw.Write(line);
|
||||
sw.Flush();
|
||||
|
||||
line = sr.ReadLine();
|
||||
|
||||
Console.WriteLine(line);
|
||||
if (!line.Contains("200"))
|
||||
{
|
||||
client.Dispose();
|
||||
client = new TcpClient();
|
||||
throw new Exception("Bad ntrip Responce\n\n" + line);
|
||||
}
|
||||
|
||||
SendNMEA();
|
||||
|
||||
VerifyConnected();
|
||||
}
|
||||
|
||||
public int Read(byte[] readto, int offset, int length)
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (Lat != 0 || Lng != 0)
|
||||
{
|
||||
if (_lastnmea.AddSeconds(30) < DateTime.Now)
|
||||
{
|
||||
double latdms = (int)Lat + ((Lat - (int)Lat) * .6f);
|
||||
double lngdms = (int)Lng + ((Lng - (int)Lng) * .6f);
|
||||
|
||||
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",
|
||||
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,
|
||||
1, alt.ToString("0.00"), "M", 0, "M", "0.0", "0");
|
||||
|
||||
string checksum = GetChecksum(line);
|
||||
WriteLine(line + "*" + checksum);
|
||||
|
||||
_lastnmea = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int BytesToRead
|
||||
{
|
||||
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)
|
||||
{
|
||||
// Loop through all chars to get a checksum
|
||||
int Checksum = 0;
|
||||
foreach (char Character in sentence.ToCharArray())
|
||||
{
|
||||
switch (Character)
|
||||
{
|
||||
case '$':
|
||||
// Ignore the dollar sign
|
||||
break;
|
||||
case '*':
|
||||
// Stop processing before the asterisk
|
||||
continue;
|
||||
default:
|
||||
// Is this the first value for the checksum?
|
||||
if (Checksum == 0)
|
||||
{
|
||||
// Yes. Set the checksum to the value
|
||||
Checksum = Convert.ToByte(Character);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No. XOR the checksum with this character's value
|
||||
Checksum = Checksum ^ Convert.ToByte(Character);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Return the checksum formatted as a two-character hexadecimal
|
||||
return Checksum.ToString("X2");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
this.Close();
|
||||
client = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (client.Client != null && client.Client.Connected)
|
||||
{
|
||||
client.Client.Dispose();
|
||||
client.Dispose();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
client.Dispose();
|
||||
}
|
||||
catch { }
|
||||
|
||||
client = new TcpClient();
|
||||
}
|
||||
}
|
||||
}
|
24
Plane.FormationCreator/Util/ICorrections.cs
Normal file
24
Plane.FormationCreator/Util/ICorrections.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Plane.Util
|
||||
{
|
||||
public interface ICorrections
|
||||
{
|
||||
/// <summary>
|
||||
/// overall packet length (use for sending forward)
|
||||
/// </summary>
|
||||
int length { get; }
|
||||
/// <summary>
|
||||
/// raw packet data
|
||||
/// </summary>
|
||||
byte[] packet { get; }
|
||||
/// <summary>
|
||||
/// reset the parser to the initial state
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool resetParser();
|
||||
}
|
||||
}
|
2283
Plane.FormationCreator/Util/rtcm3.cs
Normal file
2283
Plane.FormationCreator/Util/rtcm3.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -86,7 +86,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _SendCommand ?? (_SendCommand = new RelayCommand(async () =>
|
||||
{
|
||||
await commModule.SetCommCount(CopterCount, (short)(CopterStartNum - 1));
|
||||
await SendCommandAsync(CopterNum);
|
||||
}
|
||||
));
|
||||
}
|
||||
@ -132,27 +132,6 @@ namespace Plane.FormationCreator.ViewModels
|
||||
set { Set(nameof(CopterColor), ref _CopterColor, value); }
|
||||
}
|
||||
|
||||
private byte _TransmittedPower = 5;
|
||||
public byte TransmittedPower
|
||||
{
|
||||
get { return _TransmittedPower; }
|
||||
set { Set(nameof(TransmittedPower), ref _TransmittedPower, value); }
|
||||
}
|
||||
|
||||
private short _CopterCount;
|
||||
public short CopterCount
|
||||
{
|
||||
get { return _CopterCount; }
|
||||
set { Set(nameof(CopterCount), ref _CopterCount, value); }
|
||||
}
|
||||
|
||||
private short _CopterStartNum;
|
||||
public short CopterStartNum
|
||||
{
|
||||
get { return _CopterStartNum; }
|
||||
set { Set(nameof(CopterStartNum), ref _CopterStartNum, value); }
|
||||
}
|
||||
|
||||
private ICommand _WriteIdCommand;
|
||||
public ICommand WriteIdCommand
|
||||
{
|
||||
@ -236,9 +215,6 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全部1S一次闪灯 主要用于测试通信
|
||||
/// </summary>
|
||||
private ICommand _CommDataAsync;
|
||||
public ICommand CommDataAsync
|
||||
{
|
||||
@ -252,54 +228,6 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置回传功率
|
||||
/// </summary>
|
||||
private ICommand _CommSetPowerAsync;
|
||||
public ICommand CommSetPowerAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommSetPowerAsync ?? (_CommSetPowerAsync = new RelayCommand(async () =>
|
||||
{
|
||||
if (TransmittedPower >= 1 && TransmittedPower <= 16)
|
||||
await commModule.SetCopterCommBackPower((short)CopterNum, TransmittedPower);
|
||||
else
|
||||
Alert.Show("功率范围只能设置为1-16");
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取配置
|
||||
/// </summary>
|
||||
private ICommand _CommGetCurrSysParmAsync;
|
||||
public ICommand CommGetCurrSysParmAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommGetCurrSysParmAsync ?? (_CommGetCurrSysParmAsync = new RelayCommand(async () =>
|
||||
{
|
||||
await commModule.GetCurr_Sys_Parm();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 改写配置
|
||||
/// </summary>
|
||||
private ICommand _CommSetCurrSysParmAsync;
|
||||
public ICommand CommSetCurrSysParmAsync
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CommSetCurrSysParmAsync ?? (_CommSetCurrSysParmAsync = new RelayCommand(async () =>
|
||||
{
|
||||
await commModule.SetCurr_Sys_Parm();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private List<IMission> CreateLEDMissions(IEnumerable<LEDInfo> LEDInfos)
|
||||
{
|
||||
List<IMission> missions = new List<IMission>();
|
||||
|
@ -30,6 +30,8 @@ namespace Plane.FormationCreator.ViewModels
|
||||
private static System.Threading.Thread thrtk;
|
||||
private static bool trkthreadrun = false;
|
||||
|
||||
private static bool rtcmthreadrun = false;
|
||||
|
||||
|
||||
|
||||
public ControlPanelViewModel(FormationController formationController, CopterManager copterManager)
|
||||
@ -66,6 +68,13 @@ namespace Plane.FormationCreator.ViewModels
|
||||
set { Set(nameof(RTKbtntxt), ref _RTKbtntxt, value); }
|
||||
}
|
||||
|
||||
private string _NTRIPbtntxt = "发送RTCM";
|
||||
public string NTRIPbtntxt
|
||||
{
|
||||
get { return _NTRIPbtntxt; }
|
||||
set { Set(nameof(NTRIPbtntxt), ref _NTRIPbtntxt, value); }
|
||||
}
|
||||
|
||||
private ICommand _LockAllCommand;
|
||||
public ICommand LockAllCommand
|
||||
{
|
||||
@ -211,6 +220,38 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _ReportGPSTypeCommand;
|
||||
public ICommand ReportGPSTypeCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ReportGPSTypeCommand ?? (_ReportGPSTypeCommand = new RelayCommand(async()=>
|
||||
{
|
||||
if (_copterManager.Copters.Count > 0)
|
||||
{
|
||||
Dictionary<string, List<string>> GPSTypes = new Dictionary<string, List<string>>();
|
||||
foreach (var copter in _copterManager.Copters)
|
||||
{
|
||||
string name = copter.Name;
|
||||
if (!GPSTypes.Keys.Contains(copter.GpsFixType.ToString()))
|
||||
{
|
||||
List<string> copterNames = new List<string>();
|
||||
copterNames.Add(name);
|
||||
GPSTypes.Add(copter.GpsFixType.ToString(), copterNames);
|
||||
}
|
||||
else
|
||||
GPSTypes[copter.GpsFixType.ToString()].Add(name);
|
||||
}
|
||||
|
||||
foreach (var item in GPSTypes)
|
||||
{
|
||||
Message.Show($"{item.Key}:{string.Join(",", item.Value)}");
|
||||
}
|
||||
}
|
||||
await Task.Delay(10);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _DetectionCommModuleVersion;
|
||||
public ICommand DetectionCommModuleVersion
|
||||
@ -461,11 +502,11 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return _RLTOffsetCommand ?? (_RLTOffsetCommand = new RelayCommand(async () =>
|
||||
return _RLTOffsetCommand ?? (_RLTOffsetCommand = new RelayCommand(() =>
|
||||
{
|
||||
Message.Show($"偏移Lat = {LatOffset},Lng = {LngOffset}");
|
||||
if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
|
||||
await _commModuleManager.RLTOffsetAsync(LatOffset, LngOffset, _copterManager.AcceptingControlCopters);
|
||||
// Message.Show($"偏移Lat = {LatOffset},Lng = {LngOffset}");
|
||||
// if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
|
||||
// await _commModuleManager.RLTOffsetAsync(LatOffset, LngOffset, _copterManager.AcceptingControlCopters);
|
||||
|
||||
|
||||
}));
|
||||
@ -830,10 +871,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
RTKState = "未发送RTK数据";
|
||||
RTKbtntxt = "发送RTK";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (!Rtkport.IsOpen)
|
||||
@ -845,31 +883,71 @@ namespace Plane.FormationCreator.ViewModels
|
||||
|
||||
while (trkthreadrun)
|
||||
{
|
||||
|
||||
await ReadRTKPacketAsync();
|
||||
|
||||
// if (await Rtkport.ReadAsync(buffer, 0, Math.Min(buffer.Length, 110)) > 0)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});*/
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand _SendRTCMCommand;
|
||||
public ICommand SendRTCMCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SendRTCMCommand ?? (_SendRTCMCommand = new RelayCommand(async () =>
|
||||
{
|
||||
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
||||
if (_flightTaskManager.OriginLat == 0 && _flightTaskManager.OriginLng == 0)
|
||||
{
|
||||
Alert.Show("作为参照的原点未设置,无法发送RTCM!", "提示");
|
||||
return;
|
||||
}
|
||||
|
||||
rtcmthreadrun = !rtcmthreadrun;
|
||||
if (rtcmthreadrun)
|
||||
{
|
||||
RTKState = "RTK数据发送中";
|
||||
NTRIPbtntxt = "停止RTCM";
|
||||
Alert.Show("RTCM数据开始发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
string url = "http://qxarpz003:1dc880b@rtk.ntrip.qxwz.com:8002/RTCM32_GGB";
|
||||
CommNTRIP commNTRIP = new CommNTRIP(url, _flightTaskManager.OriginLat, _flightTaskManager.OriginLng);
|
||||
rtcm3 rtcm3 = new rtcm3();
|
||||
commNTRIP.doConnect();
|
||||
//读取RTK数据循环
|
||||
while (rtcmthreadrun)
|
||||
{
|
||||
byte[] buffer = new byte[180];
|
||||
|
||||
while (commNTRIP.BytesToRead > 0)
|
||||
{
|
||||
int read = commNTRIP.Read(buffer, 0, Math.Min(buffer.Length, commNTRIP.BytesToRead));
|
||||
|
||||
for (int a = 0; a < read; a++)
|
||||
{
|
||||
int seenmsg = -1;
|
||||
// rtcm
|
||||
if ((seenmsg = rtcm3.Read(buffer[a])) > 0)
|
||||
{
|
||||
await _commModuleManager.InjectGpsRTCMDataAsync(rtcm3.packet, rtcm3.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
await Task.Delay(10);
|
||||
}
|
||||
NTRIPbtntxt = "发送RTCM";
|
||||
RTKState = "未发送RTK数据";
|
||||
Alert.Show("RTCM数据停止发送", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -1260,7 +1338,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
foreach (LEDInfo ledInfo in LEDInfos)
|
||||
{
|
||||
Color color = (Color)ColorConverter.ConvertFromString("#" + ledInfo.LEDRGB);
|
||||
//if (ledInfo.LEDMode == 5) ledInfo.LEDMode = 6;
|
||||
if (ledInfo.LEDMode == 8) ledInfo.LEDMode = 50;
|
||||
IMission LEDMission = Mission.CreateLEDControlMission(
|
||||
(int)(ledInfo.Delay * 10),
|
||||
ledInfo.LEDMode,
|
||||
|
@ -194,6 +194,14 @@ namespace Plane.FormationCreator.ViewModels
|
||||
Tuple<double, double> colheadLatLng = new Tuple<double, double>(0, 0);
|
||||
Tuple<double, double> targetLatLng = new Tuple<double, double>(0, 0);
|
||||
|
||||
|
||||
//内蒙地区
|
||||
// if (center.Lat < 37.4307185218 || center.Lat > 45.6754821756
|
||||
// || center.Lng < 97.3493089056 || center.Lng > 115.8006783856)
|
||||
// return ;
|
||||
|
||||
|
||||
|
||||
LatLng? colLatLng = new LatLng(center.Lat, center.Lng); ;
|
||||
|
||||
for (int i = 0; i < addcount; ++i, ++_virtualCopterId)
|
||||
@ -253,6 +261,37 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _ShowLackCopterNumsCommand;
|
||||
public ICommand ShowLackCopterNumsCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ShowLackCopterNumsCommand ?? (_ShowLackCopterNumsCommand = new RelayCommand(async () =>
|
||||
{
|
||||
if (_copterManager.Copters.Count == 0) return;
|
||||
ICopter lastCopter = _copterManager.Copters.Last();
|
||||
int name = int.Parse(lastCopter.Name);
|
||||
List<string> lackCopterNums = new List<string>();
|
||||
for (int i = 1; i <= name; i++)
|
||||
{
|
||||
ICopter copter = null;
|
||||
copter = _copterManager.Copters.FirstOrDefault(o=>o.Name == i.ToString());
|
||||
if (copter == null)
|
||||
lackCopterNums.Add(i.ToString());
|
||||
}
|
||||
if (lackCopterNums.Count > 0)
|
||||
{
|
||||
Windows.Messages.Message.Show($"未连接:{string.Join(",", lackCopterNums)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Windows.Messages.Message.Show($"{name}架全部连接");
|
||||
}
|
||||
await Task.Delay(10);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _SetCoptersPutCommand;
|
||||
public ICommand SetCoptersPutCommand
|
||||
{
|
||||
|
26
Plane.FormationCreator/ViewModels/GroupsViewModel.cs
Normal file
26
Plane.FormationCreator/ViewModels/GroupsViewModel.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using Plane.FormationCreator.Formation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
public class GroupsViewModel: ViewModelBase
|
||||
{
|
||||
GroupManager _groupManager;
|
||||
|
||||
public GroupsViewModel(GroupManager groupManager)
|
||||
{
|
||||
_groupManager = groupManager;
|
||||
}
|
||||
|
||||
public GroupManager GroupManager { get { return _groupManager; } }
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -68,8 +68,6 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@ -91,8 +89,7 @@
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel1"
|
||||
Visibility="Collapsed">
|
||||
Name="panel1">
|
||||
|
||||
<ec:ProgressButton HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
@ -136,7 +133,7 @@
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel2">
|
||||
<Button Content="通信模块状态" Margin="5" Command="{Binding Path=StateInquireCommand}"/>
|
||||
|
||||
<Button Content="设置总数" Margin="5" Command="{Binding Path=SendCommand}" />
|
||||
<Button Content="切换写航点" Margin="5" Command="{Binding Path=ChangeWriteMissionCommand}" />
|
||||
|
||||
|
||||
@ -145,44 +142,21 @@
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="3"
|
||||
Grid.ColumnSpan="3">
|
||||
<Label Content="ID:"/>
|
||||
<TextBox Margin="2,5,5,5" Width="30" Text="{Binding CopterNum}"></TextBox>
|
||||
<Button Content=" 对频 " Margin="5,5,0,5" Command="{Binding Path=WriteIdCommand}" />
|
||||
<Button Content=" 闪灯 " Margin="5" Command="{Binding CommDataAsync}"/>
|
||||
<Button Content="闪灯" Margin="5" Command="{Binding CommDataAsync}"/>
|
||||
<TextBox Width="80" Text="{Binding CopterColor}"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="4"
|
||||
Grid.ColumnSpan="3">
|
||||
<Button Content="设置回传功率" Command="{Binding CommSetPowerAsync}"/>
|
||||
<TextBox Margin="5,0" Width="80" Text="{Binding TransmittedPower}"/>
|
||||
<Button Margin="5,0" Content="读取配置" Command="{Binding CommGetCurrSysParmAsync}"/>
|
||||
<Button Margin="5,0" Content="写入配置" Command="{Binding CommSetCurrSysParmAsync}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="5"
|
||||
Grid.Row="4"
|
||||
Grid.ColumnSpan="3"
|
||||
Name="panel3">
|
||||
<Button Content="空中升级" Margin="5" Command="{Binding UpdateAllCopterCommand}"></Button>
|
||||
<Button Content="搜索飞机" Margin="5" Command="{Binding QueryAllCopterCommand}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
Grid.Row="6"
|
||||
Grid.ColumnSpan="3"
|
||||
>
|
||||
<Button Content="设置总数" Margin="5" Command="{Binding Path=SendCommand}" />
|
||||
<Label Content="总数:"/>
|
||||
<TextBox Width="50" Text="{Binding CopterCount}"/>
|
||||
<Label Content="起始号:"/>
|
||||
<TextBox Width="50" Text="{Binding CopterStartNum}"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</c:MetroWindow>
|
||||
|
@ -81,14 +81,16 @@
|
||||
<WrapPanel>
|
||||
|
||||
<Button Content="选写航点"
|
||||
Command="{Binding WriteMissionSingleCommand}" />
|
||||
Command="{Binding WriteMissionSingleCommand}" />
|
||||
<Button Content="定位统计"
|
||||
Command="{Binding ReportGPSTypeCommand}"/>
|
||||
<Button Content="统计模块"
|
||||
Command="{Binding DetectionCommModuleVersion}" />
|
||||
<Label>Lat</Label>
|
||||
<TextBox Text="{Binding LatOffset}" Width="50"/>
|
||||
<Label>Lng</Label>
|
||||
<TextBox Text="{Binding LngOffset}" Width="50"/>
|
||||
<Button Content="设置返航点"
|
||||
Command="{Binding DetectionCommModuleVersion}" />
|
||||
<Label Visibility="Collapsed">Lat</Label>
|
||||
<TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/>
|
||||
<Label Visibility="Collapsed">Lng</Label>
|
||||
<TextBox Visibility="Collapsed" Text="{Binding LngOffset}" Width="50"/>
|
||||
<Button Visibility="Collapsed" Content="设置返航点"
|
||||
Command="{Binding RLTOffsetCommand}" />
|
||||
</WrapPanel>
|
||||
<Separator/>
|
||||
@ -131,8 +133,10 @@
|
||||
/>
|
||||
|
||||
<Button Content="{Binding Path=RTKbtntxt}"
|
||||
|
||||
Command="{Binding SendRTKCommand}" />
|
||||
|
||||
<Button Content="{Binding Path=NTRIPbtntxt}"
|
||||
Command="{Binding SendRTCMCommand}" />
|
||||
<TextBlock
|
||||
Margin="5,5,5,5"
|
||||
Text="{Binding Path=RTKState}"
|
||||
|
32
Plane.FormationCreator/Views/CopterAttributeView.xaml
Normal file
32
Plane.FormationCreator/Views/CopterAttributeView.xaml
Normal file
@ -0,0 +1,32 @@
|
||||
<UserControl x:Class="Plane.FormationCreator.Views.CopterAttributeView"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
BorderThickness="1"
|
||||
Background="#FF2D2D2D" Width="464">
|
||||
<UserControl.BorderBrush>
|
||||
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ActiveBorderColorKey}}"/>
|
||||
</UserControl.BorderBrush>
|
||||
|
||||
<Grid Margin="5" >
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Label Margin="5,0,0,0" Content="属性设置" VerticalAlignment="Center"/>
|
||||
<Separator></Separator>
|
||||
<StackPanel Margin="5,0,0,5" Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<Label Margin="0" Content="摆放高度" ></Label>
|
||||
<TextBox
|
||||
Margin="30,0"
|
||||
Width="80"
|
||||
Text="{Binding SelectedCopter.GroundAlt,UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<Button
|
||||
Width="120"
|
||||
Content="应用到所选"
|
||||
Command="{Binding ApplyGroundAltCommand}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
31
Plane.FormationCreator/Views/CopterAttributeView.xaml.cs
Normal file
31
Plane.FormationCreator/Views/CopterAttributeView.xaml.cs
Normal file
@ -0,0 +1,31 @@
|
||||
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>
|
||||
/// CopterAttributeView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CopterAttributeView : UserControl
|
||||
{
|
||||
public CopterAttributeView()
|
||||
{
|
||||
InitializeComponent();
|
||||
//this.DataContext = ServiceLocator.Current.GetInstance<CopterAttributeViewModel>();
|
||||
}
|
||||
}
|
||||
}
|
61
Plane.FormationCreator/Views/CopterGroupsView.xaml
Normal file
61
Plane.FormationCreator/Views/CopterGroupsView.xaml
Normal file
@ -0,0 +1,61 @@
|
||||
<UserControl x:Class="Plane.FormationCreator.Views.CopterGroupsView"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
BorderThickness="1"
|
||||
Background="#FF2D2D2D" Width="464" Height="300">
|
||||
<UserControl.BorderBrush>
|
||||
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ActiveBorderColorKey}}"/>
|
||||
</UserControl.BorderBrush>
|
||||
<Grid Margin="5" >
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Margin="5,0" Content="分组设置" HorizontalAlignment="Left" />
|
||||
<Label Margin="15,0" Grid.Column="1" Content="最后选中:" HorizontalAlignment="Left"/>
|
||||
<Label Grid.Column="1" Content="{Binding GroupManager.LastSelectedGroup}" HorizontalAlignment="Right"/>
|
||||
<Button Margin="5,0" Grid.Column="2" Content="添加分组" HorizontalAlignment="Right"
|
||||
Command="{Binding Path=GroupManager.AddGroupsCommand}"/>
|
||||
</Grid>
|
||||
<Separator></Separator>
|
||||
<ItemsControl
|
||||
MinHeight="180"
|
||||
MaxHeight="240"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
|
||||
ItemsSource="{Binding Path= GroupManager.copterGroups}">
|
||||
<ItemsControl.Template>
|
||||
<ControlTemplate>
|
||||
<ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}">
|
||||
<ItemsPresenter />
|
||||
</ScrollViewer>
|
||||
</ControlTemplate>
|
||||
</ItemsControl.Template>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBox Width="95" Text="{Binding groupName,UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<Button Margin="20,0,0,0" Width="90" Content="删除" Command="{Binding RemoveGroupCommand}"/>
|
||||
<Button Margin="20,0,0,0" Width="90" Content="设置" Command="{Binding SetGroupCoptersCommand}"/>
|
||||
<Button Margin="20,0,0,0" Width="90" Content="选中" Command="{Binding SelectCoptersCommand}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
32
Plane.FormationCreator/Views/CopterGroupsView.xaml.cs
Normal file
32
Plane.FormationCreator/Views/CopterGroupsView.xaml.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using Microsoft.Practices.ServiceLocation;
|
||||
using Plane.FormationCreator.Formation;
|
||||
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>
|
||||
/// CopterGroupsView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CopterGroupsView : UserControl
|
||||
{
|
||||
public CopterGroupsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = ServiceLocator.Current.GetInstance<GroupsViewModel>();
|
||||
}
|
||||
}
|
||||
}
|
@ -87,12 +87,15 @@
|
||||
VerticalContentAlignment="Center"
|
||||
Command="{Binding AddVirtualCopterCommand}"
|
||||
CommandParameter="{Binding Text, ElementName=txtVirtualCopterCount}" />
|
||||
<Button Content="导入飞机位置"
|
||||
<Button Visibility="Collapsed" Content="导入飞机位置"
|
||||
Margin="5,0,0,0"
|
||||
Command="{Binding ImportCoptersLocationCommand}"/>
|
||||
<Button Content="清除"
|
||||
Margin="5,0,0,0"
|
||||
Command="{Binding ClearCoptersCommand}" />
|
||||
<Button Content="缺号统计"
|
||||
Margin="5,0,0,0"
|
||||
Command="{Binding ShowLackCopterNumsCommand}"/>
|
||||
<Button Content="设置"
|
||||
Margin="5,0,5,0"
|
||||
Command="{Binding SetCoptersPutCommand}" />
|
||||
|
@ -81,7 +81,8 @@
|
||||
Visibility="Collapsed"/>
|
||||
<Button Content="优化路线" Command="{Binding OptimizeRouteCommand}"
|
||||
Visibility="Collapsed"/>
|
||||
<Button Content="导入航点" Command="{Binding ImportBlenderWayPointCommand}"/>
|
||||
<Button Content="导入航点" Command="{Binding ImportBlenderWayPointCommand}"
|
||||
Visibility="Collapsed"/>
|
||||
</StackPanel>
|
||||
|
||||
<Separator Margin="0,1"/>
|
||||
@ -412,6 +413,7 @@
|
||||
<ComboBoxItem Content="呼吸灯" />
|
||||
<ComboBoxItem Content="同步闪烁(随机)" />
|
||||
<ComboBoxItem Content="异步闪烁(单色)" />
|
||||
<ComboBoxItem Content="拉烟"/>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Text="时间" Margin="12,0,0,0" VerticalAlignment="Center"></TextBlock>
|
||||
|
Loading…
Reference in New Issue
Block a user