} //public static RemoveProximity() public static async Task GenerateProximity() { var AllKeys = Keys(); foreach (String FromKey in AllKeys) { DroneDataProcessor ProximityFromFlight = Flight(FromKey); GPSPoint FromPosition = ProximityFromFlight.GetPosition(); int FromFlightID = ProximityFromFlight.GetFlightID(); foreach (String ToKey in AllKeys) { if (FromKey != ToKey) { DroneDataProcessor ProximityToFlight = Flight(ToKey); GPSPoint ToPosition = ProximityToFlight.GetPosition(); int ToFlightID = ProximityToFlight.GetFlightID(); Double Distance = GPSCalc.GetDistance(FromPosition, ToPosition); ProximityFromFlight.ProximityAdd(new Proximity { FlightID = ToFlightID, Lat = ToPosition.lat, Lng = ToPosition.lng, Distance = Distance, DroneName = ProximityToFlight.GetProperty("DroneName").ToString(), AccountID = (int)ProximityToFlight.GetProperty("AccountID"), AccountName = ProximityToFlight.GetProperty("AccountName").ToString(), Altitude = ProximityToFlight.Altitude, PilotID = ProximityToFlight.PilotID, PilotName = ProximityToFlight.PilotName }); //Console.WriteLine($"From: {FromKey}({FromFlightID}) -> To: {ToKey}({ToFlightID}), Distance: {Distance}"); } //if(FromKey != ToKey) } //foreach (String ToKey in AllKeys) await ProximityFromFlight.GenerateProximityAlerts(); } //foreach(String FromKey in AllKeys) } //public static void UpdateProximity()
}//private static async void fnLoadPendingData() private static async Task <bool> fnThreadProcessing() { DroneData ThisDroneData; DroneDataProcessor ThisFlight; //Get the First Data from Pending Data lock (_locker) { if (!PendingDroneData.Any()) { Thread.Sleep(100); return(false); } ThisDroneData = PendingDroneData.First(); PendingDroneData.RemoveAt(0); RemovedDroneDataIDs.Add(ThisDroneData.DroneDataId); } String BBFlightID = ThisDroneData.BBFlightID; if (!ActiveFlights.ContainsKey(BBFlightID)) { DroneDataProcessor ThisDataProcessor = new DroneDataProcessor(); ThisDataProcessor.OnTaskError += fnOnTaskError; ThisDataProcessor.OnDbEntityException += fnOnDbEntityException; ThisDataProcessor.SetDroneData(ThisDroneData); await ThisDataProcessor.GenerateFlight(); ActiveFlights.Add(BBFlightID, ThisDataProcessor); ThisFlight = ActiveFlights[BBFlightID]; } else { ThisFlight = ActiveFlights[BBFlightID]; ThisFlight.SetDroneData(ThisDroneData); } ThisFlight.ProcessDroneData(); await ThisFlight.GenerateAlerts(); await ThisFlight.UpdateFlight(); await ThisFlight.Update_MSTR_Drone(); return(true); }