Exemplo n.º 1
0
        public virtual FlightStatus CheckStatus(FlightStateData flightState)
        {
            FlightStatus result = FlightStatus.Nominal;

            if (!SystemSettings.enableRangeSafety)
            {
                result = FlightStatus.Disarmed;
                Status = result;
                return(result);
            }

            if (flightState == null || FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH)
            {
                result = FlightStatus.Prelaunch;
                Status = result;
                return(result);
            }

            result |= CheckVehicleMass(flightState);
            result |= CheckVehicleVelocity(flightState);
            result |= CheckVehicleDistanceFromPad(flightState);
            if ((result & FlightStatus.NominalPadExclusion) != FlightStatus.NominalPadExclusion)
            {
                // only check bearing once we leave the exlcusion radius to avoid spurious short distance variatons
                result |= CheckCorridor(flightState);
            }

            Status = result;
            return(result);
        }
Exemplo n.º 2
0
        internal void CheckState(IFlightCorridor flightCorridor)
        {
            var flightState = new FlightStateData(FlightGlobals.ActiveVessel);

            if (State == RangeState.Nominal || State == RangeState.Armed)
            {
                var previousStatus = flightCorridor.Status;
                var currentStatus  = flightCorridor.CheckStatus(flightState);
                if (previousStatus != currentStatus)
                {
                    if ((currentStatus & FlightStatus.AnySafe) != 0)
                    {
                        EnterSafeState(currentStatus);
                    }
                    else if (State == RangeState.Nominal)
                    {
                        if ((currentStatus & FlightStatus.AnyViolation) != 0)
                        {
                            // there has been a status change and we are no longer nominal
                            EnterArmedState(currentStatus);
                        }
                    }
                    else if (State == RangeState.Armed)
                    {
                        if ((currentStatus & FlightStatus.AnyViolation) == 0)
                        {
                            // there has been a status change and we can potentially revert from armed to nominal
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 protected FlightStatus CheckVehicleVelocity(FlightStateData flightState)
 {
     if (flightState.VesselSurfaceSpeed >= SafeSpeed)
     {
         return(FlightStatus.SafeSpeed);
     }
     return(FlightStatus.Nominal);
 }
Exemplo n.º 4
0
 protected FlightStatus CheckVehicleMass(FlightStateData flightState)
 {
     if (flightState.VesselTotalMass <= SafeMass)
     {
         return(FlightStatus.SafeMass);
     }
     return(FlightStatus.Nominal);
 }
        protected override FlightStatus CheckCorridor(FlightStateData flightState)
        {
            FlightStatus result = base.CheckCorridor(flightState);

            var vesselCoords = new Coordinates(flightState.Lattitude, flightState.Longitude);

            var distance = PadCoordinates.DistanceTo(vesselCoords);
            var bearing  = PadCoordinates.BearingTo(vesselCoords);

            if ((MaximumAzimuth.val > MinimumAzimuth.val && bearing > MaximumAzimuth.val || bearing < MinimumAzimuth.val) ||
                (MaximumAzimuth.val < MinimumAzimuth.val && bearing < MaximumAzimuth.val && bearing > MinimumAzimuth.val))
            {
                result = FlightStatus.CorridorViolation;
            }
            return(result);
        }
Exemplo n.º 6
0
        protected FlightStatus CheckVehicleDistanceFromPad(FlightStateData flightState)
        {
            FlightStatus result = FlightStatus.Nominal;

            var vesselCoords = new Coordinates(flightState.Lattitude, flightState.Longitude);

            var distFromPad = vesselCoords.DistanceTo(PadCoordinates);

            if (distFromPad <= PadSafetyRadius)
            {
                result |= FlightStatus.NominalPadExclusion;
            }
            else if (distFromPad >= SafeRange)
            {
                result |= FlightStatus.SafeRange;
            }
            return(result);
        }
Exemplo n.º 7
0
 protected virtual FlightStatus CheckCorridor(FlightStateData flightState)
 {
     return(FlightStatus.NominalInCorridor);
 }