加入导入飞机位置选项
导出以前只是经纬差,改为距离差 加入文件标识和版本目前为2.0 加入文件飞机数量和实际数量不一致提醒 修改灯光设计的按钮在选中1架时会报错的bug
This commit is contained in:
parent
c27138d0e3
commit
f0ef8134d5
@ -104,11 +104,17 @@
|
||||
Command="{Binding ImportTasksCommand}"/>
|
||||
<StackPanel VerticalAlignment="Center" Margin="0,8,0,8" Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Foreground="#969696" VerticalAlignment="Center" Text="起始步骤:"/>
|
||||
<TextBox VerticalAlignment="Bottom" Width="40"
|
||||
<TextBox VerticalAlignment="Center" Width="40" Margin="0,0,5,0"
|
||||
Text="{Binding txtStarindex, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<TextBlock Foreground="#969696" VerticalAlignment="Center" Text="截止:"/>
|
||||
<TextBox VerticalAlignment="Bottom" Width="40"
|
||||
<TextBox VerticalAlignment="Center" Width="40" Margin="0,0,5,0"
|
||||
Text="{Binding txtendindex, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<CheckBox Content="飞机位置" Grid.Column="1" Margin="0,8,0,8" Foreground="#969696"
|
||||
IsChecked="{Binding isimpCopterLoc}" />
|
||||
|
||||
|
||||
|
||||
</StackPanel>
|
||||
<Button BorderThickness="1" BorderBrush="#FFFFFF" Content="导入分组信息" Margin="25,8,0,8" Grid.Row="2"
|
||||
Command="{Binding ImportGroupCommand}"/>
|
||||
|
@ -17,6 +17,7 @@ using Plane.Geography;
|
||||
using Plane.FormationCreator.Views;
|
||||
using System.Windows;
|
||||
using Plane.Collections;
|
||||
using Plane.Copters;
|
||||
|
||||
namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
@ -297,6 +298,22 @@ namespace Plane.FormationCreator.ViewModels
|
||||
set { Set(nameof(OnlyImpotWaypointS), ref _OnlyImpotWaypointS, value); }
|
||||
}
|
||||
|
||||
//导入飞机的位置
|
||||
private bool _isimpCopterLoc =true;
|
||||
public bool isimpCopterLoc
|
||||
{
|
||||
get { return _isimpCopterLoc; }
|
||||
set { Set(nameof(isimpCopterLoc), ref _isimpCopterLoc, value); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//导出飞机和航点等
|
||||
private ICommand _ExportTasksCommand;
|
||||
public ICommand ExportTasksCommand
|
||||
{
|
||||
@ -309,7 +326,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
Alert.Show("作为参照的原点未设置,无法导出相对位置!", "提示");
|
||||
return;
|
||||
}
|
||||
|
||||
bool isToMeter = false;
|
||||
var dialog = new SaveFileDialog
|
||||
{
|
||||
DefaultExt = "fcgm",
|
||||
@ -319,11 +336,16 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
IEnumerable<object> taskObject;
|
||||
string extension = Path.GetExtension(dialog.FileName);
|
||||
if (extension == ".fcgm")
|
||||
isToMeter = (extension == ".fcgm");
|
||||
|
||||
if (isToMeter)
|
||||
taskObject = _flightTaskManager.ExportTasksToMeter();
|
||||
else
|
||||
taskObject = _flightTaskManager.ExportTasks();
|
||||
|
||||
|
||||
|
||||
|
||||
string exportedText;
|
||||
|
||||
if (OnlyImpotWaypointS)
|
||||
@ -333,11 +355,15 @@ namespace Plane.FormationCreator.ViewModels
|
||||
else
|
||||
{
|
||||
var groupObject = _groupManager.ExportGroups();
|
||||
var locateObject = ExportLocate();
|
||||
|
||||
var locateObject = ExportLocate(isToMeter);
|
||||
|
||||
|
||||
object obj = new
|
||||
{
|
||||
ID="flycube.com",
|
||||
ver = "2.0",
|
||||
coptercount = _copterManager.Copters.Count,
|
||||
taskcount = _flightTaskManager.Tasks.Count,
|
||||
groups = groupObject,
|
||||
locate = locateObject,
|
||||
tasks = taskObject
|
||||
@ -354,21 +380,41 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private List<object> ExportLocate()
|
||||
private List<object> ExportLocate(bool isToMeter)
|
||||
{
|
||||
List<object> locateList = new List<object>();
|
||||
foreach (var copter in _copterManager.Copters)
|
||||
{
|
||||
double[] locate = new double[3];
|
||||
locate[0] = copter.Latitude - _flightTaskManager.OriginLat;
|
||||
locate[1] = copter.Longitude - _flightTaskManager.OriginLng;
|
||||
|
||||
if (isToMeter)
|
||||
{
|
||||
double x = GeographyUtils.CalcDistance(_flightTaskManager.OriginLat, _flightTaskManager.OriginLng, 0,
|
||||
_flightTaskManager.OriginLat, copter.Longitude, 0);
|
||||
if (copter.Longitude < _flightTaskManager.OriginLng) x = -x;
|
||||
|
||||
|
||||
double y = GeographyUtils.CalcDistance(_flightTaskManager.OriginLat, _flightTaskManager.OriginLng, 0,
|
||||
copter.Latitude, _flightTaskManager.OriginLng, 0);
|
||||
if (copter.Latitude < _flightTaskManager.OriginLat) y = -y;
|
||||
|
||||
locate[0] = x;
|
||||
locate[1] = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
//为了和老版本兼容
|
||||
locate[1] = copter.Longitude - _flightTaskManager.OriginLng;
|
||||
locate[0] = copter.Latitude - _flightTaskManager.OriginLat;
|
||||
}
|
||||
|
||||
|
||||
locate[2] = copter.GroundAlt;
|
||||
locateList.Add(locate);
|
||||
}
|
||||
return locateList;
|
||||
}
|
||||
|
||||
|
||||
private int _txtStarindex = 0;
|
||||
public int txtStarindex
|
||||
{
|
||||
@ -383,6 +429,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
set { Set(nameof(txtendindex), ref _txtendindex, value); }
|
||||
}
|
||||
|
||||
//导入航点
|
||||
private ICommand _ImportTasksCommand;
|
||||
public ICommand ImportTasksCommand
|
||||
{
|
||||
@ -404,7 +451,8 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
|
||||
|
||||
|
||||
string extension = Path.GetExtension(dialog.FileName);
|
||||
bool isMeter = extension == ".fcgm";
|
||||
int _startindex = txtStarindex;
|
||||
int _endindex = txtendindex;
|
||||
|
||||
@ -414,10 +462,31 @@ namespace Plane.FormationCreator.ViewModels
|
||||
dynamic taskinfo = null;
|
||||
if (importInfo is Newtonsoft.Json.Linq.JObject)
|
||||
{
|
||||
int ? filecoptercount = importInfo.coptercount;
|
||||
string ver = importInfo.ver;
|
||||
string ID = importInfo.ID;
|
||||
if ((ID!=null)&&(ID!="flycube.com"))
|
||||
{
|
||||
Alert.Show($"文件格式不正确", "提示");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if ((filecoptercount != null)&&(filecoptercount != _copterManager.Copters.Count ))
|
||||
{
|
||||
Alert.Show($"导入的飞机数量不符!导入飞机{filecoptercount},实际飞机{ _copterManager.Copters.Count}", "提示");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
taskinfo = importInfo.tasks;
|
||||
if (importInfo.locate != null)
|
||||
{
|
||||
ImportCoptersLocate(importInfo.locate);
|
||||
//老版本无论是fcgm还是fcg格式这个地方都存的经纬差,新版fcgm才用米为单位保存
|
||||
if ((ver != null) && (ver == "2.0"))
|
||||
ImportCoptersLocate(importInfo.locate, isMeter);
|
||||
else
|
||||
ImportCoptersLocate(importInfo.locate, false);
|
||||
}
|
||||
if (importInfo.groups != null)
|
||||
{
|
||||
@ -431,8 +500,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
|
||||
//int task Newtonsoft.Json.Linq.JArray
|
||||
|
||||
string extension = Path.GetExtension(dialog.FileName);
|
||||
bool isMeter = extension == ".fcgm";
|
||||
|
||||
|
||||
|
||||
if ((txtStarindex == 0) && (txtendindex == 0))
|
||||
@ -525,16 +593,54 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportCoptersLocate(dynamic coptersLocate)
|
||||
|
||||
private void ImportCoptersLocate(dynamic coptersLocate,bool isMeter)
|
||||
{
|
||||
//if (Newtonsoft.Json.Linq.JArray)
|
||||
try
|
||||
{
|
||||
int index = 0;
|
||||
bool loadxyLocate = isimpCopterLoc;
|
||||
foreach (var locate in coptersLocate)
|
||||
{
|
||||
_copterManager.Copters[index].GroundAlt = Convert.ToSingle(locate[2]);
|
||||
//虚拟飞机将读入保存时的位置
|
||||
if (loadxyLocate&&(_copterManager.Copters[index] is FakeCopter))
|
||||
{
|
||||
var fc = _copterManager.Copters[index] as FakeCopter;
|
||||
if (isMeter)
|
||||
{
|
||||
Tuple<double, double> observationLatLng = null;
|
||||
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||
_flightTaskManager.OriginLat,
|
||||
_flightTaskManager.OriginLng,
|
||||
90,
|
||||
Convert.ToSingle(locate[0]));
|
||||
double TargetLng = observationLatLng.Item2;
|
||||
|
||||
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||
_flightTaskManager.OriginLat,
|
||||
_flightTaskManager.OriginLng,
|
||||
0,
|
||||
Convert.ToSingle(locate[1]));
|
||||
double TargetLat = observationLatLng.Item1;
|
||||
|
||||
|
||||
fc.SetProperties(
|
||||
latitude: TargetLat,
|
||||
longitude: TargetLng
|
||||
);
|
||||
}else
|
||||
{
|
||||
double TargetLng = _flightTaskManager.OriginLng + Convert.ToSingle(locate[1]);
|
||||
double TargetLat = _flightTaskManager.OriginLat + Convert.ToSingle(locate[0]);
|
||||
fc.SetProperties(
|
||||
latitude:TargetLat,
|
||||
longitude: TargetLng
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
index++;
|
||||
|
||||
}
|
||||
|
@ -1774,7 +1774,8 @@ public ICommand VerticlAlignmentCommand
|
||||
{
|
||||
float CopterDirection =90- (float)BeltDirection ;
|
||||
|
||||
if (_copterManager.SelectedCopters.Count() <= 0)
|
||||
//必须大于1架
|
||||
if (_copterManager.SelectedCopters.Count() <= 1)
|
||||
return;
|
||||
|
||||
//旋转飞机矩阵
|
||||
@ -1893,7 +1894,8 @@ public ICommand VerticlAlignmentCommand
|
||||
{
|
||||
return _SetStrokesLampCommamd ?? (_SetStrokesLampCommamd = new RelayCommand(async () =>
|
||||
{
|
||||
if (_copterManager.SelectedCopters.Count() <= 0)
|
||||
//必须大于1架
|
||||
if (_copterManager.SelectedCopters.Count() <= 1)
|
||||
return;
|
||||
|
||||
|
||||
@ -1949,7 +1951,7 @@ public ICommand VerticlAlignmentCommand
|
||||
|
||||
|
||||
#region 渐变灯参数
|
||||
private double _GradientRampTime = 10;
|
||||
private double _GradientRampTime = 1;
|
||||
public double GradientRampTime
|
||||
{
|
||||
get { return _GradientRampTime; }
|
||||
@ -2106,8 +2108,12 @@ public ICommand VerticlAlignmentCommand
|
||||
LEDInfo endLed = new LEDInfo();
|
||||
endLed.LEDMode = 0;
|
||||
endLed.Delay = AlignmentTime - leddelay;
|
||||
endLed.LEDRGB = copterInfo.LEDInfos[copterInfo.LEDInfos.Count - 1].LEDRGB;
|
||||
copterInfo.AddLEDInfo(endLed);
|
||||
if (copterInfo.LEDInfos.Count > 0)
|
||||
endLed.LEDRGB = copterInfo.LEDInfos[copterInfo.LEDInfos.Count - 1].LEDRGB;
|
||||
else
|
||||
endLed.LEDRGB = "FFFFFF";
|
||||
|
||||
copterInfo.AddLEDInfo(endLed);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@ -2131,8 +2137,8 @@ public ICommand VerticlAlignmentCommand
|
||||
{
|
||||
|
||||
float CopterDirection = 90 - (float)GradualDirection;
|
||||
|
||||
if (_copterManager.SelectedCopters.Count() <= 0)
|
||||
//渐变需要2架以上
|
||||
if (_copterManager.SelectedCopters.Count() <= 1)
|
||||
return;
|
||||
|
||||
//旋转飞机矩阵
|
||||
@ -2184,9 +2190,22 @@ public ICommand VerticlAlignmentCommand
|
||||
LEDInfo led = new LEDInfo();
|
||||
led.LEDMode = 0;
|
||||
led.Delay = GradientRampTime;
|
||||
led.LEDRGB = "000000";
|
||||
|
||||
//led.LEDRGB = Convert.ToString(R, 16) + Convert.ToString(G, 16) + Convert.ToString(B, 16);
|
||||
led.LEDRGB = R.ToString("X2") + G.ToString("X2") + B.ToString("X2");
|
||||
|
||||
try
|
||||
{
|
||||
led.LEDRGB = R.ToString("X2") + G.ToString("X2") + B.ToString("X2");
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
//throw;
|
||||
}
|
||||
|
||||
|
||||
copterInfo.AddLEDInfo(led);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user