public static string CheckFuelCalculations() { string outString = ""; FlightEvent blockoff = GetFlightEvent("BlockOff"); FlightEvent blockon = GetFlightEvent("BlockOn"); if (blockoff == null) { outString += "Unable to calculate fuel, BlockOff Event missing"; FinishTracking(false); return(outString); } double fuelSpent = blockoff.fuel - blockon.fuel; TimeSpan duration = blockon.time.Subtract(blockoff.time); double minutes = duration.TotalMinutes; double averageConsumption = fuelSpent / minutes; outString += "calculated average comsumption : " + Math.Round(averageConsumption * 60) + " kg/h\n"; double minutesRemaining = blockon.fuel / averageConsumption; outString += " > minutes remaining : " + Math.Round(minutesRemaining) + " min\n"; XmlElement alternate = Connector.GetAirport(flightInit.alternate); double minutesToAlternate = 60; // in case the alternate airport icao is not found if (alternate != null) { NumberFormatInfo provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = "."; double altLatitude = Convert.ToDouble(alternate.GetAttribute("latitude"), provider); double altLongitude = Convert.ToDouble(alternate.GetAttribute("longitude"), provider); double distanceToAlternate = DistLatLong(blockon.latitude, blockon.longitude, altLatitude, altLongitude, "nm"); double tas = Convert.ToDouble(aircraft.tas) * .6; // minutesToAlternate = 60 * distanceToAlternate / tas; minutesToAlternate = Math.Max(minutesToAlternate, 15); } outString += " > minutes to alternate airport : " + Math.Round(minutesToAlternate) + " min\n"; double requiredReserve = minutesToAlternate + 30; outString += " > calculated required reserve : " + Math.Round(requiredReserve) + " min\n"; double maxReserve = Math.Round(requiredReserve * 3 + minutes / 6); if (minutesRemaining < requiredReserve) { outString += " >> ReserveFuelLow"; LogFlightEvent("ReserveFuelLow", outString, 4); } else if (minutesRemaining > maxReserve) { outString += " >> ReserveFuelHigh (comparing to " + maxReserve + " min)"; LogFlightEvent("ReserveFuelHigh", outString, 4); } else { outString += " >> Within tolerance"; } FinishTracking(false); return(outString); }
public static string SemikUploadString(FlightInit fi) { NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; FlightEvent block_off = FlightTracking.GetFlightEvent("BlockOff"); FlightEvent block_on = FlightTracking.GetFlightEvent("BlockOn"); FlightEvent to = FlightTracking.GetFlightEvent("Takeoff"); FlightEvent td = FlightTracking.GetFlightEvent("Touchdown"); string args = ""; args += "pid=" + pilot.pid; args += "&auth=" + pilot.auth_code; args += "&tracking_id=" + FlightTracking.tracking_id; args += "&blockoff_coords=" + block_off.latitude.ToString("####.#######", nfi) + ";" + block_off.longitude.ToString("####.#######", nfi); args += "&blockon_coords=" + block_on.latitude.ToString("####.#######", nfi) + ";" + block_on.longitude.ToString("####.#######", nfi); args += "&blockoff_time=" + block_on.GetUTCTimeString(); args += "&td_rate=" + Math.Round(td.verticalSpeed); args += "&td_speed=" + Math.Round(td.airSpeed); args += "&td_coords=" + td.latitude.ToString("####.#######", nfi) + ";" + td.longitude.ToString("####.#######", nfi) + ";" + Math.Round(td.heading).ToString(); args += "&fuel_spent=" + Math.Round(block_off.fuel - block_on.fuel); args += "&final_fuel=" + Math.Round(block_on.fuel); DateTime timeTakeoff = to.time; DateTime timeTouchdown = td.time; duration = timeTouchdown.Subtract(timeTakeoff); args += "&duration=" + duration.Hours.ToString("00") + ":" + duration.Minutes.ToString("00") + ":" + duration.Seconds.ToString("00"); args += "&distance=" + Math.Round(FlightTracking.distance); args += "&equipment=" + fi.aircraft; args += "®istration=" + fi.registration; args += "&pax=" + fi.pax; List <FlightEvent> events = FlightTracking.GetFlightEvents(); for (int i = 0; i < events.Count; i++) { FlightEvent ev = events[i]; if (ev.type > 1) { args += "&incidents[]=" + ev.GetCSV(";"); } } args += "&fsapirep=" + FSACARSCompatiblePirep(fi, "*"); return(args); }
private static void TVTIMER_Tick(Object myObject, EventArgs myEventArgs) { if (!Properties.Settings.Default.use_tv) { return; } TVTIMER.Interval = Properties.Settings.Default.tv_refresh * 1000; string file = Snapshot.TakeSnapshot(); if (file.Length > 0 && tracking_id.Length > 0 && !Properties.Settings.Default.offline) { FlightEvent fe = LogFlightEvent("TV", "tv snapshot", 3); bool result = Connector.UploadTV(tracking_id, file, fe.GetCSV(";")); } }
public static string FSACARSCompatiblePirep(FlightInit fi, string lineBreak) { NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; List <string> lines = new List <string>(); // UTC of flight init event FlightEvent initEvent = FlightTracking.GetFlightEvent("FlightInit"); if (initEvent == null) { return("Terminating - FlightInit event not found"); } DateTime initTime = initEvent.time; lines.Add("[" + initTime.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss") + "]"); // flight info lines.Add("Flight IATA:" + fi.iata); lines.Add("Pilot Number:" + pilot.callsign.Substring(3)); lines.Add("Company ICAO:" + pilot.callsign.Substring(0, 3)); lines.Add("Aircraft Type: " + Fleet.getAircraftByIcao(fi.aircraft).code); lines.Add("Aircraft Registration:" + fi.registration); lines.Add("Departing Airport:" + fi.departure); lines.Add("Destination Airport:" + fi.arrival); lines.Add("Alternate Airport:" + fi.alternate); lines.Add("PAX:" + fi.pax); lines.Add("Online:"); // TODO lines.Add("Route:" + fi.route); lines.Add("Flight Level:FL" + (fi.flight_level / 100).ToString("000")); // slew and pause bool paused = (FlightTracking.GetFlightEvent("Paused") != null); bool slewed = (FlightTracking.GetFlightEvent("Slewed") != null); bool simrate = (FlightTracking.GetFlightEvent("SimRateChange") != null); if (!slewed && !simrate) { lines.Add("No Slew and time accel"); } else if (slewed && !simrate) { lines.Add("Slew detected, no time accel"); } else if (!slewed && simrate) { lines.Add("Time accel detected, no slew"); } else { lines.Add("Time accel AND slew detected"); } if (!paused) { lines.Add("No Pause"); } else { lines.Add("Pause detected"); } // lines.Add("Detect pilot in Cockpit between each 1 and 5 minutes (Not implemented)"); // TODO - vatsim / ivao metar List <FlightEvent> events = FlightTracking.GetFlightEvents(); for (int i = 0; i < events.Count; i++) { FlightEvent ev = events[i]; if (ev.remarks.Length > 0) { lines.Add(ev.GetUTCTimeString() + " " + ev.remarks); } if (ev.id == "FlightInit") { lines.Add(ev.GetUTCTimeString() + " Zero fuel Weight: " + Math.Round(ev.grossWeight - ev.fuel).ToString() + " kg, Fuel Weight: " + Math.Round(ev.fuel).ToString() + " kg"); } if (ev.id == "BlockOff") { lines.Add(ev.GetUTCTimeString() + " Parking Brakes off"); } if (ev.id == "Rotate") { lines.Add(ev.GetUTCTimeString() + " VR= " + Math.Round(ev.airSpeed) + " knots"); } if (ev.id == "Takeoff") { lines.Add(ev.GetUTCTimeString() + " V2= " + Math.Round(ev.airSpeed) + " knots"); lines.Add(ev.GetUTCTimeString() + " Take-off"); lines.Add(ev.GetUTCTimeString() + " Take off Weight: " + Math.Round(ev.grossWeight) + " kg"); lines.Add(ev.GetUTCTimeString() + " Wind:" + Math.Round(ev.windDirection).ToString("000") + "° @ " + Math.Round(ev.windSpeed).ToString("000") + " knots Heading: " + Math.Round(ev.heading).ToString("000") + "°"); lines.Add(ev.GetUTCTimeString() + " Position: " + "lat:" + ev.latitude.ToString("####.#######", nfi) + ";lon:" + ev.longitude.ToString("####.########", nfi) + ";alt:" + Math.Round(ev.altitude) + ";hdg:" + ev.heading.ToString("000")); } if (ev.id == "TOC") { lines.Add(ev.GetUTCTimeString() + " TOC"); lines.Add(ev.GetUTCTimeString() + " Fuel Weight: " + Math.Round(ev.fuel) + " kg"); lines.Add(ev.GetUTCTimeString() + " Wind:" + Math.Round(ev.windDirection).ToString("000") + "° @ " + Math.Round(ev.windSpeed).ToString("000") + " knots Heading: " + Math.Round(ev.heading).ToString("000") + "°"); lines.Add(ev.GetUTCTimeString() + " Position: " + "lat:" + ev.latitude.ToString("####.#######", nfi) + ";lon:" + ev.longitude.ToString("####.########", nfi) + ";alt:" + Math.Round(ev.altitude) + ";hdg:" + ev.heading.ToString("000")); } if (ev.id == "TOD") { lines.Add(ev.GetUTCTimeString() + " TOD"); lines.Add(ev.GetUTCTimeString() + " Fuel Weight: " + Math.Round(ev.fuel) + " kg"); lines.Add(ev.GetUTCTimeString() + " Wind:" + Math.Round(ev.windDirection).ToString("000") + "° @ " + Math.Round(ev.windSpeed).ToString("000") + " knots Heading: " + Math.Round(ev.heading).ToString("000") + "°"); lines.Add(ev.GetUTCTimeString() + " Position: " + "lat:" + ev.latitude.ToString("####.#######", nfi) + ";lon:" + ev.longitude.ToString("####.########", nfi) + ";alt:" + Math.Round(ev.altitude) + ";hdg:" + ev.heading.ToString("000")); } if (ev.id == "Touchdown") { lines.Add(ev.GetUTCTimeString() + " TouchDown:Rate " + Math.Round(ev.verticalSpeed) + " ft/min Speed: " + Math.Round(ev.airSpeed) + " knots"); // todo landing METAR lines.Add(ev.GetUTCTimeString() + " Land"); lines.Add(ev.GetUTCTimeString() + " Wind:" + Math.Round(ev.windDirection).ToString("000") + "° @ " + Math.Round(ev.windSpeed).ToString("000") + " knots"); lines.Add(ev.GetUTCTimeString() + " Heading: " + Math.Round(ev.heading).ToString("000") + "°"); DateTime timeTakeoff = FlightTracking.GetFlightEvent("Takeoff").time; DateTime timeTouchdown = ev.time; TimeSpan duration = timeTouchdown.Subtract(timeTakeoff); lines.Add(ev.GetUTCTimeString() + " Flight Duration: " + duration.Hours.ToString("00") + ":" + duration.Minutes.ToString("00")); lines.Add(ev.GetUTCTimeString() + " Landing Weight:" + Math.Round(ev.grossWeight)); lines.Add(ev.GetUTCTimeString() + " Position: " + "lat:" + ev.latitude.ToString("####.#######", nfi) + ";lon:" + ev.longitude.ToString("####.########", nfi) + ";alt:" + Math.Round(ev.altitude) + ";hdg:" + ev.heading.ToString("000")); } if (ev.id == "BlockOn") { lines.Add(ev.GetUTCTimeString() + " Parking brakes on"); DateTime timeBlockoff = FlightTracking.GetFlightEvent("BlockOff").time; DateTime timeBlockon = ev.time; TimeSpan duration = timeBlockon.Subtract(timeBlockoff); lines.Add(ev.GetUTCTimeString() + " Block to Block Duration:" + duration.Hours.ToString("00") + ":" + duration.Minutes.ToString("00")); lines.Add(ev.GetUTCTimeString() + " Final Fuel: " + Math.Round(ev.fuel) + " kg"); double spentFuel = FlightTracking.GetFlightEvent("FlightInit").fuel - ev.fuel; lines.Add(ev.GetUTCTimeString() + " Spent Fuel: " + Math.Round(spentFuel) + " kg"); lines.Add(ev.GetUTCTimeString() + " Flight Length: " + Math.Round(FlightTracking.distance) + " NM"); FlightEvent tod = FlightTracking.GetFlightEvent("TOD"); if (tod != null) { double todLength = FlightTracking.DistLatLong(tod.latitude, tod.longitude, ev.latitude, ev.longitude, "nm"); lines.Add(ev.GetUTCTimeString() + " TOD Land Length: " + Math.Round(todLength) + " NM"); } } } return(string.Join(lineBreak, lines.ToArray())); }
public static FlightEvent LogFlightEvent(string id, string remarks, int type) { FlightEvent eev = GetFlightEvent(id); if (eev != null) { if (eev.type == 2) { return(null); } else if (eev.id == "Touchdown") { flightEvents.Remove(eev); } } FlightEvent fe = new FlightEvent(); fe.id = id; fe.type = type; fe.time = DateTime.Now; fe.latitude = fsData.latitude; fe.longitude = fsData.longitude; fe.altitude = fsData.altitude; fe.heading = fsData.heading; fe.groundSpeed = fsData.groundSpeed; fe.airSpeed = fsData.airSpeed; fe.aircraft = fsData.aircraftName; fe.fuel = fsData.fuelTotalWeight; fe.grossWeight = fsData.loadedWeight; fe.windDirection = fsData.windDirection; fe.windSpeed = fsData.windSpeed; fe.pressure = fsData.pressure; fe.altimeterSetting = fsData.altimeterSetting; fe.transponder = fsData.transponder; fe.com1 = fsData.com1; fe.pitch = fsData.pitch; fe.verticalSpeed = fsData.onGround ? 0 : fsData.verticalSpeed; fe.remarks = remarks; fe.distance = distance; fe.bank = fsData.bank; fe.groundElevation = fsData.altitude - fsData.groundAltitude; fe.flaps = aircraft.getFlaps(fsData.flapsPosition); fe.gear = (fsData.gear ? "Up" : "Down"); if (type == 2 && Properties.Settings.Default.fdr_imaging == true) { Logger.Log("Incident detected, imaging is on - taking screenshot..."); Image i = Snapshot.TakeImage(fe.id); if (i != null) { Logger.Log("Screenshot taken"); fe.image = i; } } if (type != 3) // not logging tv events { flightEvents.Add(fe); acarsForm.addEvent(fe); } return(fe); }
private static void EVENTSTIMER_Tick(Object myObject, EventArgs myEventArgs) { // FLIGHT CONTROLS EVENTS (based on flight mode) if (fsData.gear != lastGearPosition) { lastGearPosition = fsData.gear; Logger.LogEvent("GEAR", ((fsData.gear) ? "Gear up" : "Gear down") + " - " + Math.Round(fsData.airSpeed) + " knots"); if (fsData.gear) { LogFlightEvent("Gear", "Gear Up:" + Math.Round(fsData.airSpeed) + " knots", 1); } else { LogFlightEvent("Gear", "Gear Down:" + Math.Round(fsData.airSpeed) + " knots", 1); } } if (fsData.flapsPosition > lastFlapsPosition) { Logger.LogEvent("FLAPS", "Flaps move up" + " - Pos : " + aircraft.getFlaps(fsData.flapsPosition) + " - " + Math.Round(fsData.airSpeed) + " knots"); LogFlightEvent("Flaps", "Flaps " + aircraft.getFlaps(fsData.flapsPosition) + " at " + Math.Round(fsData.airSpeed) + " knots", 1); } if (fsData.flapsPosition < lastFlapsPosition) { Logger.LogEvent("FLAPS", "Flaps move down" + " - Pos : " + aircraft.getFlaps(fsData.flapsPosition) + " - " + Math.Round(fsData.airSpeed) + " knots"); LogFlightEvent("Flaps", "Flaps " + aircraft.getFlaps(fsData.flapsPosition) + " at " + Math.Round(fsData.airSpeed) + " knots", 1); } if (flightMode == 2) { if (fsData.pitch > (initialPitch + 2) && GetFlightEvent("Rotate") == null) { Logger.LogEvent("VR", Math.Round(fsData.airSpeed) + " knots"); LogFlightEvent("Rotate", "", 1); } if (lastOnGround != fsData.onGround) { Logger.LogEvent("V2", Math.Round(fsData.airSpeed) + " knots"); LogFlightEvent("Takeoff", "", 1); if (fsData.loadedWeight > aircraft.mtow) { Logger.LogEvent("TakeoffOverweight", "Exceeded MTOW by " + Math.Round(fsData.loadedWeight - aircraft.mtow) + " kg"); LogFlightEvent("TakeoffOverweight", "Exceeded MTOW by " + Math.Round(fsData.loadedWeight - aircraft.mtow) + " kg", 4); } if (fsData.pitch > aircraft.max_pitch_takeoff) { Logger.LogEvent("TakeoffOverRotate", "Pitch was " + Math.Round(fsData.pitch) + " / MaxPitch allowed: " + aircraft.max_pitch_takeoff.ToString()); LogFlightEvent("TakeoffOverRotate", "Pitch was " + Math.Round(fsData.pitch) + " / MaxPitch allowed: " + aircraft.max_pitch_takeoff.ToString(), 2); } } } /*if (fsData.onGround && !fsData.IsSafeSurface() && !wasUnsafeSurface) { * Logger.LogEvent("UNSAFE SURFACE", fsData.GetSurfaceString()); * wasUnsafeSurface = true; * LogFlightEvent("UnsafeSurface", fsData.GetSurfaceString(), 2); * }*/ if (flightMode == 7) { lastVerticalSpeed = fsData.verticalSpeed; if (lastOnGround != fsData.onGround) { Logger.LogEvent("TOUCHDOWN", "td rate : " + Math.Round(lastVerticalSpeed) + " ft/min" + " airspeed " + Math.Round(fsData.airSpeed) + " knots"); LogWeights(); LogPosition(); FlightEvent ev = GetFlightEvent("Touchdown"); if (ev != null) { flightEvents.Remove(ev); } LogFlightEvent("Touchdown", "", 1); // correct vertical speed of currently logged touchdown event FlightEvent td = GetFlightEvent("Touchdown"); td.verticalSpeed = Math.Round(lastVerticalSpeed); // do the same in case of abnormal landing incl. correction if (td.verticalSpeed < -1000) { LogFlightEvent("AbnormalLanding", "", 2); FlightEvent al = GetFlightEvent("AbnormalLanding"); al.verticalSpeed = td.verticalSpeed; } if (fsData.loadedWeight > aircraft.mlw) { Logger.LogEvent("LandingOverweight", "Exceeded MLW by " + Math.Round(fsData.loadedWeight - aircraft.mlw) + " kg"); LogFlightEvent("LandingOverweight", "Exceeded MLW by " + Math.Round(fsData.loadedWeight - aircraft.mlw) + " kg", 4); } // surface if (!fsData.IsSafeSurface()) { LogFlightEvent("LandingOffRunway", fsData.GetSurfaceString(), 2); } } lastOnGround = fsData.onGround; } // RADIOS if (fsData.com1 != lastCom1) { Logger.LogEvent("COM1", fsData.com1); lastCom1 = fsData.com1; LogFlightEvent("ComChange", "Com1 Freq=" + fsData.com1, 1); } if (fsData.transponder != lastTransponder) { Logger.LogEvent("TRANSPONDER", fsData.transponder); lastTransponder = fsData.transponder; LogFlightEvent("Transponder", "Squawk " + fsData.transponder, 1); } // LIMIT EVENTS if (wasLimitBank < Math.Abs(fsData.bank) && Math.Abs(fsData.bank) > aircraft.bank_limit) { double exceed = Math.Abs(fsData.bank) - aircraft.bank_limit; if (exceed > 3) { Logger.LogEvent("BANK LIMIT", "Bank limit exceeded by " + Math.Round(exceed) + " deg"); wasLimitBank = Math.Abs(fsData.bank); LogFlightEvent("BankLimit", "", 2); } } if (wasLimitNegativePitch > fsData.pitch && fsData.pitch < -1 * aircraft.min_pitch) { double exceed = fsData.pitch - aircraft.min_pitch; if (Math.Abs(exceed) > 3) { Logger.LogEvent("NEG PITCH LIMIT", "Negative pitch limit exceeded by " + Math.Abs(Math.Round(exceed)) + " deg"); wasLimitNegativePitch = -1 * fsData.pitch; LogFlightEvent("NegativePitch", "Limit negative pitch (down) " + aircraft.min_pitch + " deg was exceeded by" + Math.Abs(Math.Round(exceed)) + " deg", 2); } } if (wasLimitPositivePitch < fsData.pitch && fsData.pitch > aircraft.max_pitch) { double exceed = fsData.pitch - aircraft.max_pitch; if (exceed > 3) { Logger.LogEvent("POS PITCH LIMIT", "Positive pitch limit exceeded by " + Math.Round(exceed) + " deg"); wasLimitPositivePitch = fsData.pitch; LogFlightEvent("PositivePitch", "Limit positive pitch (down) " + aircraft.max_pitch + " deg was exceeded by" + Math.Abs(Math.Round(exceed)) + " deg", 2); } } if (flightMode == 7 && GetFlightEvent("SinkRate") == null && ((fsData.altitude - fsData.groundAltitude) < 1000 && fsData.groundAltitude < fsData.altitude) && fsData.verticalSpeed < -1500) { LogFlightEvent("SinkRate", "", 2); } // SIM EVENTS if (!wasPaused && fsData.paused && !fsData.onGround) { Logger.LogEvent("PAUSED SIMULATION", "Don't do that!"); LogFlightEvent("Paused", "", 2); wasPaused = true; } if (!wasSlew && fsData.slewMode) { Logger.LogEvent("SLEW MODE DETECTED", "Don't do that!"); LogFlightEvent("Slewed", "", 2); wasSlew = true; } if (!wasSimRate && fsData.simRate != 1) { Logger.LogEvent("DIFFERENT SIM RATE DETECTED", fsData.simRate.ToString() + "x"); LogFlightEvent("SimRateChange", fsData.simRate.ToString() + "x", 2); wasSimRate = true; } if (!wasRefuel && !fsData.onGround && (lastFuel + 20) < fsData.fuelTotalWeight) { Logger.LogEvent("REFUEL DETECTED", "Fuel: " + Math.Round(fsData.fuelTotalWeight) + " / Previous: " + Math.Round(lastFuel)); LogFlightEvent("Refueling", "Fuel: " + Math.Round(fsData.fuelTotalWeight) + " / Previous: " + Math.Round(lastFuel), 2); wasRefuel = true; } if (!wasAltimeterUnset && !fsData.onGround && fsData.altitude > 18500 && Math.Abs(fsData.altimeterSetting - 1013) > 1) { LogFlightEvent("AltimeterNotStd", "", 2); wasAltimeterUnset = true; } if (!wasParkingBrakeMoving && fsData.onGround && fsData.groundSpeed > 2 && fsData.parkingBrake) { LogFlightEvent("ParkingBrakeWhileMoving", "", 2); wasParkingBrakeMoving = true; } lastFuel = fsData.fuelTotalWeight; lastOnGround = fsData.onGround; lastFlapsPosition = fsData.flapsPosition; }