将Src0918的部分功能移植进来,还有倒计时,任务启动检查灯没有移植
1.shift多选航点 2.任务整体移动
This commit is contained in:
parent
074c5bdedf
commit
f31f08e530
@ -113,19 +113,27 @@ namespace Plane.FormationCreator
|
|||||||
*/
|
*/
|
||||||
MainWindow = new MainWindow();
|
MainWindow = new MainWindow();
|
||||||
MainWindow.Show();
|
MainWindow.Show();
|
||||||
|
try
|
||||||
TcpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
|
|
||||||
if (!TcpServerConnectionManager.Instance.StartListening())
|
|
||||||
{
|
{
|
||||||
Alert.Show("网络连接不正常,无法启动监听。");
|
|
||||||
|
TcpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
|
||||||
|
if (!TcpServerConnectionManager.Instance.StartListening())
|
||||||
|
{
|
||||||
|
Alert.Show("网络连接不正常,无法连接飞机。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
|
||||||
|
{
|
||||||
|
_logger.Log(e1.Exception);
|
||||||
|
};
|
||||||
|
UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
|
||||||
|
UdpServerConnectionManager.Instance.StartReceiving();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Alert.Show("网络连接不正常,无法连接飞机。");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UdpServerConnectionManager.Instance.ExceptionThrown += (sender, e1) =>
|
|
||||||
{
|
|
||||||
_logger.Log(e1.Exception);
|
|
||||||
};
|
|
||||||
UdpServerConnectionManager.Instance.ConnectionEstablished += ConnectionManager_ConnectionEstablished;
|
|
||||||
UdpServerConnectionManager.Instance.StartReceiving();
|
|
||||||
}
|
}
|
||||||
private void Copter_TextReceived(object sender, MessageCreatedEventArgs e)
|
private void Copter_TextReceived(object sender, MessageCreatedEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,8 @@ namespace Plane.FormationCreator
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_config.Center = $"{value.Lat},{value.Lng}";
|
if (_config != null)
|
||||||
|
_config.Center = $"{value.Lat},{value.Lng}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +90,8 @@ namespace Plane.FormationCreator
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_config.ZoomLevel = value;
|
if (_config != null)
|
||||||
|
_config.ZoomLevel = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +101,8 @@ namespace Plane.FormationCreator
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory(_dirPath);
|
Directory.CreateDirectory(_dirPath);
|
||||||
}
|
}
|
||||||
File.WriteAllText(_filePath, JsonConvert.SerializeObject(_config));
|
if (_config != null)
|
||||||
|
File.WriteAllText(_filePath, JsonConvert.SerializeObject(_config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
public bool shiftkeydown;
|
||||||
public IEnumerable<ICopter> SelectedCopters { get { return _selectedCoptersGetter().Cast<ICopter>(); } }
|
public IEnumerable<ICopter> SelectedCopters { get { return _selectedCoptersGetter().Cast<ICopter>(); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -62,8 +62,6 @@ namespace Plane.FormationCreator.Formation
|
|||||||
|
|
||||||
public static bool ArrivedTarget(this ICopter copter, double targetLat, double targetLng, float targetAlt)
|
public static bool ArrivedTarget(this ICopter copter, double targetLat, double targetLng, float targetAlt)
|
||||||
{
|
{
|
||||||
// return copter.DistanceTo(targetLat, targetLng, targetAlt) < 0.6; //到达航点精度
|
|
||||||
|
|
||||||
if (copter.GpsFixType == GpsFixType.RTKFIXED)
|
if (copter.GpsFixType == GpsFixType.RTKFIXED)
|
||||||
return copter.DistanceTo(targetLat, targetLng, targetAlt) < RTKArrivedDis; //RTK到达航点精度0.6米
|
return copter.DistanceTo(targetLat, targetLng, targetAlt) < RTKArrivedDis; //RTK到达航点精度0.6米
|
||||||
else
|
else
|
||||||
|
@ -224,7 +224,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
var newTask = new FlightTask(FlightTaskType.FlyTo);
|
var newTask = new FlightTask(FlightTaskType.FlyTo);
|
||||||
int coptindex = 0;
|
int coptindex = 0;
|
||||||
|
|
||||||
int colnum = 4; //自动生成列数=4
|
int colnum = 5; //自动生成列数=4
|
||||||
float coldis = 5;//列相距5米
|
float coldis = 5;//列相距5米
|
||||||
float rowdis = 5;//行相距5米
|
float rowdis = 5;//行相距5米
|
||||||
float matrixdis = 20; //生成方阵距离30米
|
float matrixdis = 20; //生成方阵距离30米
|
||||||
@ -363,6 +363,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
public void RestoreFlyToTask(bool staggerRoutes, dynamic singleCopterInfos)
|
public void RestoreFlyToTask(bool staggerRoutes, dynamic singleCopterInfos)
|
||||||
{
|
{
|
||||||
var copters = _copterManager.Copters;
|
var copters = _copterManager.Copters;
|
||||||
|
float tagalt = 15;
|
||||||
if (!copters.Any()) return;
|
if (!copters.Any()) return;
|
||||||
AppEx.Current.AppMode = AppMode.ModifyingTask;
|
AppEx.Current.AppMode = AppMode.ModifyingTask;
|
||||||
var lastTask = Tasks.LastOrDefault();
|
var lastTask = Tasks.LastOrDefault();
|
||||||
@ -371,11 +372,23 @@ namespace Plane.FormationCreator.Formation
|
|||||||
var center = nullableCenter.Value;
|
var center = nullableCenter.Value;
|
||||||
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes };
|
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes };
|
||||||
// TODO: 林俊清, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。
|
// TODO: 林俊清, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。
|
||||||
for (int i = 0; i < copters.Count && i < singleCopterInfos.Count; i++)
|
for (int i = 0; i < copters.Count; i++)
|
||||||
{
|
{
|
||||||
var copter = copters[i];
|
var copter = copters[i];
|
||||||
var singleCopterInfoObj = singleCopterInfos[i];
|
FlightTaskSingleCopterInfo newSingleCopterInfo;
|
||||||
var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt,(bool)singleCopterInfoObj.showLED);
|
if (i < singleCopterInfos.Count)
|
||||||
|
{
|
||||||
|
var singleCopterInfoObj = singleCopterInfos[i];
|
||||||
|
tagalt = (float)singleCopterInfoObj.targetAlt;
|
||||||
|
newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, new LatLng((double)singleCopterInfoObj.latOffset, (double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt, (bool)singleCopterInfoObj.showLED);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask
|
||||||
|
(copter, (double)copter.Latitude, (double)copter.Longitude, tagalt, (bool)false);
|
||||||
|
|
||||||
|
}
|
||||||
newTask.SingleCopterInfos.Add(newSingleCopterInfo);
|
newTask.SingleCopterInfos.Add(newSingleCopterInfo);
|
||||||
}
|
}
|
||||||
Tasks.Add(newTask);
|
Tasks.Add(newTask);
|
||||||
@ -493,7 +506,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
loiterTimeTask.HeadYaw = HeadYaw;
|
loiterTimeTask.HeadYaw = HeadYaw;
|
||||||
|
|
||||||
// foreach (var copter in copters)
|
// foreach (var copter in copters)
|
||||||
for (int i=0; i < copters.Count && i < singleCopterInfos.Count; i++)
|
for (int i = 0; i < copters.Count; i++)
|
||||||
{
|
{
|
||||||
var copter = copters[i];
|
var copter = copters[i];
|
||||||
var singleCopterInfoObj = singleCopterInfos[i];
|
var singleCopterInfoObj = singleCopterInfos[i];
|
||||||
|
@ -107,7 +107,9 @@ namespace Plane.FormationCreator
|
|||||||
|
|
||||||
case Key.LeftShift:
|
case Key.LeftShift:
|
||||||
{
|
{
|
||||||
|
var copters = _copterManager.AcceptingControlCopters;
|
||||||
Shiftkeydown = true;
|
Shiftkeydown = true;
|
||||||
|
_copterManager.shiftkeydown = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//开关SHOWLED
|
//开关SHOWLED
|
||||||
@ -359,6 +361,7 @@ namespace Plane.FormationCreator
|
|||||||
case Key.LeftShift:
|
case Key.LeftShift:
|
||||||
{
|
{
|
||||||
Shiftkeydown = false;
|
Shiftkeydown = false;
|
||||||
|
_copterManager.shiftkeydown = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Key.W:
|
case Key.W:
|
||||||
|
@ -54,7 +54,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
var center = _mapManager.Center;
|
var center = _mapManager.Center;
|
||||||
string id;
|
string id;
|
||||||
|
|
||||||
int colnum = 4; //自动生成列数=4
|
int colnum = 5; //自动生成列数=4
|
||||||
float coldis = 3;//列相距5米
|
float coldis = 3;//列相距5米
|
||||||
float rowdis = 3;//行相距5米
|
float rowdis = 3;//行相距5米
|
||||||
int currcol = 0; //当前列号
|
int currcol = 0; //当前列号
|
||||||
|
@ -175,6 +175,12 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
set { Set(nameof(txtendindex), ref _txtendindex, value); }
|
set { Set(nameof(txtendindex), ref _txtendindex, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float _directionvalue = 0;
|
||||||
|
public float directionvalue
|
||||||
|
{
|
||||||
|
get { return _directionvalue; }
|
||||||
|
set { Set(nameof(directionvalue), ref _directionvalue, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -263,7 +269,57 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//调整所有任务经度
|
||||||
|
private ICommand _ModiAllPosCommand;
|
||||||
|
public ICommand ModiAllPosCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _ModiAllPosCommand ?? (_ModiAllPosCommand = new RelayCommand<double>(async =>
|
||||||
|
{
|
||||||
|
if (_flightTaskManager.Tasks.Count < 2) return;
|
||||||
|
|
||||||
|
float lowalt = 200;
|
||||||
|
|
||||||
|
|
||||||
|
int _startindex = 0;
|
||||||
|
int _endindex = _flightTaskManager.Tasks.Count - 1;
|
||||||
|
int lowtask = 0;
|
||||||
|
int lowCopter = 0;
|
||||||
|
|
||||||
|
if ((txtStarindex != 0) && (txtendindex != 0))
|
||||||
|
{
|
||||||
|
_startindex = txtStarindex;
|
||||||
|
_endindex = txtendindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = _startindex; i <= _endindex; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((_flightTaskManager.Tasks[i].TaskType == FlightTaskType.TakeOff) ||
|
||||||
|
(_flightTaskManager.Tasks[i].TaskType == FlightTaskType.ReturnToLand))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
for (int j = 0; j < _flightTaskManager.Tasks[i].SingleCopterInfos.Count; j++)
|
||||||
|
{
|
||||||
|
Tuple<double, double> targetLatLng = new Tuple<double, double>(0, 0);
|
||||||
|
|
||||||
|
targetLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||||
|
_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat,
|
||||||
|
_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLng,
|
||||||
|
directionvalue,
|
||||||
|
Modialtvalue
|
||||||
|
);
|
||||||
|
_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLat = targetLatLng.Item1;
|
||||||
|
_flightTaskManager.Tasks[i].SingleCopterInfos[j].TargetLng = targetLatLng.Item2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Alert.Show("指定步骤任务位置已向" + directionvalue + "度改变" + Modialtvalue + "米,注意是否有障碍物!");
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private ICommand _LevelAverageCommand;
|
private ICommand _LevelAverageCommand;
|
||||||
@ -366,56 +422,59 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
bool copterisselect;
|
if (_flightTaskManager.SelectedTask != null)
|
||||||
int selectednumber = _copterManager.SelectedCopters.Count() - 1;
|
|
||||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
|
||||||
{
|
{
|
||||||
copterisselect = false;
|
bool copterisselect;
|
||||||
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
int selectednumber = _copterManager.SelectedCopters.Count() - 1;
|
||||||
foreach (var capter in _copterManager.SelectedCopters)
|
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
if (capter == selectedCopter)
|
copterisselect = false;
|
||||||
copterisselect = true;
|
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
if (capter == selectedCopter)
|
||||||
|
copterisselect = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (copterisselect)
|
||||||
|
{
|
||||||
|
|
||||||
|
tlat = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat;
|
||||||
|
if (minlat == 0)
|
||||||
|
minlat = tlat;
|
||||||
|
if (tlat > maxlat)
|
||||||
|
maxlat = tlat;
|
||||||
|
else if (tlat < minlat)
|
||||||
|
minlat = tlat;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (copterisselect)
|
avgl = (maxlat - minlat) / selectednumber;
|
||||||
|
int coptnum = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
|
copterisselect = false;
|
||||||
|
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
if (capter == selectedCopter)
|
||||||
|
copterisselect = true;
|
||||||
|
|
||||||
tlat = _flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat;
|
}
|
||||||
if (minlat == 0)
|
if (copterisselect)
|
||||||
minlat = tlat;
|
{
|
||||||
if (tlat > maxlat)
|
|
||||||
maxlat = tlat;
|
|
||||||
else if (tlat < minlat)
|
|
||||||
minlat = tlat;
|
|
||||||
|
|
||||||
|
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat = maxlat - avgl * coptnum;
|
||||||
|
coptnum++;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
|
||||||
|
// await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
}
|
}
|
||||||
avgl = (maxlat - minlat) / selectednumber;
|
|
||||||
int coptnum = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
|
||||||
{
|
|
||||||
copterisselect = false;
|
|
||||||
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
|
||||||
foreach (var capter in _copterManager.SelectedCopters)
|
|
||||||
{
|
|
||||||
if (capter == selectedCopter)
|
|
||||||
copterisselect = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (copterisselect)
|
|
||||||
{
|
|
||||||
|
|
||||||
_flightTaskManager.SelectedTask.SingleCopterInfos[i].TargetLat = maxlat - avgl * coptnum;
|
|
||||||
coptnum++;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////
|
|
||||||
|
|
||||||
// await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -437,7 +496,9 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
|
|
||||||
|
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
bool copterisselect;
|
if (_flightTaskManager.SelectedTask != null)
|
||||||
|
{
|
||||||
|
bool copterisselect;
|
||||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
copterisselect = false;
|
copterisselect = false;
|
||||||
@ -477,10 +538,33 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
//调整飞机
|
||||||
|
{
|
||||||
|
//模拟飞机才能调整
|
||||||
|
if (selectedCopter is FakeCopter)
|
||||||
|
{
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
tlat = capter.Latitude;
|
||||||
|
if (tlat > maxlat)
|
||||||
|
maxlat = tlat;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
var copterfk = (FakeCopter)capter;
|
||||||
|
copterfk.SetProperties(
|
||||||
|
latitude: maxlat,
|
||||||
|
longitude: copterfk.Longitude);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
//await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -505,7 +589,9 @@ public ICommand VerticlAlignmentCommand
|
|||||||
double tlng = 0;
|
double tlng = 0;
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
bool copterisselect;
|
bool copterisselect;
|
||||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
if (_flightTaskManager.SelectedTask != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
copterisselect = false;
|
copterisselect = false;
|
||||||
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
selectedCopter = _flightTaskManager.SelectedTask.SingleCopterInfos[i].Copter;
|
||||||
@ -544,11 +630,37 @@ public ICommand VerticlAlignmentCommand
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
|
||||||
|
|
||||||
}));
|
//await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
|
|
||||||
|
//await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
//调整飞机
|
||||||
|
{
|
||||||
|
//模拟飞机才能调整
|
||||||
|
if (selectedCopter is FakeCopter)
|
||||||
|
{
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
tlng = capter.Longitude;
|
||||||
|
if (tlng > maxlng)
|
||||||
|
maxlng = tlng;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
var copterfk = (FakeCopter)capter;
|
||||||
|
copterfk.SetProperties(
|
||||||
|
latitude: copterfk.Latitude,
|
||||||
|
longitude: maxlng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -623,6 +735,8 @@ public ICommand VerticlAlignmentCommand
|
|||||||
double centlng = 0;
|
double centlng = 0;
|
||||||
double centlat = 0;
|
double centlat = 0;
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
|
if (_flightTaskManager.SelectedTask != null)
|
||||||
|
{
|
||||||
bool copterisselect;
|
bool copterisselect;
|
||||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
@ -685,6 +799,56 @@ public ICommand VerticlAlignmentCommand
|
|||||||
////
|
////
|
||||||
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
//调整飞机
|
||||||
|
{
|
||||||
|
//模拟飞机才能调整
|
||||||
|
if (selectedCopter is FakeCopter)
|
||||||
|
{
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
lngsum += capter.Longitude;
|
||||||
|
latsum += capter.Latitude;
|
||||||
|
selectcount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算旋转中心
|
||||||
|
if (selectcount > 0)
|
||||||
|
{
|
||||||
|
centlng = lngsum / selectcount;
|
||||||
|
centlat = latsum / selectcount;
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
double lpDistance = CalculationLogLatDistance.GetDistanceOne(centlng, centlat,
|
||||||
|
capter.Longitude,
|
||||||
|
capter.Latitude);
|
||||||
|
|
||||||
|
CalculationLogLatDistance.MyLatLng mypos1, mypos2;
|
||||||
|
mypos1 = new CalculationLogLatDistance.MyLatLng(centlng, centlat);
|
||||||
|
mypos2 = new CalculationLogLatDistance.MyLatLng(
|
||||||
|
capter.Longitude
|
||||||
|
, capter.Latitude);
|
||||||
|
double lpAzimuth = CalculationLogLatDistance.getAngle(mypos1, mypos2);
|
||||||
|
double lng2 = 0;
|
||||||
|
double lat2 = 0;
|
||||||
|
CalculationLogLatDistance.ConvertDistanceToLogLat(centlng, centlat, lpDistance,
|
||||||
|
lpAzimuth + (double)RotateLine, out lng2, out lat2);
|
||||||
|
|
||||||
|
var copterfk = (FakeCopter)capter;
|
||||||
|
copterfk.SetProperties(
|
||||||
|
latitude: lat2,
|
||||||
|
longitude: lng2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -791,6 +955,8 @@ public ICommand VerticlAlignmentCommand
|
|||||||
double centlat = 0;
|
double centlat = 0;
|
||||||
double centalt = 0;
|
double centalt = 0;
|
||||||
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
|
if (_flightTaskManager.SelectedTask != null)
|
||||||
|
{
|
||||||
bool copterisselect;
|
bool copterisselect;
|
||||||
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
for (int i = 0; i < _flightTaskManager.SelectedTask.SingleCopterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
@ -888,7 +1054,7 @@ public ICommand VerticlAlignmentCommand
|
|||||||
|
|
||||||
|
|
||||||
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
|
|
||||||
_copterManager.SetSelectionDelegates(
|
_copterManager.SetSelectionDelegates(
|
||||||
() => lvwDrones.SelectedItems,
|
() => lvwDrones.SelectedItems,
|
||||||
copter => lvwDrones.SelectedItem = copter
|
SelectitemMessage
|
||||||
);
|
);
|
||||||
lvwDrones.SelectionChanged += (sender, e) =>
|
lvwDrones.SelectionChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
@ -41,5 +41,14 @@ namespace Plane.FormationCreator.Views
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||||
|
private void SelectitemMessage(ICopter copter)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (!_copterManager.shiftkeydown)
|
||||||
|
lvwDrones.SelectedItem = copter;
|
||||||
|
else
|
||||||
|
lvwDrones.SelectedItems.Add(copter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,6 +336,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
private void RegisterEventHandlersForTaskInfo(Ellipse wp, int taskIndex)
|
private void RegisterEventHandlersForTaskInfo(Ellipse wp, int taskIndex)
|
||||||
{
|
{
|
||||||
var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(i => i.Copter == this.Copter);
|
var info = _flightTaskManager.Tasks[taskIndex].SingleCopterInfos.FirstOrDefault(i => i.Copter == this.Copter);
|
||||||
|
if (info == null) return;
|
||||||
info.PropertyChanged += (sender, e) =>
|
info.PropertyChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
switch (e.PropertyName)
|
switch (e.PropertyName)
|
||||||
|
@ -71,18 +71,18 @@
|
|||||||
Margin="0,5,5,0"
|
Margin="0,5,5,0"
|
||||||
Command="{Binding VerticlRotateCommand}"
|
Command="{Binding VerticlRotateCommand}"
|
||||||
CommandParameter="{Binding ElementName=txtAlignmentLine, Path=Text}"/>
|
CommandParameter="{Binding ElementName=txtAlignmentLine, Path=Text}"/>
|
||||||
<TextBox x:Name="txtAlignmentLine"
|
|
||||||
Width="45"
|
<Button Content="整体旋转"
|
||||||
Margin="0,5,5,0"
|
|
||||||
Text="0"
|
|
||||||
VerticalContentAlignment="Center" />
|
|
||||||
<TextBlock Text="度" Margin="0, 10, 5, 0"/>
|
|
||||||
<Button Content="任务整体旋转"
|
|
||||||
Margin="0,5,5,0"
|
Margin="0,5,5,0"
|
||||||
Command="{Binding TaskRotateCommand}"
|
Command="{Binding TaskRotateCommand}"
|
||||||
CommandParameter="{Binding ElementName=txtAlignmentLine, Path=Text}"/>
|
CommandParameter="{Binding ElementName=txtAlignmentLine, Path=Text}"/>
|
||||||
|
|
||||||
|
<TextBox x:Name="txtAlignmentLine"
|
||||||
|
Width="35"
|
||||||
|
Margin="0,5,5,0"
|
||||||
|
Text="0"
|
||||||
|
VerticalContentAlignment="Center" />
|
||||||
|
<TextBlock Text="度" Margin="0, 10, 5, 0"/>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
@ -96,7 +96,7 @@
|
|||||||
CommandParameter="{Binding ElementName=txtScaleVale, Path=Text}"/>
|
CommandParameter="{Binding ElementName=txtScaleVale, Path=Text}"/>
|
||||||
|
|
||||||
<TextBox x:Name="txtScaleVale"
|
<TextBox x:Name="txtScaleVale"
|
||||||
Width="40"
|
Width="35"
|
||||||
Margin="0,5,5,0"
|
Margin="0,5,5,0"
|
||||||
Text="100"
|
Text="100"
|
||||||
VerticalContentAlignment="Center" />
|
VerticalContentAlignment="Center" />
|
||||||
@ -109,29 +109,27 @@
|
|||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="40"
|
Width="35"
|
||||||
Margin="0, 5, 5, 0"
|
Margin="0, 5, 5, 0"
|
||||||
HorizontalContentAlignment="Right"
|
HorizontalContentAlignment="Right"
|
||||||
Text="{Binding Distancevalue, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding Distancevalue, UpdateSourceTrigger=PropertyChanged}"
|
||||||
/>
|
/>
|
||||||
<TextBlock Text="米" Margin="0, 10, 5, 0"/>
|
<TextBlock Text="米" Margin="0, 10, 5, 0"/>
|
||||||
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel>
|
|
||||||
|
|
||||||
<Button Content="自动高度"
|
|
||||||
Margin="0,5,5,0"
|
|
||||||
Command="{Binding AutoaltCommand}" />
|
|
||||||
<Button Content="前一高度"
|
<Button Content="前一高度"
|
||||||
Margin="0,5,5,0"
|
Margin="0,5,5,0"
|
||||||
Command="{Binding PrealtCommand}" />
|
Command="{Binding PrealtCommand}" />
|
||||||
|
|
||||||
<Button Content="修改任务高度"
|
</StackPanel>
|
||||||
|
<StackPanel>
|
||||||
|
|
||||||
|
<Button Content="整体提高"
|
||||||
Margin="0,5,5,0"
|
Margin="0,5,5,0"
|
||||||
Command="{Binding ModiAltCommand}"
|
Command="{Binding ModiAltCommand}"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
<Button Content="整体移动"
|
||||||
|
Margin="0,5,5,0"
|
||||||
|
Command="{Binding ModiAllPosCommand}" />
|
||||||
<TextBox
|
<TextBox
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="40"
|
Width="40"
|
||||||
@ -139,8 +137,16 @@
|
|||||||
HorizontalContentAlignment="Right"
|
HorizontalContentAlignment="Right"
|
||||||
Text="{Binding Modialtvalue, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding Modialtvalue, UpdateSourceTrigger=PropertyChanged}"
|
||||||
/>
|
/>
|
||||||
<TextBlock Text="米" Margin="0, 10, 5, 0"/>
|
<TextBlock Text="米 方向" Margin="0, 10, 5, 0"/>
|
||||||
|
|
||||||
|
<TextBox
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="35"
|
||||||
|
Margin="0, 5, 5, 0"
|
||||||
|
HorizontalContentAlignment="Right"
|
||||||
|
Text="{Binding directionvalue, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
/>
|
||||||
|
<TextBlock Text="度" Margin="0, 10, 5, 0"/>
|
||||||
|
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
Loading…
Reference in New Issue
Block a user