1,加入回传功率设置,在设置窗口里面
2. 增加删除按钮,可以删除不存在的飞机 3. 发送起飞从10次变为20次重复 4.加入256个航点的任务限制提示 5.加入计算任务数按钮
This commit is contained in:
parent
512d9e5386
commit
09da3f24ba
@ -25,7 +25,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
public class CopterCollection : ObservableCollection<ICopter>
|
public class CopterCollection : ObservableCollection<ICopter>
|
||||||
{
|
{
|
||||||
//软件过期时间---过期将无法添加飞机,并自动退出
|
//软件过期时间---过期将无法添加飞机,并自动退出
|
||||||
public static DateTime Expire_App = DateTime.Parse("2022-06-10");
|
public static DateTime Expire_App = DateTime.Parse("2022-12-31");
|
||||||
//超级用户过期时间--过期将无法使用内置超级用户登录
|
//超级用户过期时间--过期将无法使用内置超级用户登录
|
||||||
public static DateTime Expire_SuperUser = Expire_App;
|
public static DateTime Expire_SuperUser = Expire_App;
|
||||||
//允许飞行的飞机数量
|
//允许飞行的飞机数量
|
||||||
@ -627,7 +627,9 @@ namespace Plane.FormationCreator.Formation
|
|||||||
|
|
||||||
if ((username== supername) && (password== superpass) &&(DateTime.UtcNow < CopterCollection.Expire_SuperUser) )
|
if ((username== supername) && (password== superpass) &&(DateTime.UtcNow < CopterCollection.Expire_SuperUser) )
|
||||||
{
|
{
|
||||||
NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN);
|
// NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN);
|
||||||
|
NetLogined(supername, superDispname,6, 50, LEVEL_NORMAL);
|
||||||
|
VersionControl.SaveLogininfoToIni(supername, superpass, savepassword); //超级密码是否保存---不要就不保存
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,6 +778,38 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public async Task DelSelCopters()
|
||||||
|
{
|
||||||
|
if (AcceptingControlCopters == null || AcceptingControlCopters.Count() ==0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var copter in AcceptingControlCopters)
|
||||||
|
{
|
||||||
|
await copter.DisconnectAsync();
|
||||||
|
|
||||||
|
if(Copters.Contains(copter))
|
||||||
|
{
|
||||||
|
Copters.Remove(copter);
|
||||||
|
}
|
||||||
|
|
||||||
|
//标记是否跳过,这个已经没用了,随便删除第一个
|
||||||
|
CopterStatus.RemoveAt(0);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
await Task.Delay(100); // 如果不等待一段时间,很可能会再触发 DataStreamReceived 事件导致飞行器重新出现在地图上。
|
||||||
|
|
||||||
|
//wifi
|
||||||
|
// if (VersionControl.ConType == 1)
|
||||||
|
// UdpServerConnectionManager.Instance.ClearConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool EnAddCopter_Real()
|
public bool EnAddCopter_Real()
|
||||||
{
|
{
|
||||||
if (EnCopterNumber == -1) return true;
|
if (EnCopterNumber == -1) return true;
|
||||||
|
@ -222,7 +222,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
{
|
{
|
||||||
str = ts.Seconds + "秒";
|
str = ts.Seconds + "秒";
|
||||||
}
|
}
|
||||||
Message.ShowStatus($"选中 [{value.TaskIndex+1} {value.TaskCnName }] 从{str}开始执行,需{ GetTaskTime(value.TaskIndex)}秒");
|
Message.ShowStatus($"选中 [{value.TaskIndex+1} {value.TaskCnName }] 从{str}开始执行,需{ GetTaskTime(value.TaskIndex)}秒,共{Tasks.Count}个任务");
|
||||||
}
|
}
|
||||||
else Message.ShowStatus($"无任务选中");
|
else Message.ShowStatus($"无任务选中");
|
||||||
|
|
||||||
|
@ -133,15 +133,16 @@ namespace Plane.FormationCreator.Formation
|
|||||||
// {
|
// {
|
||||||
//_copterManager.Select(_copterManager.Copters[copterIndex]);
|
//_copterManager.Select(_copterManager.Copters[copterIndex]);
|
||||||
ICopter copter = null;
|
ICopter copter = null;
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// copter = _copterManager.Copters.First(o => o.Name == (copterIndex + 1).ToString());
|
// copter = _copterManager.Copters.First(o => o.Name == (copterIndex + 1).ToString());
|
||||||
// }
|
// }
|
||||||
// catch (Exception)
|
// catch (Exception)
|
||||||
// {
|
// {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
copter = _copterManager.Copters.FirstOrDefault(o => o.Name == (copterIndex + 1).ToString());
|
string strcoptername = _copterManager.Copters[copterIndex].Name;
|
||||||
|
copter = _copterManager.Copters.FirstOrDefault(o => o.Name == strcoptername);
|
||||||
if (copter != null)
|
if (copter != null)
|
||||||
{
|
{
|
||||||
_copterManager.Select(copter);
|
_copterManager.Select(copter);
|
||||||
|
@ -273,8 +273,10 @@
|
|||||||
<TextBlock Margin="10,4" Width="400"
|
<TextBlock Margin="10,4" Width="400"
|
||||||
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
|
Text="{Binding CopterListViewModel.SelectedCopter.StatusText}" />
|
||||||
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
|
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
|
||||||
<TextBlock Margin="10,4" Width="400"
|
<TextBlock Margin="10,4" Width="200"
|
||||||
Text="{Binding ControlPanelViewModel.RTKState}" />
|
Text="{Binding ControlPanelViewModel.RTKState}" />
|
||||||
|
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" Margin="0,8" BorderBrush="LightGray" BorderThickness="1"/>
|
||||||
|
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
|
@ -256,6 +256,20 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ICommand _SetModulePowerCommand;
|
||||||
|
public ICommand SetModulePowerCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _SetModulePowerCommand ?? (_SetModulePowerCommand = new RelayCommand(async () =>
|
||||||
|
{
|
||||||
|
int mPower = int.Parse(CopterColor);
|
||||||
|
await commModule.SetModulePower((short)CopterNum, (short)mPower);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private ICommand _CommDataAsync;
|
private ICommand _CommDataAsync;
|
||||||
public ICommand CommDataAsync
|
public ICommand CommDataAsync
|
||||||
|
@ -126,54 +126,69 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
minVol = float.Parse(inputDialog.Answer);
|
minVol = float.Parse(inputDialog.Answer);
|
||||||
else return;
|
else return;
|
||||||
|
|
||||||
//测试电池
|
//测试电池
|
||||||
await _commModuleManager.TestBattery((short)0, minVol);
|
await _commModuleManager.TestBattery((short)0, minVol);
|
||||||
if (minVol == 0.0) return;
|
if (minVol == 0.0) return;
|
||||||
Message.Show("---请检查飞机灯光---");
|
Message.Show("---请检查飞机灯光---");
|
||||||
Message.Show(string.Format("---绿 色 电压高于 {0:F2}v (单节高于 {1:F2}v)--- ", minVol , minVol / 4.0f));
|
Message.Show(string.Format("---绿 色 电压高于 {0:F2}v (单节高于 {1:F2}v)--- ", minVol, minVol / 4.0f));
|
||||||
Message.Show(string.Format("---黄 色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol , minVol / 4.0f));
|
Message.Show(string.Format("---黄 色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol, minVol / 4.0f));
|
||||||
Message.Show(string.Format("---棕 色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.2, (minVol - 0.2) / 4.0f));
|
Message.Show(string.Format("---棕 色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.2, (minVol - 0.2) / 4.0f));
|
||||||
Message.Show(string.Format("---洋红色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.4, (minVol - 0.4) / 4.0f));
|
Message.Show(string.Format("---洋红色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.4, (minVol - 0.4) / 4.0f));
|
||||||
Message.Show(string.Format("---亮红色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.6, (minVol - 0.6) / 4.0f));
|
Message.Show(string.Format("---亮红色 电压低于 {0:F2}v (单节低于 {1:F2}v)--- ", minVol - 0.6, (minVol - 0.6) / 4.0f));
|
||||||
Message.Show("---输入0恢复灯光---");
|
Message.Show("---输入0恢复灯光---");
|
||||||
|
|
||||||
Message.Show("--------------开始检测单机电压--------------");
|
Message.Show("--------------开始检测单机电压--------------");
|
||||||
Dictionary<string, float> dic_voltage = new Dictionary<string, float>();
|
Dictionary<string, float> dic_voltage = new Dictionary<string, float>();
|
||||||
await Task.WhenAll(_copterManager.Copters.Select(async c =>
|
await Task.WhenAll(_copterManager.Copters.Select(async c =>
|
||||||
{
|
|
||||||
float voltageSum = 0.0f;
|
|
||||||
string name = c.Name;
|
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
{
|
||||||
|
float voltageSum = 0.0f;
|
||||||
voltageSum += c.Voltage;
|
string name = c.Name;
|
||||||
await Task.Delay(1000).ConfigureAwait(false);
|
|
||||||
}
|
for (int i = 0; i < 5; i++)
|
||||||
float voltageAverage = voltageSum / 5;
|
|
||||||
if (name != null && name != "")
|
|
||||||
{
|
|
||||||
lock(locker)
|
|
||||||
{
|
{
|
||||||
dic_voltage.Add(name, voltageAverage);
|
|
||||||
|
voltageSum += c.Voltage;
|
||||||
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
float voltageAverage = voltageSum / 5;
|
||||||
})).ConfigureAwait(false);
|
if (name != null && name != "")
|
||||||
await Task.Run(async () => {
|
{
|
||||||
|
lock (locker)
|
||||||
|
{
|
||||||
|
dic_voltage.Add(name, voltageAverage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})).ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
||||||
Dictionary<string, float> dic_voltage_Order = dic_voltage.OrderByDescending(o => o.Value).ToDictionary(o => o.Key, o => o.Value);
|
Dictionary<string, float> dic_voltage_Order = dic_voltage.OrderByDescending(o => o.Value).ToDictionary(o => o.Key, o => o.Value);
|
||||||
bool showch = false;
|
bool showch = false;
|
||||||
|
ICopter vcopter = null;
|
||||||
|
_copterManager.shiftkeydown = true;
|
||||||
|
//清除选择
|
||||||
|
_copterManager.Select(null);
|
||||||
foreach (KeyValuePair<string, float> kv in dic_voltage_Order)
|
foreach (KeyValuePair<string, float> kv in dic_voltage_Order)
|
||||||
{
|
{
|
||||||
if ((!showch) &&(minVol>0.00) && (kv.Value<=minVol))
|
if ((!showch) && (minVol > 0.00) && (kv.Value <= minVol))
|
||||||
{
|
{
|
||||||
Message.Show(string.Format("以下飞机电压低于[{0}V,单节{1:F2}]", minVol, minVol/4));
|
Message.Show(string.Format("以下飞机电压低于[{0}V,单节{1:F2}]", minVol, minVol / 4));
|
||||||
showch = true;
|
showch = true;
|
||||||
}
|
}
|
||||||
Message.Show(string.Format("{0} --> 5秒平均电压:{1:F2},单节{2:F2}", kv.Key, kv.Value, kv.Value/4));
|
Message.Show(string.Format("{0} --> 5秒平均电压:{1:F2},单节{2:F2}", kv.Key, kv.Value, kv.Value / 4));
|
||||||
|
|
||||||
|
|
||||||
|
//选中低电压飞机
|
||||||
|
if ((minVol > 0.00) && (kv.Value <= minVol))
|
||||||
|
{
|
||||||
|
vcopter = _copterManager.Copters.FirstOrDefault(o => o.Name == kv.Key);
|
||||||
|
if (vcopter != null)
|
||||||
|
_copterManager.Select(vcopter); //需要访问UI线程
|
||||||
|
}
|
||||||
await Task.Delay(5).ConfigureAwait(false);
|
await Task.Delay(5).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
await Task.Delay(500).ConfigureAwait(false);
|
||||||
|
_copterManager.shiftkeydown = false;
|
||||||
Message.Show(string.Format("----检测电压完成,检测总数:{0}----", dic_voltage.Count));
|
Message.Show(string.Format("----检测电压完成,检测总数:{0}----", dic_voltage.Count));
|
||||||
}).ConfigureAwait(false);
|
|
||||||
//todo:增加电压阈值变成不同颜色灯
|
//todo:增加电压阈值变成不同颜色灯
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -390,6 +405,30 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ICommand _DelCommand;
|
||||||
|
public ICommand DelCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _DelCommand ?? (_DelCommand = new RelayCommand(async () =>
|
||||||
|
{
|
||||||
|
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
|
||||||
|
if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
|
||||||
|
{
|
||||||
|
if (_flightTaskManager.Tasks.Count > 0)
|
||||||
|
{
|
||||||
|
Alert.Show("有航点任务无法删除飞机,请先清除航点!", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _copterManager.DelSelCopters();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private ICommand _MotorTestCommand;
|
private ICommand _MotorTestCommand;
|
||||||
public ICommand MotorTestCommand
|
public ICommand MotorTestCommand
|
||||||
{
|
{
|
||||||
@ -616,8 +655,11 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
DateTime MissionTime = DateTime.UtcNow.AddSeconds(5);
|
DateTime MissionTime = DateTime.UtcNow.AddSeconds(5);
|
||||||
DateTime MissionTime_log = DateTime.Now.AddSeconds(5);
|
DateTime MissionTime_log = DateTime.Now.AddSeconds(5);
|
||||||
Message.Show("任务开始:" + MissionTime_log.ToString());
|
Message.Show("任务开始:" + MissionTime_log.ToString());
|
||||||
|
|
||||||
|
IEnumerable<ICopter> selcopters = _copterManager.AcceptingControlCopters;
|
||||||
|
|
||||||
//循环3次 发送起飞命令 避免通信问题
|
//循环3次 发送起飞命令 避免通信问题
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*await _commModuleManager.DoMissionStartAsync(_copterManager.Copters,
|
/*await _commModuleManager.DoMissionStartAsync(_copterManager.Copters,
|
||||||
@ -630,7 +672,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
await _commModuleManager.DoMissionStartAsync(_copterManager.AcceptingControlCopters,
|
await _commModuleManager.DoMissionStartAsync(selcopters,
|
||||||
MissionTime.Hour,
|
MissionTime.Hour,
|
||||||
MissionTime.Minute,
|
MissionTime.Minute,
|
||||||
MissionTime.Second,
|
MissionTime.Second,
|
||||||
@ -650,17 +692,25 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
await Task.Delay(10).ConfigureAwait(false);
|
await Task.Delay(20).ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
//_copterManager.Net_LogStartMission(MissionTime_log, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat);
|
//_copterManager.Net_LogStartMission(MissionTime_log, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat);
|
||||||
Alert.Show("所有选中飞机开始执行航点任务。请勿多次开始任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
Alert.Show("所有选中飞机开始执行航点任务。请勿多次开始任务!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICommand _ThrowoutCommand;
|
||||||
|
public ICommand ThrowoutCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _ThrowoutCommand ?? (_ThrowoutCommand = new RelayCommand( () =>
|
||||||
|
{
|
||||||
|
// await Task.WhenAll(_copterManager.AcceptingControlCopters.Select(copter => copter.UnlockAsync()));
|
||||||
|
if (_copterManager.AcceptingControlCopters != null && _copterManager.AcceptingControlCopters.Count() > 0)
|
||||||
|
_commModuleManager.ThrowoutAsync(_copterManager.AcceptingControlCopters);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1346,9 +1396,9 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
DateTime MissionTime_log = DateTime.Now.AddSeconds(5);
|
DateTime MissionTime_log = DateTime.Now.AddSeconds(5);
|
||||||
Message.Show("任务开始:" + MissionTime_log.ToString());
|
Message.Show("任务开始:" + MissionTime_log.ToString());
|
||||||
//循环3次 发送起飞命令 避免通信问题
|
//循环3次 发送起飞命令 避免通信问题
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
await _commModuleManager.DoMissionStartAsync(_copterManager.Copters,
|
await _commModuleManager.DoMissionStartAsync(null,
|
||||||
MissionTime.Hour,
|
MissionTime.Hour,
|
||||||
MissionTime.Minute,
|
MissionTime.Minute,
|
||||||
MissionTime.Second,
|
MissionTime.Second,
|
||||||
@ -1368,7 +1418,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await Task.Delay(10).ConfigureAwait(false);
|
await Task.Delay(20).ConfigureAwait(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
_copterManager.Net_LogStartMission(MissionTime_log, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat);
|
_copterManager.Net_LogStartMission(MissionTime_log, _flightTaskManager.OriginLng, _flightTaskManager.OriginLat);
|
||||||
@ -1532,7 +1582,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用通讯模块 写入航点信息
|
/// 用通讯模块 写入航点信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="i">copterIndex</param>
|
/// <param name="i">copterIndex</param>
|
||||||
@ -1612,11 +1662,18 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
//_commModuleManager.missionWriteState.Add(int.Parse(_copterManager.Copters[i].Id), state);
|
//_commModuleManager.missionWriteState.Add(int.Parse(_copterManager.Copters[i].Id), state);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输失败!");
|
|
||||||
|
if (_copterManager.SortType == CopterManager.CopterSortType.ByVID)
|
||||||
|
Message.Show($"飞机:{_copterManager.Copters[i].VirtualId} 通信模块传输失败!");
|
||||||
|
else
|
||||||
|
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输失败!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输完成!");
|
if (_copterManager.SortType == CopterManager.CopterSortType.ByVID)
|
||||||
|
Message.Show($"飞机:{_copterManager.Copters[i].VirtualId} 通信模块传输完成!");
|
||||||
|
else
|
||||||
|
Message.Show($"飞机:{_copterManager.Copters[i].Id} 通信模块传输完成!");
|
||||||
}
|
}
|
||||||
await Task.Delay(500).ConfigureAwait(false);
|
await Task.Delay(500).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -401,6 +401,86 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void GetMaxMissions()
|
||||||
|
{
|
||||||
|
int missiontmp = 0;
|
||||||
|
|
||||||
|
string maxCopterName = "";
|
||||||
|
int maxmission = 0;
|
||||||
|
string minCopterName = "";
|
||||||
|
int minmission = 65535;
|
||||||
|
|
||||||
|
ICopter vcopter = _copterManager.SelectedCopters.FirstOrDefault();
|
||||||
|
if (vcopter == null)
|
||||||
|
{
|
||||||
|
Alert.Show($"请先选中飞机!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int coptercount = _copterManager.Copters.Count;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < coptercount; i++)
|
||||||
|
{
|
||||||
|
missiontmp = 0;
|
||||||
|
|
||||||
|
var currcopter = _copterManager.Copters[i];
|
||||||
|
|
||||||
|
foreach (var capter in _copterManager.SelectedCopters)
|
||||||
|
{
|
||||||
|
if (currcopter == capter)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _flightTaskManager.Tasks.Count; j++)
|
||||||
|
{
|
||||||
|
missiontmp++;
|
||||||
|
missiontmp += _flightTaskManager.Tasks[j].SingleCopterInfos[i].LEDInfos.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missiontmp > maxmission)
|
||||||
|
{
|
||||||
|
maxCopterName = _copterManager.Copters[i].Name;
|
||||||
|
maxmission = missiontmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missiontmp < minmission)
|
||||||
|
{
|
||||||
|
minCopterName = _copterManager.Copters[i].Name;
|
||||||
|
minmission = missiontmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (maxmission>256)
|
||||||
|
Alert.Show($"飞机:[ {maxCopterName} ] 有最多任务数量:{maxmission} 已超出256的最大航点限制,请减少灯光; \n飞机:[ {minCopterName} ] 有最少任务数量:{minmission}", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
else
|
||||||
|
Alert.Show($"飞机:[ {maxCopterName} ] 有最多任务数量:{maxmission} \n飞机:[ {minCopterName} ] 有最少任务数量:{minmission} \n (航点加灯光不能超过256个任务)", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICommand _CheckMissionCountCommand;
|
||||||
|
public ICommand CheckMissionCountCommand
|
||||||
|
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _CheckMissionCountCommand ?? (_CheckMissionCountCommand = new RelayCommand<float>(async =>
|
||||||
|
{
|
||||||
|
GetMaxMissions();
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//调整所有任务经度
|
//调整所有任务经度
|
||||||
private ICommand _ModiAllPosCommand;
|
private ICommand _ModiAllPosCommand;
|
||||||
public ICommand ModiAllPosCommand
|
public ICommand ModiAllPosCommand
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
xmlns:ec="clr-namespace:Plane.Windows.Controls;assembly=Plane.Windows"
|
xmlns:ec="clr-namespace:Plane.Windows.Controls;assembly=Plane.Windows"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title=""
|
Title=""
|
||||||
Width="500"
|
Width="565.58"
|
||||||
Height="325.107"
|
Height="325.107"
|
||||||
|
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
@ -48,6 +48,7 @@
|
|||||||
<Button Content="闪灯 " Width="67" Margin="5,5,5,5" Command="{Binding CommDataAsync}" ToolTip="参数为十六进制颜色"/>
|
<Button Content="闪灯 " Width="67" Margin="5,5,5,5" Command="{Binding CommDataAsync}" ToolTip="参数为十六进制颜色"/>
|
||||||
<Button Content="拉烟" Width="67" Margin="5,5,5,5" Command="{Binding TestFireCommandAsync}" ToolTip="参数为通道号1-4"/>
|
<Button Content="拉烟" Width="67" Margin="5,5,5,5" Command="{Binding TestFireCommandAsync}" ToolTip="参数为通道号1-4"/>
|
||||||
<Button Content="抛物" Width="67" Margin="5,5,5,5" Command="{Binding TestPWMCommandAsync}" ToolTip="接入舵机控制"/>
|
<Button Content="抛物" Width="67" Margin="5,5,5,5" Command="{Binding TestPWMCommandAsync}" ToolTip="接入舵机控制"/>
|
||||||
|
<Button Content="功率" Width="67" Margin="5,5,5,5" Command="{Binding SetModulePowerCommand}" ToolTip="设置模块回传功率"/>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
@ -60,10 +60,15 @@
|
|||||||
Command="{Binding CalibrationSingleCommand}" />
|
Command="{Binding CalibrationSingleCommand}" />
|
||||||
<Button Content="正式参数" Command="{Binding TurnOffTestLightsCommand}" Visibility="Collapsed" />
|
<Button Content="正式参数" Command="{Binding TurnOffTestLightsCommand}" Visibility="Collapsed" />
|
||||||
|
|
||||||
<Button Content="电机测试"
|
<Button Content="电机" Visibility="Collapsed"
|
||||||
|
|
||||||
Command="{Binding MotorTestCommand}" />
|
Command="{Binding MotorTestCommand}" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button Content="删除飞机"
|
||||||
|
|
||||||
|
Command="{Binding DelCommand}" />
|
||||||
|
|
||||||
<Label Visibility="Collapsed" Content="Lat"/>
|
<Label Visibility="Collapsed" Content="Lat"/>
|
||||||
<TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/>
|
<TextBox Visibility="Collapsed" Text="{Binding LatOffset}" Width="50"/>
|
||||||
<Label Visibility="Collapsed" Content="Lng"/>
|
<Label Visibility="Collapsed" Content="Lng"/>
|
||||||
@ -113,8 +118,9 @@
|
|||||||
Command="{Binding LockCommand}" />
|
Command="{Binding LockCommand}" />
|
||||||
<Button Content="单独任务"
|
<Button Content="单独任务"
|
||||||
Command="{Binding TakeOffCommand}" />
|
Command="{Binding TakeOffCommand}" />
|
||||||
|
|
||||||
|
<Button Content="抛物"
|
||||||
|
Command="{Binding ThrowoutCommand}" />
|
||||||
|
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
<WrapPanel>
|
<WrapPanel>
|
||||||
@ -192,8 +198,6 @@
|
|||||||
|
|
||||||
<Button Content="全部降落"
|
<Button Content="全部降落"
|
||||||
Command="{Binding AllLandCommand}" />
|
Command="{Binding AllLandCommand}" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -16,6 +16,8 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
namespace Plane.FormationCreator.Views
|
namespace Plane.FormationCreator.Views
|
||||||
{
|
{
|
||||||
@ -44,22 +46,47 @@ namespace Plane.FormationCreator.Views
|
|||||||
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||||
private void SelectitemMessage(ICopter copter)
|
private void SelectitemMessage(ICopter copter)
|
||||||
{
|
{
|
||||||
if (copter == null)
|
|
||||||
|
////需要访问UI线程,可能在其他线程里面
|
||||||
|
Dispatcher dispatcher = Dispatcher.FromThread(Thread.CurrentThread);
|
||||||
|
if (dispatcher != null)
|
||||||
{
|
{
|
||||||
lvwDrones.SelectedItems.Clear();
|
if (copter == null)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!_copterManager.shiftkeydown)
|
|
||||||
{
|
{
|
||||||
lvwDrones.SelectedItems.Clear();
|
lvwDrones.SelectedItems.Clear();
|
||||||
lvwDrones.SelectedItem = copter;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lvwDrones.SelectedItems.Add(copter);
|
{
|
||||||
}
|
if (!_copterManager.shiftkeydown)
|
||||||
|
{
|
||||||
|
lvwDrones.SelectedItems.Clear();
|
||||||
|
lvwDrones.SelectedItem = copter;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lvwDrones.SelectedItems.Add(copter);
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
|
||||||
|
lvwDrones.Dispatcher.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
|
||||||
|
if (copter == null)
|
||||||
|
{
|
||||||
|
lvwDrones.SelectedItems.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!_copterManager.shiftkeydown)
|
||||||
|
{
|
||||||
|
lvwDrones.SelectedItems.Clear();
|
||||||
|
lvwDrones.SelectedItem = copter;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lvwDrones.SelectedItems.Add(copter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectitemClearMessage(ICopter copter)
|
private void SelectitemClearMessage(ICopter copter)
|
||||||
|
@ -660,7 +660,12 @@
|
|||||||
Margin="10,5,0,5" Height="26"
|
Margin="10,5,0,5" Height="26"
|
||||||
Command="{Binding ShowallTaskpointCommand}"
|
Command="{Binding ShowallTaskpointCommand}"
|
||||||
/>
|
/>
|
||||||
</StackPanel>
|
|
||||||
|
<Button Content="计算任务数" Width="120"
|
||||||
|
Margin="10,5,0,5" Height="26"
|
||||||
|
Command="{Binding CheckMissionCountCommand}"
|
||||||
|
/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user