private void UpdateMarkerBeaconLight(FlightData flightData, F4SharedMem.FlightData fromFalcon) { bool outerMarkerFromFalcon = ((fromFalcon.hsiBits & (int)HsiBits.OuterMarker) == (int)HsiBits.OuterMarker); bool middleMarkerFromFalcon = ((fromFalcon.hsiBits & (int)HsiBits.MiddleMarker) == (int)HsiBits.MiddleMarker); if (Settings.Default.RunAsServer) { flightData.MarkerBeaconOuterMarkerFlag = outerMarkerFromFalcon; flightData.MarkerBeaconMiddleMarkerFlag = middleMarkerFromFalcon; } else { flightData.MarkerBeaconOuterMarkerFlag = outerMarkerFromFalcon & _morseCodeSignalLineValue; flightData.MarkerBeaconMiddleMarkerFlag = middleMarkerFromFalcon & _morseCodeSignalLineValue; if (outerMarkerFromFalcon) { _morseCodeGenerator.PlainText = "T"; //dot } else if (middleMarkerFromFalcon) { _morseCodeGenerator.PlainText = "A"; //dot-dash } if ((outerMarkerFromFalcon || middleMarkerFromFalcon) && !_morseCodeGenerator.Sending) { _morseCodeGenerator.StartSending(); } else if (!outerMarkerFromFalcon && !middleMarkerFromFalcon) { _morseCodeGenerator.StopSending(); } } }
private void UpdateAltitudeAGL(FlightData flightData, F4SharedMem.FlightData fromFalcon, uint lod = 2) { try { float terrainHeight = _terrainDB.CalculateTerrainHeight(fromFalcon.x, fromFalcon.y, lod); float agl = -fromFalcon.z - terrainHeight; //reset AGL altitude to zero if we're on the ground if ( ((fromFalcon.lightBits & (int)LightBits.ONGROUND) == (int)LightBits.ONGROUND) || ( ((fromFalcon.lightBits3 & (int)LightBits3.OnGround) == (int)LightBits3.OnGround) ) ) { agl = 0; } if (agl < 0) { agl = 0; } flightData.AltitudeAboveGroundLevelInDecimalFeet = agl; } catch (Exception e) { Log.Debug(e.Message, e); flightData.AltitudeAboveGroundLevelInDecimalFeet = flightData.TrueAltitudeAboveMeanSeaLevelInDecimalFeet; } }
private void UpdateALOW(FlightData flightData, F4SharedMem.FlightData fromFalcon) { int newAlow; var foundNewAlow = _dedAlowReader.CheckDED_ALOW(fromFalcon, out newAlow); if (foundNewAlow) { flightData.AutomaticLowAltitudeWarningInFeet = newAlow; } }
private F4SharedMem.FlightData ReadF4SharedMem() { var toReturn = new F4SharedMem.FlightData(); CreateSharedMemReaderIfNotExists(); if (_sharedMemReader != null) { toReturn = _sharedMemReader.GetCurrentData(); } return(toReturn); }
private void UpdateTACANChannel(FlightData flightData, F4SharedMem.FlightData fromFalcon) { if (TacanChannelSource == TacanChannelSource.Backup) { flightData.TacanChannel = fromFalcon.AUXTChan + Enum.GetName(typeof(TacanBand), BackupTacanBand); } else if (TacanChannelSource == TacanChannelSource.Ufc) { flightData.TacanChannel = fromFalcon.UFCTChan.ToString(); } }
private static void UpdateVerticalVelocity(FlightData flightData, F4SharedMem.FlightData fromFalcon, HsiBits hsibits) { if (((hsibits & HsiBits.VVI) == HsiBits.VVI)) { flightData.VerticalVelocityInDecimalFeetPerSecond = 0; } else { flightData.VerticalVelocityInDecimalFeetPerSecond = -fromFalcon.zDot; } }
private static void UpdateIndicatedAirspeed(FlightData flightData, F4SharedMem.FlightData fromFalcon) { if (Settings.Default.UseAsiLockoutSpeed && (fromFalcon.kias < Settings.Default.AsiLockoutSpeedKnots)) { //lockout airspeed if under 60 knots { flightData.IndicatedAirspeedInDecimalFeetPerSecond = 0; } } else { flightData.IndicatedAirspeedInDecimalFeetPerSecond = fromFalcon.kias * Common.Math.Constants.FPS_PER_KNOT; } }
private void UpdateMapPosition(FlightData flightData, F4SharedMem.FlightData fromFalcon) { int latWholeDegrees; float latMinutes; int longWholeDegrees; float longMinutes; _terrainDB.CalculateLatLong(fromFalcon.x, fromFalcon.y, out latWholeDegrees, out latMinutes, out longWholeDegrees, out longMinutes); flightData.LatitudeInDecimalDegrees = latWholeDegrees + (latMinutes / 60.0f); flightData.LongitudeInDecimalDegrees = longWholeDegrees + (longMinutes / 60.0f); flightData.MapCoordinateFeetEast = fromFalcon.y; flightData.MapCoordinateFeetNorth = fromFalcon.x; }
private static void UpdateHSIToFromFlagVisibilityAndADICommandBarsVisibilityBasedOnBMS4NavMode( FlightData flightData, F4SharedMem.FlightData fromFalcon) { var showToFromFlag = true; var showCommandBars = ((Math.Abs((fromFalcon.AdiIlsVerPos / Common.Math.Constants.RADIANS_PER_DEGREE)) <= (fromFalcon.deviationLimit / 5.0f)) && (Math.Abs((fromFalcon.AdiIlsHorPos / Common.Math.Constants.RADIANS_PER_DEGREE)) <= fromFalcon.deviationLimit)) && !(((HsiBits)fromFalcon.hsiBits & HsiBits.ADI_GS) == HsiBits.ADI_GS) && !(((HsiBits)fromFalcon.hsiBits & HsiBits.ADI_LOC) == HsiBits.ADI_LOC) && !(((HsiBits)fromFalcon.hsiBits & HsiBits.ADI_OFF) == HsiBits.ADI_OFF); switch (fromFalcon.navMode) { case 0: //NavModes.PlsTcn: showToFromFlag = false; break; case 1: //NavModes.Tcn: showToFromFlag = true; showCommandBars = false; break; case 2: //NavModes.Nav: showToFromFlag = false; showCommandBars = false; break; case 3: //NavModes.PlsNav: showToFromFlag = false; break; } if (showCommandBars) { showToFromFlag = false; } flightData.AdiEnableCommandBars = showCommandBars; flightData.HsiDisplayToFromFlag = showToFromFlag; }
private static void UpdateHSIData(FlightData flightData, F4SharedMem.FlightData fromFalcon, HsiBits hsibits) { if (((hsibits & HsiBits.HSI_OFF) == HsiBits.HSI_OFF)) { TurnOffHSI(flightData); } else { flightData.HsiDistanceInvalidFlag = ((hsibits & HsiBits.CourseWarning) == HsiBits.CourseWarning); flightData.HsiDeviationInvalidFlag = ((hsibits & HsiBits.IlsWarning) == HsiBits.IlsWarning); flightData.HsiCourseDeviationLimitInDecimalDegrees = fromFalcon.deviationLimit; flightData.HsiCourseDeviationInDecimalDegrees = fromFalcon.courseDeviation; flightData.HsiLocalizerDeviationInDecimalDegrees = fromFalcon.localizerCourse; flightData.HsiDesiredCourseInDegrees = (int)fromFalcon.desiredCourse; flightData.HsiDesiredHeadingInDegrees = (int)fromFalcon.desiredHeading; flightData.HsiBearingToBeaconInDecimalDegrees = fromFalcon.bearingToBeacon; flightData.HsiDistanceToBeaconInNauticalMiles = fromFalcon.distanceToBeacon; } }
public FlightData GetCurrentData() { Type dataType = null; switch (_dataFormat) { case FalconDataFormats.AlliedForce: dataType = typeof(Headers.AFFlightData); break; case FalconDataFormats.BMS4: dataType = typeof(Headers.BMS4FlightData); break; default: break; } if (dataType == null) { return(null); } if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero)) { ConnectToFalcon(); } if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero)) { return(null); } object data = Convert.ChangeType(Marshal.PtrToStructure(_lpPrimarySharedMemoryAreaBaseAddress, dataType), dataType); var len = Marshal.SizeOf(dataType); FlightData toReturn = null; switch (_dataFormat) { case FalconDataFormats.AlliedForce: toReturn = new FlightData((Headers.AFFlightData)data); break; case FalconDataFormats.BMS4: toReturn = new FlightData((Headers.BMS4FlightData)data); break; default: break; } if (toReturn == null) { return(null); } if (!_hSecondarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero)) { data = (Marshal.PtrToStructure(_lpSecondarySharedMemoryAreaBaseAddress, typeof(Headers.FlightData2))); toReturn.PopulateFromStruct(data); } if (!_hOsbSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero)) { data = (Marshal.PtrToStructure(_lpOsbSharedMemoryAreaBaseAddress, typeof(Headers.OSBData))); toReturn.PopulateFromStruct(data); } toReturn.DataFormat = _dataFormat; return(toReturn); }
private void UpdateIndicatedAltitude(FlightData flightData, F4SharedMem.FlightData fromFalcon) { flightData.IndicatedAltitudeAboveMeanSeaLevelInDecimalFeet = -fromFalcon.aauz; }
private void UpdateCpdPowerState(FlightData flightData, F4SharedMem.FlightData fromFalcon) { flightData.CpdPowerOnFlag = ((fromFalcon.lightBits3 & (int)LightBits3.Power_Off) != (int)LightBits3.Power_Off); }
public void UpdateManagerFlightData() { GetNextMorseCodeUnit(); if (Settings.Default.RunAsClient) { PerformClientSideFlightDataUpdates(); return; } FlightData flightData = Manager.FlightData; string exePath = F4Utils.Process.Util.GetFalconExePath(); CreateSharedMemReaderIfNotExists(); F4SharedMem.FlightData fromFalcon = ReadF4SharedMem(); if (_keyFile == null) { LoadCurrentKeyFile(); } EnsureTerrainIsLoaded(); if (exePath != null && ((_sharedMemReader != null && _sharedMemReader.IsFalconRunning))) { IsSimRunning = true; if (fromFalcon == null) { fromFalcon = new F4SharedMem.FlightData(); } var hsibits = ((HsiBits)fromFalcon.hsiBits); flightData.VviOffFlag = ((hsibits & HsiBits.VVI) == HsiBits.VVI); flightData.AoaOffFlag = ((hsibits & HsiBits.AOA) == HsiBits.AOA); flightData.HsiOffFlag = ((hsibits & HsiBits.HSI_OFF) == HsiBits.HSI_OFF); flightData.AdiOffFlag = ((hsibits & HsiBits.ADI_OFF) == HsiBits.ADI_OFF); flightData.PfdOffFlag = false; UpdateCpdPowerState(flightData, fromFalcon); flightData.RadarAltimeterOffFlag = ((fromFalcon.lightBits & (int)LightBits.RadarAlt) == (int)LightBits.RadarAlt); flightData.BarometricPressure = (fromFalcon.AltCalReading / 100.00f); flightData.AltimeterUnits = (((AltBits)fromFalcon.altBits & AltBits.CalType) == AltBits.CalType) ? AltimeterUnits.Hg : AltimeterUnits.hPa; flightData.AltimeterMode = (((AltBits)fromFalcon.altBits & AltBits.PneuFlag) == AltBits.PneuFlag) ? AltimeterMode.Pneumatic : AltimeterMode.Electronic; switch (fromFalcon.navMode) { case (byte)F4SharedMem.Headers.NavModes.ILS_NAV: flightData.NavMode = NavModes.IlsNav; break; case (byte)F4SharedMem.Headers.NavModes.ILS_TACAN: flightData.NavMode = NavModes.IlsTcn; break; case (byte)F4SharedMem.Headers.NavModes.TACAN: flightData.NavMode = NavModes.Tcn; break; case (byte)F4SharedMem.Headers.NavModes.NAV: flightData.NavMode = NavModes.Nav; break; } UpdateIndicatedAltitude(flightData, fromFalcon); UpdateAltitudeAGL(flightData, fromFalcon); UpdateIndicatedAirspeed(flightData, fromFalcon); UpdateALOW(flightData, fromFalcon); flightData.TrueAirspeedInDecimalFeetPerSecond = fromFalcon.vt; flightData.MachNumber = fromFalcon.mach; flightData.GroundSpeedInDecimalFeetPerSecond = (float)Math.Sqrt((fromFalcon.xDot * fromFalcon.xDot) + (fromFalcon.yDot * fromFalcon.yDot)); flightData.MagneticHeadingInDecimalDegrees = (360 + (fromFalcon.yaw / Common.Math.Constants.RADIANS_PER_DEGREE)) % 360; UpdateVerticalVelocity(flightData, fromFalcon, hsibits); flightData.AngleOfAttackInDegrees = ((hsibits & HsiBits.AOA) == HsiBits.AOA) ? 0 : fromFalcon.alpha; flightData.AdiAuxFlag = ((hsibits & HsiBits.ADI_AUX) == HsiBits.ADI_AUX); flightData.AdiGlideslopeInvalidFlag = ((hsibits & HsiBits.ADI_GS) == HsiBits.ADI_GS); flightData.AdiLocalizerInvalidFlag = ((hsibits & HsiBits.ADI_LOC) == HsiBits.ADI_LOC); UpdateMarkerBeaconLight(flightData, fromFalcon); if (((hsibits & HsiBits.ADI_OFF) == HsiBits.ADI_OFF)) { TurnOffADI(flightData); } else { flightData.PitchAngleInDecimalDegrees = ((fromFalcon.pitch / Common.Math.Constants.RADIANS_PER_DEGREE)); flightData.RollAngleInDecimalDegrees = fromFalcon.roll / Common.Math.Constants.RADIANS_PER_DEGREE; flightData.BetaAngleInDecimalDegrees = fromFalcon.beta; flightData.GammaAngleInDecimalDegrees = fromFalcon.gamma / Common.Math.Constants.RADIANS_PER_DEGREE; flightData.WindOffsetToFlightPathMarkerInDecimalDegrees = fromFalcon.windOffset / Common.Math.Constants.RADIANS_PER_DEGREE; flightData.AdiIlsGlideslopeDeviationInDecimalDegrees = fromFalcon.AdiIlsVerPos / Common.Math.Constants.RADIANS_PER_DEGREE; flightData.AdiIlsLocalizerDeviationInDecimalDegrees = fromFalcon.AdiIlsHorPos / Common.Math.Constants.RADIANS_PER_DEGREE; UpdateHSIToFromFlagVisibilityAndADICommandBarsVisibilityBasedOnBMS4NavMode(flightData, fromFalcon); } UpdateHSIData(flightData, fromFalcon, hsibits); flightData.RateOfTurnInDecimalDegreesPerSecond = _indicatedRateOfTurnCalculator.DetermineIndicatedRateOfTurn(flightData.MagneticHeadingInDecimalDegrees); UpdateTACANChannel(flightData, fromFalcon); UpdateMapPosition(flightData, fromFalcon); flightData.LMFDImage = GetLMFDImage(); flightData.RMFDImage = GetRMFDImage(); } else //Falcon's not running { IsSimRunning = false; if (Settings.Default.ShutoffIfFalconNotRunning) { TurnOffAllInstruments(flightData); } if (_sharedMemReader != null) { Common.Util.DisposeObject(_sharedMemReader); _sharedMemReader = null; } if (_texSharedMemReader != null) { Common.Util.DisposeObject(_texSharedMemReader); _texSharedMemReader = null; } Common.Util.DisposeObject(_keyFile); Common.Util.DisposeObject(_terrainDB); _keyFile = null; _terrainDB = null; } //if running in server mode, send updated flight data to client if (Settings.Default.RunAsServer) { F16CPDServer.SetSimProperty("F4FlightData", Common.Serialization.Util.ToRawBytes(flightData)); } }
private void UpdateALOW(FlightData flightData, F4SharedMem.FlightData fromFalcon) { flightData.AutomaticLowAltitudeWarningInFeet = fromFalcon.caraAlow; }