From: <sv...@ww...> - 2006-01-22 08:24:46
|
Author: mkrose Date: 2006-01-22 00:24:37 -0800 (Sun, 22 Jan 2006) New Revision: 1832 Modified: trunk/CSP/csp/cspsim/f16/F16System.cpp trunk/CSP/csp/cspsim/f16/F16System.h Log: Add support for low speed and gear configuration warning tones, and fix the mastermode channel declaration needed by the f16 hud. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1832 Modified: trunk/CSP/csp/cspsim/f16/F16System.cpp =================================================================== --- trunk/CSP/csp/cspsim/f16/F16System.cpp 2006-01-22 04:54:12 UTC (rev 1831) +++ trunk/CSP/csp/cspsim/f16/F16System.cpp 2006-01-22 08:24:37 UTC (rev 1832) @@ -25,21 +25,25 @@ #include <csp/cspsim/f16/F16System.h> #include <csp/cspsim/f16/F16Channels.h> #include <csp/cspsim/AnimationSequence.h> -#include <csp/cspsim/CSPSim.h> #include <csp/cspsim/FlightDynamicsChannels.h> +#include <csp/cspsim/FuelManagementSystem.h> +#include <csp/cspsim/InputEventChannel.h> +#include <csp/cspsim/KineticsChannels.h> #include <csp/cspsim/LandingGearChannels.h> #include <csp/cspsim/NavigationChannels.h> +#include <csp/cspsim/SoundEffect.h> #include <csp/cspsim/SystemsModel.h> // for testing stores release #include <csp/cspsim/stores/StoresManagementSystem.h> #include <csp/cspsim/stores/Stores.h> +#include <csp/csplib/data/Date.h> +#include <csp/csplib/data/ObjectInterface.h> #include <csp/csplib/util/Conversions.h> -#include <csp/csplib/data/Date.h> #include <csp/csplib/util/Math.h> -#include <csp/csplib/data/ObjectInterface.h> + CSP_NAMESPACE CSP_XML_BEGIN(F16System) @@ -49,9 +53,7 @@ DEFINE_INPUT_INTERFACE(F16System) -const Enumeration F16System::MasterModes("NAV AA AG"); - F16System::F16System(): m_CatIII(false) { } @@ -65,7 +67,7 @@ b_StandbyGains = bus->registerLocalDataChannel<bool>(bus::F16::StandbyGains, false); b_TakeoffLandingGains = bus->registerLocalDataChannel<bool>(bus::F16::TakeoffLandingGains, false); b_NavigationSystem = bus->registerSharedDataChannel<Ref<NavigationSystem> >("Navigation", new NavigationSystem); - b_MasterMode = bus->registerLocalPushChannel<EnumLink>("MasterMode", MasterMode("NAV")); + b_MasterMode = bus->registerChannel(new f16::MasterModeSelection); bus->registerSharedDataChannel<double>("F16.CaraAlow", 0.0); bus->registerSharedDataChannel<double>("F16.MslFloor", 0.0); bus->registerSharedDataChannel<double>("F16.TfAdv", 0.0); @@ -82,14 +84,26 @@ b_LeftMainLandingGearWOW = bus->getChannel(bus::LandingGear::selectWOW("LeftGear")); b_RightMainLandingGearWOW = bus->getChannel(bus::LandingGear::selectWOW("RightGear")); b_GearFullyRetracted = bus->getChannel(bus::LandingGear::FullyRetracted); - // TODO bus::LandingGear::GearExtendSelected or bus::F16::GearHandleUp? + b_GearFullyExtended = bus->getChannel(bus::LandingGear::FullyExtended); b_GearExtendSelected = bus->getChannel(bus::LandingGear::GearExtendSelected); + b_GearHandleUp = bus->getChannel(bus::F16::GearHandleUp); b_Airspeed = bus->getChannel(bus::FlightDynamics::Airspeed); + b_Alpha = bus->getChannel(bus::FlightDynamics::Alpha); + b_Pitch = bus->getChannel(bus::Kinetics::Pitch); + b_Position = bus->getChannel(bus::Kinetics::Position); + b_Velocity = bus->getChannel(bus::Kinetics::Velocity); + b_PressureAltitude = bus->getChannel(bus::FlightDynamics::PressureAltitude); b_FuelDoorSequence = bus->getChannel("Aircraft.FuelDoorSequence.NormalizedTime", false); b_AirRefuelSwitch = bus->getChannel("F16.AirRefuelSwitch", false); + b_EngineRpm = bus->getChannel("Engine.RPM", true); + b_FuelManagementSystem = bus->getChannel("FuelManagementSystem"); + if (b_AirRefuelSwitch.valid()) { b_AirRefuelSwitch->connect(this, &F16System::onAirRefuelSwitch); } + + m_LowSpeedWarning = addSoundEffect("low_speed_warning_sound", SoundEffect::HEADSET); + m_ConfigurationWarning = addSoundEffect("configuration_warning_sound", SoundEffect::HEADSET); } double F16System::onUpdate(double dt) { @@ -114,6 +128,7 @@ if (m_CanopySequence.valid()) { m_CanopySequence->update(dt); } + updateWarnings(dt); return 0.0; } @@ -190,5 +205,50 @@ b_ManualPitchOverride->value() = false; } +void F16System::getInfo(InfoList &) const { +} + +// TODO use LocalUpdate to call this only occasionally +void F16System::updateWarnings(double) { + double alpha = toDegrees(b_Alpha->value()); + double pitch = toDegrees(b_Pitch->value()); + double airspeed = convert::mps_kts(b_Airspeed->value()); + bool horn = false; + bool tone = false; + bool light = false; + if (alpha > 15.0 && (!b_GearHandleUp->value() || b_AltFlaps->value())) { + tone = true;; + } else if (b_GearHandleUp->value() && !b_AltFlaps->value() && pitch >= 45.0) { + double limit = 200.0 - (90.0 - pitch) * (100.0 / 45.0); + tone = (airspeed < limit); + } + if (airspeed < 170.0) { + static const double altitude_limit = convert::ft_m(10000.0); + if (b_Position->value().z() < altitude_limit) { + static const double vv_limit = convert::ft_m(250.0 / 60.0); // fpm to mps + if (b_Velocity->value().z() < -vv_limit) { + if (!b_GearFullyExtended->value()) { + horn = true; + light = true; + } else if (b_TrailingEdgeFlapExtension->value() < toRadians(24.9)) { + light = true; + } + } + } + } + + // FIXME replace statics with member varibales + static bool low = false; + if (tone != low) { + low = tone; + if (m_LowSpeedWarning.valid()) m_LowSpeedWarning->play(tone); + } + static bool gear = false; + if (gear != (horn || light)) { + gear = !gear; + if (m_ConfigurationWarning.valid()) m_ConfigurationWarning->play(horn); + } +} + CSP_NAMESPACE_END Modified: trunk/CSP/csp/cspsim/f16/F16System.h =================================================================== --- trunk/CSP/csp/cspsim/f16/F16System.h 2006-01-22 04:54:12 UTC (rev 1831) +++ trunk/CSP/csp/cspsim/f16/F16System.h 2006-01-22 08:24:37 UTC (rev 1832) @@ -30,6 +30,7 @@ #ifndef __CSPSIM_F16_F16SYSTEM_H__ #define __CSPSIM_F16_F16SYSTEM_H__ +#include <csp/cspsim/f16/Constants.h> #include <csp/cspsim/f16/NavigationSystem.h> #include <csp/cspsim/System.h> #include <csp/cspsim/Steerpoint.h> @@ -40,11 +41,12 @@ CSP_NAMESPACE +class FuelManagementSystem; +class JetFuelStarter; class TimedSequence; + class F16System: public System { - static const Enumeration MasterModes; - public: CSP_DECLARE_OBJECT(F16System) @@ -78,39 +80,57 @@ virtual void nextSteerpoint(); virtual void prevSteerpoint(); + virtual void getInfo(InfoList &info) const; + +protected: virtual void registerChannels(Bus*); virtual void importChannels(Bus*); - typedef Enum<MasterModes> MasterMode; + DataChannel<EnumLink>::CRefT b_AirRefuelSwitch; -protected: + DataChannel<bool>::CRefT b_GearExtendSelected; + DataChannel<bool>::CRefT b_GearFullyExtended; + DataChannel<bool>::CRefT b_GearFullyRetracted; + DataChannel<bool>::CRefT b_GearHandleUp; - //void addTestSteerpoints(); + DataChannel<Vector3>::CRefT b_Position; + DataChannel<Vector3>::CRefT b_Velocity; - DataChannel<EnumLink>::CRefT b_AirRefuelSwitch; - DataChannel<bool>::CRefT b_GearExtendSelected; - DataChannel<bool>::CRefT b_GearFullyRetracted; + DataChannel<double>::CRefT b_Alpha; + DataChannel<double>::CRefT b_Pitch; DataChannel<double>::CRefT b_Airspeed; + DataChannel<double>::CRefT b_PressureAltitude; + DataChannel<double>::CRefT b_EngineRpm; + DataChannel<double>::CRefT b_FuelDoorSequence; DataChannel<bool>::CRefT b_NoseLandingGearWOW; DataChannel<bool>::CRefT b_LeftMainLandingGearWOW; DataChannel<bool>::CRefT b_RightMainLandingGearWOW; DataChannel<bool>::CRefT b_WheelSpin; + DataChannel<double>::RefT b_TrailingEdgeFlapExtension; DataChannel<double>::RefT b_AirbrakeLimit; + DataChannel<bool>::RefT b_AltFlaps; DataChannel<bool>::RefT b_CatIII; DataChannel<bool>::RefT b_ManualPitchOverride; DataChannel<bool>::RefT b_ManualPitchOverrideActive; + DataChannel<bool>::RefT b_StandbyGains; DataChannel<bool>::RefT b_TakeoffLandingGains; + + DataChannel<Ref<FuelManagementSystem> >::CRefT b_FuelManagementSystem; DataChannel<Ref<NavigationSystem> >::RefT b_NavigationSystem; - DataChannel<EnumLink>::RefT b_MasterMode; + f16::MasterModeSelection::RefT b_MasterMode; Link<TimedSequence> m_FuelDoorSequence; Link<TimedSequence> m_CanopySequence; + Ref<SoundEffect> m_LowSpeedWarning; + Ref<SoundEffect> m_ConfigurationWarning; + virtual double onUpdate(double dt); + void updateWarnings(double dt); // TODO should use push channels so we don't have to track state separately! // right now we poll state variables in the update handler to check if anything |