取消单个航点的FlytoTime和LoiterTime,

同一个任务每一架飞机的FlytoTime和LoiterTime保持统一
This commit is contained in:
zxd 2018-07-17 17:13:49 +08:00
parent 66fb5531a1
commit d6554486ab
5 changed files with 99 additions and 101 deletions

View File

@ -70,7 +70,22 @@ namespace Plane.FormationCreator.Formation
get { return _IsRightSelected; }
set { Set(nameof(IsRightSelected), ref _IsRightSelected, value); }
}
//同一个任务每一架飞机的FlytoTime和LoiterTime保持统一
private int _FlytoTime = 123;
public int FlytoTime
{
get { return _FlytoTime; }
set { Set(nameof(FlytoTime), ref _FlytoTime, value); }
}
private int _LoiterTime = 321;
public int LoiterTime
{
get { return _LoiterTime; }
set { Set(nameof(LoiterTime), ref _LoiterTime, value); }
}
public List<FlightTaskSingleCopterInfo> SingleCopterInfos { get; set; } = new List<FlightTaskSingleCopterInfo>();
private FlightTaskSingleCopterInfo _ModifyingSingleCopterInfo;

View File

@ -251,7 +251,7 @@ namespace Plane.FormationCreator.Formation
coptindex++;
var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, preSingleCopterInfo.TargetAlt, 10,10);
var newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(copter, targetLatLng.Item1, targetLatLng.Item2, preSingleCopterInfo.TargetAlt);
newSingleCopterInfo.TargetHeading = lastSingleCopterInfo.TargetHeading;
newSingleCopterInfo.CenterDirectionDeg = lastSingleCopterInfo.TargetHeading;
newTask.SingleCopterInfos.Add(newSingleCopterInfo);
@ -372,7 +372,7 @@ namespace Plane.FormationCreator.Formation
}
}
public void RestoreFlyToTask(bool staggerRoutes, dynamic singleCopterInfos)
public void RestoreFlyToTask(bool staggerRoutes, int flytoTime, int loiterTime, dynamic singleCopterInfos)
{
var copters = _copterManager.Copters;
float tagalt = 15;
@ -382,7 +382,8 @@ namespace Plane.FormationCreator.Formation
var nullableCenter = copters.GetCenter();
if (nullableCenter == null) return;
var center = nullableCenter.Value;
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes };
var newTask = new FlightTask(FlightTaskType.FlyTo) { StaggerRoutes = staggerRoutes, FlytoTime = flytoTime, LoiterTime = loiterTime };
// TODO: 林俊清, 20150801, 处理实际飞行器数目与记录中数目不一致的情况。
for (int i = 0; i < copters.Count; i++)
{
@ -394,17 +395,14 @@ namespace Plane.FormationCreator.Formation
tagalt = (float)singleCopterInfoObj.targetAlt;
newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask(
copter, new LatLng((double)singleCopterInfoObj.latOffset,
(double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt,
(int)singleCopterInfoObj.flytoTime,
(int)singleCopterInfoObj.loiterTime);
(double)singleCopterInfoObj.lngOffset), (float)singleCopterInfoObj.targetAlt);
}
else
{
//实际飞机比保存的任务计划的飞机多,多的飞机设置默认航点
newSingleCopterInfo = FlightTaskSingleCopterInfo.CreateForFlyToTask
(copter, (double)copter.Latitude, (double)copter.Longitude, tagalt, 10,10
);
(copter, (double)copter.Latitude, (double)copter.Longitude, tagalt);
}
newTask.SingleCopterInfos.Add(newSingleCopterInfo);
@ -646,6 +644,8 @@ namespace Plane.FormationCreator.Formation
{
type = type,
staggerRoutes = task.StaggerRoutes,
flytoTime = task.FlytoTime,
loiterTime = task.LoiterTime,
singleCopterInfos = task.SingleCopterInfos.Select(info =>
{
var offset = info.LatLngOffset;
@ -655,8 +655,6 @@ namespace Plane.FormationCreator.Formation
lngOffset = offset.Lng,
targetAlt = info.TargetAlt,
showLED = info.FlytoShowLED,
flytoTime = info.FlytoTime,
loiterTime = info.LoiterTime
};
})
};
@ -778,7 +776,7 @@ namespace Plane.FormationCreator.Formation
// TakeOffNumAttr = task.takeoffnumber;
break;
case FlightTaskType.FlyTo:
RestoreFlyToTask((bool)task.staggerRoutes, task.singleCopterInfos);
RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, task.singleCopterInfos);
break;
case FlightTaskType.Turn:
RestoreTurnTask(task.singleCopterInfos);
@ -819,7 +817,7 @@ namespace Plane.FormationCreator.Formation
TakeOffNumAttr = task.takeoffnumber;
break;
case FlightTaskType.FlyTo:
RestoreFlyToTask((bool)task.staggerRoutes, task.singleCopterInfos);
RestoreFlyToTask((bool)task.staggerRoutes, (int)task.flytoTime, (int)task.loiterTime, task.singleCopterInfos);
break;
case FlightTaskType.Turn:
RestoreTurnTask(task.singleCopterInfos);

View File

@ -12,30 +12,27 @@ namespace Plane.FormationCreator.Formation
{
public partial class FlightTaskSingleCopterInfo
{
public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, double targetLat, double targetLng, float targetAlt,int flytoTime,int loiterTime)
public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, double targetLat, double targetLng, float targetAlt)
{
var info = new FlightTaskSingleCopterInfo(copter)
{
TargetLat = targetLat,
TargetLng = targetLng,
TargetAlt = targetAlt,
FlytoTime= flytoTime,
LoiterTime = loiterTime
TargetAlt = targetAlt
};
return info;
}
public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, LatLng latLngOffset, float targetAlt, int flytoTime, int loiterTime)
public static FlightTaskSingleCopterInfo CreateForFlyToTask(ICopter copter, LatLng latLngOffset, float targetAlt)
{
var info = new FlightTaskSingleCopterInfo(copter)
{
LatLngOffset = latLngOffset,
TargetAlt = targetAlt,
FlytoTime = flytoTime,
LoiterTime = loiterTime
TargetAlt = targetAlt
};
return info;
}
private bool _FlytoShowLED = true;
public bool FlytoShowLED
{
@ -43,6 +40,10 @@ namespace Plane.FormationCreator.Formation
set { Set(nameof(FlytoShowLED), ref _FlytoShowLED, value); }
}
/*
* //同一个任务每一架飞机的FlytoTime和LoiterTime保持统一,已将FlytoTime和LoiterTime改到FlightTask.cs中
*
private int _FlytoTime = 10;
public int FlytoTime
{
@ -55,6 +56,8 @@ namespace Plane.FormationCreator.Formation
get { return _LoiterTime; }
set { Set(nameof(LoiterTime), ref _LoiterTime, value); }
}
*/
//设置飞机航点中灯光
private ICommand _ModiFlytoLEDCommand;
public ICommand ModiFlytoLEDCommand
@ -63,7 +66,9 @@ namespace Plane.FormationCreator.Formation
{
return _ModiFlytoLEDCommand ?? (_ModiFlytoLEDCommand = new RelayCommand<double>(async =>
{
Alert.Show("灯光控制");
//Alert.Show("灯光控制");
Views.modiLED LEDConfig = new Views.modiLED();
LEDConfig.ShowDialog();
}));
}
}

View File

@ -661,8 +661,10 @@ namespace Plane.FormationCreator.ViewModels
case FlightTaskType.FlyTo:
missions[missindex++] = Mission.CreateWaypointMission(
5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime,
5,// _flightTaskManager.Tasks[j].SingleCopterInfos[i].FlytoTime,
//5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime,
//5,// _flightTaskManager.Tasks[j].SingleCopterInfos[i].FlytoTime,
_flightTaskManager.Tasks[j].LoiterTime,
_flightTaskManager.Tasks[j].FlytoTime,
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat - _flightTaskManager.OriginLat,
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng,
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt);

View File

@ -8,19 +8,19 @@
xmlns:m="clr-namespace:Plane.FormationCreator.Formation"
mc:Ignorable="d"
d:DesignWidth="300" Height="420">
<StackPanel Orientation="Vertical" Margin="0,0,0,-30">
<TabControl>
<TabItem Header="航点设计">
<StackPanel Orientation="Vertical" Margin="0,0,0,-30">
<StackPanel.Resources>
<Style TargetType="StackPanel">
<Setter Property="Orientation"
Value="Horizontal" />
</Style>
</StackPanel.Resources>
<StackPanel>
<Button Content="导出任务"
Margin="0,5,0,0"
Command="{Binding ExportTasksCommand}" />
@ -45,6 +45,7 @@
Text="{Binding txtendindex, UpdateSourceTrigger=PropertyChanged}"
/>
</StackPanel>
<StackPanel>
<Button Content="上边对齐"
Margin="0,5,5,0"
@ -58,10 +59,8 @@
<Button Content="垂直均分"
Margin="0,5,5,0"
Command="{Binding VerticlAverageCommand}" />
</StackPanel>
<StackPanel>
<Button Content="水平旋转"
Margin="0,5,5,0"
@ -83,13 +82,9 @@
Text="0"
VerticalContentAlignment="Center" />
<TextBlock Text="度" Margin="0, 10, 5, 0"/>
</StackPanel>
<StackPanel>
<Button Content="缩放比例"
Margin="0,5,5,0"
Command="{Binding ScaleCommand}"
@ -103,71 +98,57 @@
<TextBlock Text="%" Margin="0, 10, 5, 0"/>
<Button Content="计算距离"
Margin="0,5,5,0"
Command="{Binding calDistinceCommand}"
/>
Command="{Binding calDistinceCommand}"/>
<TextBox
Grid.Column="1"
<TextBox Grid.Column="1"
Width="35"
Margin="0, 5, 5, 0"
HorizontalContentAlignment="Right"
Text="{Binding Distancevalue, UpdateSourceTrigger=PropertyChanged}"
/>
Text="{Binding Distancevalue, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="米" Margin="0, 10, 5, 0"/>
<Button Content="前一高度"
Margin="0,5,5,0"
Command="{Binding PrealtCommand}" />
</StackPanel>
<StackPanel>
<Button Content="整体提高"
Margin="0,5,5,0"
Command="{Binding ModiAltCommand}"
/>
Command="{Binding ModiAltCommand}"/>
<Button Content="整体移动"
Margin="0,5,5,0"
Command="{Binding ModiAllPosCommand}" />
Command="{Binding ModiAllPosCommand}" />
<TextBox
Grid.Column="1"
Width="40"
Margin="0, 5, 5, 0"
HorizontalContentAlignment="Right"
Text="{Binding Modialtvalue, UpdateSourceTrigger=PropertyChanged}"
/>
Grid.Column="1"
Width="40"
Margin="0, 5, 5, 0"
HorizontalContentAlignment="Right"
Text="{Binding Modialtvalue, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="米 方向" Margin="0, 10, 5, 0"/>
<TextBox
Grid.Column="1"
<TextBox Grid.Column="1"
Width="35"
Margin="0, 5, 5, 0"
HorizontalContentAlignment="Right"
Text="{Binding directionvalue, UpdateSourceTrigger=PropertyChanged}"
/>
Text="{Binding directionvalue, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="度" Margin="0, 10, 5, 0"/>
</StackPanel>
<Separator />
<StackPanel>
<TextBlock Text="起飞数量:" Margin="5,10,5,0" />
<TextBox x:Name="txttakeoff"
Width="25"
Margin="0,5,5,0"
VerticalContentAlignment="Center"
DataContext="{Binding FlightTaskManager}"
Text="{Binding TakeOffNumAttr, UpdateSourceTrigger=PropertyChanged}"
/>
Text="{Binding TakeOffNumAttr, UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
<TabControl Margin="0,5"
</StackPanel>
</TabItem>
<TabItem Header="航点参数">
<TabControl Margin="0,5"
Grid.IsSharedSizeScope="True"
DataContext="{Binding FlightTaskManager.SelectedTask}"
SelectedIndex="{Binding TaskTypeIndex}">
@ -204,48 +185,43 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0" DataContext="{Binding ModifyingSingleCopterInfo}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0" >
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="飞行时间: " />
<TextBox Grid.Column="1"
Margin="0,5,10,0"
<TextBlock Grid.Row="0" Text="飞行时间: " />
<TextBox Grid.Column="1" Margin="0,5,10,0"
Text="{Binding FlytoTime, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Row="1" Text="悬停时间: " />
<TextBox Grid.Row="1" Grid.Column="1"
Margin="0,5,10,0"
<TextBlock Grid.Row="1" Text="悬停时间: " />
<TextBox Grid.Row="1" Margin="0,5,10,0" Grid.Column="1"
Text="{Binding LoiterTime, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
<TextBlock Grid.Row="2" Text="灯光控制: " />
<Button Content="设置"
Grid.Row="2" Grid.Column="1"
<Separator Grid.Row="1" />
<Grid Grid.Row="2" DataContext="{Binding ModifyingSingleCopterInfo}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="灯光控制: " />
<Button Content="设置"
Grid.Column="1"
Margin="0,5,5,0"
Command="{Binding ModiFlytoLEDCommand}" />
</Grid>
<Separator Grid.Row="1" />
<Grid Grid.Row="2"
</Grid>
<Separator Grid.Row="3" />
<Grid Grid.Row="4"
DataContext="{Binding ModifyingSingleCopterInfo}"
IsEnabled="{Binding CanModifySingleCopterInfo}">
<Grid.RowDefinitions>
@ -596,5 +572,7 @@
</Grid>
</TabItem>-->
</TabControl>
</StackPanel>
</TabItem>
</TabControl>
</UserControl>