取消单个航点的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; } get { return _IsRightSelected; }
set { Set(nameof(IsRightSelected), ref _IsRightSelected, value); } 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>(); public List<FlightTaskSingleCopterInfo> SingleCopterInfos { get; set; } = new List<FlightTaskSingleCopterInfo>();
private FlightTaskSingleCopterInfo _ModifyingSingleCopterInfo; private FlightTaskSingleCopterInfo _ModifyingSingleCopterInfo;

View File

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

View File

@ -12,30 +12,27 @@ namespace Plane.FormationCreator.Formation
{ {
public partial class FlightTaskSingleCopterInfo 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) var info = new FlightTaskSingleCopterInfo(copter)
{ {
TargetLat = targetLat, TargetLat = targetLat,
TargetLng = targetLng, TargetLng = targetLng,
TargetAlt = targetAlt, TargetAlt = targetAlt
FlytoTime= flytoTime,
LoiterTime = loiterTime
}; };
return info; 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) var info = new FlightTaskSingleCopterInfo(copter)
{ {
LatLngOffset = latLngOffset, LatLngOffset = latLngOffset,
TargetAlt = targetAlt, TargetAlt = targetAlt
FlytoTime = flytoTime,
LoiterTime = loiterTime
}; };
return info; return info;
} }
private bool _FlytoShowLED = true; private bool _FlytoShowLED = true;
public bool FlytoShowLED public bool FlytoShowLED
{ {
@ -43,6 +40,10 @@ namespace Plane.FormationCreator.Formation
set { Set(nameof(FlytoShowLED), ref _FlytoShowLED, value); } set { Set(nameof(FlytoShowLED), ref _FlytoShowLED, value); }
} }
/*
* //同一个任务每一架飞机的FlytoTime和LoiterTime保持统一,已将FlytoTime和LoiterTime改到FlightTask.cs中
*
private int _FlytoTime = 10; private int _FlytoTime = 10;
public int FlytoTime public int FlytoTime
{ {
@ -55,6 +56,8 @@ namespace Plane.FormationCreator.Formation
get { return _LoiterTime; } get { return _LoiterTime; }
set { Set(nameof(LoiterTime), ref _LoiterTime, value); } set { Set(nameof(LoiterTime), ref _LoiterTime, value); }
} }
*/
//设置飞机航点中灯光 //设置飞机航点中灯光
private ICommand _ModiFlytoLEDCommand; private ICommand _ModiFlytoLEDCommand;
public ICommand ModiFlytoLEDCommand public ICommand ModiFlytoLEDCommand
@ -63,7 +66,9 @@ namespace Plane.FormationCreator.Formation
{ {
return _ModiFlytoLEDCommand ?? (_ModiFlytoLEDCommand = new RelayCommand<double>(async => 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: case FlightTaskType.FlyTo:
missions[missindex++] = Mission.CreateWaypointMission( missions[missindex++] = Mission.CreateWaypointMission(
5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime, //5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime,
5,// _flightTaskManager.Tasks[j].SingleCopterInfos[i].FlytoTime, //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].TargetLat - _flightTaskManager.OriginLat,
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng - _flightTaskManager.OriginLng,
_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt); _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt);

View File

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