/// <summary> /// PreGenerate all Accesses from all Assets to all Tasks based on a simple Line of Sight model. Access is based on Line of Sight, a spherical Earth and the current ECI /// position of the Asset and the Task.Target.DynamicState /// </summary> /// <param name="system">The system underconsideration</param> /// <param name="tasks"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <param name="stepTime"></param> public static Stack<Access> pregenerateAccessesByAsset(SystemClass system, Stack<Task> tasks, double startTime, double endTime, double stepTime) { Stack<Access> accessesByAsset = new Stack<Access>(); // For all assets... foreach (Asset asset in system.Assets) { // ...for all tasks... foreach (Task task in tasks) { // ...for all time.... for (double accessTime = SimParameters.SimStartSeconds; accessTime <= SimParameters.SimEndSeconds; accessTime += SchedParameters.SimStepSeconds) { // create a new access, or extend the access endTime if this is an update to an existing access bool hasAccess = Utilities.GeometryUtilities.hasLOS(asset.AssetDynamicState.PositionECI(accessTime), task.Target.DynamicState.PositionECI(accessTime)); if (hasAccess) { bool isNewAccess; if (accessesByAsset.Count == 0 || accessTime == SimParameters.SimStartSeconds || accessesByAsset.Peek().Task.Target.Name != task.Target.Name) isNewAccess = true; else isNewAccess = (accessTime - accessesByAsset.Peek().AccessEnd) > SchedParameters.SimStepSeconds; if (isNewAccess) { Access newAccess = new Access(asset, task); newAccess.AccessStart = accessTime; newAccess.AccessEnd = accessTime; accessesByAsset.Push(newAccess); } else // extend the access accessesByAsset.Peek().AccessEnd = accessTime; } } } } return accessesByAsset; }
/// <summary> /// Find all accesses available to an asset at the current time /// </summary> /// <param name="accesses"></param> /// <param name="asset"></param> /// <param name="currentTime"></param> /// <returns></returns> public static Stack <Access> getCurrentAccessesForAsset(Stack <Access> accesses, Asset asset, double currentTime) { Stack <Access> allAccesses = Access.getCurrentAccesses(accesses, currentTime); return(new Stack <Access>(allAccesses.Where(item => item.Asset == asset))); }