Skip to content

Commit

Permalink
- AH64 check if point already present
Browse files Browse the repository at this point in the history
- AH64 implement read points from aircraft function
- AH64 smart point delete skips non existing points
- Refactor SleepForCommands and into DCS Command
- Adds RunAndSleep to DCSCommand
- Allow GetActions to return null to skip that coordinate for entry
- Change lua to read multiple lines from display data
- update todo
- bump version to 0.11.0
- Update CoordinateSharp
  • Loading branch information
FalcoGer committed Aug 12, 2024
1 parent 853ea53 commit da81828
Show file tree
Hide file tree
Showing 10 changed files with 475 additions and 140 deletions.
4 changes: 2 additions & 2 deletions CoordinateConverter/CoordinateConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="CoordinateSharp, Version=2.22.1.1, Culture=neutral, PublicKeyToken=f45e02df057b7725, processorArchitecture=MSIL">
<HintPath>..\packages\CoordinateSharp.2.22.1.1\lib\net40\CoordinateSharp.dll</HintPath>
<Reference Include="CoordinateSharp, Version=2.24.2.1, Culture=neutral, PublicKeyToken=f45e02df057b7725, processorArchitecture=MSIL">
<HintPath>..\packages\CoordinateSharp.2.24.2.1\lib\net40\CoordinateSharp.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
321 changes: 297 additions & 24 deletions CoordinateConverter/DCS/Aircraft/AH64/AH64.cs

Large diffs are not rendered by default.

43 changes: 5 additions & 38 deletions CoordinateConverter/DCS/Aircraft/AH64/AH64TSDOptionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -897,15 +897,6 @@ private enum EScreens
TSD_SHOW_THREAT
}

static private void SleepForCommands(List<DCSCommand> commands)
{
int totalDelay = (int)(commands.Sum(c => c.Delay) * 1.2);
if (totalDelay > 0)
{
Thread.Sleep(totalDelay);
}
}

/// <summary>
/// Reads the current map settings from DCS.
/// </summary>
Expand Down Expand Up @@ -974,14 +965,10 @@ static public AH64TSDOptionData ReadFromAC(bool isPilot)
{
// execute the navigation commands
commands = kvp.Value;
message = new DCSMessage() { Commands = commands };
message = DCSConnection.SendRequest(message);

if (message == null)
if (!DCSCommand.RunAndSleep(commands))
{
return null;
}
SleepForCommands(commands);

// Read the display
message = new DCSMessage()
Expand Down Expand Up @@ -1051,15 +1038,10 @@ static public AH64TSDOptionData ReadFromAC(bool isPilot)

if (commands.Count > 0)
{
message = DCSConnection.SendRequest(new DCSMessage()
{
Commands = commands
});
if (message == null)
if (!DCSCommand.RunAndSleep(commands))
{
return null;
}
SleepForCommands(commands);
}
break;
case EScreens.TSD_SHOW_NAV:
Expand Down Expand Up @@ -1111,15 +1093,10 @@ static public AH64TSDOptionData ReadFromAC(bool isPilot)
{
new DCSCommand(mfd, (int)AH64.EKeyCode.MFD_R1)
};
message = DCSConnection.SendRequest(new DCSMessage()
{
Commands = commands
});
if (message == null)
if (!DCSCommand.RunAndSleep(commands))
{
return null;
}
SleepForCommands(commands);

message = DCSConnection.SendRequest(new DCSMessage()
{
Expand Down Expand Up @@ -1148,15 +1125,10 @@ static public AH64TSDOptionData ReadFromAC(bool isPilot)
{
new DCSCommand(mfd, (int)AH64.EKeyCode.MFD_R1)
};
message = DCSConnection.SendRequest(new DCSMessage()
{
Commands = commands
});
if (message == null)
if (!DCSCommand.RunAndSleep(commands))
{
return null;
}
SleepForCommands(commands);

message = DCSConnection.SendRequest(new DCSMessage()
{
Expand Down Expand Up @@ -1198,15 +1170,10 @@ static public AH64TSDOptionData ReadFromAC(bool isPilot)
commands.Add(new DCSCommand(mfd, (int)AH64.EKeyCode.MFD_B2));
}

message = DCSConnection.SendRequest(new DCSMessage()
{
Commands = commands
});
if (message == null)
if (!DCSCommand.RunAndSleep(commands))
{
return null;
}
SleepForCommands(commands);

return result;
}
Expand Down
8 changes: 7 additions & 1 deletion CoordinateConverter/DCS/Aircraft/DCSAircraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ protected override List<DCSCommand> GenerateCommands(object items)
List<DCSCommand> commands = GetPreActions();
foreach (CoordinateDataEntry entry in coordinateList)
{
commands.AddRange(GetActions(entry).Where(x => x != null));
var actions = GetActions(entry);
if (actions == null)
{
continue;
}

commands.AddRange(actions.Where(x => x != null));
}
commands.AddRange(GetPostActions());
return commands;
Expand Down
Loading

0 comments on commit da81828

Please sign in to comment.