Skip to content

Commit bfe356e

Browse files
committed
Added orderCommandList() to be chronological
Fixes RemoteTechnologiesGroup#51
1 parent 984f89e commit bfe356e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/RemoteTech/FlightComputer/FlightComputer.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public void Enqueue(ICommand cmd, bool ignore_control = false, bool ignore_delay
128128
if (pos < 0)
129129
{
130130
mCommandQueue.Insert(~pos, cmd);
131+
orderCommandList();
131132
}
132133
}
133134

@@ -312,6 +313,26 @@ public void updatePIDParameters()
312313
initPIDParameters();
313314
}
314315

316+
/// <summary>
317+
/// Orders the mCommand queue to be chronological
318+
/// </summary>
319+
public void orderCommandList()
320+
{
321+
if (mCommandQueue.Count <= 0) return;
322+
323+
List<ICommand> backupList = mCommandQueue;
324+
// sort the backup queue
325+
backupList = backupList.OrderBy(s => (s.TimeStamp + s.ExtraDelay)).ToList();
326+
// clear the old queue
327+
mCommandQueue.Clear();
328+
329+
// add the sorted queue
330+
foreach(var command in backupList)
331+
{
332+
mCommandQueue.Add(command);
333+
}
334+
}
335+
315336
/// <summary>
316337
///
317338
/// </summary>

0 commit comments

Comments
 (0)