1
0
Fork 0

SGSubsystem classes: Whitespace standardisation of the declarations.

This is a clean up commit prior to the subsystem API standardisation to simplify
the diffs.  It includes all SGSubsystem and SGSubsystemGroup derived classes.
This commit is contained in:
Edward d'Auvergne 2018-04-03 12:21:33 +02:00
parent 8428cd2a44
commit 60a2444766
122 changed files with 2449 additions and 2543 deletions

View file

@ -54,16 +54,15 @@ SGSubsystem and define at least a small set of functions:
class FGFX : public SGSubsystem class FGFX : public SGSubsystem
{ {
public: public:
FGFX();
virtual ~FGFX();
FGFX (); virtual void init();
virtual ~FGFX (); virtual void reinit();
virtual void bind();
virtual void init (); virtual void unbind();
virtual void reinit (); virtual void update(double dt);
virtual void bind (); };
virtual void unbind ();
virtual void update (double dt);
}
The init() functions should make sure everything is set and ready so the The init() functions should make sure everything is set and ready so the
update() function can be run by the main loop. The reinit() function handles update() function can be run by the main loop. The reinit() function handles

View file

@ -37,7 +37,6 @@ typedef SGSharedPtr<FGAIBase> FGAIBasePtr;
class FGAIManager : public SGSubsystem class FGAIManager : public SGSubsystem
{ {
public: public:
FGAIManager(); FGAIManager();
virtual ~FGAIManager(); virtual ~FGAIManager();
@ -99,15 +98,16 @@ public:
* avoid correctly. * avoid correctly.
*/ */
FGAIAircraft* getUserAircraft() const; FGAIAircraft* getUserAircraft() const;
bool isRadarEnabled() const bool isRadarEnabled() const
{ return _radarEnabled; } { return _radarEnabled; }
bool enableRadarDebug() const bool enableRadarDebug() const
{ return _radarDebugMode; } { return _radarDebugMode; }
double radarRangeM() const double radarRangeM() const
{ return _radarRangeM; } { return _radarRangeM; }
private: private:
// FGSubmodelMgr is a friend for access to the AI_list // FGSubmodelMgr is a friend for access to the AI_list
friend class FGSubmodelMgr; friend class FGSubmodelMgr;

View file

@ -15,7 +15,7 @@ class SGPath;
* *
* Allows to store performance data for later reuse/retrieval. Just * Allows to store performance data for later reuse/retrieval. Just
* a simple map for now. * a simple map for now.
* *
* @author Thomas F<EFBFBD>rster <t.foerster@biologie.hu-berlin.de> * @author Thomas F<EFBFBD>rster <t.foerster@biologie.hu-berlin.de>
*/ */
//TODO provide std::map interface? //TODO provide std::map interface?
@ -41,6 +41,7 @@ public:
PerformanceData* getDefaultPerformance() const; PerformanceData* getDefaultPerformance() const;
static const char* subsystemName() { return "aircraft-performance-db"; } static const char* subsystemName() { return "aircraft-performance-db"; }
private: private:
void load(const SGPath& path); void load(const SGPath& path);
@ -49,13 +50,13 @@ private:
typedef std::map<std::string, PerformanceData*> PerformanceDataDict; typedef std::map<std::string, PerformanceData*> PerformanceDataDict;
PerformanceDataDict _db; PerformanceDataDict _db;
const std::string& findAlias(const std::string& acType) const; const std::string& findAlias(const std::string& acType) const;
typedef std::pair<std::string, std::string> StringPair; typedef std::pair<std::string, std::string> StringPair;
/// alias list, to allow type/class names to share data. This is used to merge /// alias list, to allow type/class names to share data. This is used to merge
/// related types together. Note it's ordered, and not a map since we permit /// related types together. Note it's ordered, and not a map since we permit
/// partial matches when merging - the first matching alias is used. /// partial matches when merging - the first matching alias is used.
std::vector<StringPair> _aliases; std::vector<StringPair> _aliases;
}; };

View file

@ -19,11 +19,10 @@
class FGAIBase; class FGAIBase;
class FGAIManager; class FGAIManager;
class FGSubmodelMgr : public SGSubsystem, public SGPropertyChangeListener class FGSubmodelMgr : public SGSubsystem,
public SGPropertyChangeListener
{ {
public: public:
typedef struct { typedef struct {
SGPropertyNode_ptr trigger_node; SGPropertyNode_ptr trigger_node;
SGPropertyNode_ptr prop; SGPropertyNode_ptr prop;
@ -107,7 +106,6 @@ public:
void shutdown() override; void shutdown() override;
private: private:
typedef std::vector <submodel*> submodel_vector_type; typedef std::vector <submodel*> submodel_vector_type;
typedef submodel_vector_type::iterator submodel_vector_iterator; typedef submodel_vector_type::iterator submodel_vector_iterator;
@ -183,10 +181,9 @@ private:
SGGeod userpos; SGGeod userpos;
SGGeod offsetpos; SGGeod offsetpos;
SGVec3d getCartOffsetPos(submodel* sm) const; SGVec3d getCartOffsetPos(submodel* sm) const;
void setOffsetPos(submodel* sm); void setOffsetPos(submodel* sm);
}; };
#endif // __SYSTEMS_SUBMODEL_HXX #endif // __SYSTEMS_SUBMODEL_HXX

View file

@ -23,8 +23,8 @@
/************************************************************************** /**************************************************************************
* The ATC Manager interfaces the users aircraft with the AI traffic system * The ATC Manager interfaces the users aircraft with the AI traffic system
* and also monitors the ongoing AI traffic patterns for potential conflicts * and also monitors the ongoing AI traffic patterns for potential conflicts
* and interferes where necessary. * and interferes where necessary.
*************************************************************************/ *************************************************************************/
#ifndef _ATC_MGR_HXX_ #ifndef _ATC_MGR_HXX_
#define _ATC_MGR_HXX_ #define _ATC_MGR_HXX_
@ -42,21 +42,21 @@ typedef std::vector<FGATCController*>::iterator AtcVecIterator;
class FGATCManager : public SGSubsystem class FGATCManager : public SGSubsystem
{ {
private: private:
AtcVec activeStations; AtcVec activeStations;
FGATCController *controller, *prevController; // The ATC controller that is responsible for the user's aircraft. FGATCController *controller, *prevController; // The ATC controller that is responsible for the user's aircraft.
bool networkVisible; bool networkVisible;
bool initSucceeded; bool initSucceeded;
SGPropertyNode_ptr trans_num; SGPropertyNode_ptr trans_num;
public: public:
FGATCManager(); FGATCManager();
~FGATCManager(); ~FGATCManager();
void postinit() override; void postinit() override;
void shutdown() override; void shutdown() override;
void addController(FGATCController *controller); void addController(FGATCController *controller);
void removeController(FGATCController* controller); void removeController(FGATCController* controller);
void update(double time); void update(double time);
}; };
#endif // _ATC_MRG_HXX_ #endif // _ATC_MRG_HXX_

View file

@ -31,13 +31,15 @@
typedef std::vector<SGGeod> SGGeodVec; typedef std::vector<SGGeod> SGGeodVec;
class PagedPathForHistory : public SGReferenced { class PagedPathForHistory : public SGReferenced
{
public: public:
PagedPathForHistory() : last_seen(0) {} PagedPathForHistory() : last_seen(0) {}
virtual ~PagedPathForHistory() {} virtual ~PagedPathForHistory() {}
SGGeodVec path; SGGeodVec path;
time_t last_seen; time_t last_seen;
}; };
typedef SGSharedPtr<PagedPathForHistory> PagedPathForHistory_ptr; typedef SGSharedPtr<PagedPathForHistory> PagedPathForHistory_ptr;
const unsigned int SAMPLE_BUCKET_WIDTH = 1024; const unsigned int SAMPLE_BUCKET_WIDTH = 1024;
@ -54,12 +56,12 @@ class FGFlightHistory : public SGSubsystem
public: public:
FGFlightHistory(); FGFlightHistory();
virtual ~FGFlightHistory(); virtual ~FGFlightHistory();
virtual void init(); virtual void init();
virtual void shutdown(); virtual void shutdown();
virtual void reinit(); virtual void reinit();
virtual void update(double dt); virtual void update(double dt);
PagedPathForHistory_ptr pagedPathForHistory(size_t max_entries, size_t newerThan = 0) const; PagedPathForHistory_ptr pagedPathForHistory(size_t max_entries, size_t newerThan = 0) const;
/** /**
* retrieve the path, collapsing segments shorter than * retrieve the path, collapsing segments shorter than
@ -86,9 +88,8 @@ private:
float heading, pitch, roll; float heading, pitch, roll;
size_t simTimeMSec; size_t simTimeMSec;
}; };
/** /**
* Bucket is a fixed-size container of samples. This is a crude slab * Bucket is a fixed-size container of samples. This is a crude slab
* allocation of samples, in chunks defined by the width constant above. * allocation of samples, in chunks defined by the width constant above.
@ -101,26 +102,26 @@ private:
public: public:
Sample samples[SAMPLE_BUCKET_WIDTH]; Sample samples[SAMPLE_BUCKET_WIDTH];
}; };
double m_lastCaptureTime; double m_lastCaptureTime;
double m_sampleInterval; ///< sample interval in seconds double m_sampleInterval; ///< sample interval in seconds
/// our store of samples (in buckets). The last bucket is partially full, /// our store of samples (in buckets). The last bucket is partially full,
/// with the number of valid samples indicated by m_validSampleCount /// with the number of valid samples indicated by m_validSampleCount
std::vector<SampleBucket*> m_buckets; std::vector<SampleBucket*> m_buckets;
/// number of valid samples in the final bucket /// number of valid samples in the final bucket
unsigned int m_validSampleCount; unsigned int m_validSampleCount;
SGPropertyNode_ptr m_weightOnWheels; SGPropertyNode_ptr m_weightOnWheels;
SGPropertyNode_ptr m_enabled; SGPropertyNode_ptr m_enabled;
bool m_lastWoW; bool m_lastWoW;
size_t m_maxMemoryUseBytes; size_t m_maxMemoryUseBytes;
void allocateNewBucket(); void allocateNewBucket();
void capture(); void capture();
size_t currentMemoryUseBytes() const; size_t currentMemoryUseBytes() const;
}; };

View file

@ -31,9 +31,7 @@
class FGControls : public SGSubsystem class FGControls : public SGSubsystem
{ {
public: public:
enum { enum {
ALL_ENGINES = -1, ALL_ENGINES = -1,
MAX_ENGINES = 12 MAX_ENGINES = 12
@ -83,19 +81,19 @@ public:
ALL_EJECTION_SEATS = -1, ALL_EJECTION_SEATS = -1,
MAX_EJECTION_SEATS = 10 MAX_EJECTION_SEATS = 10
}; };
enum { enum {
SEAT_SAFED = -1, SEAT_SAFED = -1,
SEAT_ARMED = 0, SEAT_ARMED = 0,
SEAT_FAIL = 1 SEAT_FAIL = 1
}; };
enum { enum {
CMD_SEL_NORM = -1, CMD_SEL_NORM = -1,
CMD_SEL_AFT = 0, CMD_SEL_AFT = 0,
CMD_SEL_SOLO = 1 CMD_SEL_SOLO = 1
}; };
private: private:
// controls/flight/ // controls/flight/
double aileron; double aileron;
@ -143,7 +141,7 @@ private:
bool fuel_selector[MAX_TANKS]; bool fuel_selector[MAX_TANKS];
int to_engine[MAX_TANKS]; int to_engine[MAX_TANKS];
int to_tank[MAX_TANKS]; int to_tank[MAX_TANKS];
// controls/fuel/tank[n]/pump[p]/ // controls/fuel/tank[n]/pump[p]/
bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS]; bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS];
@ -174,7 +172,7 @@ private:
// controls/anti-ice/engine[n]/ // controls/anti-ice/engine[n]/
bool carb_heat[MAX_ENGINES]; bool carb_heat[MAX_ENGINES];
bool inlet_heat[MAX_ENGINES]; bool inlet_heat[MAX_ENGINES];
// controls/hydraulic/system[n]/ // controls/hydraulic/system[n]/
bool engine_pump[MAX_HYD_SYSTEMS]; bool engine_pump[MAX_HYD_SYSTEMS];
bool electric_pump[MAX_HYD_SYSTEMS]; bool electric_pump[MAX_HYD_SYSTEMS];
@ -193,7 +191,7 @@ private:
// controls/pneumatic/engine[n]/ // controls/pneumatic/engine[n]/
bool engine_bleed[MAX_ENGINES]; bool engine_bleed[MAX_ENGINES];
// controls/pressurization/ // controls/pressurization/
int mode; int mode;
bool dump; bool dump;
@ -247,16 +245,15 @@ private:
double bank_angle_select; double bank_angle_select;
double vertical_speed_select; double vertical_speed_select;
double speed_select; double speed_select;
double mach_select; double mach_select;
int vertical_mode; int vertical_mode;
int lateral_mode; int lateral_mode;
SGPropertyNode_ptr auto_coordination; SGPropertyNode_ptr auto_coordination;
SGPropertyNode_ptr auto_coordination_factor; SGPropertyNode_ptr auto_coordination_factor;
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
public:
public:
FGControls(); FGControls();
~FGControls(); ~FGControls();
@ -266,10 +263,10 @@ public:
void unbind (); void unbind ();
void update (double dt); void update (double dt);
virtual void reinit(); virtual void reinit();
// Reset function // Reset function
void reset_all(void); void reset_all(void);
// Query functions // Query functions
// controls/flight/ // controls/flight/
inline double get_aileron() const { return aileron; } inline double get_aileron() const { return aileron; }
@ -280,7 +277,7 @@ public:
inline double get_rudder_trim() const { return rudder_trim; } inline double get_rudder_trim() const { return rudder_trim; }
inline double get_flaps() const { return flaps; } inline double get_flaps() const { return flaps; }
inline double get_slats() const { return slats; } inline double get_slats() const { return slats; }
inline bool get_BLC() const { return BLC; } inline bool get_BLC() const { return BLC; }
inline double get_spoilers() const { return spoilers; } inline double get_spoilers() const { return spoilers; }
inline double get_speedbrake() const { return speedbrake; } inline double get_speedbrake() const { return speedbrake; }
inline double get_wing_sweep() const { return wing_sweep; } inline double get_wing_sweep() const { return wing_sweep; }
@ -305,7 +302,7 @@ public:
} }
inline int get_magnetos(int engine) const { return magnetos[engine]; } inline int get_magnetos(int engine) const { return magnetos[engine]; }
inline int get_feed_tank(int engine) const { return feed_tank[engine]; } inline int get_feed_tank(int engine) const { return feed_tank[engine]; }
inline bool get_nitrous_injection(int engine) const { inline bool get_nitrous_injection(int engine) const {
return nitrous_injection[engine]; return nitrous_injection[engine];
} }
inline double get_cowl_flaps_norm(int engine) const { inline double get_cowl_flaps_norm(int engine) const {
@ -315,8 +312,8 @@ public:
inline int get_ignition(int engine) const { return ignition[engine]; } inline int get_ignition(int engine) const { return ignition[engine]; }
inline bool get_augmentation(int engine) const { return augmentation[engine]; } inline bool get_augmentation(int engine) const { return augmentation[engine]; }
inline bool get_reverser(int engine) const { return reverser[engine]; } inline bool get_reverser(int engine) const { return reverser[engine]; }
inline bool get_water_injection(int engine) const { inline bool get_water_injection(int engine) const {
return water_injection[engine]; return water_injection[engine];
} }
inline double get_condition(int engine) const { return condition[engine]; } inline double get_condition(int engine) const { return condition[engine]; }
@ -375,7 +372,7 @@ public:
inline bool get_APU_generator() const { return APU_generator; } inline bool get_APU_generator() const { return APU_generator; }
// controls/electric/engine[n]/ // controls/electric/engine[n]/
inline bool get_generator_breaker(int engine) const { inline bool get_generator_breaker(int engine) const {
return generator_breaker[engine]; return generator_breaker[engine];
} }
inline bool get_bus_tie(int engine) const { return bus_tie[engine]; } inline bool get_bus_tie(int engine) const { return bus_tie[engine]; }
@ -385,7 +382,7 @@ public:
// controls/pneumatic/engine[n]/ // controls/pneumatic/engine[n]/
inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; } inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; }
// controls/pressurization/ // controls/pressurization/
inline int get_mode() const { return mode; } inline int get_mode() const { return mode; }
inline double get_outflow_valve() const { return outflow_valve; } inline double get_outflow_valve() const { return outflow_valve; }
@ -427,7 +424,7 @@ public:
return eseat_status[which_seat]; return eseat_status[which_seat];
} }
inline int get_cmd_selector_valve() const { return cmd_selector_valve; } inline int get_cmd_selector_valve() const { return cmd_selector_valve; }
// controls/APU/ // controls/APU/
inline int get_off_start_run() const { return off_start_run; } inline int get_off_start_run() const { return off_start_run; }
@ -439,19 +436,19 @@ public:
inline double get_heading_select() const { return heading_select; } inline double get_heading_select() const { return heading_select; }
inline double get_altitude_select() const { return altitude_select; } inline double get_altitude_select() const { return altitude_select; }
inline double get_bank_angle_select() const { return bank_angle_select; } inline double get_bank_angle_select() const { return bank_angle_select; }
inline double get_vertical_speed_select() const { inline double get_vertical_speed_select() const {
return vertical_speed_select; return vertical_speed_select;
} }
inline double get_speed_select() const { return speed_select; } inline double get_speed_select() const { return speed_select; }
inline double get_mach_select() const { return mach_select; } inline double get_mach_select() const { return mach_select; }
inline int get_vertical_mode() const { return vertical_mode; } inline int get_vertical_mode() const { return vertical_mode; }
inline int get_lateral_mode() const { return lateral_mode; } inline int get_lateral_mode() const { return lateral_mode; }
// controls/autoflight/autopilot[n]/ // controls/autoflight/autopilot[n]/
inline bool get_autopilot_engage(int ap) const { inline bool get_autopilot_engage(int ap) const {
return autopilot_engage[ap]; return autopilot_engage[ap];
} }
// Update functions // Update functions
// controls/flight/ // controls/flight/
@ -471,14 +468,14 @@ public:
void move_flaps( double amt ); void move_flaps( double amt );
void set_slats( double pos ); void set_slats( double pos );
void move_slats( double amt ); void move_slats( double amt );
void set_BLC( bool val ); void set_BLC( bool val );
void set_spoilers( double pos ); void set_spoilers( double pos );
void move_spoilers( double amt ); void move_spoilers( double amt );
void set_speedbrake( double pos ); void set_speedbrake( double pos );
void move_speedbrake( double amt ); void move_speedbrake( double amt );
void set_wing_sweep( double pos ); void set_wing_sweep( double pos );
void move_wing_sweep( double amt ); void move_wing_sweep( double amt );
void set_wing_fold( bool val ); void set_wing_fold( bool val );
void set_drag_chute( bool val ); void set_drag_chute( bool val );
// controls/engines/ // controls/engines/
@ -507,7 +504,7 @@ public:
void set_augmentation( int engine, bool val ); void set_augmentation( int engine, bool val );
void set_reverser( int engine, bool val ); void set_reverser( int engine, bool val );
void set_water_injection( int engine, bool val ); void set_water_injection( int engine, bool val );
void set_condition( int engine, double val ); void set_condition( int engine, double val );
// controls/fuel // controls/fuel
void set_dump_valve( bool val ); void set_dump_valve( bool val );
@ -569,7 +566,7 @@ public:
// controls/pneumatic/engine[n]/ // controls/pneumatic/engine[n]/
void set_engine_bleed( int engine, bool val ); void set_engine_bleed( int engine, bool val );
// controls/pressurization/ // controls/pressurization/
void set_mode( int mode ); void set_mode( int mode );
void set_outflow_valve( double pos ); void set_outflow_valve( double pos );
@ -631,8 +628,8 @@ public:
void move_vertical_speed_select( double amt ); void move_vertical_speed_select( double amt );
void set_speed_select( double speed ); void set_speed_select( double speed );
void move_speed_select( double amt ); void move_speed_select( double amt );
void set_mach_select( double mach ); void set_mach_select( double mach );
void move_mach_select( double amt ); void move_mach_select( double amt );
void set_vertical_mode( int mode ); void set_vertical_mode( int mode );
void set_lateral_mode( int mode ); void set_lateral_mode( int mode );
@ -640,17 +637,17 @@ public:
void set_autopilot_engage( int ap, bool val ); void set_autopilot_engage( int ap, bool val );
static const char* subsystemName() { return "controls"; } static const char* subsystemName() { return "controls"; }
private: private:
inline void do_autocoordination() { inline void do_autocoordination() {
// check for autocoordination // check for autocoordination
if ( auto_coordination->getBoolValue() ) { if ( auto_coordination->getBoolValue() ) {
double factor = auto_coordination_factor->getDoubleValue(); double factor = auto_coordination_factor->getDoubleValue();
if( factor > 0.0 ) set_rudder( aileron * factor ); if( factor > 0.0 ) set_rudder( aileron * factor );
} }
} }
}; };
#endif // _CONTROLS_HXX #endif // _CONTROLS_HXX

View file

@ -56,7 +56,7 @@ typedef std::vector < FGReplayMessages > replay_messages_type;
/** /**
* A recording/replay module for FlightGear flights * A recording/replay module for FlightGear flights
* *
*/ */
class FGReplay : public SGSubsystem class FGReplay : public SGSubsystem

View file

@ -50,6 +50,7 @@ public:
FGAirportDynamicsRef dynamicsForICAO(const std::string& icao); FGAirportDynamicsRef dynamicsForICAO(const std::string& icao);
static const char* subsystemName() { return "airport-dynamics"; } static const char* subsystemName() { return "airport-dynamics"; }
private: private:
typedef std::map<std::string, FGAirportDynamicsRef> ICAODynamicsDict; typedef std::map<std::string, FGAirportDynamicsRef> ICAODynamicsDict;
ICAODynamicsDict m_dynamics; ICAODynamicsDict m_dynamics;

View file

@ -40,8 +40,8 @@ namespace FGXMLAutopilot {
* <li>an optional periodical definition</li> * <li>an optional periodical definition</li>
* </ul> * </ul>
*/ */
class AnalogComponent : public Component { class AnalogComponent : public Component
{
private: private:
/** /**
* @brief a flag signalling that the output property value shall be fed back * @brief a flag signalling that the output property value shall be fed back
@ -77,7 +77,7 @@ protected:
PeriodicalValue_ptr _periodical; PeriodicalValue_ptr _periodical;
/** /**
* @brief A constructor for an analog component. Call configure() to * @brief A constructor for an analog component. Call configure() to
* configure this component from a property node * configure this component from a property node
*/ */
AnalogComponent(); AnalogComponent();
@ -104,8 +104,8 @@ protected:
/** /**
* @brief overideable method being called from the update() method if this component * @brief overideable method being called from the update() method if this component
* is disabled. Analog components feed back it's output value to the active * is disabled. Analog components feed back it's output value to the active
input value if disabled and feedback-if-disabled is true input value if disabled and feedback-if-disabled is true
*/ */
virtual void disabled( double dt ); virtual void disabled( double dt );
@ -115,10 +115,10 @@ protected:
* If no output property is configured, a value of zero will be returned. * If no output property is configured, a value of zero will be returned.
* If more than one output property is configured, the value of the first output property * If more than one output property is configured, the value of the first output property
* is returned. The current value of the output property will be clamped to the configured * is returned. The current value of the output property will be clamped to the configured
* values of &lt;min&gt; and/or &lt;max&gt;. * values of &lt;min&gt; and/or &lt;max&gt;.
*/ */
inline double get_output_value() const { inline double get_output_value() const {
return _output_list.empty() ? 0.0 : clamp(_output_list[0]->getDoubleValue()); return _output_list.empty() ? 0.0 : clamp(_output_list[0]->getDoubleValue());
} }
simgear::PropertyList _output_list; simgear::PropertyList _output_list;
@ -134,7 +134,7 @@ protected:
value = clamp( value ); value = clamp( value );
for( simgear::PropertyList::iterator it = _output_list.begin(); for( simgear::PropertyList::iterator it = _output_list.begin();
it != _output_list.end(); ++it) it != _output_list.end(); ++it)
(*it)->setDoubleValue( value ); (*it)->setDoubleValue( value );
} }
public: public:
@ -143,11 +143,11 @@ public:
inline void AnalogComponent::disabled( double dt ) inline void AnalogComponent::disabled( double dt )
{ {
if( _feedback_if_disabled && ! _output_list.empty() ) { if( _feedback_if_disabled && ! _output_list.empty() ) {
InputValue * input; InputValue * input;
if( (input = _valueInput.get_active() ) != NULL ) if( (input = _valueInput.get_active() ) != NULL )
input->set_value( _output_list[0]->getDoubleValue() ); input->set_value( _output_list[0]->getDoubleValue() );
} }
} }
} }

View file

@ -49,25 +49,22 @@ using namespace FGXMLAutopilot;
class StateMachineComponent : public Component class StateMachineComponent : public Component
{ {
public: public:
StateMachineComponent( SGPropertyNode& props_root, StateMachineComponent( SGPropertyNode& props_root,
SGPropertyNode& cfg ) SGPropertyNode& cfg ) {
{ inner = simgear::StateMachine::createFromPlist(&cfg, &props_root);
inner = simgear::StateMachine::createFromPlist(&cfg, &props_root); }
}
virtual bool configure( const std::string & nodeName, SGPropertyNode_ptr config) {
virtual bool configure( const std::string & nodeName, SGPropertyNode_ptr config) return false;
{ }
return false;
} virtual void update( bool firstTime, double dt ) {
SG_UNUSED(firstTime);
virtual void update( bool firstTime, double dt ) inner->update(dt);
{ }
SG_UNUSED(firstTime);
inner->update(dt);
}
private: private:
simgear::StateMachine_ptr inner; simgear::StateMachine_ptr inner;
}; };
class StateMachineFunctor : public FunctorBase<Component> class StateMachineFunctor : public FunctorBase<Component>

View file

@ -40,13 +40,12 @@ using std::vector;
using simgear::PropertyList; using simgear::PropertyList;
using FGXMLAutopilot::Autopilot; using FGXMLAutopilot::Autopilot;
class FGXMLAutopilotGroupImplementation: class FGXMLAutopilotGroupImplementation : public FGXMLAutopilotGroup
public FGXMLAutopilotGroup
{ {
public: public:
FGXMLAutopilotGroupImplementation(const std::string& nodeName): FGXMLAutopilotGroupImplementation(const std::string& nodeName):
FGXMLAutopilotGroup(), FGXMLAutopilotGroup(),
_nodeName(nodeName) _nodeName(nodeName)
{} {}
virtual void addAutopilot( const std::string& name, virtual void addAutopilot( const std::string& name,
@ -57,10 +56,9 @@ class FGXMLAutopilotGroupImplementation:
InitStatus incrementalInit(); InitStatus incrementalInit();
void reinit(); void reinit();
private: private:
void initFrom( SGPropertyNode_ptr rootNode, const char * childName ); void initFrom( SGPropertyNode_ptr rootNode, const char * childName );
std::string _nodeName; std::string _nodeName;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View file

@ -26,19 +26,19 @@
/** /**
* @brief Model an autopilot system by implementing a SGSubsystemGroup * @brief Model an autopilot system by implementing a SGSubsystemGroup
* *
*/ */
class FGXMLAutopilotGroup : public SGSubsystemGroup class FGXMLAutopilotGroup : public SGSubsystemGroup
{ {
public: public:
static FGXMLAutopilotGroup * createInstance(const std::string& nodeName); static FGXMLAutopilotGroup * createInstance(const std::string& nodeName);
void addAutopilotFromFile( const std::string & name, SGPropertyNode_ptr apNode, const char * path ); void addAutopilotFromFile( const std::string & name, SGPropertyNode_ptr apNode, const char * path );
virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ) = 0; virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ) = 0;
virtual void removeAutopilot( const std::string & name ) = 0; virtual void removeAutopilot( const std::string & name ) = 0;
protected: protected:
FGXMLAutopilotGroup() : SGSubsystemGroup("FGXMLAutopilotGroup") {} FGXMLAutopilotGroup() : SGSubsystemGroup("FGXMLAutopilotGroup") {}
}; };
#endif // _XMLAUTO_HXX #endif // _XMLAUTO_HXX

View file

@ -35,17 +35,15 @@ namespace FGXMLAutopilot {
/** /**
* @brief Base class for other autopilot components * @brief Base class for other autopilot components
*/ */
class Component : public SGSubsystem { class Component : public SGSubsystem
{
private: private:
SGSharedPtr<const SGCondition> _condition; SGSharedPtr<const SGCondition> _condition;
SGPropertyNode_ptr _enable_prop; SGPropertyNode_ptr _enable_prop;
std::string * _enable_value; std::string * _enable_value;
bool _enabled; bool _enabled;
protected: protected:
virtual bool configure( SGPropertyNode& cfg_node, virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name, const std::string& cfg_name,
SGPropertyNode& prop_root ); SGPropertyNode& prop_root );
@ -55,10 +53,10 @@ protected:
*/ */
virtual void update( double dt ); virtual void update( double dt );
/** /**
* @brief pure virtual function to be implemented by the derived classes. Gets called from * @brief pure virtual function to be implemented by the derived classes. Gets called from
* the update method if it's not disabled with the firstTime parameter set to true if this * the update method if it's not disabled with the firstTime parameter set to true if this
* is the first call after being enabled * is the first call after being enabled
* @param firstTime set to true if this is the first update call since this component has * @param firstTime set to true if this is the first update call since this component has
been enabled. Set to false for every subsequent call. been enabled. Set to false for every subsequent call.
* @param dt the elapsed time since the last call * @param dt the elapsed time since the last call
@ -71,21 +69,20 @@ protected:
*/ */
virtual void disabled( double dt ) {} virtual void disabled( double dt ) {}
/** /**
* @brief debug flag, true if this component should generate some useful output * @brief debug flag, true if this component should generate some useful output
* on every iteration * on every iteration
*/ */
bool _debug; bool _debug;
/** /**
* @brief a (historic) flag signalling the derived class that it should compute it's internal * @brief a (historic) flag signalling the derived class that it should compute it's internal
* state but shall not set the output properties if /autopilot/locks/passive-mode is true. * state but shall not set the output properties if /autopilot/locks/passive-mode is true.
*/ */
bool _honor_passive; bool _honor_passive;
public: public:
/** /**
* @brief A constructor for an empty Component. * @brief A constructor for an empty Component.
*/ */
@ -124,7 +121,7 @@ public:
* &lt;enable&gt; section * &lt;enable&gt; section
* @return true if the enable-condition is true. * @return true if the enable-condition is true.
* *
* If a &lt;condition&gt; is defined, this condition is evaluated, * If a &lt;condition&gt; is defined, this condition is evaluated,
* &lt;prop&gt; and &lt;value&gt; tags are ignored. * &lt;prop&gt; and &lt;value&gt; tags are ignored.
* *
* If a &lt;prop&gt; is defined and no &lt;value&gt; is defined, the property * If a &lt;prop&gt; is defined and no &lt;value&gt; is defined, the property
@ -139,6 +136,6 @@ public:
bool isPropertyEnabled(); bool isPropertyEnabled();
}; };
} }
#endif // COMPONENT_HXX #endif // COMPONENT_HXX

View file

@ -90,12 +90,14 @@ typedef SGSharedPtr<DigitalOutput> DigitalOutput_ptr;
* <li>any number of output properties</li> * <li>any number of output properties</li>
* </ul> * </ul>
*/ */
class DigitalComponent : public Component { class DigitalComponent : public Component
{
public: public:
DigitalComponent(); DigitalComponent();
class InputMap : public std::map<const std::string,SGSharedPtr<const SGCondition> > { class InputMap : public std::map<const std::string,SGSharedPtr<const SGCondition> >
public: {
public:
bool get_value( const std::string & name ) const; bool get_value( const std::string & name ) const;
}; };

View file

@ -37,16 +37,16 @@ namespace FGXMLAutopilot {
*/ */
class DigitalFilter : public AnalogComponent class DigitalFilter : public AnalogComponent
{ {
private: private:
SGSharedPtr<class DigitalFilterImplementation> _implementation; SGSharedPtr<class DigitalFilterImplementation> _implementation;
enum InitializeTo { enum InitializeTo {
INITIALIZE_OUTPUT, INITIALIZE_OUTPUT,
INITIALIZE_INPUT, INITIALIZE_INPUT,
INITIALIZE_NONE INITIALIZE_NONE
}; };
protected: protected:
virtual bool configure( SGPropertyNode& cfg_node, virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name, const std::string& cfg_name,
SGPropertyNode& prop_root ); SGPropertyNode& prop_root );
@ -64,7 +64,6 @@ public:
virtual bool configure( SGPropertyNode& prop_root, virtual bool configure( SGPropertyNode& prop_root,
SGPropertyNode& cfg ); SGPropertyNode& cfg );
}; };
} // namespace FGXMLAutopilot } // namespace FGXMLAutopilot

View file

@ -34,7 +34,7 @@ protected:
/** /**
* @brief configure this component from a property node. Iterates through all nodes found * @brief configure this component from a property node. Iterates through all nodes found
* as childs under configNode and calls configure of the derived class for each child. * as childs under configNode and calls configure of the derived class for each child.
* @param configNode the property node containing the configuration * @param configNode the property node containing the configuration
*/ */
virtual bool configure( SGPropertyNode& cfg_node, virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name, const std::string& cfg_name,
@ -54,7 +54,7 @@ public:
/** /**
* @brief configure this component from a property node. Iterates through all nodes found * @brief configure this component from a property node. Iterates through all nodes found
* as childs under configNode and calls configure of the derived class for each child. * as childs under configNode and calls configure of the derived class for each child.
* @param configNode the property node containing the configuration * @param configNode the property node containing the configuration
*/ */
bool configure( SGPropertyNode& prop_root, bool configure( SGPropertyNode& prop_root,
SGPropertyNode& cfg ); SGPropertyNode& cfg );
@ -63,12 +63,14 @@ public:
/** /**
* @brief A simple flipflop implementation * @brief A simple flipflop implementation
*/ */
class FlipFlop : public Logic { class FlipFlop : public Logic
{
public: public:
protected: protected:
/** /**
* @brief Over-rideable hook method to allow derived classes to refine top-level * @brief Over-rideable hook method to allow derived classes to refine top-level
* node parsing. * node parsing.
* @param aName * @param aName
* @param aNode * @param aNode
* @return true if the node was handled, false otherwise. * @return true if the node was handled, false otherwise.
@ -77,10 +79,10 @@ protected:
const std::string& cfg_name, const std::string& cfg_name,
SGPropertyNode& prop_root ); SGPropertyNode& prop_root );
/** /**
* @brief Implementation of the pure virtual function of the Component class. Gets called from * @brief Implementation of the pure virtual function of the Component class. Gets called from
* the update method if it's not disabled with the firstTime parameter set to true if this * the update method if it's not disabled with the firstTime parameter set to true if this
* is the first call after being enabled * is the first call after being enabled
* @param firstTime set to true if this is the first update call since this component has * @param firstTime set to true if this is the first update call since this component has
been enabled. Set to false for every subsequent call. been enabled. Set to false for every subsequent call.
* @param dt the elapsed time since the last call * @param dt the elapsed time since the last call
@ -88,11 +90,10 @@ protected:
void update( bool firstTime, double dt ); void update( bool firstTime, double dt );
private: private:
/** /**
* @brief Pointer to the actual flip flop implementation * @brief Pointer to the actual flip flop implementation
*/ */
SGSharedPtr<FlipFlopImplementation> _implementation; SGSharedPtr<FlipFlopImplementation> _implementation;
}; };
} }

View file

@ -32,11 +32,13 @@ namespace FGXMLAutopilot {
/** /**
* @brief A simple logic class writing &lt;condition&gt; to a property * @brief A simple logic class writing &lt;condition&gt; to a property
*/ */
class Logic : public DigitalComponent { class Logic : public DigitalComponent
{
public: public:
bool get_input() const; bool get_input() const;
void set_output( bool value ); void set_output( bool value );
bool get_output() const; bool get_output() const;
protected: protected:
void update( bool firstTime, double dt ); void update( bool firstTime, double dt );
}; };

View file

@ -37,8 +37,8 @@ namespace FGXMLAutopilot {
/** /**
* Roy Ovesen's PID controller * Roy Ovesen's PID controller
*/ */
class PIDController : public AnalogComponent { class PIDController : public AnalogComponent
{
private: private:
// Configuration values // Configuration values
InputValueList Kp; // proportional gain InputValueList Kp; // proportional gain
@ -65,6 +65,7 @@ protected:
virtual bool configure( SGPropertyNode& cfg_node, virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name, const std::string& cfg_name,
SGPropertyNode& prop_root ); SGPropertyNode& prop_root );
public: public:
PIDController(); PIDController();
~PIDController() {} ~PIDController() {}

View file

@ -37,10 +37,10 @@ namespace FGXMLAutopilot {
/** /**
* A simplistic P [ + I ] PI controller * A simplistic P [ + I ] PI controller
*/ */
class PISimpleController : public AnalogComponent { class PISimpleController : public AnalogComponent
{
private: private:
// proportional component data // proportional component data
InputValueList _Kp; InputValueList _Kp;
@ -54,7 +54,6 @@ protected:
SGPropertyNode& prop_root ); SGPropertyNode& prop_root );
public: public:
PISimpleController(); PISimpleController();
~PISimpleController() {} ~PISimpleController() {}

View file

@ -44,8 +44,8 @@ namespace FGXMLAutopilot {
* 0.1 would mean (9 parts past value + 1 part current value) / 10 * 0.1 would mean (9 parts past value + 1 part current value) / 10
* 0.25 would mean (3 parts past value + 1 part current value) / 4 * 0.25 would mean (3 parts past value + 1 part current value) / 4
*/ */
class Predictor : public AnalogComponent { class Predictor : public AnalogComponent
{
private: private:
double _last_value; double _last_value;
double _average; double _average;
@ -53,9 +53,9 @@ private:
InputValueList _filter_gain; InputValueList _filter_gain;
protected: protected:
virtual bool configure( SGPropertyNode& cfg_node, virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name, const std::string& cfg_name,
SGPropertyNode& prop_root ); SGPropertyNode& prop_root );
public: public:
Predictor(); Predictor();

View file

@ -35,127 +35,128 @@ class PropertyWatcher;
/** /**
* Top level route manager class * Top level route manager class
* *
*/ */
class FGRouteMgr : public SGSubsystem, class FGRouteMgr : public SGSubsystem,
public flightgear::FlightPlan::Delegate public flightgear::FlightPlan::Delegate
{ {
public: public:
FGRouteMgr(); FGRouteMgr();
~FGRouteMgr(); ~FGRouteMgr();
void init (); void init ();
void postinit (); void postinit ();
void bind (); void bind ();
void unbind (); void unbind ();
void update (double dt); void update (double dt);
bool isRouteActive() const;
int currentIndex() const;
void setFlightPlan(const flightgear::FlightPlanRef& plan);
flightgear::FlightPlanRef flightPlan() const;
void clearRoute();
flightgear::Waypt* currentWaypt() const;
int numLegs() const;
// deprecated
int numWaypts() const
{ return numLegs(); }
// deprecated
flightgear::Waypt* wayptAtIndex(int index) const;
SGPropertyNode_ptr wayptNodeAtIndex(int index) const;
void removeLegAtIndex(int aIndex);
/**
* Activate a built route. This checks for various mandatory pieces of
* data, such as departure and destination airports, and creates waypoints
* for them on the route structure.
*
* returns true if the route was activated successfully, or false if the
* route could not be activated for some reason
*/
bool activate();
/**
* deactivate the route if active
*/
void deactivate();
/** bool isRouteActive() const;
* Set the current waypoint to the specified index.
*/ int currentIndex() const;
void jumpToIndex(int index);
void setFlightPlan(const flightgear::FlightPlanRef& plan);
bool saveRoute(const SGPath& p); flightgear::FlightPlanRef flightPlan() const;
bool loadRoute(const SGPath& p);
void clearRoute();
flightgear::WayptRef waypointFromString(const std::string& target);
flightgear::Waypt* currentWaypt() const;
int numLegs() const;
// deprecated
int numWaypts() const
{ return numLegs(); }
// deprecated
flightgear::Waypt* wayptAtIndex(int index) const;
SGPropertyNode_ptr wayptNodeAtIndex(int index) const;
void removeLegAtIndex(int aIndex);
/**
* Activate a built route. This checks for various mandatory pieces of
* data, such as departure and destination airports, and creates waypoints
* for them on the route structure.
*
* returns true if the route was activated successfully, or false if the
* route could not be activated for some reason
*/
bool activate();
/**
* deactivate the route if active
*/
void deactivate();
/**
* Set the current waypoint to the specified index.
*/
void jumpToIndex(int index);
bool saveRoute(const SGPath& p);
bool loadRoute(const SGPath& p);
flightgear::WayptRef waypointFromString(const std::string& target);
static const char* subsystemName() { return "route-manager"; }
static const char* subsystemName() { return "route-manager"; }
private: private:
bool commandDefineUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root); bool commandDefineUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root);
bool commandDeleteUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root); bool commandDeleteUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root);
flightgear::FlightPlanRef _plan; flightgear::FlightPlanRef _plan;
time_t _takeoffTime; time_t _takeoffTime;
time_t _touchdownTime; time_t _touchdownTime;
// automatic inputs // automatic inputs
SGPropertyNode_ptr magvar; SGPropertyNode_ptr magvar;
// automatic outputs // automatic outputs
SGPropertyNode_ptr departure; ///< departure airport information SGPropertyNode_ptr departure; ///< departure airport information
SGPropertyNode_ptr destination; ///< destination airport information SGPropertyNode_ptr destination; ///< destination airport information
SGPropertyNode_ptr alternate; ///< alternate airport information SGPropertyNode_ptr alternate; ///< alternate airport information
SGPropertyNode_ptr cruise; ///< cruise information SGPropertyNode_ptr cruise; ///< cruise information
SGPropertyNode_ptr totalDistance; SGPropertyNode_ptr totalDistance;
SGPropertyNode_ptr distanceToGo; SGPropertyNode_ptr distanceToGo;
SGPropertyNode_ptr ete; SGPropertyNode_ptr ete;
SGPropertyNode_ptr elapsedFlightTime; SGPropertyNode_ptr elapsedFlightTime;
SGPropertyNode_ptr active; SGPropertyNode_ptr active;
SGPropertyNode_ptr airborne; SGPropertyNode_ptr airborne;
SGPropertyNode_ptr wp0; SGPropertyNode_ptr wp0;
SGPropertyNode_ptr wp1; SGPropertyNode_ptr wp1;
SGPropertyNode_ptr wpn; SGPropertyNode_ptr wpn;
SGPropertyNode_ptr _pathNode; SGPropertyNode_ptr _pathNode;
SGPropertyNode_ptr _currentWpt; SGPropertyNode_ptr _currentWpt;
/** /**
* Signal property to notify people that the route was edited * Signal property to notify people that the route was edited
*/ */
SGPropertyNode_ptr _edited; SGPropertyNode_ptr _edited;
/** /**
* Signal property to notify when the last waypoint is reached * Signal property to notify when the last waypoint is reached
*/ */
SGPropertyNode_ptr _finished; SGPropertyNode_ptr _finished;
SGPropertyNode_ptr _flightplanChanged; SGPropertyNode_ptr _flightplanChanged;
void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance); void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance);
/** /**
* retrieve the cached path distance along a leg * retrieve the cached path distance along a leg
*/ */
double cachedLegPathDistanceM(int index) const; double cachedLegPathDistanceM(int index) const;
double cachedWaypointPathTotalDistance(int index) const; double cachedWaypointPathTotalDistance(int index) const;
class InputListener : public SGPropertyChangeListener { class InputListener : public SGPropertyChangeListener {
public: public:
InputListener(FGRouteMgr *m) : mgr(m) {} InputListener(FGRouteMgr *m) : mgr(m) {}
@ -167,47 +168,47 @@ private:
SGPropertyNode_ptr input; SGPropertyNode_ptr input;
SGPropertyNode_ptr weightOnWheels; SGPropertyNode_ptr weightOnWheels;
SGPropertyNode_ptr groundSpeed; SGPropertyNode_ptr groundSpeed;
InputListener *listener; InputListener *listener;
SGPropertyNode_ptr mirror; SGPropertyNode_ptr mirror;
/** /**
* Helper to keep various pieces of state in sync when the route is * Helper to keep various pieces of state in sync when the route is
* modified (waypoints added, inserted, removed). Notably, this fires the * modified (waypoints added, inserted, removed). Notably, this fires the
* 'edited' signal. * 'edited' signal.
*/ */
virtual void waypointsChanged(); virtual void waypointsChanged();
void update_mirror(); void update_mirror();
virtual void currentWaypointChanged(); virtual void currentWaypointChanged();
// tied getters and setters // tied getters and setters
std::string getDepartureICAO() const; std::string getDepartureICAO() const;
std::string getDepartureName() const; std::string getDepartureName() const;
void setDepartureICAO(const std::string& aIdent); void setDepartureICAO(const std::string& aIdent);
std::string getDepartureRunway() const; std::string getDepartureRunway() const;
void setDepartureRunway(const std::string& aIdent); void setDepartureRunway(const std::string& aIdent);
std::string getSID() const; std::string getSID() const;
void setSID(const std::string& aIdent); void setSID(const std::string& aIdent);
std::string getDestinationICAO() const; std::string getDestinationICAO() const;
std::string getDestinationName() const; std::string getDestinationName() const;
void setDestinationICAO(const std::string& aIdent); void setDestinationICAO(const std::string& aIdent);
std::string getDestinationRunway() const; std::string getDestinationRunway() const;
void setDestinationRunway(const std::string& aIdent); void setDestinationRunway(const std::string& aIdent);
std::string getApproach() const; std::string getApproach() const;
void setApproach(const std::string& aIdent); void setApproach(const std::string& aIdent);
std::string getSTAR() const; std::string getSTAR() const;
void setSTAR(const std::string& aIdent); void setSTAR(const std::string& aIdent);
double getDepartureFieldElevation() const; double getDepartureFieldElevation() const;
double getDestinationFieldElevation() const; double getDestinationFieldElevation() const;
int getCruiseAltitudeFt() const; int getCruiseAltitudeFt() const;
void setCruiseAltitudeFt(int ft); void setCruiseAltitudeFt(int ft);
@ -226,5 +227,4 @@ private:
void setAlternate(const std::string &icao); void setAlternate(const std::string &icao);
}; };
#endif // _ROUTE_MGR_HXX #endif // _ROUTE_MGR_HXX

View file

@ -22,10 +22,9 @@
#include <simgear/canvas/CanvasMgr.hxx> #include <simgear/canvas/CanvasMgr.hxx>
#include <simgear/props/PropertyBasedMgr.hxx> #include <simgear/props/PropertyBasedMgr.hxx>
class CanvasMgr: class CanvasMgr : public simgear::canvas::CanvasMgr
public simgear::canvas::CanvasMgr
{ {
public: public:
CanvasMgr(); CanvasMgr();
virtual void init(); virtual void init();
@ -43,7 +42,8 @@ class CanvasMgr:
unsigned int getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const; unsigned int getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const;
static const char* subsystemName() { return "Canvas"; } static const char* subsystemName() { return "Canvas"; }
protected:
protected:
osg::observer_ptr<osg::Camera> _gui_camera; osg::observer_ptr<osg::Camera> _gui_camera;
SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit; SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit;

View file

@ -34,10 +34,9 @@ namespace osgGA
} }
class GUIEventHandler; class GUIEventHandler;
class GUIMgr: class GUIMgr : public SGSubsystem
public SGSubsystem
{ {
public: public:
GUIMgr(); GUIMgr();
simgear::canvas::WindowPtr createWindow(const std::string& name = ""); simgear::canvas::WindowPtr createWindow(const std::string& name = "");
@ -68,8 +67,7 @@ class GUIMgr:
*/ */
void ungrabPointer(const simgear::canvas::WindowPtr& window); void ungrabPointer(const simgear::canvas::WindowPtr& window);
protected: protected:
simgear::canvas::GroupPtr _desktop; simgear::canvas::GroupPtr _desktop;
osg::ref_ptr<GUIEventHandler> _event_handler; osg::ref_ptr<GUIEventHandler> _event_handler;

View file

@ -69,29 +69,30 @@ public:
{ {
_cachedItemsValid = false; _cachedItemsValid = false;
} }
double textureSize() const double textureSize() const
{ return _textureSize; } { return _textureSize; }
void forceUpdate() void forceUpdate()
{ _forceUpdate = true; } { _forceUpdate = true; }
bool anyRuleForType(const std::string& type) const; bool anyRuleForType(const std::string& type) const;
bool isPositionedShown(FGPositioned* pos); bool isPositionedShown(FGPositioned* pos);
protected: protected:
std::string _name; std::string _name;
int _num; int _num;
double _time; double _time;
double _updateInterval; double _updateInterval;
bool _forceUpdate; bool _forceUpdate;
SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _Instrument; SGPropertyNode_ptr _Instrument;
SGPropertyNode_ptr _radar_mode_control_node; SGPropertyNode_ptr _radar_mode_control_node;
SGPropertyNode_ptr _user_heading_node; SGPropertyNode_ptr _user_heading_node;
SGPropertyNode_ptr _testModeNode; SGPropertyNode_ptr _testModeNode;
SGPropertyNode_ptr _userLatNode, _userLonNode, _userPositionEnable; SGPropertyNode_ptr _userLatNode, _userLonNode, _userPositionEnable;
FGODGauge *_odg; FGODGauge *_odg;
// Convenience function for creating a property node with a // Convenience function for creating a property node with a
@ -102,13 +103,13 @@ protected:
private: private:
friend class SymbolRule; friend class SymbolRule;
friend class SymbolDef; friend class SymbolDef;
void addRule(SymbolRule*); void addRule(SymbolRule*);
void addSymbolsToScene(); void addSymbolsToScene();
void addSymbolToScene(SymbolInstance* sym); void addSymbolToScene(SymbolInstance* sym);
void limitDisplayedSymbols(); void limitDisplayedSymbols();
void findItems(); void findItems();
void isPositionedShownInner(FGPositioned* pos, SymbolRuleVector& rules); void isPositionedShownInner(FGPositioned* pos, SymbolRuleVector& rules);
void foundPositionedItem(FGPositioned* pos); void foundPositionedItem(FGPositioned* pos);
@ -120,59 +121,58 @@ private:
FGNavRecord* processNavRadio(const SGPropertyNode_ptr& radio); FGNavRecord* processNavRadio(const SGPropertyNode_ptr& radio);
void processAI(); void processAI();
void computeAIStates(const SGPropertyNode* ai, string_set& states); void computeAIStates(const SGPropertyNode* ai, string_set& states);
void computeCustomSymbolStates(const SGPropertyNode* sym, string_set& states); void computeCustomSymbolStates(const SGPropertyNode* sym, string_set& states);
void processCustomSymbols(); void processCustomSymbols();
void findRules(const std::string& type, const string_set& states, SymbolRuleVector& rules); void findRules(const std::string& type, const string_set& states, SymbolRuleVector& rules);
SymbolInstance* addSymbolInstance(const osg::Vec2& proj, double heading, SymbolDef* def, SGPropertyNode* vars); SymbolInstance* addSymbolInstance(const osg::Vec2& proj, double heading, SymbolDef* def, SGPropertyNode* vars);
void addLine(osg::Vec2 a, osg::Vec2 b, const osg::Vec4& color); void addLine(osg::Vec2 a, osg::Vec2 b, const osg::Vec4& color);
osg::Vec2 projectBearingRange(double bearingDeg, double rangeNm) const; osg::Vec2 projectBearingRange(double bearingDeg, double rangeNm) const;
osg::Vec2 projectGeod(const SGGeod& geod) const; osg::Vec2 projectGeod(const SGGeod& geod) const;
bool isProjectedClipped(const osg::Vec2& projected) const; bool isProjectedClipped(const osg::Vec2& projected) const;
void updateFont(); void updateFont();
void addTestSymbol(const std::string& type, const std::string& states, const SGGeod& pos, double heading, SGPropertyNode* vars); void addTestSymbol(const std::string& type, const std::string& states, const SGGeod& pos, double heading, SGPropertyNode* vars);
void addTestSymbols(); void addTestSymbols();
std::string _texture_path; std::string _texture_path;
unsigned int _textureSize; unsigned int _textureSize;
float _scale; // factor to convert nm to display units float _scale; // factor to convert nm to display units
float _view_heading; float _view_heading;
SGPropertyNode_ptr _Radar_controls; SGPropertyNode_ptr _Radar_controls;
SGPropertyNode_ptr _font_node; SGPropertyNode_ptr _font_node;
SGPropertyNode_ptr _ai_enabled_node; SGPropertyNode_ptr _ai_enabled_node;
SGPropertyNode_ptr _navRadio1Node; SGPropertyNode_ptr _navRadio1Node;
SGPropertyNode_ptr _navRadio2Node; SGPropertyNode_ptr _navRadio2Node;
SGPropertyNode_ptr _xCenterNode, _yCenterNode; SGPropertyNode_ptr _xCenterNode, _yCenterNode;
SGPropertyNode_ptr _viewHeadingNode; SGPropertyNode_ptr _viewHeadingNode;
osg::ref_ptr<osg::Texture2D> _symbolTexture; osg::ref_ptr<osg::Texture2D> _symbolTexture;
osg::ref_ptr<osg::Geode> _radarGeode; osg::ref_ptr<osg::Geode> _radarGeode;
osg::ref_ptr<osg::Geode> _textGeode; osg::ref_ptr<osg::Geode> _textGeode;
osg::Geometry *_geom; osg::Geometry *_geom;
osg::DrawArrays* _symbolPrimSet; osg::DrawArrays* _symbolPrimSet;
osg::Vec2Array *_vertices; osg::Vec2Array *_vertices;
osg::Vec2Array *_texCoords; osg::Vec2Array *_texCoords;
osg::Vec4Array* _quadColors; osg::Vec4Array* _quadColors;
osg::Geometry* _lineGeometry; osg::Geometry* _lineGeometry;
osg::DrawArrays* _linePrimSet; osg::DrawArrays* _linePrimSet;
osg::Vec2Array* _lineVertices; osg::Vec2Array* _lineVertices;
osg::Vec4Array* _lineColors; osg::Vec4Array* _lineColors;
osg::Matrixf _centerTrans; osg::Matrixf _centerTrans;
osg::Matrixf _projectMat; osg::Matrixf _projectMat;
osg::ref_ptr<osgText::Font> _font; osg::ref_ptr<osgText::Font> _font;
osg::Vec4 _font_color; osg::Vec4 _font_color;
float _font_size; float _font_size;
@ -182,24 +182,24 @@ private:
SGGeod _pos; SGGeod _pos;
double _rangeNm; double _rangeNm;
SGPropertyNode_ptr _rangeNode; SGPropertyNode_ptr _rangeNode;
SymbolDefVector _definitions; SymbolDefVector _definitions;
SymbolRuleVector _rules; SymbolRuleVector _rules;
FGNavRecord* _nav1Station; FGNavRecord* _nav1Station;
FGNavRecord* _nav2Station; FGNavRecord* _nav2Station;
std::vector<SymbolInstance*> _symbols; std::vector<SymbolInstance*> _symbols;
std::set<FGPositioned*> _routeSources; std::set<FGPositioned*> _routeSources;
bool _cachedItemsValid; bool _cachedItemsValid;
SGVec3d _cachedPos; SGVec3d _cachedPos;
FGPositionedList _itemsInRange; FGPositionedList _itemsInRange;
SGPropertyNode_ptr _excessDataNode; SGPropertyNode_ptr _excessDataNode;
int _maxSymbols; int _maxSymbols;
SGPropertyNode_ptr _customSymbols; SGPropertyNode_ptr _customSymbols;
class CacheListener; class CacheListener;
std::unique_ptr<CacheListener> _cacheListener; std::unique_ptr<CacheListener> _cacheListener;
class ForceUpdateListener; class ForceUpdateListener;
std::unique_ptr<ForceUpdateListener> _forceUpdateListener; std::unique_ptr<ForceUpdateListener> _forceUpdateListener;
}; };

View file

@ -1,7 +1,7 @@
// Air Ground Radar // Air Ground Radar
// //
// Written by Vivian MEAZZA, started Feb 2008. // Written by Vivian MEAZZA, started Feb 2008.
// //
// //
// Copyright (C) 2008 Vivain MEAZZA - vivian.meazza@lineone.net // Copyright (C) 2008 Vivain MEAZZA - vivian.meazza@lineone.net
// //
@ -30,9 +30,9 @@
#include "wxradar.hxx" #include "wxradar.hxx"
class agRadar : public wxRadarBg{ class agRadar : public wxRadarBg
{
public: public:
agRadar ( SGPropertyNode *node ); agRadar ( SGPropertyNode *node );
agRadar (); agRadar ();
virtual ~agRadar (); virtual ~agRadar ();

View file

@ -29,23 +29,22 @@ class SGPropertyNode;
namespace flightgear namespace flightgear
{ {
/** /**
* Manage aircraft displays. * Manage aircraft displays.
*/ */
class CockpitDisplayManager : public SGSubsystemGroup class CockpitDisplayManager : public SGSubsystemGroup
{ {
public: public:
CockpitDisplayManager (); CockpitDisplayManager ();
virtual ~CockpitDisplayManager (); virtual ~CockpitDisplayManager ();
virtual void init(); virtual void init();
virtual InitStatus incrementalInit(); virtual InitStatus incrementalInit();
private: private:
bool build (SGPropertyNode* config_props); bool build (SGPropertyNode* config_props);
std::vector<std::string> _displays; std::vector<std::string> _displays;
}; };

View file

@ -36,7 +36,9 @@ class FGPavement;
// Built-in layer for the atc radar. // Built-in layer for the atc radar.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
class GroundRadar : public SGSubsystem, public SGPropertyChangeListener, private FGODGauge class GroundRadar : public SGSubsystem,
public SGPropertyChangeListener,
private FGODGauge
{ {
public: public:
static const int TextureHalfSize = 256; static const int TextureHalfSize = 256;
@ -45,12 +47,13 @@ public:
void updateTexture(); void updateTexture();
virtual void valueChanged(SGPropertyNode*); virtual void valueChanged(SGPropertyNode*);
virtual void update (double dt); virtual void update (double dt);
protected: protected:
void createTexture(const char* texture_name); void createTexture(const char* texture_name);
void addRunwayVertices(const FGRunwayBase* aRunway, double aTowerLat, double aTowerLon, double aScale, osg::Vec3Array* aVertices); void addRunwayVertices(const FGRunwayBase* aRunway, double aTowerLat, double aTowerLon, double aScale, osg::Vec3Array* aVertices);
osg::Geometry *addPavementGeometry(const FGPavement* aPavement, double aTowerLat, double aTowerLon, double aScale); osg::Geometry *addPavementGeometry(const FGPavement* aPavement, double aTowerLat, double aTowerLon, double aScale);
osg::ref_ptr<osg::Geode> _geode; osg::ref_ptr<osg::Geode> _geode;
SGPropertyNode_ptr _airport_node; SGPropertyNode_ptr _airport_node;
SGPropertyNode_ptr _range_node; SGPropertyNode_ptr _range_node;

View file

@ -36,16 +36,17 @@
class FGODGauge; class FGODGauge;
class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener { class wxRadarBg : public SGSubsystem,
public SGPropertyChangeListener
{
public: public:
wxRadarBg(SGPropertyNode *node); wxRadarBg(SGPropertyNode *node);
wxRadarBg(); wxRadarBg();
virtual ~wxRadarBg(); virtual ~wxRadarBg();
virtual void init(); virtual void init();
virtual void shutdown(); virtual void shutdown();
virtual void update(double dt); virtual void update(double dt);
virtual void valueChanged(SGPropertyNode *); virtual void valueChanged(SGPropertyNode *);
@ -75,7 +76,7 @@ protected:
double elevation; double elevation;
double bumpiness; double bumpiness;
double elapsed_time; double elapsed_time;
}ground_echo; } ground_echo;
typedef std::vector <ground_echo*> ground_echo_vector_type; typedef std::vector <ground_echo*> ground_echo_vector_type;
typedef ground_echo_vector_type::iterator ground_echo_vector_iterator; typedef ground_echo_vector_type::iterator ground_echo_vector_iterator;
@ -200,5 +201,4 @@ SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, const char *value
return result; return result;
} }
#endif // _INST_WXRADAR_HXX #endif // _INST_WXRADAR_HXX

View file

@ -25,10 +25,13 @@
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
namespace Environment { namespace Environment {
class LayerInterpolateController : public SGSubsystem {
public: class LayerInterpolateController : public SGSubsystem
static LayerInterpolateController * createInstance( SGPropertyNode_ptr rootNode ); {
}; public:
static LayerInterpolateController * createInstance( SGPropertyNode_ptr rootNode );
};
} // namespace } // namespace
#endif // _ENVIRONMENT_CTRL_HXX #endif // _ENVIRONMENT_CTRL_HXX

View file

@ -38,62 +38,60 @@ class SGSky;
*/ */
class FGEnvironmentMgr : public SGSubsystemGroup class FGEnvironmentMgr : public SGSubsystemGroup
{ {
public: public:
enum {
MAX_CLOUD_LAYERS = 5
};
enum { FGEnvironmentMgr ();
MAX_CLOUD_LAYERS = 5 virtual ~FGEnvironmentMgr ();
};
FGEnvironmentMgr (); virtual InitStatus incrementalInit ();
virtual ~FGEnvironmentMgr (); virtual void reinit ();
virtual void shutdown ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
virtual InitStatus incrementalInit (); /**
virtual void reinit (); * Get the environment information for the plane's current position.
virtual void shutdown (); */
virtual void bind (); virtual FGEnvironment getEnvironment () const;
virtual void unbind ();
virtual void update (double dt);
/** /**
* Get the environment information for the plane's current position. * Get the environment information for another location.
*/ */
virtual FGEnvironment getEnvironment () const; virtual FGEnvironment getEnvironment (double lat, double lon,
double alt) const;
virtual FGEnvironment getEnvironment(const SGGeod& aPos) const;
/**
* Get the environment information for another location.
*/
virtual FGEnvironment getEnvironment (double lat, double lon,
double alt) const;
virtual FGEnvironment getEnvironment(const SGGeod& aPos) const;
private: private:
void updateClosestAirport(); void updateClosestAirport();
double get_cloud_layer_span_m (int index) const;
void set_cloud_layer_span_m (int index, double span_m);
double get_cloud_layer_elevation_ft (int index) const;
void set_cloud_layer_elevation_ft (int index, double elevation_ft);
double get_cloud_layer_thickness_ft (int index) const;
void set_cloud_layer_thickness_ft (int index, double thickness_ft);
double get_cloud_layer_transition_ft (int index) const;
void set_cloud_layer_transition_ft (int index, double transition_ft);
const char * get_cloud_layer_coverage (int index) const;
void set_cloud_layer_coverage (int index, const char * coverage);
int get_cloud_layer_coverage_type (int index) const;
void set_cloud_layer_coverage_type (int index, int type );
double get_cloud_layer_visibility_m (int index) const;
void set_cloud_layer_visibility_m (int index, double visibility_m);
double get_cloud_layer_maxalpha (int index ) const;
void set_cloud_layer_maxalpha (int index, double maxalpha);
FGEnvironment * _environment; // always the same, for now double get_cloud_layer_span_m (int index) const;
FGClouds *fgClouds; void set_cloud_layer_span_m (int index, double span_m);
bool _cloudLayersDirty; double get_cloud_layer_elevation_ft (int index) const;
simgear::TiedPropertyList _tiedProperties; void set_cloud_layer_elevation_ft (int index, double elevation_ft);
SGPropertyChangeListener * _3dCloudsEnableListener; double get_cloud_layer_thickness_ft (int index) const;
SGSky* _sky; void set_cloud_layer_thickness_ft (int index, double thickness_ft);
double get_cloud_layer_transition_ft (int index) const;
void set_cloud_layer_transition_ft (int index, double transition_ft);
const char * get_cloud_layer_coverage (int index) const;
void set_cloud_layer_coverage (int index, const char * coverage);
int get_cloud_layer_coverage_type (int index) const;
void set_cloud_layer_coverage_type (int index, int type );
double get_cloud_layer_visibility_m (int index) const;
void set_cloud_layer_visibility_m (int index, double visibility_m);
double get_cloud_layer_maxalpha (int index ) const;
void set_cloud_layer_maxalpha (int index, double maxalpha);
FGEnvironment * _environment; // always the same, for now
FGClouds *fgClouds;
bool _cloudLayersDirty;
simgear::TiedPropertyList _tiedProperties;
SGPropertyChangeListener * _3dCloudsEnableListener;
SGSky* _sky;
}; };
#endif // _ENVIRONMENT_MGR_HXX #endif // _ENVIRONMENT_MGR_HXX

View file

@ -36,25 +36,24 @@ class SGPropertyNode;
class Ephemeris : public SGSubsystem class Ephemeris : public SGSubsystem
{ {
public: public:
Ephemeris();
~Ephemeris();
Ephemeris(); virtual void bind();
~Ephemeris(); virtual void unbind();
virtual void update(double dt);
virtual void bind(); virtual void init();
virtual void unbind();
virtual void update(double dt);
virtual void init();
virtual void shutdown(); virtual void shutdown();
virtual void postinit(); virtual void postinit();
static const char* subsystemName() { return "ephemeris"; } static const char* subsystemName() { return "ephemeris"; }
SGEphemeris* data(); SGEphemeris* data();
private: private:
std::unique_ptr<SGEphemeris> _impl; std::unique_ptr<SGEphemeris> _impl;
SGPropertyNode_ptr _latProp; SGPropertyNode_ptr _latProp;
SGPropertyNode_ptr _moonlight; SGPropertyNode_ptr _moonlight;
}; };
#endif // of FG_ENVIRONMENT_EPHEMERIS_HXX #endif // of FG_ENVIRONMENT_EPHEMERIS_HXX

View file

@ -33,17 +33,17 @@ class FGMagVarManager : public SGSubsystem
public: public:
FGMagVarManager(); FGMagVarManager();
virtual ~FGMagVarManager(); virtual ~FGMagVarManager();
virtual void init(); virtual void init();
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
virtual void update(double dt); virtual void update(double dt);
private: private:
std::unique_ptr<SGMagVar> _magVar; std::unique_ptr<SGMagVar> _magVar;
SGPropertyNode_ptr _magVarNode, _magDipNode; SGPropertyNode_ptr _magVarNode, _magDipNode;
}; };
#endif // of FG_MAGVAR_MANAGER #endif // of FG_MAGVAR_MANAGER

View file

@ -171,6 +171,7 @@ public:
typedef std::vector<LiveMetarProperties_ptr> MetarPropertiesList; typedef std::vector<LiveMetarProperties_ptr> MetarPropertiesList;
MetarPropertiesList::iterator findMetarAtPath(const string &propPath); MetarPropertiesList::iterator findMetarAtPath(const string &propPath);
protected: protected:
void bind(); void bind();
void unbind(); void unbind();
@ -189,7 +190,6 @@ protected:
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
MetarPropertiesList _metarProperties; MetarPropertiesList _metarProperties;
MetarRequester* _requester; MetarRequester* _requester;
}; };
static bool commandRequestMetar(const SGPropertyNode * arg, SGPropertyNode * root) static bool commandRequestMetar(const SGPropertyNode * arg, SGPropertyNode * root)
@ -400,7 +400,8 @@ void BasicRealWxController::checkNearbyMetar()
/* -------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------- */
class NoaaMetarRealWxController : public BasicRealWxController, MetarRequester { class NoaaMetarRealWxController : public BasicRealWxController, MetarRequester
{
public: public:
NoaaMetarRealWxController( SGPropertyNode_ptr rootNode ); NoaaMetarRealWxController( SGPropertyNode_ptr rootNode );
@ -410,6 +411,7 @@ public:
virtual ~NoaaMetarRealWxController() virtual ~NoaaMetarRealWxController()
{ {
} }
private: private:
std::string noaa_base_url; std::string noaa_base_url;
}; };

View file

@ -25,13 +25,15 @@
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
namespace Environment { namespace Environment {
class RealWxController : public SGSubsystem class RealWxController : public SGSubsystem
{ {
public: public:
virtual ~RealWxController(); virtual ~RealWxController();
static RealWxController * createInstance( SGPropertyNode_ptr rootNode ); static RealWxController * createInstance( SGPropertyNode_ptr rootNode );
}; };
} // namespace } // namespace

View file

@ -4,7 +4,7 @@
// Copyright (C) 2009 Patrice Poly - p.polypa@gmail.com // Copyright (C) 2009 Patrice Poly - p.polypa@gmail.com
// //
// //
// Entirely based on the paper : // Entirely based on the paper :
// http://carrier.csi.cam.ac.uk/forsterlewis/soaring/sim/fsx/dev/sim_probe/sim_probe_paper.html // http://carrier.csi.cam.ac.uk/forsterlewis/soaring/sim/fsx/dev/sim_probe/sim_probe_paper.html
// by Ian Forster-Lewis, University of Cambridge, 26th December 2007 // by Ian Forster-Lewis, University of Cambridge, 26th December 2007
// //
@ -38,50 +38,50 @@ using std::string;
#include <simgear/props/tiedpropertylist.hxx> #include <simgear/props/tiedpropertylist.hxx>
class FGRidgeLift : public SGSubsystem { class FGRidgeLift : public SGSubsystem
{
public: public:
FGRidgeLift();
~FGRidgeLift();
FGRidgeLift(); virtual void bind();
~FGRidgeLift(); virtual void unbind();
virtual void update(double dt);
virtual void bind(); virtual void init();
virtual void unbind();
virtual void update(double dt);
virtual void init();
inline double getStrength() const { return strength; }; inline double getStrength() const { return strength; };
inline double get_probe_elev_m( int index ) const { return probe_elev_m[index]; }; inline double get_probe_elev_m( int index ) const { return probe_elev_m[index]; };
inline double get_probe_lat_deg( int index ) const { return probe_lat_deg[index]; }; inline double get_probe_lat_deg( int index ) const { return probe_lat_deg[index]; };
inline double get_probe_lon_deg( int index ) const { return probe_lon_deg[index]; }; inline double get_probe_lon_deg( int index ) const { return probe_lon_deg[index]; };
inline double get_slope( int index ) const { return slope[index]; }; inline double get_slope( int index ) const { return slope[index]; };
private: private:
static const double dist_probe_m[5]; static const double dist_probe_m[5];
double strength; double strength;
double timer; double timer;
double probe_lat_deg[5]; double probe_lat_deg[5];
double probe_lon_deg[5]; double probe_lon_deg[5];
double probe_elev_m[5]; double probe_elev_m[5];
double slope[4]; double slope[4];
double lift_factor; double lift_factor;
SGPropertyNode_ptr _enabled_node; SGPropertyNode_ptr _enabled_node;
SGPropertyNode_ptr _ridge_lift_fps_node; SGPropertyNode_ptr _ridge_lift_fps_node;
SGPropertyNode_ptr _surface_wind_from_deg_node; SGPropertyNode_ptr _surface_wind_from_deg_node;
SGPropertyNode_ptr _surface_wind_speed_node; SGPropertyNode_ptr _surface_wind_speed_node;
SGPropertyNode_ptr _user_altitude_agl_ft_node; SGPropertyNode_ptr _user_altitude_agl_ft_node;
SGPropertyNode_ptr _user_longitude_node; SGPropertyNode_ptr _user_longitude_node;
SGPropertyNode_ptr _user_latitude_node; SGPropertyNode_ptr _user_latitude_node;
SGPropertyNode_ptr _ground_elev_node; SGPropertyNode_ptr _ground_elev_node;
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
}; };
#endif // _FG_RidgeLift_HXX #endif // _FG_RidgeLift_HXX

View file

@ -1,7 +1,7 @@
// terrainsampler.cxx -- // terrainsampler.cxx --
// //
// Written by Torsten Dreyer, started July 2010 // Written by Torsten Dreyer, started July 2010
// Based on local weather implementation in nasal from // Based on local weather implementation in nasal from
// Thorsten Renk // Thorsten Renk
// //
// Copyright (C) 2010 Curtis Olson // Copyright (C) 2010 Curtis Olson
@ -40,10 +40,12 @@ using std::string;
#include <simgear/props/tiedpropertylist.hxx> #include <simgear/props/tiedpropertylist.hxx>
namespace Environment { namespace Environment {
/** /**
* @brief Class for presampling the terrain roughness * @brief Class for presampling the terrain roughness
*/ */
class AreaSampler : public SGSubsystem { class AreaSampler : public SGSubsystem
{
public: public:
AreaSampler( SGPropertyNode_ptr rootNode ); AreaSampler( SGPropertyNode_ptr rootNode );
virtual ~AreaSampler(); virtual ~AreaSampler();
@ -54,13 +56,13 @@ public:
void reinit(); void reinit();
int getElevationHistogramStep() const { return _elevationHistogramStep; } int getElevationHistogramStep() const { return _elevationHistogramStep; }
void setElevationHistograpStep( int value ) { void setElevationHistograpStep( int value ) {
_elevationHistogramStep = value > 0 ? value : 500; _elevationHistogramStep = value > 0 ? value : 500;
_elevationHistogramCount = _elevationHistogramMax / _elevationHistogramStep; _elevationHistogramCount = _elevationHistogramMax / _elevationHistogramStep;
} }
int getElevationHistogramMax() const { return _elevationHistogramMax; } int getElevationHistogramMax() const { return _elevationHistogramMax; }
void setElevationHistograpMax( int value ) { void setElevationHistograpMax( int value ) {
_elevationHistogramMax = value > 0 ? value : 10000; _elevationHistogramMax = value > 0 ? value : 10000;
_elevationHistogramCount = _elevationHistogramMax / _elevationHistogramStep; _elevationHistogramCount = _elevationHistogramMax / _elevationHistogramStep;
} }
@ -192,9 +194,9 @@ void AreaSampler::update( double dt )
// get the aircraft's position if requested // get the aircraft's position if requested
if( _useAircraftPosition && _speed_kt < 0.5 ) { if( _useAircraftPosition && _speed_kt < 0.5 ) {
_inputPosition = SGGeod::fromDegM( _inputPosition = SGGeod::fromDegM(
_positionLongitudeNode->getDoubleValue(), _positionLongitudeNode->getDoubleValue(),
_positionLatitudeNode->getDoubleValue(), _positionLatitudeNode->getDoubleValue(),
SG_MAX_ELEVATION_M ); SG_MAX_ELEVATION_M );
} }
@ -231,11 +233,11 @@ void AreaSampler::update( double dt )
SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, distance )); SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, distance ));
double elevation_m = 0.0; double elevation_m = 0.0;
if (scenery->get_elevation_m( probe, elevation_m, NULL )) if (scenery->get_elevation_m( probe, elevation_m, NULL ))
_elevations.push_front(elevation_m *= SG_METER_TO_FEET); _elevations.push_front(elevation_m *= SG_METER_TO_FEET);
if( _elevations.size() >= (deque<unsigned>::size_type)_max_samples ) { if( _elevations.size() >= (deque<unsigned>::size_type)_max_samples ) {
// sampling complete? // sampling complete?
analyse(); analyse();
_outputPosition = _inputPosition; _outputPosition = _inputPosition;
_signalNode->setBoolValue( true ); _signalNode->setBoolValue( true );
@ -249,7 +251,7 @@ void AreaSampler::analyse()
double sum; double sum;
vector<int> histogram(_elevationHistogramCount,0); vector<int> histogram(_elevationHistogramCount,0);
for( deque<double>::size_type i = 0; i < _elevations.size(); i++ ) { for( deque<double>::size_type i = 0; i < _elevations.size(); i++ ) {
int idx = SGMisc<int>::clip( (int)(_elevations[i]/_elevationHistogramStep), 0, histogram.size()-1 ); int idx = SGMisc<int>::clip( (int)(_elevations[i]/_elevationHistogramStep), 0, histogram.size()-1 );
histogram[idx]++; histogram[idx]++;
@ -275,7 +277,7 @@ void AreaSampler::analyse()
} }
} }
_altMean = 0.0; _altMean = 0.0;
for( vector<int>::size_type i = 0; i < histogram.size(); i++ ) { for( vector<int>::size_type i = 0; i < histogram.size(); i++ ) {
_altMean += histogram[i] * i; _altMean += histogram[i] * i;
} }
@ -319,7 +321,7 @@ class TerrainSamplerImplementation : public TerrainSampler
public: public:
TerrainSamplerImplementation ( SGPropertyNode_ptr rootNode ); TerrainSamplerImplementation ( SGPropertyNode_ptr rootNode );
virtual ~TerrainSamplerImplementation (); virtual ~TerrainSamplerImplementation ();
virtual void init (); virtual void init ();
virtual InitStatus incrementalInit (); virtual InitStatus incrementalInit ();
virtual void postinit(); virtual void postinit();
@ -327,11 +329,12 @@ public:
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
virtual void update (double delta_time_sec); virtual void update (double delta_time_sec);
private: private:
inline string areaSubsystemName( unsigned i ) { inline string areaSubsystemName( unsigned i ) {
ostringstream name; ostringstream name;
name << "area" << i; name << "area" << i;
return name.str(); return name.str();
} }
SGPropertyNode_ptr _rootNode; SGPropertyNode_ptr _rootNode;
@ -348,7 +351,7 @@ TerrainSamplerImplementation::TerrainSamplerImplementation( SGPropertyNode_ptr r
TerrainSamplerImplementation::~TerrainSamplerImplementation() TerrainSamplerImplementation::~TerrainSamplerImplementation()
{ {
} }
SGSubsystem::InitStatus TerrainSamplerImplementation::incrementalInit() SGSubsystem::InitStatus TerrainSamplerImplementation::incrementalInit()
{ {
init(); init();
@ -358,7 +361,7 @@ SGSubsystem::InitStatus TerrainSamplerImplementation::incrementalInit()
void TerrainSamplerImplementation::init() void TerrainSamplerImplementation::init()
{ {
PropertyList areaNodes = _rootNode->getChildren( "area" ); PropertyList areaNodes = _rootNode->getChildren( "area" );
for( PropertyList::size_type i = 0; i < areaNodes.size(); i++ ) for( PropertyList::size_type i = 0; i < areaNodes.size(); i++ )
set_subsystem( areaSubsystemName(i), new AreaSampler( areaNodes[i] ) ); set_subsystem( areaSubsystemName(i), new AreaSampler( areaNodes[i] ) );
@ -380,7 +383,7 @@ void TerrainSamplerImplementation::reinit()
subsys->unbind(); subsys->unbind();
delete subsys; delete subsys;
} }
init(); init();
} }

View file

@ -1,7 +1,7 @@
// terrainsampler.hxx -- // terrainsampler.hxx --
// //
// Written by Torsten Dreyer, started July 2010 // Written by Torsten Dreyer, started July 2010
// Based on local weather implementation in nasal from // Based on local weather implementation in nasal from
// Thorsten Renk // Thorsten Renk
// //
// Copyright (C) 2010 Curtis Olson // Copyright (C) 2010 Curtis Olson
@ -26,11 +26,12 @@
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
namespace Environment { namespace Environment {
class TerrainSampler : public SGSubsystemGroup class TerrainSampler : public SGSubsystemGroup
{ {
public: public:
TerrainSampler() : SGSubsystemGroup("TerrainSampler") {} TerrainSampler() : SGSubsystemGroup("TerrainSampler") {}
static TerrainSampler * createInstance( SGPropertyNode_ptr rootNode ); static TerrainSampler * createInstance( SGPropertyNode_ptr rootNode );
}; };
} // namespace } // namespace

View file

@ -31,10 +31,9 @@
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
class FGExternalNet: public FGInterface { class FGExternalNet : public FGInterface
{
private: private:
int data_in_port; int data_in_port;
int data_out_port; int data_out_port;
int cmd_port; int cmd_port;
@ -49,7 +48,6 @@ private:
FGNetFDM fdm; FGNetFDM fdm;
public: public:
// Constructor // Constructor
FGExternalNet( double dt, std::string host, int dop, int dip, int cp ); FGExternalNet( double dt, std::string host, int dop, int dip, int cp );
@ -61,8 +59,6 @@ public:
// update the fdm // update the fdm
void update( double dt ); void update( double dt );
}; };
#endif // _EXTERNAL_NET_HXX #endif // _EXTERNAL_NET_HXX

View file

@ -32,10 +32,9 @@
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
class FGExternalPipe: public FGInterface { class FGExternalPipe : public FGInterface
{
private: private:
bool valid; bool valid;
std::string fifo_name_1; std::string fifo_name_1;
@ -63,8 +62,8 @@ private:
void update_property( double dt ); void update_property( double dt );
void process_set_command( const string_list &tokens ); void process_set_command( const string_list &tokens );
public:
public:
// Constructor // Constructor
FGExternalPipe( double dt, std::string fifo_name, std::string protocol ); FGExternalPipe( double dt, std::string fifo_name, std::string protocol );
@ -76,8 +75,6 @@ public:
// update the fdm // update the fdm
void update( double dt ); void update( double dt );
}; };
#endif // _EXTERNAL_PIPE_HXX #endif // _EXTERNAL_PIPE_HXX

View file

@ -98,11 +98,12 @@ CLASS DOCUMENTATION
CLASS DECLARATION CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGJSBsim: public FGInterface { class FGJSBsim : public FGInterface
{
public: public:
/// Constructor /// Constructor
FGJSBsim( double dt ); FGJSBsim( double dt );
/// Destructor /// Destructor
~FGJSBsim(); ~FGJSBsim();
@ -221,6 +222,7 @@ public:
double get_agl_ft(double t, const JSBSim::FGColumnVector3& loc, double get_agl_ft(double t, const JSBSim::FGColumnVector3& loc,
double alt_off, double contact[3], double normal[3], double alt_off, double contact[3], double normal[3],
double vel[3], double angularVel[3]); double vel[3], double angularVel[3]);
private: private:
JSBSim::FGFDMExec *fdmex; JSBSim::FGFDMExec *fdmex;
JSBSim::FGInitialCondition *fgic; JSBSim::FGInitialCondition *fgic;
@ -274,7 +276,7 @@ private:
SGPropertyNode_ptr ab_brake_engaged; SGPropertyNode_ptr ab_brake_engaged;
SGPropertyNode_ptr ab_brake_left_pct; SGPropertyNode_ptr ab_brake_left_pct;
SGPropertyNode_ptr ab_brake_right_pct; SGPropertyNode_ptr ab_brake_right_pct;
SGPropertyNode_ptr gear_pos_pct; SGPropertyNode_ptr gear_pos_pct;
SGPropertyNode_ptr wing_fold_pos_pct; SGPropertyNode_ptr wing_fold_pos_pct;
SGPropertyNode_ptr tailhook_pos_pct; SGPropertyNode_ptr tailhook_pos_pct;
@ -324,5 +326,4 @@ private:
void update_external_forces(double t_off); void update_external_forces(double t_off);
}; };
#endif // _JSBSIM_HXX #endif // _JSBSIM_HXX

View file

@ -32,10 +32,9 @@
#include "IO360.hxx" #include "IO360.hxx"
#include "LaRCsimIC.hxx" #include "LaRCsimIC.hxx"
class FGLaRCsim: public FGInterface { class FGLaRCsim : public FGInterface
{
private: private:
FGNewEngine eng; FGNewEngine eng;
LaRCsimIC* lsic; LaRCsimIC* lsic;
void set_ls(void); void set_ls(void);
@ -44,47 +43,46 @@ private:
SGPropertyNode_ptr aero; SGPropertyNode_ptr aero;
SGPropertyNode_ptr uiuc_type; SGPropertyNode_ptr uiuc_type;
double mass, i_xx, i_yy, i_zz, i_xz; double mass, i_xx, i_yy, i_zz, i_xz;
public:
public:
FGLaRCsim( double dt ); FGLaRCsim( double dt );
~FGLaRCsim(void); ~FGLaRCsim(void);
// copy FDM state to LaRCsim structures // copy FDM state to LaRCsim structures
bool copy_to_LaRCsim(); bool copy_to_LaRCsim();
// copy FDM state from LaRCsim structures // copy FDM state from LaRCsim structures
bool copy_from_LaRCsim(); bool copy_from_LaRCsim();
// reset flight params to a specific position // reset flight params to a specific position
void init(); void init();
// update position based on inputs, positions, velocities, etc. // update position based on inputs, positions, velocities, etc.
void update( double dt ); void update( double dt );
// Positions // Positions
void set_Latitude(double lat); //geocentric void set_Latitude(double lat); //geocentric
void set_Longitude(double lon); void set_Longitude(double lon);
void set_Altitude(double alt); // triggers re-calc of AGL altitude void set_Altitude(double alt); // triggers re-calc of AGL altitude
void set_AltitudeAGL(double altagl); // and vice-versa void set_AltitudeAGL(double altagl); // and vice-versa
// Speeds -- setting any of these will trigger a re-calc of the rest // Speeds -- setting any of these will trigger a re-calc of the rest
void set_V_calibrated_kts(double vc); void set_V_calibrated_kts(double vc);
void set_Mach_number(double mach); void set_Mach_number(double mach);
void set_Velocities_Local( double north, double east, double down ); void set_Velocities_Local( double north, double east, double down );
void set_Velocities_Body( double u, double v, double w); void set_Velocities_Body( double u, double v, double w);
// Euler angles // Euler angles
void set_Euler_Angles( double phi, double theta, double psi ); void set_Euler_Angles( double phi, double theta, double psi );
// Flight Path // Flight Path
void set_Climb_Rate( double roc); void set_Climb_Rate( double roc);
void set_Gamma_vert_rad( double gamma); void set_Gamma_vert_rad( double gamma);
// Earth // Earth
void set_Static_pressure(double p); void set_Static_pressure(double p);
void set_Static_temperature(double T); void set_Static_temperature(double T);
void set_Density(double rho); void set_Density(double rho);
// Inertias // Inertias
double get_Mass() const { return mass; } double get_Mass() const { return mass; }
@ -103,7 +101,4 @@ public:
} }
}; };
#endif // _LARCSIM_HXX #endif // _LARCSIM_HXX

View file

@ -29,18 +29,17 @@
#include "flight.hxx" #include "flight.hxx"
class FGNullFDM: public FGInterface { class FGNullFDM : public FGInterface
{
public: public:
FGNullFDM( double dt ); FGNullFDM( double dt );
~FGNullFDM(); ~FGNullFDM();
// reset flight params to a specific position // reset flight params to a specific position
void init(); void init();
// update position based on inputs, positions, velocities, etc. // update position based on inputs, positions, velocities, etc.
void update( double dt ); void update( double dt );
}; };
#endif // _NULLFDM_HXX #endif // _NULLFDM_HXX

View file

@ -28,25 +28,23 @@
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
class FGACMS: public FGInterface class FGACMS : public FGInterface
{ {
public: public:
FGACMS( double dt ); FGACMS( double dt );
~FGACMS(); ~FGACMS();
// reset flight params to a specific position // reset flight params to a specific position
void init(); void init();
// update position based on properties // update position based on properties
void update( double dt ); void update( double dt );
private: private:
SGPropertyNode_ptr _alt, _speed, _climb_rate; SGPropertyNode_ptr _alt, _speed, _climb_rate;
SGPropertyNode_ptr _pitch, _roll, _heading; SGPropertyNode_ptr _pitch, _roll, _heading;
SGPropertyNode_ptr _acc_lat, _acc_lon, _acc_down; SGPropertyNode_ptr _acc_lat, _acc_lon, _acc_down;
SGPropertyNode_ptr _temp, _wow; SGPropertyNode_ptr _temp, _wow;
}; };
#endif // _ACMS_HXX #endif // _ACMS_HXX

View file

@ -26,10 +26,9 @@ class SGSocket;
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
class FGADA: public FGInterface { class FGADA : public FGInterface
{
private: private:
SGSocket *fdmsock; SGSocket *fdmsock;
#if 0 #if 0
// Auxilliary Flight Model parameters, basically for HUD // Auxilliary Flight Model parameters, basically for HUD
@ -71,17 +70,14 @@ private:
bool copy_from_FGADA(); bool copy_from_FGADA();
public: public:
FGADA( double dt ); FGADA( double dt );
~FGADA(); ~FGADA();
// reset flight params to a specific position // reset flight params to a specific position
void init(); void init();
// update position based on inputs, positions, velocities, etc. // update position based on inputs, positions, velocities, etc.
void update(double dt); void update(double dt);
}; };
#endif // _ADA_HXX #endif // _ADA_HXX

View file

@ -38,18 +38,18 @@
#else #else
# include "simd.hxx" # include "simd.hxx"
# include "simd4x4.hxx" # include "simd4x4.hxx"
# define SG_METER_TO_FEET 3.2808399 # define SG_METER_TO_FEET 3.2808399
# define SG_FEET_TO_METER (1/SG_METER_TO_FEET) # define SG_FEET_TO_METER (1/SG_METER_TO_FEET)
# define SGD_DEGREES_TO_RADIANS 0.0174532925 # define SGD_DEGREES_TO_RADIANS 0.0174532925
# define SGD_RADIANS_TO_DEGREES (1/SGD_DEGREES_TO_RADIANS) # define SGD_RADIANS_TO_DEGREES (1/SGD_DEGREES_TO_RADIANS)
# define SGD_PI 3.1415926535 # define SGD_PI 3.1415926535
#endif #endif
// #define SG_DEGREES_TO_RADIANS 0.0174532925f // #define SG_DEGREES_TO_RADIANS 0.0174532925f
// max. no. gears, maxi. no. engines // max. no. gears, maxi. no. engines
#define AISIM_MAX 4 #define AISIM_MAX 4
#define AISIM_G 32.174f #define AISIM_G 32.174f
class FGAISim class FGAISim
#ifdef ENABLE_SP_FDM #ifdef ENABLE_SP_FDM
@ -75,7 +75,7 @@ public:
FGAISim(double dt); FGAISim(double dt);
~FGAISim(); ~FGAISim();
// reset flight params to a specific location // reset flight params to a specific location
void init(); void init();
// update location based on properties // update location based on properties
@ -104,7 +104,7 @@ public:
xClmnT.ptr()[AILERON][ROLL] = Clda_n*f; xClmnT.ptr()[AILERON][ROLL] = Clda_n*f;
xClmnT.ptr()[AILERON][YAW] = Cnda_n*f; xClmnT.ptr()[AILERON][YAW] = Cnda_n*f;
} }
inline void set_flaps_norm(float f) { inline void set_flaps_norm(float f) {
xCDYLT.ptr()[FLAPS][LIFT] = CLdf_n*f; xCDYLT.ptr()[FLAPS][LIFT] = CLdf_n*f;
xCDYLT.ptr()[FLAPS][DRAG] = CDdf_n*std::abs(f); xCDYLT.ptr()[FLAPS][DRAG] = CDdf_n*std::abs(f);
xClmnT.ptr()[FLAPS][PITCH] = Cmdf_n*f; xClmnT.ptr()[FLAPS][PITCH] = Cmdf_n*f;
@ -154,7 +154,7 @@ public:
inline void set_beta_rad(float f) { inline void set_beta_rad(float f) {
xCDYLT.ptr()[BETA][DRAG] = CDb*std::abs(f); xCDYLT.ptr()[BETA][DRAG] = CDb*std::abs(f);
xCDYLT.ptr()[BETA][SIDE] = CYb*f; xCDYLT.ptr()[BETA][SIDE] = CYb*f;
xClmnT.ptr()[BETA][ROLL] = Clb*f; xClmnT.ptr()[BETA][ROLL] = Clb*f;
xClmnT.ptr()[BETA][YAW] = Cnb*f; xClmnT.ptr()[BETA][YAW] = Cnb*f;
AOA[BETA] = f; AOA[BETA] = f;
} }
@ -171,33 +171,33 @@ private:
simd4x4_t<float,4> invert_inertia(simd4x4_t<float,4> mtx); simd4x4_t<float,4> invert_inertia(simd4x4_t<float,4> mtx);
/* aircraft normalized controls */ /* aircraft normalized controls */
float th; /* throttle command */ float th; /* throttle command */
float br; /* brake command */ float br; /* brake command */
/* aircraft state */ /* aircraft state */
simd4_t<double,3> location_geod; /* lat, lon, altitude */ simd4_t<double,3> location_geod; /* lat, lon, altitude */
simd4_t<float,3> aXYZ; /* local body accelrations */ simd4_t<float,3> aXYZ; /* local body accelrations */
simd4_t<float,3> NEDdot; /* North, East, Down velocity */ simd4_t<float,3> NEDdot; /* North, East, Down velocity */
simd4_t<float,3> vUVW; /* fwd, side, down velocity */ simd4_t<float,3> vUVW; /* fwd, side, down velocity */
simd4_t<float,3> vUVWdot; /* fwd, side, down accel. */ simd4_t<float,3> vUVWdot; /* fwd, side, down accel. */
simd4_t<float,3> vPQR; /* roll, pitch, yaw rate */ simd4_t<float,3> vPQR; /* roll, pitch, yaw rate */
simd4_t<float,3> vPQRdot; /* roll, pitch, yaw accel. */ simd4_t<float,3> vPQRdot; /* roll, pitch, yaw accel. */
simd4_t<float,3> AOA; /* alpha, beta */ simd4_t<float,3> AOA; /* alpha, beta */
simd4_t<float,3> AOAdot; /* adot, bdot */ simd4_t<float,3> AOAdot; /* adot, bdot */
simd4_t<float,3> euler; /* phi, theta, psi */ simd4_t<float,3> euler; /* phi, theta, psi */
simd4_t<float,3> euler_dot; /* change in phi, theta, psi */ simd4_t<float,3> euler_dot; /* change in phi, theta, psi */
simd4_t<float,3> wind_ned; /* wind north, east, down */ simd4_t<float,3> wind_ned; /* wind north, east, down */
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* This should reduce the time spent in update() since controls */ /* This should reduce the time spent in update() since controls */
/* change less often than the update function runs which might */ /* change less often than the update function runs which might */
/* run 20 to 60 times (or more) per second */ /* run 20 to 60 times (or more) per second */
/* cache */ /* cache */
simd4_t<float,3> vUVWaero; /* airmass relative to the body */ simd4_t<float,3> vUVWaero; /* airmass relative to the body */
simd4_t<float,3> FT[AISIM_MAX]; /* thrust force */ simd4_t<float,3> FT[AISIM_MAX]; /* thrust force */
simd4_t<float,3> FTM[AISIM_MAX]; /* thrust due to mach force */ simd4_t<float,3> FTM[AISIM_MAX]; /* thrust due to mach force */
simd4_t<float,3> MT[AISIM_MAX]; /* thrust moment */ simd4_t<float,3> MT[AISIM_MAX]; /* thrust moment */
simd4_t<float,3> b_2U, cbar_2U; simd4_t<float,3> b_2U, cbar_2U;
simd4_t<float,3> inv_m; simd4_t<float,3> inv_m;
float velocity, mach; float velocity, mach;
@ -214,17 +214,17 @@ private:
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* aircraft static data */ /* aircraft static data */
int no_engines, no_gears; int no_engines, no_gears;
simd4x4_t<float,4> mI, mIinv; /* inertia matrix */ simd4x4_t<float,4> mI, mIinv; /* inertia matrix */
simd4_t<float,3> gear_pos[AISIM_MAX]; /* pos in structural frame */ simd4_t<float,3> gear_pos[AISIM_MAX]; /* pos in structural frame */
simd4_t<float,3> cg; /* center of gravity */ simd4_t<float,3> cg; /* center of gravity */
simd4_t<float,4> I; /* inertia */ simd4_t<float,4> I; /* inertia */
float S, cbar, b; /* wing area, mean average chord, span */ float S, cbar, b; /* wing area, mean average chord, span */
float m; /* mass */ float m; /* mass */
/* static coefficients, *_n is for normalized surface deflection */ /* static coefficients, *_n is for normalized surface deflection */
float Cg_spring[AISIM_MAX]; /* gear spring coeffients */ float Cg_spring[AISIM_MAX]; /* gear spring coeffients */
float Cg_damp[AISIM_MAX]; /* gear damping coefficients */ float Cg_damp[AISIM_MAX]; /* gear damping coefficients */
float CTmax, CTu; /* thrust max, due to speed */ float CTmax, CTu; /* thrust max, due to speed */
float CLmin, CLa, CLadot, CLq, CLdf_n; float CLmin, CLa, CLadot, CLq, CLdf_n;
float CDmin, CDa, CDb, CDi, CDdf_n; float CDmin, CDa, CDb, CDi, CDdf_n;
float CYb, CYp, CYr, CYdr_n; float CYb, CYp, CYr, CYdr_n;

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Header: BalloonSimInterface.h Header: BalloonSimInterface.h
Author: Christian Mayer Author: Christian Mayer
Date started: 07.10.99 Date started: 07.10.99
@ -25,11 +25,11 @@
FUNCTIONAL DESCRIPTION FUNCTIONAL DESCRIPTION
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
interface to the the hot air balloon simulator interface to the hot air balloon simulator
HISTORY HISTORY
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
07.10.1999 Christian Mayer Created 07.10.1999 Christian Mayer Created
*****************************************************************************/ *****************************************************************************/
/****************************************************************************/ /****************************************************************************/
@ -39,28 +39,27 @@ HISTORY
#define BalloonSimInterface_H #define BalloonSimInterface_H
/****************************************************************************/ /****************************************************************************/
/* INCLUDES */ /* INCLUDES */
/****************************************************************************/ /****************************************************************************/
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
#include "BalloonSim.h" #include "BalloonSim.h"
/****************************************************************************/ /****************************************************************************/
/* DEFINES */ /* DEFINES */
/****************************************************************************/ /****************************************************************************/
/****************************************************************************/ /****************************************************************************/
/* DECLARATIONS */ /* DECLARATIONS */
/****************************************************************************/ /****************************************************************************/
class FGBalloonSim: public FGInterface { class FGBalloonSim : public FGInterface
{
balloon current_balloon; balloon current_balloon;
public: public:
FGBalloonSim( double dt ); FGBalloonSim( double dt );
~FGBalloonSim(); ~FGBalloonSim();
@ -70,17 +69,12 @@ public:
// copy FDM state from BalloonSim structures // copy FDM state from BalloonSim structures
bool copy_from_BalloonSim(); bool copy_from_BalloonSim();
// reset flight params to a specific position // reset flight params to a specific position
void init(); void init();
// update position based on inputs, positions, velocities, etc. // update position based on inputs, positions, velocities, etc.
void update( double dt ); void update( double dt );
}; };
/****************************************************************************/ /****************************************************************************/
#endif /*BalloonSimInterface_H*/ #endif /*BalloonSimInterface_H*/

View file

@ -28,19 +28,17 @@
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
class FGMagicCarpet: public FGInterface { class FGMagicCarpet : public FGInterface
{
public: public:
FGMagicCarpet( double dt ); FGMagicCarpet( double dt );
~FGMagicCarpet(); ~FGMagicCarpet();
// reset flight params to a specific position // reset flight params to a specific position
void init(); void init();
// update position based on inputs, positions, velocities, etc. // update position based on inputs, positions, velocities, etc.
void update( double dt ); void update( double dt );
}; };
#endif // _MAGICCARPET_HXX #endif // _MAGICCARPET_HXX

View file

@ -27,15 +27,17 @@
#include "flight.hxx" #include "flight.hxx"
class FGUFO: public FGInterface { class FGUFO : public FGInterface
{
private: private:
class lowpass
class lowpass { {
private: private:
static double _dt; static double _dt;
double _coeff; double _coeff;
double _last; double _last;
bool _initialized; bool _initialized;
public: public:
lowpass(double coeff) : _coeff(coeff), _initialized(false) {} lowpass(double coeff) : _coeff(coeff), _initialized(false) {}
static inline void set_delta(double dt) { _dt = dt; } static inline void set_delta(double dt) { _dt = dt; }
@ -67,8 +69,6 @@ public:
// update position based on inputs, positions, velocities, etc. // update position based on inputs, positions, velocities, etc.
void update( double dt ); void update( double dt );
}; };
#endif // _UFO_HXX #endif // _UFO_HXX

View file

@ -6,7 +6,8 @@
namespace yasim { class FGFDM; }; namespace yasim { class FGFDM; };
class YASim : public FGInterface { class YASim : public FGInterface
{
public: public:
YASim(double dt); YASim(double dt);
~YASim(); ~YASim();
@ -19,8 +20,7 @@ public:
// Run an iteration // Run an iteration
virtual void update(double dt); virtual void update(double dt);
private: private:
void report(); void report();
void copyFromYASim(); void copyFromYASim();
void copyToYASim(bool copyState); void copyToYASim(bool copyState);

View file

@ -41,36 +41,36 @@ class FGAIManager;
class FDMShell : public SGSubsystem class FDMShell : public SGSubsystem
{ {
public: public:
FDMShell(); FDMShell();
~FDMShell() override; ~FDMShell() override;
void init() override; void init() override;
void shutdown() override; void shutdown() override;
void reinit() override; void reinit() override;
void postinit() override; void postinit() override;
void bind() override; void bind() override;
void unbind() override; void unbind() override;
void update(double dt) override; void update(double dt) override;
FGInterface* getInterface() const; FGInterface* getInterface() const;
static const char* subsystemName() { return "flight"; } static const char* subsystemName() { return "flight"; }
private:
void createImplementation(); private:
void createImplementation();
TankPropertiesList _tankProperties;
SGSharedPtr<FGInterface> _impl; TankPropertiesList _tankProperties;
SGPropertyNode_ptr _props; // root property tree for this FDM instance SGSharedPtr<FGInterface> _impl;
bool _dataLogging; SGPropertyNode_ptr _props; // root property tree for this FDM instance
bool _dataLogging;
SGPropertyNode_ptr _wind_north, _wind_east,_wind_down;
SGPropertyNode_ptr _control_fdm_atmo,_temp_degc,_pressure_inhg; SGPropertyNode_ptr _wind_north, _wind_east,_wind_down;
SGPropertyNode_ptr _density_slugft, _data_logging, _replay_master; SGPropertyNode_ptr _control_fdm_atmo,_temp_degc,_pressure_inhg;
SGPropertyNode_ptr _density_slugft, _data_logging, _replay_master;
SGPropertyNode_ptr _initialFdmProperties;
SGPropertyNode_ptr _initialFdmProperties;
SGSharedPtr<FGAIManager> _ai_mgr; SGSharedPtr<FGAIManager> _ai_mgr;
SGPropertyNode_ptr _max_radius_nm; SGPropertyNode_ptr _max_radius_nm;

View file

@ -99,35 +99,37 @@ class FGAIAircraft;
* life/visibility, computes the track if the * life/visibility, computes the track if the
* position has changed. * position has changed.
*/ */
class TrackComputer { class TrackComputer
{
public: public:
inline TrackComputer( double & track, double & path, const SGGeod & position ) : inline TrackComputer( double & track, double & path, const SGGeod & position ) :
_track( track ), _track( track ),
_path( path ), _path( path ),
_position( position ), _position( position ),
_prevPosition( position ) { _prevPosition( position ) {
}
inline ~TrackComputer() {
if( _prevPosition == _position ) return;
// _track = SGGeodesy::courseDeg( _prevPosition, _position );
double d = .0;
double distance = .0;
if( SGGeodesy::inverse( _prevPosition, _position, _track, d, distance ) ) {
d = _position.getElevationM() - _prevPosition.getElevationM();
_path = atan2( d, distance ) * SGD_RADIANS_TO_DEGREES;
} }
}
inline ~TrackComputer() {
if( _prevPosition == _position ) return;
// _track = SGGeodesy::courseDeg( _prevPosition, _position );
double d = .0;
double distance = .0;
if( SGGeodesy::inverse( _prevPosition, _position, _track, d, distance ) ) {
d = _position.getElevationM() - _prevPosition.getElevationM();
_path = atan2( d, distance ) * SGD_RADIANS_TO_DEGREES;
}
}
private: private:
double & _track; double & _track;
double & _path; double & _path;
const SGGeod & _position; const SGGeod & _position;
const SGGeod _prevPosition; const SGGeod _prevPosition;
}; };
// This is based heavily on LaRCsim/ls_generic.h // This is based heavily on LaRCsim/ls_generic.h
class FGInterface : public SGSubsystem { class FGInterface : public SGSubsystem
{
// Has the init() method been called. This is used to delay // Has the init() method been called. This is used to delay
// initialization until scenery can be loaded and we know the true // initialization until scenery can be loaded and we know the true
// ground elevation. // ground elevation.
@ -220,16 +222,14 @@ class FGInterface : public SGSubsystem {
void set_A_Z_pilot(double z) void set_A_Z_pilot(double z)
{ _set_Accels_Pilot_Body(_state.a_pilot_body_v[0], _state.a_pilot_body_v[1], z); } { _set_Accels_Pilot_Body(_state.a_pilot_body_v[0], _state.a_pilot_body_v[1], z); }
protected: protected:
int _calc_multiloop (double dt); int _calc_multiloop (double dt);
// deliberately not virtual so that // deliberately not virtual so that
// FGInterface constructor will call // FGInterface constructor will call
// the right version // the right version
void _setup(); void _setup();
void _busdump(void); void _busdump(void);
@ -245,92 +245,92 @@ protected:
void _update_ground_elev_at_pos( void ); void _update_ground_elev_at_pos( void );
inline void _set_CG_Position( double dx, double dy, double dz ) { inline void _set_CG_Position( double dx, double dy, double dz ) {
_state.d_cg_rp_body_v[0] = dx; _state.d_cg_rp_body_v[0] = dx;
_state.d_cg_rp_body_v[1] = dy; _state.d_cg_rp_body_v[1] = dy;
_state.d_cg_rp_body_v[2] = dz; _state.d_cg_rp_body_v[2] = dz;
} }
inline void _set_Accels_Local( double north, double east, double down ) { inline void _set_Accels_Local( double north, double east, double down ) {
_state.v_dot_local_v[0] = north; _state.v_dot_local_v[0] = north;
_state.v_dot_local_v[1] = east; _state.v_dot_local_v[1] = east;
_state.v_dot_local_v[2] = down; _state.v_dot_local_v[2] = down;
} }
inline void _set_Accels_Body( double u, double v, double w ) { inline void _set_Accels_Body( double u, double v, double w ) {
_state.v_dot_body_v[0] = u; _state.v_dot_body_v[0] = u;
_state.v_dot_body_v[1] = v; _state.v_dot_body_v[1] = v;
_state.v_dot_body_v[2] = w; _state.v_dot_body_v[2] = w;
} }
inline void _set_Accels_CG_Body( double x, double y, double z ) { inline void _set_Accels_CG_Body( double x, double y, double z ) {
_state.a_cg_body_v[0] = x; _state.a_cg_body_v[0] = x;
_state.a_cg_body_v[1] = y; _state.a_cg_body_v[1] = y;
_state.a_cg_body_v[2] = z; _state.a_cg_body_v[2] = z;
} }
inline void _set_Accels_Pilot_Body( double x, double y, double z ) { inline void _set_Accels_Pilot_Body( double x, double y, double z ) {
_state.a_pilot_body_v[0] = x; _state.a_pilot_body_v[0] = x;
_state.a_pilot_body_v[1] = y; _state.a_pilot_body_v[1] = y;
_state.a_pilot_body_v[2] = z; _state.a_pilot_body_v[2] = z;
} }
inline void _set_Accels_CG_Body_N( double x, double y, double z ) { inline void _set_Accels_CG_Body_N( double x, double y, double z ) {
_state.n_cg_body_v[0] = x; _state.n_cg_body_v[0] = x;
_state.n_cg_body_v[1] = y; _state.n_cg_body_v[1] = y;
_state.n_cg_body_v[2] = z; _state.n_cg_body_v[2] = z;
} }
void _set_Nlf(double n) { _state.nlf=n; } void _set_Nlf(double n) { _state.nlf=n; }
inline void _set_Velocities_Local( double north, double east, double down ){ inline void _set_Velocities_Local( double north, double east, double down ){
_state.v_local_v[0] = north; _state.v_local_v[0] = north;
_state.v_local_v[1] = east; _state.v_local_v[1] = east;
_state.v_local_v[2] = down; _state.v_local_v[2] = down;
} }
inline void _set_Velocities_Ground(double north, double east, double down) { inline void _set_Velocities_Ground(double north, double east, double down) {
_state.v_local_rel_ground_v[0] = north; _state.v_local_rel_ground_v[0] = north;
_state.v_local_rel_ground_v[1] = east; _state.v_local_rel_ground_v[1] = east;
_state.v_local_rel_ground_v[2] = down; _state.v_local_rel_ground_v[2] = down;
} }
inline void _set_Velocities_Local_Airmass( double north, double east, inline void _set_Velocities_Local_Airmass( double north, double east,
double down) double down)
{ {
_state.v_local_airmass_v[0] = north; _state.v_local_airmass_v[0] = north;
_state.v_local_airmass_v[1] = east; _state.v_local_airmass_v[1] = east;
_state.v_local_airmass_v[2] = down; _state.v_local_airmass_v[2] = down;
} }
inline void _set_Velocities_Body( double u, double v, double w) { inline void _set_Velocities_Body( double u, double v, double w) {
_state.v_body_v[0] = u; _state.v_body_v[0] = u;
_state.v_body_v[1] = v; _state.v_body_v[1] = v;
_state.v_body_v[2] = w; _state.v_body_v[2] = w;
} }
inline void _set_V_rel_wind(double vt) { _state.v_rel_wind = vt; } inline void _set_V_rel_wind(double vt) { _state.v_rel_wind = vt; }
inline void _set_V_ground_speed( double v) { _state.v_ground_speed = v; } inline void _set_V_ground_speed( double v) { _state.v_ground_speed = v; }
inline void _set_V_equiv_kts( double kts ) { _state.v_equiv_kts = kts; } inline void _set_V_equiv_kts( double kts ) { _state.v_equiv_kts = kts; }
inline void _set_V_calibrated_kts( double kts ) { _state.v_calibrated_kts = kts; } inline void _set_V_calibrated_kts( double kts ) { _state.v_calibrated_kts = kts; }
inline void _set_Omega_Body( double p, double q, double r ) { inline void _set_Omega_Body( double p, double q, double r ) {
_state.omega_body_v[0] = p; _state.omega_body_v[0] = p;
_state.omega_body_v[1] = q; _state.omega_body_v[1] = q;
_state.omega_body_v[2] = r; _state.omega_body_v[2] = r;
} }
inline void _set_Euler_Rates( double phi, double theta, double psi ) { inline void _set_Euler_Rates( double phi, double theta, double psi ) {
_state.euler_rates_v[0] = phi; _state.euler_rates_v[0] = phi;
_state.euler_rates_v[1] = theta; _state.euler_rates_v[1] = theta;
_state.euler_rates_v[2] = psi; _state.euler_rates_v[2] = psi;
} }
void set_Phi_dot_degps(double x) void set_Phi_dot_degps(double x)
{ {
_state.euler_rates_v[0] = x * SGD_DEGREES_TO_RADIANS; _state.euler_rates_v[0] = x * SGD_DEGREES_TO_RADIANS;
} }
void set_Theta_dot_degps(double x) void set_Theta_dot_degps(double x)
{ {
_state.euler_rates_v[1] = x * SGD_DEGREES_TO_RADIANS; _state.euler_rates_v[1] = x * SGD_DEGREES_TO_RADIANS;
} }
void set_Psi_dot_degps(double x) void set_Psi_dot_degps(double x)
{ {
_state.euler_rates_v[2] = x * SGD_DEGREES_TO_RADIANS; _state.euler_rates_v[2] = x * SGD_DEGREES_TO_RADIANS;
} }
inline void _set_Geocentric_Rates( double lat, double lon, double rad ) { inline void _set_Geocentric_Rates( double lat, double lon, double rad ) {
_state.geocentric_rates_v[0] = lat; _state.geocentric_rates_v[0] = lat;
_state.geocentric_rates_v[1] = lon; _state.geocentric_rates_v[1] = lon;
_state.geocentric_rates_v[2] = rad; _state.geocentric_rates_v[2] = rad;
} }
inline void _set_Geocentric_Position( double lat, double lon, double rad ) { inline void _set_Geocentric_Position( double lat, double lon, double rad ) {
_state.geocentric_position_v.setLatitudeRad(lat); _state.geocentric_position_v.setLatitudeRad(lat);
@ -363,9 +363,9 @@ protected:
_state.geodetic_position_v.setElevationFt(alt); _state.geodetic_position_v.setElevationFt(alt);
} }
inline void _set_Euler_Angles( double phi, double theta, double psi ) { inline void _set_Euler_Angles( double phi, double theta, double psi ) {
_state.euler_angles_v[0] = phi; _state.euler_angles_v[0] = phi;
_state.euler_angles_v[1] = theta; _state.euler_angles_v[1] = theta;
_state.euler_angles_v[2] = psi; _state.euler_angles_v[2] = psi;
} }
// FIXME, for compatibility with JSBSim // FIXME, for compatibility with JSBSim
inline void _set_T_Local_to_Body( int i, int j, double value) { } inline void _set_T_Local_to_Body( int i, int j, double value) { }
@ -386,7 +386,6 @@ protected:
inline void _set_Climb_Rate(double rate) { _state.climb_rate = rate; } inline void _set_Climb_Rate(double rate) { _state.climb_rate = rate; }
public: public:
FGInterface(); FGInterface();
FGInterface( double dt ); FGInterface( double dt );
virtual ~FGInterface(); virtual ~FGInterface();
@ -403,31 +402,31 @@ public:
// Define the various supported flight models (many not yet implemented) // Define the various supported flight models (many not yet implemented)
enum { enum {
// Magic Carpet mode // Magic Carpet mode
FG_MAGICCARPET = 0, FG_MAGICCARPET = 0,
// The NASA LaRCsim (Navion) flight model // The NASA LaRCsim (Navion) flight model
FG_LARCSIM = 1, FG_LARCSIM = 1,
// Jon S. Berndt's new FDM written from the ground up in C++ // Jon S. Berndt's new FDM written from the ground up in C++
FG_JSBSIM = 2, FG_JSBSIM = 2,
// Christian's hot air balloon simulation // Christian's hot air balloon simulation
FG_BALLOONSIM = 3, FG_BALLOONSIM = 3,
// Aeronautical DEvelopment AGEncy, Bangalore India // Aeronautical DEvelopment AGEncy, Bangalore India
FG_ADA = 4, FG_ADA = 4,
// The following aren't implemented but are here to spark // The following aren't implemented but are here to spark
// thoughts and discussions, and maybe even action. // thoughts and discussions, and maybe even action.
FG_ACM = 5, FG_ACM = 5,
FG_SUPER_SONIC = 6, FG_SUPER_SONIC = 6,
FG_HELICOPTER = 7, FG_HELICOPTER = 7,
FG_AUTOGYRO = 8, FG_AUTOGYRO = 8,
FG_PARACHUTE = 9, FG_PARACHUTE = 9,
// Driven externally via a serial port, net, file, etc. // Driven externally via a serial port, net, file, etc.
FG_EXTERNAL = 10 FG_EXTERNAL = 10
}; };
// initialization // initialization
@ -445,10 +444,10 @@ public:
virtual void set_Altitude(double alt); // triggers re-calc of AGL altitude virtual void set_Altitude(double alt); // triggers re-calc of AGL altitude
virtual void set_AltitudeAGL(double altagl); // and vice-versa virtual void set_AltitudeAGL(double altagl); // and vice-versa
virtual void set_Latitude_deg (double lat) { virtual void set_Latitude_deg (double lat) {
set_Latitude(lat * SGD_DEGREES_TO_RADIANS); set_Latitude(lat * SGD_DEGREES_TO_RADIANS);
} }
virtual void set_Longitude_deg (double lon) { virtual void set_Longitude_deg (double lon) {
set_Longitude(lon * SGD_DEGREES_TO_RADIANS); set_Longitude(lon * SGD_DEGREES_TO_RADIANS);
} }
// Speeds -- setting any of these will trigger a re-calc of the rest // Speeds -- setting any of these will trigger a re-calc of the rest
@ -456,44 +455,44 @@ public:
virtual void set_Mach_number(double mach); virtual void set_Mach_number(double mach);
virtual void set_Velocities_Local( double north, double east, double down ); virtual void set_Velocities_Local( double north, double east, double down );
inline void set_V_north (double north) { inline void set_V_north (double north) {
set_Velocities_Local(north, _state.v_local_v[1], _state.v_local_v[2]); set_Velocities_Local(north, _state.v_local_v[1], _state.v_local_v[2]);
} }
inline void set_V_east (double east) { inline void set_V_east (double east) {
set_Velocities_Local(_state.v_local_v[0], east, _state.v_local_v[2]); set_Velocities_Local(_state.v_local_v[0], east, _state.v_local_v[2]);
} }
inline void set_V_down (double down) { inline void set_V_down (double down) {
set_Velocities_Local(_state.v_local_v[0], _state.v_local_v[1], down); set_Velocities_Local(_state.v_local_v[0], _state.v_local_v[1], down);
} }
virtual void set_Velocities_Body( double u, double v, double w); virtual void set_Velocities_Body( double u, double v, double w);
virtual void set_uBody (double uBody) { virtual void set_uBody (double uBody) {
set_Velocities_Body(uBody, _state.v_body_v[1], _state.v_body_v[2]); set_Velocities_Body(uBody, _state.v_body_v[1], _state.v_body_v[2]);
} }
virtual void set_vBody (double vBody) { virtual void set_vBody (double vBody) {
set_Velocities_Body(_state.v_body_v[0], vBody, _state.v_body_v[2]); set_Velocities_Body(_state.v_body_v[0], vBody, _state.v_body_v[2]);
} }
virtual void set_wBody (double wBody) { virtual void set_wBody (double wBody) {
set_Velocities_Body(_state.v_body_v[0], _state.v_body_v[1], wBody); set_Velocities_Body(_state.v_body_v[0], _state.v_body_v[1], wBody);
} }
// Euler angles // Euler angles
virtual void set_Euler_Angles( double phi, double theta, double psi ); virtual void set_Euler_Angles( double phi, double theta, double psi );
virtual void set_Phi (double phi) { virtual void set_Phi (double phi) {
set_Euler_Angles(phi, get_Theta(), get_Psi()); set_Euler_Angles(phi, get_Theta(), get_Psi());
} }
virtual void set_Theta (double theta) { virtual void set_Theta (double theta) {
set_Euler_Angles(get_Phi(), theta, get_Psi()); set_Euler_Angles(get_Phi(), theta, get_Psi());
} }
virtual void set_Psi (double psi) { virtual void set_Psi (double psi) {
set_Euler_Angles(get_Phi(), get_Theta(), psi); set_Euler_Angles(get_Phi(), get_Theta(), psi);
} }
virtual void set_Phi_deg (double phi) { virtual void set_Phi_deg (double phi) {
set_Phi(phi * SGD_DEGREES_TO_RADIANS); set_Phi(phi * SGD_DEGREES_TO_RADIANS);
} }
virtual void set_Theta_deg (double theta) { virtual void set_Theta_deg (double theta) {
set_Theta(theta * SGD_DEGREES_TO_RADIANS); set_Theta(theta * SGD_DEGREES_TO_RADIANS);
} }
virtual void set_Psi_deg (double psi) { virtual void set_Psi_deg (double psi) {
set_Psi(psi * SGD_DEGREES_TO_RADIANS); set_Psi(psi * SGD_DEGREES_TO_RADIANS);
} }
// Flight Path // Flight Path
@ -507,8 +506,8 @@ public:
virtual void set_Density(double rho); virtual void set_Density(double rho);
virtual void set_Velocities_Local_Airmass (double wnorth, virtual void set_Velocities_Local_Airmass (double wnorth,
double weast, double weast,
double wdown ); double wdown );
// ========== Mass properties and geometry values ========== // ========== Mass properties and geometry values ==========
@ -604,10 +603,10 @@ public:
return _state.geocentric_position_v.getLatitudeRad(); return _state.geocentric_position_v.getLatitudeRad();
} }
inline double get_Lon_geocentric() const { inline double get_Lon_geocentric() const {
return _state.geocentric_position_v.getLongitudeRad(); return _state.geocentric_position_v.getLongitudeRad();
} }
inline double get_Radius_to_vehicle() const { inline double get_Radius_to_vehicle() const {
return _state.geocentric_position_v.getRadiusFt(); return _state.geocentric_position_v.getRadiusFt();
} }
const SGGeod& getPosition() const { return _state.geodetic_position_v; } const SGGeod& getPosition() const { return _state.geodetic_position_v; }
@ -662,7 +661,7 @@ public:
inline double get_Sea_level_radius() const { return _state.sea_level_radius; } inline double get_Sea_level_radius() const { return _state.sea_level_radius; }
inline double get_Earth_position_angle() const { inline double get_Earth_position_angle() const {
return _state.earth_position_angle; return _state.earth_position_angle;
} }
inline double get_Runway_altitude() const { return _state.runway_altitude; } inline double get_Runway_altitude() const { return _state.runway_altitude; }

View file

@ -30,7 +30,6 @@ class puFont;
class NewGUI : public SGSubsystem class NewGUI : public SGSubsystem
{ {
public: public:
/** /**
* Constructor. * Constructor.
*/ */
@ -47,7 +46,7 @@ public:
virtual void init (); virtual void init ();
virtual void shutdown (); virtual void shutdown ();
/** /**
* Reinitialize the GUI subsystem. Reloads all XML dialogs. * Reinitialize the GUI subsystem. Reloads all XML dialogs.
*/ */
@ -174,7 +173,6 @@ public:
static const char* subsystemName() { return "gui"; } static const char* subsystemName() { return "gui"; }
protected: protected:
/** /**
* Test if the menubar is visible. * Test if the menubar is visible.
* *
@ -203,9 +201,10 @@ protected:
bool getMenuBarOverlapHide() const; bool getMenuBarOverlapHide() const;
void setMenuBarOverlapHide(bool hide); void setMenuBarOverlapHide(bool hide);
private: private:
void createMenuBarImplementation(); void createMenuBarImplementation();
struct ltstr struct ltstr
{ {
bool operator()(const char* s1, const char* s2) const { bool operator()(const char* s1, const char* s2) const {
@ -228,18 +227,16 @@ private:
FGDialog * _active_dialog; FGDialog * _active_dialog;
typedef std::map<std::string,FGDialog *> DialogDict; typedef std::map<std::string,FGDialog *> DialogDict;
DialogDict _active_dialogs; DialogDict _active_dialogs;
typedef std::map<std::string, SGPath> NamePathDict; typedef std::map<std::string, SGPath> NamePathDict;
// mapping from dialog names to the corresponding XML property list // mapping from dialog names to the corresponding XML property list
// which defines them // which defines them
NamePathDict _dialog_names; NamePathDict _dialog_names;
// cache of loaded dialog proeprties // cache of loaded dialog proeprties
typedef std::map<std::string,SGPropertyNode_ptr> NameDialogDict; typedef std::map<std::string,SGPropertyNode_ptr> NameDialogDict;
NameDialogDict _dialog_props; NameDialogDict _dialog_props;
}; };
#endif // __NEW_GUI_HXX #endif // __NEW_GUI_HXX

View file

@ -36,38 +36,39 @@
class SGInterpTable; class SGInterpTable;
/* /*
* A base structure for event data. * A base structure for event data.
* To be extended for O/S specific implementation data * To be extended for O/S specific implementation data
*/ */
struct FGEventData { struct FGEventData {
FGEventData( double aValue, double aDt, int aModifiers ) : modifiers(aModifiers), value(aValue), dt(aDt) {} FGEventData( double aValue, double aDt, int aModifiers ) : modifiers(aModifiers), value(aValue), dt(aDt) {}
int modifiers; int modifiers;
double value; double value;
double dt; double dt;
}; };
class FGEventSetting : public SGReferenced { class FGEventSetting : public SGReferenced
{
public: public:
FGEventSetting( SGPropertyNode_ptr base ); FGEventSetting( SGPropertyNode_ptr base );
bool Test(); bool Test();
/* /*
* access for the value property * access for the value property
*/ */
double GetValue(); double GetValue();
protected: protected:
double value; double value;
SGPropertyNode_ptr valueNode; SGPropertyNode_ptr valueNode;
SGSharedPtr<const SGCondition> condition; SGSharedPtr<const SGCondition> condition;
}; };
typedef SGSharedPtr<FGEventSetting> FGEventSetting_ptr; typedef SGSharedPtr<FGEventSetting> FGEventSetting_ptr;
typedef std::vector<FGEventSetting_ptr> setting_list_t; typedef std::vector<FGEventSetting_ptr> setting_list_t;
class FGReportSetting : public SGReferenced, class FGReportSetting : public SGReferenced,
public SGPropertyChangeListener public SGPropertyChangeListener
{ {
public: public:
FGReportSetting( SGPropertyNode_ptr base ); FGReportSetting( SGPropertyNode_ptr base );
@ -87,19 +88,19 @@ public:
std::string reportBytes(const std::string& moduleName) const; std::string reportBytes(const std::string& moduleName) const;
virtual void valueChanged(SGPropertyNode * node); virtual void valueChanged(SGPropertyNode * node);
protected: protected:
unsigned int reportId; unsigned int reportId;
std::string nasalFunction; std::string nasalFunction;
bool dirty; bool dirty;
}; };
typedef SGSharedPtr<FGReportSetting> FGReportSetting_ptr; typedef SGSharedPtr<FGReportSetting> FGReportSetting_ptr;
typedef std::vector<FGReportSetting_ptr> report_setting_list_t; typedef std::vector<FGReportSetting_ptr> report_setting_list_t;
/* /*
* A wrapper class for a configured event. * A wrapper class for a configured event.
* *
* <event> * <event>
* <desc>Change the view pitch</desc> * <desc>Change the view pitch</desc>
* <name>rel-x-rotate</name> * <name>rel-x-rotate</name>
@ -119,102 +120,110 @@ typedef std::vector<FGReportSetting_ptr> report_setting_list_t;
* </event> * </event>
*/ */
class FGInputDevice; class FGInputDevice;
class FGInputEvent : public SGReferenced,FGCommonInput { class FGInputEvent : public SGReferenced,
FGCommonInput
{
public: public:
/*
* Constructor for the class. The arg node shall point
* to the property corresponding to the <event> node
*/
FGInputEvent( FGInputDevice * device, SGPropertyNode_ptr node );
virtual ~FGInputEvent();
/* /*
* Constructor for the class. The arg node shall point * dispatch the event value through all bindings
* to the property corresponding to the <event> node */
*/ virtual void fire( FGEventData & eventData );
FGInputEvent( FGInputDevice * device, SGPropertyNode_ptr node );
virtual ~FGInputEvent();
/* /*
* dispatch the event value through all bindings * access for the name property
*/ */
virtual void fire( FGEventData & eventData ); std::string GetName() const { return name; }
/* /*
* access for the name property * access for the description property
*/ */
std::string GetName() const { return name; } std::string GetDescription() const { return desc; }
/* virtual void update( double dt );
* access for the description property
*/
std::string GetDescription() const { return desc; }
virtual void update( double dt ); static FGInputEvent * NewObject( FGInputDevice * device, SGPropertyNode_ptr node );
static FGInputEvent * NewObject( FGInputDevice * device, SGPropertyNode_ptr node );
protected: protected:
virtual void fire( SGBinding * binding, FGEventData & eventData ); virtual void fire( SGBinding * binding, FGEventData & eventData );
/* A more or less meaningfull description of the event */ /* A more or less meaningfull description of the event */
std::string desc; std::string desc;
/* One of the predefined names of the event */ /* One of the predefined names of the event */
std::string name; std::string name;
/* A list of SGBinding objects */ /* A list of SGBinding objects */
binding_list_t bindings[KEYMOD_MAX]; binding_list_t bindings[KEYMOD_MAX];
/* A list of FGEventSetting objects */ /* A list of FGEventSetting objects */
setting_list_t settings; setting_list_t settings;
/* A pointer to the associated device */ /* A pointer to the associated device */
FGInputDevice * device; FGInputDevice * device;
double lastDt; double lastDt;
double intervalSec; double intervalSec;
double lastSettingValue; double lastSettingValue;
}; };
class FGButtonEvent : public FGInputEvent { class FGButtonEvent : public FGInputEvent
{
public: public:
FGButtonEvent( FGInputDevice * device, SGPropertyNode_ptr node ); FGButtonEvent( FGInputDevice * device, SGPropertyNode_ptr node );
virtual void fire( FGEventData & eventData ); virtual void fire( FGEventData & eventData );
void update( double dt ) override; void update( double dt ) override;
protected: protected:
bool repeatable; bool repeatable;
bool lastState; bool lastState;
}; };
class FGAxisEvent : public FGInputEvent { class FGAxisEvent : public FGInputEvent
{
public: public:
FGAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ); FGAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node );
~FGAxisEvent(); ~FGAxisEvent();
void SetMaxRange( double value ) { maxRange = value; } void SetMaxRange( double value ) { maxRange = value; }
void SetMinRange( double value ) { minRange = value; } void SetMinRange( double value ) { minRange = value; }
void SetRange( double min, double max ) { minRange = min; maxRange = max; } void SetRange( double min, double max ) { minRange = min; maxRange = max; }
protected: protected:
virtual void fire( FGEventData & eventData ); virtual void fire( FGEventData & eventData );
double tolerance; double tolerance;
double minRange; double minRange;
double maxRange; double maxRange;
double center; double center;
double deadband; double deadband;
double lowThreshold; double lowThreshold;
double highThreshold; double highThreshold;
double lastValue; double lastValue;
std::unique_ptr<SGInterpTable> interpolater; std::unique_ptr<SGInterpTable> interpolater;
bool mirrorInterpolater = false; bool mirrorInterpolater = false;
}; };
class FGRelAxisEvent : public FGAxisEvent { class FGRelAxisEvent : public FGAxisEvent
{
public: public:
FGRelAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ); FGRelAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node );
protected: protected:
virtual void fire( SGBinding * binding, FGEventData & eventData ); virtual void fire( SGBinding * binding, FGEventData & eventData );
}; };
class FGAbsAxisEvent : public FGAxisEvent { class FGAbsAxisEvent : public FGAxisEvent
{
public: public:
FGAbsAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ) : FGAxisEvent( device, node ) {} FGAbsAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ) : FGAxisEvent( device, node ) {}
protected: protected:
virtual void fire( SGBinding * binding, FGEventData & eventData ); virtual void fire( SGBinding * binding, FGEventData & eventData );
}; };
typedef class SGSharedPtr<FGInputEvent> FGInputEvent_ptr; typedef class SGSharedPtr<FGInputEvent> FGInputEvent_ptr;
@ -224,73 +233,74 @@ typedef class SGSharedPtr<FGInputEvent> FGInputEvent_ptr;
* all operating systems. This is the base class for the O/S-specific * all operating systems. This is the base class for the O/S-specific
* implementation of input device handlers * implementation of input device handlers
*/ */
class FGInputDevice : public SGReferenced { class FGInputDevice : public SGReferenced
{
public: public:
FGInputDevice() {} FGInputDevice() {}
FGInputDevice( std::string aName, std::string aSerial = {} ) : FGInputDevice( std::string aName, std::string aSerial = {} ) :
name(aName), serialNumber(aSerial) {} name(aName), serialNumber(aSerial) {}
virtual ~FGInputDevice();
virtual bool Open() = 0; virtual ~FGInputDevice();
virtual void Close() = 0;
virtual void Send( const char * eventName, double value ) = 0; virtual bool Open() = 0;
virtual void Close() = 0;
inline void Send( const std::string & eventName, double value ) { virtual void Send( const char * eventName, double value ) = 0;
Send( eventName.c_str(), value );
} inline void Send( const std::string & eventName, double value ) {
Send( eventName.c_str(), value );
}
virtual void SendFeatureReport(unsigned int reportId, const std::string& data); virtual void SendFeatureReport(unsigned int reportId, const std::string& data);
virtual const char * TranslateEventName( FGEventData & eventData ) = 0; virtual const char * TranslateEventName( FGEventData & eventData ) = 0;
void SetName( std::string name ); void SetName( std::string name );
std::string & GetName() { return name; } std::string & GetName() { return name; }
void SetUniqueName(const std::string& name); void SetUniqueName(const std::string& name);
const std::string GetUniqueName() const const std::string GetUniqueName() const
{ return _uniqueName; } { return _uniqueName; }
void SetSerialNumber( std::string serial ); void SetSerialNumber( std::string serial );
std::string& GetSerialNumber() { return serialNumber; } std::string& GetSerialNumber() { return serialNumber; }
void HandleEvent( FGEventData & eventData );
virtual void AddHandledEvent( FGInputEvent_ptr handledEvent ); void HandleEvent( FGEventData & eventData );
virtual void Configure( SGPropertyNode_ptr deviceNode ); virtual void AddHandledEvent( FGInputEvent_ptr handledEvent );
virtual void update( double dt ); virtual void Configure( SGPropertyNode_ptr deviceNode );
bool GetDebugEvents () const { return debugEvents; } virtual void update( double dt );
bool GetGrab() const { return grab; } bool GetDebugEvents () const { return debugEvents; }
const std::string & GetNasalModule() const { return nasalModule; } bool GetGrab() const { return grab; }
const std::string & GetNasalModule() const { return nasalModule; }
protected: protected:
// A map of events, this device handles // A map of events, this device handles
std::map<std::string,FGInputEvent_ptr> handledEvents; std::map<std::string,FGInputEvent_ptr> handledEvents;
// the device has a name to be recognized // the device has a name to be recognized
std::string name; std::string name;
// serial number string to disambiguate multiple instances // serial number string to disambiguate multiple instances
// of the same device // of the same device
std::string serialNumber; std::string serialNumber;
// print out events comming in from the device
// if true
bool debugEvents = false;
// grab the device exclusively, if O/S supports this // print out events comming in from the device
// so events are not sent to other applications // if true
bool grab = false; bool debugEvents = false;
SGPropertyNode_ptr deviceNode; // grab the device exclusively, if O/S supports this
std::string nasalModule; // so events are not sent to other applications
bool grab = false;
SGPropertyNode_ptr deviceNode;
std::string nasalModule;
report_setting_list_t reportSettings; report_setting_list_t reportSettings;
@ -304,32 +314,35 @@ typedef SGSharedPtr<FGInputDevice> FGInputDevice_ptr;
/* /*
* The Subsystem for the event input device * The Subsystem for the event input device
*/ */
class FGEventInput : public SGSubsystem,FGCommonInput { class FGEventInput : public SGSubsystem,
FGCommonInput
{
public: public:
FGEventInput(); FGEventInput();
virtual ~FGEventInput(); virtual ~FGEventInput();
void init() override; void init() override;
void postinit() override; void postinit() override;
void update( double dt ) override; void update( double dt ) override;
void shutdown() override; void shutdown() override;
const static unsigned MAX_DEVICES = 1000;
const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1;
const static unsigned MAX_DEVICES = 1000;
const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1;
protected: protected:
static const char * PROPERTY_ROOT; static const char * PROPERTY_ROOT;
unsigned AddDevice( FGInputDevice * inputDevice ); unsigned AddDevice( FGInputDevice * inputDevice );
void RemoveDevice( unsigned index ); void RemoveDevice( unsigned index );
std::map<int,FGInputDevice*> input_devices; std::map<int,FGInputDevice*> input_devices;
FGDeviceConfigurationMap configMap; FGDeviceConfigurationMap configMap;
SGPropertyNode_ptr nasalClose; SGPropertyNode_ptr nasalClose;
private: private:
std::string computeDeviceIndexName(FGInputDevice *dev) const; std::string computeDeviceIndexName(FGInputDevice *dev) const;
}; };
#endif #endif

View file

@ -35,21 +35,22 @@ void writeBits(uint8_t* bytes, size_t bitOffset, size_t bitSize, int value);
class FGHIDEventInput : public FGEventInput { class FGHIDEventInput : public FGEventInput {
public: public:
FGHIDEventInput(); FGHIDEventInput();
virtual ~FGHIDEventInput(); virtual ~FGHIDEventInput();
void update(double dt) override; void update(double dt) override;
void init() override; void init() override;
void reinit() override; void reinit() override;
void postinit(); void postinit();
void shutdown() override; void shutdown() override;
static const char* subsystemName() { return "input-hid"; }
static const char* subsystemName() { return "input-hid"; }
private: private:
class FGHIDEventInputPrivate; class FGHIDEventInputPrivate;
std::unique_ptr<FGHIDEventInputPrivate> d; std::unique_ptr<FGHIDEventInputPrivate> d;
}; };
#endif #endif

View file

@ -36,72 +36,73 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// The Joystick Input Class // The Joystick Input Class
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
class FGJoystickInput : public SGSubsystem,FGCommonInput { class FGJoystickInput : public SGSubsystem,
FGCommonInput
{
public: public:
FGJoystickInput(); FGJoystickInput();
virtual ~FGJoystickInput(); virtual ~FGJoystickInput();
virtual void init(); virtual void init();
virtual void postinit(); virtual void postinit();
virtual void reinit(); virtual void reinit();
virtual void update( double dt ); virtual void update( double dt );
static const int MAX_JOYSTICKS = 16; static const int MAX_JOYSTICKS = 16;
static const int MAX_JOYSTICK_AXES = _JS_MAX_AXES; static const int MAX_JOYSTICK_AXES = _JS_MAX_AXES;
static const int MAX_JOYSTICK_BUTTONS = 32; static const int MAX_JOYSTICK_BUTTONS = 32;
private: private:
/** /**
* @brief computeDeviceIndexName - compute the name including the index, based * @brief computeDeviceIndexName - compute the name including the index, based
* on the number of identically named devices. This is used to allow multiple * on the number of identically named devices. This is used to allow multiple
* different files for identical hardware, especially throttles * different files for identical hardware, especially throttles
* @param name - the base joystick name * @param name - the base joystick name
* @param lastIndex - don't check names at this index or above. Needed to * @param lastIndex - don't check names at this index or above. Needed to
* ensure we only check as far as the joystick we are currently processing * ensure we only check as far as the joystick we are currently processing
* @return * @return
*/ */
std::string computeDeviceIndexName(const std::string &name, int lastIndex) const; std::string computeDeviceIndexName(const std::string &name, int lastIndex) const;
void _remove(bool all);
SGPropertyNode_ptr status_node;
/** void _remove(bool all);
* Settings for a single joystick axis. SGPropertyNode_ptr status_node;
*/
struct axis {
axis ();
virtual ~axis ();
float last_value;
float tolerance;
binding_list_t bindings[KEYMOD_MAX];
float low_threshold;
float high_threshold;
FGButton low;
FGButton high;
float interval_sec, delay_sec, release_delay_sec;
double last_dt;
};
/** /**
* Settings for a joystick. * Settings for a single joystick axis.
*/ */
struct joystick { struct axis {
joystick (); axis ();
virtual ~joystick (); virtual ~axis ();
int jsnum; float last_value;
std::unique_ptr<jsJoystick> plibJS; float tolerance;
int naxes; binding_list_t bindings[KEYMOD_MAX];
int nbuttons; float low_threshold;
axis * axes; float high_threshold;
FGButton * buttons; FGButton low;
bool predefined; FGButton high;
float interval_sec, delay_sec, release_delay_sec;
void clearAxesAndButtons(); double last_dt;
}; };
joystick joysticks[MAX_JOYSTICKS];
void updateJoystick(int index, joystick* joy, double dt);
/**
* Settings for a joystick.
*/
struct joystick {
joystick ();
virtual ~joystick ();
int jsnum;
std::unique_ptr<jsJoystick> plibJS;
int naxes;
int nbuttons;
axis * axes;
FGButton * buttons;
bool predefined;
void clearAxesAndButtons();
};
joystick joysticks[MAX_JOYSTICKS];
void updateJoystick(int index, joystick* joy, double dt);
}; };
#endif #endif

View file

@ -37,37 +37,39 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// The Keyboard Input Class // The Keyboard Input Class
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
class FGKeyboardInput : public SGSubsystem,FGCommonInput { class FGKeyboardInput : public SGSubsystem,
FGCommonInput
{
public: public:
FGKeyboardInput(); FGKeyboardInput();
virtual ~FGKeyboardInput(); virtual ~FGKeyboardInput();
virtual void init(); virtual void init();
virtual void postinit(); virtual void postinit();
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
virtual void update( double dt ); virtual void update( double dt );
static const int MAX_KEYS = 1024; static const int MAX_KEYS = 1024;
private: private:
const binding_list_t& _find_key_bindings (unsigned int k, int modifiers); const binding_list_t& _find_key_bindings (unsigned int k, int modifiers);
void doKey (int k, int modifiers, int x, int y); void doKey (int k, int modifiers, int x, int y);
static void keyHandler(int key, int keymod, int mousex, int mousey); static void keyHandler(int key, int keymod, int mousex, int mousey);
static FGKeyboardInput * keyboardInput; static FGKeyboardInput * keyboardInput;
FGButton bindings[MAX_KEYS]; FGButton bindings[MAX_KEYS];
SGPropertyNode_ptr _key_event; SGPropertyNode_ptr _key_event;
int _key_code; int _key_code;
int _key_modifiers; int _key_modifiers;
bool _key_pressed; bool _key_pressed;
bool _key_shift; bool _key_shift;
bool _key_ctrl; bool _key_ctrl;
bool _key_alt; bool _key_alt;
bool _key_meta; bool _key_meta;
bool _key_super; bool _key_super;
bool _key_hyper; bool _key_hyper;
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
}; };
#endif #endif

View file

@ -27,48 +27,51 @@
#include <linux/input.h> #include <linux/input.h>
struct FGLinuxEventData : public FGEventData { struct FGLinuxEventData : public FGEventData {
FGLinuxEventData( struct input_event & event, double dt, int modifiers ) : FGLinuxEventData( struct input_event & event, double dt, int modifiers ) :
FGEventData( (double)event.value, dt, modifiers ), FGEventData( (double)event.value, dt, modifiers ),
type(event.type), type(event.type),
code(event.code) { code(event.code) {
} }
unsigned type; unsigned type;
unsigned code; unsigned code;
}; };
/* /*
* A implementation for linux event devices * A implementation for linux event devices
*/ */
class FGLinuxInputDevice : public FGInputDevice { class FGLinuxInputDevice : public FGInputDevice
{
public: public:
FGLinuxInputDevice(); FGLinuxInputDevice();
FGLinuxInputDevice( std::string name, std::string devname, std::string aSerial ); FGLinuxInputDevice( std::string name, std::string devname, std::string aSerial );
virtual ~FGLinuxInputDevice(); virtual ~FGLinuxInputDevice();
bool Open() override; bool Open() override;
void Close() override; void Close() override;
void Send( const char * eventName, double value ) override; void Send( const char * eventName, double value ) override;
const char * TranslateEventName( FGEventData & eventData ) override; const char * TranslateEventName( FGEventData & eventData ) override;
void SetDevname( const std::string & name ); void SetDevname( const std::string & name );
std::string GetDevname() const { return devname; } std::string GetDevname() const { return devname; }
int GetFd() { return fd; } int GetFd() { return fd; }
double Normalize( struct input_event & event );
double Normalize( struct input_event & event );
private: private:
std::string devname; std::string devname;
int fd; int fd;
std::map<unsigned int,input_absinfo> absinfo; std::map<unsigned int,input_absinfo> absinfo;
}; };
class FGLinuxEventInput : public FGEventInput { class FGLinuxEventInput : public FGEventInput
{
public: public:
FGLinuxEventInput(); FGLinuxEventInput();
virtual ~ FGLinuxEventInput(); virtual ~ FGLinuxEventInput();
virtual void update (double dt); virtual void update (double dt);
virtual void postinit(); virtual void postinit();
protected: protected:
}; };

View file

@ -33,28 +33,30 @@
class FGMacOSXEventInputPrivate; class FGMacOSXEventInputPrivate;
struct FGMacOSXEventData : public FGEventData { struct FGMacOSXEventData : public FGEventData {
FGMacOSXEventData(std::string name, double value, double dt, int modifiers) : FGMacOSXEventData(std::string name, double value, double dt, int modifiers) :
FGEventData(value, dt, modifiers), name(name) {} FGEventData(value, dt, modifiers), name(name) {}
std::string name; std::string name;
}; };
// //
// Mac OS X specific FGEventInput // Mac OS X specific FGEventInput
// //
class FGMacOSXEventInput : public FGEventInput { class FGMacOSXEventInput : public FGEventInput
{
public: public:
FGMacOSXEventInput(); FGMacOSXEventInput();
virtual ~FGMacOSXEventInput(); virtual ~FGMacOSXEventInput();
virtual void update(double dt); virtual void update(double dt);
virtual void init(); virtual void init();
virtual void postinit(); virtual void postinit();
virtual void shutdown(); virtual void shutdown();
private: private:
friend class FGMacOSXEventInputPrivate; friend class FGMacOSXEventInputPrivate;
std::unique_ptr<FGMacOSXEventInputPrivate> d; std::unique_ptr<FGMacOSXEventInputPrivate> d;
}; };
#endif #endif

View file

@ -38,7 +38,9 @@ namespace osgGA { class GUIEventAdapter; }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// The Mouse Input Class // The Mouse Input Class
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
class FGMouseInput : public SGSubsystem, FGCommonInput { class FGMouseInput : public SGSubsystem,
FGCommonInput
{
public: public:
FGMouseInput(); FGMouseInput();
virtual ~FGMouseInput() = default; virtual ~FGMouseInput() = default;
@ -59,17 +61,17 @@ public:
* @return * @return
*/ */
bool isRightDragToLookEnabled() const; bool isRightDragToLookEnabled() const;
/** /**
* @brief check if the active mode passes clicks through to the UI or not * @brief check if the active mode passes clicks through to the UI or not
*/ */
bool isActiveModePassThrough() const; bool isActiveModePassThrough() const;
private: private:
void processMotion(int x, int y, const osgGA::GUIEventAdapter* ea); void processMotion(int x, int y, const osgGA::GUIEventAdapter* ea);
class FGMouseInputPrivate; class FGMouseInputPrivate;
std::unique_ptr<FGMouseInputPrivate> d; std::unique_ptr<FGMouseInputPrivate> d;
}; };
#endif #endif

View file

@ -45,18 +45,17 @@
class FGInput : public SGSubsystemGroup class FGInput : public SGSubsystemGroup
{ {
public: public:
/** /**
* Default constructor. * Default constructor.
*/ */
FGInput (); FGInput ();
/** /**
* Destructor. * Destructor.
*/ */
virtual ~FGInput(); virtual ~FGInput();
static const char* subsystemName() { return "input"; }
static const char* subsystemName() { return "input"; }
}; };
#endif // _INPUT_HXX #endif // _INPUT_HXX

View file

@ -40,7 +40,8 @@ class fntTexFont;
class FGViewer; class FGViewer;
class ClipBox; class ClipBox;
class LineSegment { class LineSegment
{
public: public:
LineSegment(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1) LineSegment(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1)
: _x0(x0), _y0(y0), _x1(x1), _y1(y1) {} : _x0(x0), _y0(y0), _x1(x1), _y1(y1) {}
@ -56,7 +57,8 @@ private:
class LineList { class LineList
{
public: public:
void add(const LineSegment& seg) { _list.push_back(seg); } void add(const LineSegment& seg) { _list.push_back(seg); }
void erase() { _list.erase(_list.begin(), _list.end()); } void erase() { _list.erase(_list.begin(), _list.end()); }
@ -76,7 +78,8 @@ private:
class HUDText { class HUDText
{
public: public:
HUDText(fntRenderer *f, float x, float y, const char *s, int align = 0, int digits = 0); HUDText(fntRenderer *f, float x, float y, const char *s, int align = 0, int digits = 0);
void draw(); void draw();
@ -91,7 +94,8 @@ private:
class TextList { class TextList
{
public: public:
TextList() { _font = 0; } TextList() { _font = 0; }
@ -111,14 +115,16 @@ private:
class HUD : public SGSubsystem, public SGPropertyChangeListener { class HUD : public SGSubsystem,
public SGPropertyChangeListener
{
public: public:
HUD(); HUD();
~HUD(); ~HUD();
void init(); void init();
void update(double); void update(double);
void reinit(); void reinit();
// called from Main/renderer.cxx to draw 2D and 3D HUD // called from Main/renderer.cxx to draw 2D and 3D HUD
void draw(osg::State&); void draw(osg::State&);
@ -163,12 +169,12 @@ protected:
private: private:
void deinit(); void deinit();
void draw3D(); void draw3D();
void draw2D(GLfloat, GLfloat, GLfloat, GLfloat); void draw2D(GLfloat, GLfloat, GLfloat, GLfloat);
void currentColorChanged(); void currentColorChanged();
class Input; class Input;
class Item; class Item;
class Label; class Label;

View file

@ -1,9 +1,9 @@
// kln89_page.hxx - a class to manage the simulation of a KLN89 // kln89_page.hxx - a class to manage the simulation of a KLN89
// GPS unit. Note that this is primarily the // GPS unit. Note that this is primarily the
// simulation of the user interface and display // simulation of the user interface and display
// - the core GPS calculations such as position // - the core GPS calculations such as position
// and waypoint sequencing are done (or should // and waypoint sequencing are done (or should
// be done) by FG code. // be done) by FG code.
// //
// Written by David Luff, started 2005. // Written by David Luff, started 2005.
// //
@ -34,36 +34,36 @@
class KLN89Page; class KLN89Page;
const int KLN89MapScales[2][21] = {{1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30, 40, 60, 80, 100, 120, 160, 240, 320, 500}, const int KLN89MapScales[2][21] = {{1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30, 40, 60, 80, 100, 120, 160, 240, 320, 500},
{2, 4, 6, 9, 13, 18, 22, 28, 32, 37, 46, 55, 75, 110, 150, 185, 220, 300, 440, 600, 925}}; {2, 4, 6, 9, 13, 18, 22, 28, 32, 37, 46, 55, 75, 110, 150, 185, 220, 300, 440, 600, 925}};
enum KLN89Mode { enum KLN89Mode {
KLN89_MODE_DISP, KLN89_MODE_DISP,
KLN89_MODE_CRSR KLN89_MODE_CRSR
}; };
enum KLN89DistanceUnits { enum KLN89DistanceUnits {
GPS_DIST_UNITS_NM = 0, GPS_DIST_UNITS_NM = 0,
GPS_DIST_UNITS_KM GPS_DIST_UNITS_KM
}; };
enum KLN89SpeedUnits { enum KLN89SpeedUnits {
GPS_VEL_UNITS_KT, GPS_VEL_UNITS_KT,
GPS_VEL_UNITS_KPH GPS_VEL_UNITS_KPH
}; };
enum KLN89AltitudeUnits { enum KLN89AltitudeUnits {
GPS_ALT_UNITS_FT, GPS_ALT_UNITS_FT,
GPS_ALT_UNITS_M GPS_ALT_UNITS_M
}; };
enum KLN89PressureUnits { enum KLN89PressureUnits {
GPS_PRES_UNITS_IN = 1, GPS_PRES_UNITS_IN = 1,
GPS_PRES_UNITS_MB, GPS_PRES_UNITS_MB,
GPS_PRES_UNITS_HP GPS_PRES_UNITS_HP
}; };
/* /*
const char* KLN89TimeCodes[20] = { "UTC", "GST", "GDT", "ATS", "ATD", "EST", "EDT", "CST", "CDT", "MST", const char* KLN89TimeCodes[20] = { "UTC", "GST", "GDT", "ATS", "ATD", "EST", "EDT", "CST", "CDT", "MST",
"MDT", "PST", "PDT", "AKS", "AKD", "HAS", "HAD", "SST", "SDT", "LCL" }; "MDT", "PST", "PDT", "AKS", "AKD", "HAS", "HAD", "SST", "SDT", "LCL" };
*/ */
@ -74,286 +74,286 @@ typedef airport_id_str_map_type::iterator airport_id_str_map_iterator;
typedef std::vector<KLN89Page*> kln89_page_list_type; typedef std::vector<KLN89Page*> kln89_page_list_type;
typedef kln89_page_list_type::iterator kln89_page_list_itr; typedef kln89_page_list_type::iterator kln89_page_list_itr;
class KLN89 : public DCLGPS { class KLN89 : public DCLGPS
{
friend class KLN89Page; friend class KLN89Page;
friend class KLN89AptPage; friend class KLN89AptPage;
friend class KLN89VorPage; friend class KLN89VorPage;
friend class KLN89NDBPage; friend class KLN89NDBPage;
friend class KLN89IntPage; friend class KLN89IntPage;
friend class KLN89UsrPage; friend class KLN89UsrPage;
friend class KLN89ActPage; friend class KLN89ActPage;
friend class KLN89NavPage; friend class KLN89NavPage;
friend class KLN89FplPage; friend class KLN89FplPage;
friend class KLN89CalPage; friend class KLN89CalPage;
friend class KLN89SetPage; friend class KLN89SetPage;
friend class KLN89OthPage; friend class KLN89OthPage;
friend class KLN89AltPage; friend class KLN89AltPage;
friend class KLN89DirPage; friend class KLN89DirPage;
friend class KLN89NrstPage; friend class KLN89NrstPage;
public: public:
KLN89(RenderArea2D* instrument); KLN89(RenderArea2D* instrument);
~KLN89(); ~KLN89();
void bind();
void unbind();
void init();
void update(double dt);
// Set Units
// m if true, ft if false
inline void SetAltUnitsSI(bool b) { _altUnits = (b ? GPS_ALT_UNITS_M : GPS_ALT_UNITS_FT); }
// Returns true if alt units are SI (m), false if ft
inline bool GetAltUnitsSI() { return(_altUnits == GPS_ALT_UNITS_M ? true : false); }
// km and k/h if true, nm and kt if false
inline void SetDistVelUnitsSI(bool b) { _distUnits = (b ? GPS_DIST_UNITS_KM : GPS_DIST_UNITS_NM); _velUnits = (b ? GPS_VEL_UNITS_KPH : GPS_VEL_UNITS_KT); }
// Returns true if dist/vel units are SI
inline bool GetDistVelUnitsSI() { return(_distUnits == GPS_DIST_UNITS_KM && _velUnits == GPS_VEL_UNITS_KPH ? true : false); }
// Set baro units - 1 = in, 2 = mB, 3 = hP Wrapping if for the convienience of the GPS setter.
void SetBaroUnits(int n, bool wrap = false);
// Get baro units: 1 = in, 2 = mB, 3 = hP
inline int GetBaroUnits() { return((int)_baroUnits); }
inline void SetTurnAnticipation(bool b) { _turnAnticipationEnabled = b; }
inline bool GetTurnAnticipation() { return(_turnAnticipationEnabled); }
inline void SetSuaAlertEnabled(bool b) { _suaAlertEnabled = b; } void bind();
inline bool GetSuaAlertEnabled() { return(_suaAlertEnabled); } void unbind();
void init();
inline void SetAltAlertEnabled(bool b) { _altAlertEnabled = b; } void update(double dt);
inline bool GetAltAlertEnabled() { return(_altAlertEnabled); }
void SetMinDisplayBrightness(int n); // Set minDisplayBrightness (between 1 and 9) // Set Units
void DecrementMinDisplayBrightness(); // Decrease by 1 // m if true, ft if false
void IncrementMinDisplayBrightness(); // Increase by 1 inline void SetAltUnitsSI(bool b) { _altUnits = (b ? GPS_ALT_UNITS_M : GPS_ALT_UNITS_FT); }
inline int GetMinDisplayBrightness() { return(_minDisplayBrightness); } // Returns true if alt units are SI (m), false if ft
inline bool GetAltUnitsSI() { return(_altUnits == GPS_ALT_UNITS_M ? true : false); }
inline bool GetMsgAlert() const { return(!_messageStack.empty()); } // km and k/h if true, nm and kt if false
inline void SetDistVelUnitsSI(bool b) { _distUnits = (b ? GPS_DIST_UNITS_KM : GPS_DIST_UNITS_NM); _velUnits = (b ? GPS_VEL_UNITS_KPH : GPS_VEL_UNITS_KT); }
void Knob1Right1(); // Returns true if dist/vel units are SI
void Knob1Left1(); inline bool GetDistVelUnitsSI() { return(_distUnits == GPS_DIST_UNITS_KM && _velUnits == GPS_VEL_UNITS_KPH ? true : false); }
void Knob2Right1(); // Set baro units - 1 = in, 2 = mB, 3 = hP Wrapping if for the convienience of the GPS setter.
void Knob2Left1(); void SetBaroUnits(int n, bool wrap = false);
void CrsrPressed(); // Get baro units: 1 = in, 2 = mB, 3 = hP
void EntPressed(); inline int GetBaroUnits() { return((int)_baroUnits); }
void ClrPressed();
void DtoPressed(); inline void SetTurnAnticipation(bool b) { _turnAnticipationEnabled = b; }
void NrstPressed(); inline bool GetTurnAnticipation() { return(_turnAnticipationEnabled); }
void AltPressed();
void OBSPressed(); inline void SetSuaAlertEnabled(bool b) { _suaAlertEnabled = b; }
void MsgPressed(); inline bool GetSuaAlertEnabled() { return(_suaAlertEnabled); }
void CreateDefaultFlightPlans(); inline void SetAltAlertEnabled(bool b) { _altAlertEnabled = b; }
inline bool GetAltAlertEnabled() { return(_altAlertEnabled); }
void SetMinDisplayBrightness(int n); // Set minDisplayBrightness (between 1 and 9)
void DecrementMinDisplayBrightness(); // Decrease by 1
void IncrementMinDisplayBrightness(); // Increase by 1
inline int GetMinDisplayBrightness() { return(_minDisplayBrightness); }
inline bool GetMsgAlert() const { return(!_messageStack.empty()); }
void Knob1Right1();
void Knob1Left1();
void Knob2Right1();
void Knob2Left1();
void CrsrPressed();
void EntPressed();
void ClrPressed();
void DtoPressed();
void NrstPressed();
void AltPressed();
void OBSPressed();
void MsgPressed();
void CreateDefaultFlightPlans();
private: private:
void ToggleOBSMode(); void ToggleOBSMode();
// Initiate Direct To operation to the supplied ID.
void DtoInitiate(const std::string& id);
//----------------------- Drawing functions which take CHARACTER units ------------------------- // Initiate Direct To operation to the supplied ID.
// Render string s in display field field at position x, y void DtoInitiate(const std::string& id);
// WHERE POSITION IS IN CHARACTER UNITS!
// zero y at bottom?
// invert: -1 => no inversion, 0 -> n => 1 char - s[invert] gets inverted, 99 => entire string gets inverted
void DrawText(const std::string& s, int field, int px, int py, bool bold = false, int invert = -1);
void DrawLatitude(double d, int field, int px, int py);
void DrawLongitude(double d, int field, int px, int py);
// Draw a frequency as xxx.xx //----------------------- Drawing functions which take CHARACTER units -------------------------
void DrawFreq(double d, int field, int px, int py); // Render string s in display field field at position x, y
// WHERE POSITION IS IN CHARACTER UNITS!
// Draw a time in seconds as hh:mm // zero y at bottom?
// NOTE: px is RIGHT JUSTIFIED! // invert: -1 => no inversion, 0 -> n => 1 char - s[invert] gets inverted, 99 => entire string gets inverted
void DrawTime(double time, int field, int px, int py); void DrawText(const std::string& s, int field, int px, int py, bool bold = false, int invert = -1);
// Draw an integer heading, where px specifies the position of the degrees sign at the RIGHT of the value. void DrawLatitude(double d, int field, int px, int py);
void DrawHeading(int h, int field, int px, int py); void DrawLongitude(double d, int field, int px, int py);
// Draw a distance spec'd as nm as an integer (TODO - may need 1 decimal place if < 100) where px specifies RHS of units.
// Some uses definately don't want decimal place though (as at present), so would have to be arg.
void DrawDist(double d, int field, int px, int py);
// Draw a speed specifed in knots. px is RHS of the units. Can draw up to 2 decimal places.
void DrawSpeed(double v, int field, int px, int py, int decimals = 0);
void Underline(int field, int px, int py, int len);
// Render a char at a given position as above (position in CHARACTER units)
void DrawChar(char c, int field, int px, int py, bool bold = false, bool invert = false);
void DrawSpecialChar(char c, int field, int cx, int cy, bool bold = false);
// Draws the dir/dist field at the bottom of the main field
void DrawDirDistField(double lat, double lon, int field, int px, int py, bool to_flag = true, bool cursel = false);
//
//--------------------------------- end char units -----------------------------------------------
//----------------------- Drawing functions which take PIXEL units ------------------------------
//
// Takes instrument *pixel* co-ordinates NOT character units
// Position is specified by the bottom of the *visible* portion, by default the left position unless align_right is true.
// The return value is the pixel width of the visible portion
int DrawSmallChar(char c, int x, int y, bool align_right = false);
void DrawFreeChar(char c, int x, int y, bool draw_background = false);
//
//----------------------------------- end pixel unit functions -----------------------------------
void DrawDivider();
void DrawEnt(int field = 1, int px = 0, int py = 1);
void DrawMessageAlert();
void DrawKPH(int field, int cx, int cy);
void DrawDTO(int field, int cx, int cy);
// Draw the bar that indicates which page we're on (zero-based)
void DrawBar(int page);
void DrawCDI();
void DrawLegTail(int py);
void DrawLongLegTail(int py);
void DrawHalfLegTail(int py);
void UpdateMapHeading();
// Draw the moving map
// Apt, VOR and SUA drawing can be suspended by setting draw_avs to false, without affecting the stored drawing preference state.
void DrawMap(bool draw_avs = true);
// Set whether the display should be drawn pixelated (more primitives, but might be closer to real-life)
// or not (in which case it is assumed that pixels are square and can be merged into quads).
bool _pixelated;
// Flashing output should be hidden when blink is true
bool _blink;
double _cum_dt;
// In Crsr mode, CRSR pressed events are passed to the active page, in disp mode they change which page is active
KLN89Mode _mode;
// And the facility to save a mode
KLN89Mode _lastMode;
// Increment/Decrement a character in the KLN89 A-Z,0-9 scheme.
// Set gap to true to get a space between A and 9 when wrapping, set wrap to false to disable wrap.
char IncChar(char c, bool gap = false, bool wrap = true);
char DecChar(char c, bool gap = false, bool wrap = true);
// ==================== Page organisation stuff ============= // Draw a frequency as xxx.xx
// The list of cyclical pages that the user can cycle through void DrawFreq(double d, int field, int px, int py);
kln89_page_list_type _pages;
// The currently active page
KLN89Page* _activePage;
// And a facility to save the immediately preceding active page
KLN89Page* _lastActivePage;
// Ugly hack. Housekeeping to allow us to temporarily display one page, while remembering which
// other page to "jump" back to. Used when the waypoint pages are used to review waypoint entry
// from the flightplan page.
int _entJump; // The page to jump back to if ENT is pressed. -1 indicates no jump.
int _clrJump; // The page to jump back to if CLR is pressed. -1 indicates no jump.
bool _jumpRestoreCrsr; // Indicates that jump back at this point should restore cursor mode.
// Misc pages that aren't in the cyclic list.
// ALT
KLN89Page* _alt_page;
// Direct To
KLN89Page* _dir_page;
// Nearest
KLN89Page* _nrst_page;
// ====================== end of page stuff ===================
// Moving-map display stuff
int _mapOrientation; // 0 => North (true) up, 1 => DTK up, 2 => TK up, 3 => heading up (only when connected to external heading source).
double _mapHeading; // Degrees. The actual map heading gets updated at a lower frequency than DrawMap() is called at, hence we need to store it.
double _mapHeadingUpdateTimer; // Timer to determine when to update the above.
bool _mapScaleAuto; // Indicates that map should autoscale when true.
int _mapScaleIndex; // Index into array of available map scales.
int _mapScaleUnits; // 0 => nm, 1 => km.
double _mapScale; // nm or km from aircraft position to top of map.
// Note that aircraft position differs depending on orientation, but 'scale' retains the same meaning,
// so the scale per pixel alters to suit the defined scale when the rendered aircraft position changes.
bool _drawSUA; // special user airspace
bool _drawVOR;
bool _drawApt;
// Convert map to instrument coordinates
void MapToInstrument(int &x, int &y);
// The following map drawing functions all take MAP co-ordinates, NOT instrument co-ordinates!
// Draw the diamond style of user pos
void DrawUser1(int x, int y);
// Draw the airplane style of user pos // Draw a time in seconds as hh:mm
void DrawUser2(int x, int y); // NOTE: px is RIGHT JUSTIFIED!
void DrawTime(double time, int field, int px, int py);
// Draw an airport symbol on the moving map
void DrawApt(int x, int y); // Draw an integer heading, where px specifies the position of the degrees sign at the RIGHT of the value.
void DrawHeading(int h, int field, int px, int py);
// Draw a waypoint on the moving map
void DrawWaypoint(int x, int y); // Draw a distance spec'd as nm as an integer (TODO - may need 1 decimal place if < 100) where px specifies RHS of units.
// Some uses definately don't want decimal place though (as at present), so would have to be arg.
// Draw a VOR on the moving map void DrawDist(double d, int field, int px, int py);
void DrawVOR(int x, int y);
// Draw a speed specifed in knots. px is RHS of the units. Can draw up to 2 decimal places.
// Draw an airport or waypoint label on the moving map void DrawSpeed(double v, int field, int px, int py, int decimals = 0);
// Specify position by the map pixel co-ordinate of the left or right, bottom, of the *visible* portion of the label.
// The black background quad will automatically overlap this by 1 pixel. void Underline(int field, int px, int py, int len);
void DrawLabel(const std::string& s, int x1, int y1, bool right_align = false);
// Render a char at a given position as above (position in CHARACTER units)
int GetLabelQuadrant(double h); void DrawChar(char c, int field, int px, int py, bool bold = false, bool invert = false);
int GetLabelQuadrant(double h1, double h2); void DrawSpecialChar(char c, int field, int cx, int cy, bool bold = false);
// Draw a line on the moving map // Draws the dir/dist field at the bottom of the main field
void DrawLine(int x1, int y1, int x2, int y2); void DrawDirDistField(double lat, double lon, int field, int px, int py, bool to_flag = true, bool cursel = false);
//
// Draw normal sized text on the moving map //--------------------------------- end char units -----------------------------------------------
void DrawMapText(const std::string& s, int x, int y, bool draw_background = false);
//----------------------- Drawing functions which take PIXEL units ------------------------------
void DrawMapUpArrow(int x, int y); //
// Takes instrument *pixel* co-ordinates NOT character units
// Draw a Quad on the moving map // Position is specified by the bottom of the *visible* portion, by default the left position unless align_right is true.
void DrawMapQuad(int x1, int y1, int x2, int y2, bool invert = false); // The return value is the pixel width of the visible portion
int DrawSmallChar(char c, int x, int y, bool align_right = false);
// Airport town and state mapped by ID, since currently FG does not store this
airport_id_str_map_type _airportTowns; void DrawFreeChar(char c, int x, int y, bool draw_background = false);
airport_id_str_map_type _airportStates; //
//----------------------------------- end pixel unit functions -----------------------------------
// NOTE - It is a deliberate decision not to have a proper message page class,
// since button events get directed to the page that was active before the void DrawDivider();
// message was displayed, not the message page itself.
bool _dispMsg; // Set true while the message page is being displayed void DrawEnt(int field = 1, int px = 0, int py = 1);
// Sometimes the datapages can be used to review a waypoint whilst the user makes a decision, void DrawMessageAlert();
// and we need to remember why.
bool _dtoReview; // Set true when we a reviewing a waypoint for DTO operation. void DrawKPH(int field, int cx, int cy);
// Configuration settings that the user can set via. the KLN89 SET pages. void DrawDTO(int field, int cx, int cy);
KLN89SpeedUnits _velUnits;
KLN89DistanceUnits _distUnits; // Draw the bar that indicates which page we're on (zero-based)
KLN89PressureUnits _baroUnits; void DrawBar(int page);
KLN89AltitudeUnits _altUnits;
bool _suaAlertEnabled; // Alert user to potential SUA entry void DrawCDI();
bool _altAlertEnabled; // Alert user to min safe alt violation
int _minDisplayBrightness; // Minimum display brightness in low light. void DrawLegTail(int py);
char _defaultFirstChar; // Default first waypoint character. void DrawLongLegTail(int py);
void DrawHalfLegTail(int py);
// The user-settable barometric pressure.
// This can be set in the range 22.00 -> 32.99", or 745 -> 1117mB/hPa. void UpdateMapHeading();
// For user input, we maintain a single integer value that is either between 2200 and 3299 (")
// or between 745 and 1117 (mB/hPa). It gets converted from one to the other only when the // Draw the moving map
// units are changed. // Apt, VOR and SUA drawing can be suspended by setting draw_avs to false, without affecting the stored drawing preference state.
// For internal VNAV calculations (which we don't currently do) this will be converted to a floating void DrawMap(bool draw_avs = true);
// point value before use.
int _userBaroSetting; // Set whether the display should be drawn pixelated (more primitives, but might be closer to real-life)
// or not (in which case it is assumed that pixels are square and can be merged into quads).
bool _pixelated;
// Flashing output should be hidden when blink is true
bool _blink;
double _cum_dt;
// In Crsr mode, CRSR pressed events are passed to the active page, in disp mode they change which page is active
KLN89Mode _mode;
// And the facility to save a mode
KLN89Mode _lastMode;
// Increment/Decrement a character in the KLN89 A-Z,0-9 scheme.
// Set gap to true to get a space between A and 9 when wrapping, set wrap to false to disable wrap.
char IncChar(char c, bool gap = false, bool wrap = true);
char DecChar(char c, bool gap = false, bool wrap = true);
// ==================== Page organisation stuff =============
// The list of cyclical pages that the user can cycle through
kln89_page_list_type _pages;
// The currently active page
KLN89Page* _activePage;
// And a facility to save the immediately preceding active page
KLN89Page* _lastActivePage;
// Ugly hack. Housekeeping to allow us to temporarily display one page, while remembering which
// other page to "jump" back to. Used when the waypoint pages are used to review waypoint entry
// from the flightplan page.
int _entJump; // The page to jump back to if ENT is pressed. -1 indicates no jump.
int _clrJump; // The page to jump back to if CLR is pressed. -1 indicates no jump.
bool _jumpRestoreCrsr; // Indicates that jump back at this point should restore cursor mode.
// Misc pages that aren't in the cyclic list.
// ALT
KLN89Page* _alt_page;
// Direct To
KLN89Page* _dir_page;
// Nearest
KLN89Page* _nrst_page;
// ====================== end of page stuff ===================
// Moving-map display stuff
int _mapOrientation; // 0 => North (true) up, 1 => DTK up, 2 => TK up, 3 => heading up (only when connected to external heading source).
double _mapHeading; // Degrees. The actual map heading gets updated at a lower frequency than DrawMap() is called at, hence we need to store it.
double _mapHeadingUpdateTimer; // Timer to determine when to update the above.
bool _mapScaleAuto; // Indicates that map should autoscale when true.
int _mapScaleIndex; // Index into array of available map scales.
int _mapScaleUnits; // 0 => nm, 1 => km.
double _mapScale; // nm or km from aircraft position to top of map.
// Note that aircraft position differs depending on orientation, but 'scale' retains the same meaning,
// so the scale per pixel alters to suit the defined scale when the rendered aircraft position changes.
bool _drawSUA; // special user airspace
bool _drawVOR;
bool _drawApt;
// Convert map to instrument coordinates
void MapToInstrument(int &x, int &y);
// The following map drawing functions all take MAP co-ordinates, NOT instrument co-ordinates!
// Draw the diamond style of user pos
void DrawUser1(int x, int y);
// Draw the airplane style of user pos
void DrawUser2(int x, int y);
// Draw an airport symbol on the moving map
void DrawApt(int x, int y);
// Draw a waypoint on the moving map
void DrawWaypoint(int x, int y);
// Draw a VOR on the moving map
void DrawVOR(int x, int y);
// Draw an airport or waypoint label on the moving map
// Specify position by the map pixel co-ordinate of the left or right, bottom, of the *visible* portion of the label.
// The black background quad will automatically overlap this by 1 pixel.
void DrawLabel(const std::string& s, int x1, int y1, bool right_align = false);
int GetLabelQuadrant(double h);
int GetLabelQuadrant(double h1, double h2);
// Draw a line on the moving map
void DrawLine(int x1, int y1, int x2, int y2);
// Draw normal sized text on the moving map
void DrawMapText(const std::string& s, int x, int y, bool draw_background = false);
void DrawMapUpArrow(int x, int y);
// Draw a Quad on the moving map
void DrawMapQuad(int x1, int y1, int x2, int y2, bool invert = false);
// Airport town and state mapped by ID, since currently FG does not store this
airport_id_str_map_type _airportTowns;
airport_id_str_map_type _airportStates;
// NOTE - It is a deliberate decision not to have a proper message page class,
// since button events get directed to the page that was active before the
// message was displayed, not the message page itself.
bool _dispMsg; // Set true while the message page is being displayed
// Sometimes the datapages can be used to review a waypoint whilst the user makes a decision,
// and we need to remember why.
bool _dtoReview; // Set true when we a reviewing a waypoint for DTO operation.
// Configuration settings that the user can set via. the KLN89 SET pages.
KLN89SpeedUnits _velUnits;
KLN89DistanceUnits _distUnits;
KLN89PressureUnits _baroUnits;
KLN89AltitudeUnits _altUnits;
bool _suaAlertEnabled; // Alert user to potential SUA entry
bool _altAlertEnabled; // Alert user to min safe alt violation
int _minDisplayBrightness; // Minimum display brightness in low light.
char _defaultFirstChar; // Default first waypoint character.
// The user-settable barometric pressure.
// This can be set in the range 22.00 -> 32.99", or 745 -> 1117mB/hPa.
// For user input, we maintain a single integer value that is either between 2200 and 3299 (")
// or between 745 and 1117 (mB/hPa). It gets converted from one to the other only when the
// units are changed.
// For internal VNAV calculations (which we don't currently do) this will be converted to a floating
// point value before use.
int _userBaroSetting;
}; };
#endif // _KLN89_HXX #endif // _KLN89_HXX

View file

@ -39,9 +39,7 @@ class SGSampleGroup;
*/ */
class ADF : public AbstractInstrument class ADF : public AbstractInstrument
{ {
public: public:
ADF ( SGPropertyNode *node ); ADF ( SGPropertyNode *node );
virtual ~ADF (); virtual ~ADF ();
@ -49,7 +47,6 @@ public:
virtual void update (double delta_time_sec); virtual void update (double delta_time_sec);
private: private:
void set_bearing (double delta_time_sec, double bearing); void set_bearing (double delta_time_sec, double bearing);
void search (double frequency, const SGGeod& pos); void search (double frequency, const SGGeod& pos);
@ -82,5 +79,4 @@ private:
SGSharedPtr<SGSampleGroup> _sgr; SGSharedPtr<SGSampleGroup> _sgr;
}; };
#endif // __INSTRUMENTS_ADF_HXX #endif // __INSTRUMENTS_ADF_HXX

View file

@ -36,9 +36,7 @@ class FGEnvironmentMgr;
*/ */
class AirspeedIndicator : public SGSubsystem class AirspeedIndicator : public SGSubsystem
{ {
public: public:
AirspeedIndicator ( SGPropertyNode *node ); AirspeedIndicator ( SGPropertyNode *node );
virtual ~AirspeedIndicator (); virtual ~AirspeedIndicator ();
@ -58,7 +56,7 @@ private:
double _ias_limit; double _ias_limit;
double _mach_limit; double _mach_limit;
double _alt_threshold; double _alt_threshold;
SGPropertyNode_ptr _ias_limit_node; SGPropertyNode_ptr _ias_limit_node;
SGPropertyNode_ptr _mach_limit_node; SGPropertyNode_ptr _mach_limit_node;
SGPropertyNode_ptr _alt_threshold_node; SGPropertyNode_ptr _alt_threshold_node;
@ -71,7 +69,7 @@ private:
SGPropertyNode_ptr _pressure_alt; SGPropertyNode_ptr _pressure_alt;
SGPropertyNode_ptr _mach_node; SGPropertyNode_ptr _mach_node;
SGPropertyNode_ptr _tas_node; SGPropertyNode_ptr _tas_node;
FGEnvironmentMgr* _environmentManager; FGEnvironmentMgr* _environmentManager;
}; };

View file

@ -29,9 +29,7 @@
*/ */
class Altimeter : public SGSubsystem class Altimeter : public SGSubsystem
{ {
public: public:
Altimeter (SGPropertyNode *node, const std::string& aDefaultName, double quantum = 0); Altimeter (SGPropertyNode *node, const std::string& aDefaultName, double quantum = 0);
virtual ~Altimeter (); virtual ~Altimeter ();
@ -58,7 +56,7 @@ private:
double _settingInHg; double _settingInHg;
bool _encodeModeC; bool _encodeModeC;
bool _encodeModeS; bool _encodeModeS;
SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _pressure_node; SGPropertyNode_ptr _pressure_node;
SGPropertyNode_ptr _press_alt_node; SGPropertyNode_ptr _press_alt_node;

View file

@ -38,9 +38,7 @@
*/ */
class AttitudeIndicator : public SGSubsystem class AttitudeIndicator : public SGSubsystem
{ {
public: public:
AttitudeIndicator ( SGPropertyNode *node ); AttitudeIndicator ( SGPropertyNode *node );
virtual ~AttitudeIndicator (); virtual ~AttitudeIndicator ();
@ -51,7 +49,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
std::string _name; std::string _name;
int _num; int _num;
std::string _suction; std::string _suction;

View file

@ -26,7 +26,8 @@
* /instrumentation/clock/indicated-sec * /instrumentation/clock/indicated-sec
* /instrumentation/clock/indicated-string * /instrumentation/clock/indicated-string
*/ */
class Clock : public SGSubsystem { class Clock : public SGSubsystem
{
public: public:
Clock(SGPropertyNode *node); Clock(SGPropertyNode *node);
virtual ~Clock(); virtual ~Clock();

View file

@ -454,40 +454,40 @@ private:
/* ------------- The CommRadio implementation ---------------------- */ /* ------------- The CommRadio implementation ---------------------- */
class CommRadioImpl: public CommRadio, OutputProperties { class CommRadioImpl: public CommRadio,
OutputProperties
{
public: public:
CommRadioImpl(SGPropertyNode_ptr node); CommRadioImpl(SGPropertyNode_ptr node);
virtual ~CommRadioImpl(); virtual ~CommRadioImpl();
void update(double dt) override; void update(double dt) override;
void init() override; void init() override;
void bind() override; void bind() override;
void unbind() override; void unbind() override;
private: private:
bool _useEightPointThree = false; bool _useEightPointThree = false;
MetarBridgeRef _metarBridge; MetarBridgeRef _metarBridge;
AtisSpeaker _atisSpeaker; AtisSpeaker _atisSpeaker;
SGSharedPtr<FrequencyFormatterBase> _useFrequencyFormatter; SGSharedPtr<FrequencyFormatterBase> _useFrequencyFormatter;
SGSharedPtr<FrequencyFormatterBase> _stbyFrequencyFormatter; SGSharedPtr<FrequencyFormatterBase> _stbyFrequencyFormatter;
const SignalQualityComputerRef _signalQualityComputer; const SignalQualityComputerRef _signalQualityComputer;
double _stationTTL = 0.0; double _stationTTL = 0.0;
double _frequency = -1.0; double _frequency = -1.0;
flightgear::CommStationRef _commStationForFrequency; flightgear::CommStationRef _commStationForFrequency;
PropertyObject<double> _volume_norm; PropertyObject<double> _volume_norm;
PropertyObject<string> _atis; PropertyObject<string> _atis;
PropertyObject<bool> _addNoise; PropertyObject<bool> _addNoise;
PropertyObject<double> _cutoffSignalQuality; PropertyObject<double> _cutoffSignalQuality;
std::string _soundPrefix;
void stopAudio();
void updateAudio();
SGSampleGroup* _sampleGroup = nullptr;
std::string _soundPrefix;
void stopAudio();
void updateAudio();
SGSampleGroup* _sampleGroup = nullptr;
}; };
CommRadioImpl::CommRadioImpl(SGPropertyNode_ptr node) : CommRadioImpl::CommRadioImpl(SGPropertyNode_ptr node) :

View file

@ -28,10 +28,11 @@
namespace Instrumentation { namespace Instrumentation {
class SignalQualityComputer : public SGReferenced { class SignalQualityComputer : public SGReferenced
{
public: public:
virtual ~SignalQualityComputer(); virtual ~SignalQualityComputer();
virtual double computeSignalQuality( double distance_nm ) const = 0; virtual double computeSignalQuality( double distance_nm ) const = 0;
}; };
typedef SGSharedPtr<SignalQualityComputer> SignalQualityComputerRef; typedef SGSharedPtr<SignalQualityComputer> SignalQualityComputerRef;
@ -39,7 +40,7 @@ typedef SGSharedPtr<SignalQualityComputer> SignalQualityComputerRef;
class CommRadio : public AbstractInstrument class CommRadio : public AbstractInstrument
{ {
public: public:
static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode ); static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode );
}; };
} }

View file

@ -51,20 +51,20 @@ class FGFix;
// NOTE - ORDERING IS IMPORTANT HERE - it matches the Bendix-King page ordering! // NOTE - ORDERING IS IMPORTANT HERE - it matches the Bendix-King page ordering!
enum GPSWpType { enum GPSWpType {
GPS_WP_APT = 0, GPS_WP_APT = 0,
GPS_WP_VOR, GPS_WP_VOR,
GPS_WP_NDB, GPS_WP_NDB,
GPS_WP_INT, GPS_WP_INT,
GPS_WP_USR, GPS_WP_USR,
GPS_WP_VIRT // Used for virtual waypoints, such as the start of DTO operation. GPS_WP_VIRT // Used for virtual waypoints, such as the start of DTO operation.
}; };
enum GPSAppWpType { enum GPSAppWpType {
GPS_IAF, // Initial approach fix GPS_IAF, // Initial approach fix
GPS_IAP, // Waypoint on approach sequence that isn't any of the others. GPS_IAP, // Waypoint on approach sequence that isn't any of the others.
GPS_FAF, // Final approach fix GPS_FAF, // Final approach fix
GPS_MAP, // Missed approach point GPS_MAP, // Missed approach point
GPS_MAHP, // Initial missed approach holding point. GPS_MAHP, // Initial missed approach holding point.
GPS_HDR, // A virtual 'waypoint' to represent the approach header in the fpl page GPS_HDR, // A virtual 'waypoint' to represent the approach header in the fpl page
GPS_FENCE, // A virtual 'waypoint' to represent the NO WPT SEQ fence. GPS_FENCE, // A virtual 'waypoint' to represent the NO WPT SEQ fence.
GPS_APP_NONE // Not part of the approach sequence - the default. GPS_APP_NONE // Not part of the approach sequence - the default.
@ -74,18 +74,18 @@ std::ostream& operator << (std::ostream& os, GPSAppWpType type);
struct GPSWaypoint { struct GPSWaypoint {
GPSWaypoint(); GPSWaypoint();
GPSWaypoint(const std::string& aIdent, float lat, float lon, GPSWpType aType); GPSWaypoint(const std::string& aIdent, float lat, float lon, GPSWpType aType);
static GPSWaypoint* createFromPositioned(const FGPositioned* aFix); static GPSWaypoint* createFromPositioned(const FGPositioned* aFix);
~GPSWaypoint(); ~GPSWaypoint();
std::string GetAprId(); // Returns the id with i, f, m or h added if appropriate. (Initial approach fix, final approach fix, etc) std::string GetAprId(); // Returns the id with i, f, m or h added if appropriate. (Initial approach fix, final approach fix, etc)
std::string id; std::string id;
float lat; // Radians float lat; // Radians
float lon; // Radians float lon; // Radians
GPSWpType type; GPSWpType type;
GPSAppWpType appType; // only used for waypoints that are part of an approach sequence GPSAppWpType appType; // only used for waypoints that are part of an approach sequence
}; };
typedef std::vector < GPSWaypoint* > gps_waypoint_array; typedef std::vector < GPSWaypoint* > gps_waypoint_array;
@ -94,56 +94,60 @@ typedef std::map < std::string, gps_waypoint_array > gps_waypoint_map;
typedef gps_waypoint_map::iterator gps_waypoint_map_iterator; typedef gps_waypoint_map::iterator gps_waypoint_map_iterator;
typedef gps_waypoint_map::const_iterator gps_waypoint_map_const_iterator; typedef gps_waypoint_map::const_iterator gps_waypoint_map_const_iterator;
class GPSFlightPlan { class GPSFlightPlan
{
public: public:
std::vector<GPSWaypoint*> waypoints; std::vector<GPSWaypoint*> waypoints;
inline bool IsEmpty() { return waypoints.empty(); } inline bool IsEmpty() { return waypoints.empty(); }
}; };
// TODO - probably de-public the internals of the next 2 classes and add some methods! // TODO - probably de-public the internals of the next 2 classes and add some methods!
// Instrument approach procedure base class // Instrument approach procedure base class
class FGIAP { class FGIAP
{
public: public:
FGIAP(); FGIAP();
virtual ~FGIAP() = 0; virtual ~FGIAP() = 0;
//protected:
std::string _aptIdent; // The ident of the airport this approach is for //protected:
std::string _ident; // The approach ident. std::string _aptIdent; // The ident of the airport this approach is for
std::string _name; // The full approach name. std::string _ident; // The approach ident.
std::string _rwyStr; // The string used to specify the rwy - eg "B" in this instance. std::string _name; // The full approach name.
bool _precision; // True for precision approach, false for non-precision. std::string _rwyStr; // The string used to specify the rwy - eg "B" in this instance.
bool _precision; // True for precision approach, false for non-precision.
}; };
// Non-precision instrument approach procedure // Non-precision instrument approach procedure
class FGNPIAP : public FGIAP { class FGNPIAP : public FGIAP
{
public: public:
FGNPIAP(); FGNPIAP();
~FGNPIAP(); ~FGNPIAP();
//private: //private:
public: public:
std::vector<GPSFlightPlan*> _approachRoutes; // The approach route(s) from the IAF(s) to the IF. std::vector<GPSFlightPlan*> _approachRoutes; // The approach route(s) from the IAF(s) to the IF.
// NOTE: It is an assumption in the code that uses this that there is a unique IAF per approach route. // NOTE: It is an assumption in the code that uses this that there is a unique IAF per approach route.
std::vector<GPSWaypoint*> _IAP; // The compulsory waypoints of the approach procedure (may duplicate one of the above). std::vector<GPSWaypoint*> _IAP; // The compulsory waypoints of the approach procedure (may duplicate one of the above).
// _IAP includes the FAF and MAF, and the missed approach waypoints. // _IAP includes the FAF and MAF, and the missed approach waypoints.
}; };
typedef std::vector < FGIAP* > iap_list_type; typedef std::vector < FGIAP* > iap_list_type;
typedef std::map < std::string, iap_list_type > iap_map_type; typedef std::map < std::string, iap_list_type > iap_map_type;
typedef iap_map_type::iterator iap_map_iterator; typedef iap_map_type::iterator iap_map_iterator;
// A class to encapsulate hr:min representation of time. // A class to encapsulate hr:min representation of time.
class ClockTime
class ClockTime { {
public: public:
ClockTime(); ClockTime();
ClockTime(int hr, int min); ClockTime(int hr, int min);
~ClockTime(); ~ClockTime();
inline void set_hr(int hr) { _hr = hr; } inline void set_hr(int hr) { _hr = hr; }
inline int hr() const { return(_hr); } inline int hr() const { return(_hr); }
inline void set_min(int min) { _min = min; } inline void set_min(int min) { _min = min; }
inline int min() const { return(_min); } inline int min() const { return(_min); }
ClockTime operator+ (const ClockTime& t) { ClockTime operator+ (const ClockTime& t) {
int cumMin = _hr * 60 + _min + t.hr() * 60 + t.min(); int cumMin = _hr * 60 + _min + t.hr() * 60 + t.min();
ClockTime t2(cumMin / 60, cumMin % 60); ClockTime t2(cumMin / 60, cumMin % 60);
@ -168,8 +172,8 @@ private:
// AlignedProjection - a class to project an area local to a runway onto an orthogonal co-ordinate system // AlignedProjection - a class to project an area local to a runway onto an orthogonal co-ordinate system
// with the origin at the threshold and the runway aligned with the y axis. // with the origin at the threshold and the runway aligned with the y axis.
class AlignedProjection { class AlignedProjection
{
public: public:
AlignedProjection(); AlignedProjection();
AlignedProjection(const SGGeod& centre, double heading); AlignedProjection(const SGGeod& centre, double heading);
@ -184,311 +188,312 @@ public:
SGGeod ConvertFromLocal(const SGVec3d& pt); SGGeod ConvertFromLocal(const SGVec3d& pt);
private: private:
SGGeod _origin; // lat/lon of local area origin (the threshold) SGGeod _origin; // lat/lon of local area origin (the threshold)
double _theta; // the rotation angle for alignment in radians double _theta; // the rotation angle for alignment in radians
double _correction_factor; // Reduction in surface distance per degree of longitude due to latitude. Saves having to do a cos() every call. double _correction_factor; // Reduction in surface distance per degree of longitude due to latitude. Saves having to do a cos() every call.
}; };
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// TODO - merge generic GPS functions instead and split out KLN specific stuff. // TODO - merge generic GPS functions instead and split out KLN specific stuff.
class DCLGPS : public SGSubsystem { class DCLGPS : public SGSubsystem
{
public: public:
DCLGPS(RenderArea2D* instrument); DCLGPS(RenderArea2D* instrument);
virtual ~DCLGPS() = 0; virtual ~DCLGPS() = 0;
virtual void draw(osg::State& state);
virtual void init();
virtual void bind();
virtual void unbind();
virtual void update(double dt);
// Expand a SIAP ident to the full procedure name.
std::string ExpandSIAPIdent(const std::string& ident);
// Render string s in display field field at position x, y virtual void draw(osg::State& state);
// WHERE POSITION IS IN CHARACTER UNITS!
// zero y at bottom?
virtual void DrawText(const std::string& s, int field, int px, int py, bool bold = false);
// Render a char at a given position as above
virtual void DrawChar(char c, int field, int px, int py, bool bold = false);
virtual void ToggleOBSMode();
// Set the number of fields
inline void SetNumFields(int n) { _nFields = (n > _maxFields ? _maxFields : (n < 1 ? 1 : n)); }
// It is expected that specific GPS units will override these functions.
// Increase the CDI full-scale deflection (ie. increase the nm per dot) one (GPS unit dependent) increment. Wraps if necessary (GPS unit dependent).
virtual void CDIFSDIncrease();
// Ditto for decrease the distance per dot
virtual void CDIFSDDecrease();
// Host specifc
////inline void SetOverlays(Overlays* overlays) { _overlays = overlays; }
virtual void CreateDefaultFlightPlans();
void SetOBSFromWaypoint();
GPSWaypoint* GetActiveWaypoint();
// Get the (zero-based) position of the active waypoint in the active flightplan
// Returns -1 if no active waypoint.
int GetActiveWaypointIndex();
// Ditto for an arbitrary waypoint id
int GetWaypointIndex(const std::string& id);
// Returns meters
float GetDistToActiveWaypoint();
// Returns degrees (magnetic)
float GetHeadingToActiveWaypoint();
// Returns degrees (magnetic)
float GetHeadingFromActiveWaypoint();
// Get the time to the active waypoint in seconds.
// Returns -1 if groundspeed < 30 kts
double GetTimeToActiveWaypoint();
// Get the time to the final waypoint in seconds.
// Returns -1 if groundspeed < 30 kts
double GetETE();
// Get the time to a given waypoint (spec'd by ID) in seconds.
// returns -1 if groundspeed is less than 30kts.
// If the waypoint is an unreached part of the active flight plan the time will be via each leg.
// otherwise it will be a direct-to time.
double GetTimeToWaypoint(const std::string& id);
// Return true if waypoint alerting is occuring
inline bool GetWaypointAlert() const { return(_waypointAlert); }
// Return true if in OBS mode
inline bool GetOBSMode() const { return(_obsMode); }
// Return true if in Leg mode
inline bool GetLegMode() const { return(!_obsMode); }
// Clear a flightplan
void ClearFlightPlan(int n);
void ClearFlightPlan(GPSFlightPlan* fp);
// Returns true if an approach is loaded/armed/active in the active flight plan
inline bool ApproachLoaded() const { return(_approachLoaded); }
inline bool GetApproachArm() const { return(_approachArm); }
inline bool GetApproachActive() const { return(_approachActive); }
double GetCDIDeflection() const;
inline bool GetToFlag() const { return(_headingBugTo); }
// Initiate Direct To operation to the supplied ID.
virtual void DtoInitiate(const std::string& id);
// Cancel Direct To operation
void DtoCancel();
protected:
// Maximum number of display fields for this device
int _maxFields;
// Current number of on-screen fields
int _nFields;
// Full x border
int _xBorder;
// Full y border
int _yBorder;
// Lower (y) border per field
int _yFieldBorder[4];
// Left (x) border per field
int _xFieldBorder[4];
// Field start in x dir (border is part of field since it is the normal char border - sometimes map mode etc draws in it)
int _xFieldStart[4];
// Field start in y dir (for completeness - KLN89 only has vertical divider.
int _yFieldStart[4];
// The number of pages on the cyclic knob control
unsigned int _nPages;
// The current page we're on (Not sure how this ties in with extra pages such as direct or nearest).
unsigned int _curPage;
// 2D rendering area
RenderArea2D* _instrument;
// CDI full-scale deflection, specified either as an index into a vector of values (standard values) or as a double precision float (intermediate values).
// This will influence how an externally driven CDI will display as well as the NAV1 page.
// Hence the variables are located here, not in the nav page class.
std::vector<float> _cdiScales;
unsigned int _currentCdiScaleIndex;
bool _cdiScaleTransition; // Set true when the floating CDI value is used during transitions
double _currentCdiScale; // The floating value to use.
unsigned int _targetCdiScaleIndex; // The target indexed value to attain during a transition.
unsigned int _sourceCdiScaleIndex; // The source indexed value during a transition - so we know which way we're heading!
// Timers to handle the transitions - not sure if we need these.
double _apprArmTimer;
double _apprActvTimer;
double _cdiTransitionTime; // Time for transition to occur in - normally 30sec but may be quicker if time to FAF < 30sec?
//
// Data and lookup functions
virtual void init();
virtual void bind();
virtual void unbind();
virtual void update(double dt);
// Expand a SIAP ident to the full procedure name.
std::string ExpandSIAPIdent(const std::string& ident);
// Render string s in display field field at position x, y
// WHERE POSITION IS IN CHARACTER UNITS!
// zero y at bottom?
virtual void DrawText(const std::string& s, int field, int px, int py, bool bold = false);
// Render a char at a given position as above
virtual void DrawChar(char c, int field, int px, int py, bool bold = false);
virtual void ToggleOBSMode();
// Set the number of fields
inline void SetNumFields(int n) { _nFields = (n > _maxFields ? _maxFields : (n < 1 ? 1 : n)); }
// It is expected that specific GPS units will override these functions.
// Increase the CDI full-scale deflection (ie. increase the nm per dot) one (GPS unit dependent) increment. Wraps if necessary (GPS unit dependent).
virtual void CDIFSDIncrease();
// Ditto for decrease the distance per dot
virtual void CDIFSDDecrease();
// Host specifc
////inline void SetOverlays(Overlays* overlays) { _overlays = overlays; }
virtual void CreateDefaultFlightPlans();
void SetOBSFromWaypoint();
GPSWaypoint* GetActiveWaypoint();
// Get the (zero-based) position of the active waypoint in the active flightplan
// Returns -1 if no active waypoint.
int GetActiveWaypointIndex();
// Ditto for an arbitrary waypoint id
int GetWaypointIndex(const std::string& id);
// Returns meters
float GetDistToActiveWaypoint();
// Returns degrees (magnetic)
float GetHeadingToActiveWaypoint();
// Returns degrees (magnetic)
float GetHeadingFromActiveWaypoint();
// Get the time to the active waypoint in seconds.
// Returns -1 if groundspeed < 30 kts
double GetTimeToActiveWaypoint();
// Get the time to the final waypoint in seconds.
// Returns -1 if groundspeed < 30 kts
double GetETE();
// Get the time to a given waypoint (spec'd by ID) in seconds.
// returns -1 if groundspeed is less than 30kts.
// If the waypoint is an unreached part of the active flight plan the time will be via each leg.
// otherwise it will be a direct-to time.
double GetTimeToWaypoint(const std::string& id);
// Return true if waypoint alerting is occuring
inline bool GetWaypointAlert() const { return(_waypointAlert); }
// Return true if in OBS mode
inline bool GetOBSMode() const { return(_obsMode); }
// Return true if in Leg mode
inline bool GetLegMode() const { return(!_obsMode); }
// Clear a flightplan
void ClearFlightPlan(int n);
void ClearFlightPlan(GPSFlightPlan* fp);
// Returns true if an approach is loaded/armed/active in the active flight plan
inline bool ApproachLoaded() const { return(_approachLoaded); }
inline bool GetApproachArm() const { return(_approachArm); }
inline bool GetApproachActive() const { return(_approachActive); }
double GetCDIDeflection() const;
inline bool GetToFlag() const { return(_headingBugTo); }
// Initiate Direct To operation to the supplied ID.
virtual void DtoInitiate(const std::string& id);
// Cancel Direct To operation
void DtoCancel();
protected: protected:
void LoadApproachData(); // Maximum number of display fields for this device
int _maxFields;
// Current number of on-screen fields
int _nFields;
// Full x border
int _xBorder;
// Full y border
int _yBorder;
// Lower (y) border per field
int _yFieldBorder[4];
// Left (x) border per field
int _xFieldBorder[4];
// Field start in x dir (border is part of field since it is the normal char border - sometimes map mode etc draws in it)
int _xFieldStart[4];
// Field start in y dir (for completeness - KLN89 only has vertical divider.
int _yFieldStart[4];
// Find first of any type of waypoint by id. (TODO - Possibly we should return multiple waypoints here). // The number of pages on the cyclic knob control
GPSWaypoint* FindFirstById(const std::string& id) const; unsigned int _nPages;
GPSWaypoint* FindFirstByExactId(const std::string& id) const; // The current page we're on (Not sure how this ties in with extra pages such as direct or nearest).
unsigned int _curPage;
FGNavRecord* FindFirstVorById(const std::string& id, bool &multi, bool exact = false);
FGNavRecord* FindFirstNDBById(const std::string& id, bool &multi, bool exact = false);
const FGAirport* FindFirstAptById(const std::string& id, bool &multi, bool exact = false);
const FGFix* FindFirstIntById(const std::string& id, bool &multi, bool exact = false);
// Find the closest VOR to a position in RADIANS.
FGNavRecord* FindClosestVor(double lat_rad, double lon_rad);
// helper to implement the above FindFirstXXX methods // 2D rendering area
FGPositioned* FindTypedFirstById(const std::string& id, FGPositioned::Type ty, bool &multi, bool exact); RenderArea2D* _instrument;
// Position, orientation and velocity. // CDI full-scale deflection, specified either as an index into a vector of values (standard values) or as a double precision float (intermediate values).
// These should be read from FG's built-in GPS logic if possible. // This will influence how an externally driven CDI will display as well as the NAV1 page.
// Use the property node pointers below to do this. // Hence the variables are located here, not in the nav page class.
std::vector<float> _cdiScales;
unsigned int _currentCdiScaleIndex;
bool _cdiScaleTransition; // Set true when the floating CDI value is used during transitions
double _currentCdiScale; // The floating value to use.
unsigned int _targetCdiScaleIndex; // The target indexed value to attain during a transition.
unsigned int _sourceCdiScaleIndex; // The source indexed value during a transition - so we know which way we're heading!
// Timers to handle the transitions - not sure if we need these.
double _apprArmTimer;
double _apprActvTimer;
double _cdiTransitionTime; // Time for transition to occur in - normally 30sec but may be quicker if time to FAF < 30sec?
//
// Data and lookup functions
protected:
void LoadApproachData();
// Find first of any type of waypoint by id. (TODO - Possibly we should return multiple waypoints here).
GPSWaypoint* FindFirstById(const std::string& id) const;
GPSWaypoint* FindFirstByExactId(const std::string& id) const;
FGNavRecord* FindFirstVorById(const std::string& id, bool &multi, bool exact = false);
FGNavRecord* FindFirstNDBById(const std::string& id, bool &multi, bool exact = false);
const FGAirport* FindFirstAptById(const std::string& id, bool &multi, bool exact = false);
const FGFix* FindFirstIntById(const std::string& id, bool &multi, bool exact = false);
// Find the closest VOR to a position in RADIANS.
FGNavRecord* FindClosestVor(double lat_rad, double lon_rad);
// helper to implement the above FindFirstXXX methods
FGPositioned* FindTypedFirstById(const std::string& id, FGPositioned::Type ty, bool &multi, bool exact);
// Position, orientation and velocity.
// These should be read from FG's built-in GPS logic if possible.
// Use the property node pointers below to do this.
SGPropertyNode_ptr _lon_node; SGPropertyNode_ptr _lon_node;
SGPropertyNode_ptr _lat_node; SGPropertyNode_ptr _lat_node;
SGPropertyNode_ptr _alt_node; SGPropertyNode_ptr _alt_node;
SGPropertyNode_ptr _grnd_speed_node; SGPropertyNode_ptr _grnd_speed_node;
SGPropertyNode_ptr _true_track_node; SGPropertyNode_ptr _true_track_node;
SGPropertyNode_ptr _mag_track_node; SGPropertyNode_ptr _mag_track_node;
// Present position. (Radians) // Present position. (Radians)
double _lat, _lon; double _lat, _lon;
// Present altitude (ft). (Yuk! but it saves converting ft->m->ft every update). // Present altitude (ft). (Yuk! but it saves converting ft->m->ft every update).
double _alt; double _alt;
// Reported position as measured by GPS. For now this is the same // Reported position as measured by GPS. For now this is the same
// as present position, but in the future we might want to model // as present position, but in the future we might want to model
// GPS lat and lon errors. // GPS lat and lon errors.
// Note - we can depriciate _gpsLat and _gpsLon if we implement error handling in FG // Note - we can depriciate _gpsLat and _gpsLon if we implement error handling in FG
// gps code and not our own. // gps code and not our own.
double _gpsLat, _gpsLon; //(Radians) double _gpsLat, _gpsLon; //(Radians)
// Hack - it seems that the GPS gets initialised before FG's initial position is properly set. // Hack - it seems that the GPS gets initialised before FG's initial position is properly set.
// By checking for abnormal slew in the position we can force a re-initialisation of active flight // By checking for abnormal slew in the position we can force a re-initialisation of active flight
// plan leg and anything else that might be affected. // plan leg and anything else that might be affected.
// TODO - sort FlightGear's initialisation order properly!!! // TODO - sort FlightGear's initialisation order properly!!!
double _checkLat, _checkLon; // (Radians) double _checkLat, _checkLon; // (Radians)
double _groundSpeed_ms; // filtered groundspeed (m/s) double _groundSpeed_ms; // filtered groundspeed (m/s)
double _groundSpeed_kts; // ditto in knots double _groundSpeed_kts; // ditto in knots
double _track; // filtered true track (degrees) double _track; // filtered true track (degrees)
double _magTrackDeg; // magnetic track in degrees calculated from true track above double _magTrackDeg; // magnetic track in degrees calculated from true track above
// _navFlagged is set true when GPS navigation is either not possible or not logical. // _navFlagged is set true when GPS navigation is either not possible or not logical.
// This includes not receiving adequate signals, and not having an active flightplan entered. // This includes not receiving adequate signals, and not having an active flightplan entered.
bool _navFlagged; bool _navFlagged;
// Positional functions copied from ATCutils that might get replaced // Positional functions copied from ATCutils that might get replaced
// INPUT in RADIANS, returns DEGREES! // INPUT in RADIANS, returns DEGREES!
// Magnetic // Magnetic
double GetMagHeadingFromTo(double latA, double lonA, double latB, double lonB); double GetMagHeadingFromTo(double latA, double lonA, double latB, double lonB);
// True // True
//double GetHeadingFromTo(double latA, double lonA, double latB, double lonB); //double GetHeadingFromTo(double latA, double lonA, double latB, double lonB);
// Given two positions (lat & lon in RADIANS), get the HORIZONTAL separation (in meters) // Given two positions (lat & lon in RADIANS), get the HORIZONTAL separation (in meters)
//double GetHorizontalSeparation(double lat1, double lon1, double lat2, double lon2); //double GetHorizontalSeparation(double lat1, double lon1, double lat2, double lon2);
// Proper great circle positional functions from The Aviation Formulary // Proper great circle positional functions from The Aviation Formulary
// Returns distance in Nm, input in RADIANS. // Returns distance in Nm, input in RADIANS.
double GetGreatCircleDistance(double lat1, double lon1, double lat2, double lon2) const; double GetGreatCircleDistance(double lat1, double lon1, double lat2, double lon2) const;
// Input in RADIANS, output in DEGREES. // Input in RADIANS, output in DEGREES.
// True // True
double GetGreatCircleCourse(double lat1, double lon1, double lat2, double lon2) const; double GetGreatCircleCourse(double lat1, double lon1, double lat2, double lon2) const;
// Return a position on a radial from wp1 given distance d (nm) and magnetic heading h (degrees) // Return a position on a radial from wp1 given distance d (nm) and magnetic heading h (degrees)
// Note that d should be less that 1/4 Earth diameter! // Note that d should be less that 1/4 Earth diameter!
GPSWaypoint GetPositionOnMagRadial(const GPSWaypoint& wp1, double d, double h); GPSWaypoint GetPositionOnMagRadial(const GPSWaypoint& wp1, double d, double h);
// Return a position on a radial from wp1 given distance d (nm) and TRUE heading h (degrees) // Return a position on a radial from wp1 given distance d (nm) and TRUE heading h (degrees)
// Note that d should be less that 1/4 Earth diameter! // Note that d should be less that 1/4 Earth diameter!
GPSWaypoint GetPositionOnRadial(const GPSWaypoint& wp1, double d, double h); GPSWaypoint GetPositionOnRadial(const GPSWaypoint& wp1, double d, double h);
// Calculate the current cross-track deviation in nm. // Calculate the current cross-track deviation in nm.
// Returns zero if a sensible value cannot be calculated. // Returns zero if a sensible value cannot be calculated.
double CalcCrossTrackDeviation() const; double CalcCrossTrackDeviation() const;
// Calculate the cross-track deviation between 2 arbitrary waypoints in nm. // Calculate the cross-track deviation between 2 arbitrary waypoints in nm.
// Returns zero if a sensible value cannot be calculated. // Returns zero if a sensible value cannot be calculated.
double CalcCrossTrackDeviation(const GPSWaypoint& wp1, const GPSWaypoint& wp2) const; double CalcCrossTrackDeviation(const GPSWaypoint& wp1, const GPSWaypoint& wp2) const;
// Flightplans // Flightplans
// GPS can have up to _maxFlightPlans flightplans stored, PLUS an active FP which may or my not be one of the stored ones. // GPS can have up to _maxFlightPlans flightplans stored, PLUS an active FP which may or my not be one of the stored ones.
// This is from KLN89, but is probably not far off the mark for most if not all GPS. // This is from KLN89, but is probably not far off the mark for most if not all GPS.
std::vector<GPSFlightPlan*> _flightPlans; std::vector<GPSFlightPlan*> _flightPlans;
unsigned int _maxFlightPlans; unsigned int _maxFlightPlans;
GPSFlightPlan* _activeFP; GPSFlightPlan* _activeFP;
// Modes of operation. // Modes of operation.
// This is currently somewhat Bendix-King specific, but probably applies fundamentally to other units as well // This is currently somewhat Bendix-King specific, but probably applies fundamentally to other units as well
// Mode defaults to leg, but is OBS if _obsMode is true. // Mode defaults to leg, but is OBS if _obsMode is true.
bool _obsMode; bool _obsMode;
// _dto is set true for DTO operation // _dto is set true for DTO operation
bool _dto; bool _dto;
// In leg mode, we need to know if we are displaying a from and to waypoint, or just the to waypoint (eg. when OBS mode is cancelled). // In leg mode, we need to know if we are displaying a from and to waypoint, or just the to waypoint (eg. when OBS mode is cancelled).
bool _fullLegMode; bool _fullLegMode;
// In OBS mode we need to know the set OBS heading // In OBS mode we need to know the set OBS heading
int _obsHeading; int _obsHeading;
// Operational variables // Operational variables
GPSWaypoint _activeWaypoint; GPSWaypoint _activeWaypoint;
GPSWaypoint _fromWaypoint; GPSWaypoint _fromWaypoint;
float _dist2Act; float _dist2Act;
float _crosstrackDist; // UNITS ?????????? float _crosstrackDist; // UNITS ??????????
double _eta; // ETA in SECONDS to active waypoint. double _eta; // ETA in SECONDS to active waypoint.
// Desired track for active leg, true and magnetic, in degrees // Desired track for active leg, true and magnetic, in degrees
double _dtkTrue, _dtkMag; double _dtkTrue, _dtkMag;
bool _headingBugTo; // Set true when the heading bug is TO, false when FROM. bool _headingBugTo; // Set true when the heading bug is TO, false when FROM.
bool _waypointAlert; // Set true when waypoint alerting is happening. (This is a variable NOT a user-setting). bool _waypointAlert; // Set true when waypoint alerting is happening. (This is a variable NOT a user-setting).
bool _departed; // Set when groundspeed first exceeds 30kts. bool _departed; // Set when groundspeed first exceeds 30kts.
std::string _departureTimeString; // Ditto. std::string _departureTimeString; // Ditto.
double _elapsedTime; // Elapsed time in seconds since departure double _elapsedTime; // Elapsed time in seconds since departure
ClockTime _powerOnTime; // Time (hr:min) of unit power-up. ClockTime _powerOnTime; // Time (hr:min) of unit power-up.
bool _powerOnTimerSet; // Indicates that we have set the above following power-up. bool _powerOnTimerSet; // Indicates that we have set the above following power-up.
void SetPowerOnTimer(); void SetPowerOnTimer();
public: public:
void ResetPowerOnTimer(); void ResetPowerOnTimer();
// Set the alarm to go off at a given time. // Set the alarm to go off at a given time.
inline void SetAlarm(int hr, int min) { inline void SetAlarm(int hr, int min) {
_alarmTime.set_hr(hr); _alarmTime.set_hr(hr);
_alarmTime.set_min(min); _alarmTime.set_min(min);
_alarmSet = true; _alarmSet = true;
} }
protected: protected:
ClockTime _alarmTime; ClockTime _alarmTime;
bool _alarmSet; bool _alarmSet;
// Configuration that affects flightplan operation
bool _turnAnticipationEnabled;
std::list<std::string> _messageStack; // Configuration that affects flightplan operation
bool _turnAnticipationEnabled;
std::list<std::string> _messageStack;
virtual void CreateFlightPlan(GPSFlightPlan* fp, std::vector<std::string> ids, std::vector<GPSWpType> wps);
// Orientate the GPS unit to a flightplan - ie. figure out from current position
// and possibly orientation which leg of the FP we are on.
virtual void OrientateToFlightPlan(GPSFlightPlan* fp);
// Ditto for active fp. Probably all we need really!
virtual void OrientateToActiveFlightPlan();
int _cleanUpPage; // -1 => no cleanup required.
// IAP stuff
iap_map_type _np_iap; // Non-precision approaches
iap_map_type _pr_iap; // Precision approaches
bool _approachLoaded; // Set true when an approach is loaded in the active flightplan
bool _approachArm; // Set true when in approach-arm mode
bool _approachReallyArmed; // Apparently, approach-arm mode can be set from an external GPS-APR switch outside 30nm from airport,
// but the CDI scale change doesn't happen until 30nm from airport. Bizarre that it can be armed without
// the scale change, but it's in the manual...
bool _approachActive; // Set true when in approach-active mode
GPSFlightPlan* _approachFP; // Current approach - not necessarily loaded.
std::string _approachID; // ID of the airport we have an approach loaded for - bit of a hack that can hopefully be removed in future.
// More hackery since we aren't actually storing an approach class... Doh!
std::string _approachAbbrev;
std::string _approachRwyStr;
virtual void CreateFlightPlan(GPSFlightPlan* fp, std::vector<std::string> ids, std::vector<GPSWpType> wps);
// Orientate the GPS unit to a flightplan - ie. figure out from current position
// and possibly orientation which leg of the FP we are on.
virtual void OrientateToFlightPlan(GPSFlightPlan* fp);
// Ditto for active fp. Probably all we need really!
virtual void OrientateToActiveFlightPlan();
int _cleanUpPage; // -1 => no cleanup required.
// IAP stuff
iap_map_type _np_iap; // Non-precision approaches
iap_map_type _pr_iap; // Precision approaches
bool _approachLoaded; // Set true when an approach is loaded in the active flightplan
bool _approachArm; // Set true when in approach-arm mode
bool _approachReallyArmed; // Apparently, approach-arm mode can be set from an external GPS-APR switch outside 30nm from airport,
// but the CDI scale change doesn't happen until 30nm from airport. Bizarre that it can be armed without
// the scale change, but it's in the manual...
bool _approachActive; // Set true when in approach-active mode
GPSFlightPlan* _approachFP; // Current approach - not necessarily loaded.
std::string _approachID; // ID of the airport we have an approach loaded for - bit of a hack that can hopefully be removed in future.
// More hackery since we aren't actually storing an approach class... Doh!
std::string _approachAbbrev;
std::string _approachRwyStr;
private: private:
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
}; };
#endif // _DCLGPS_HXX #endif // _DCLGPS_HXX

View file

@ -34,9 +34,7 @@ class FGNavRecord;
*/ */
class DME : public AbstractInstrument class DME : public AbstractInstrument
{ {
public: public:
DME ( SGPropertyNode *node ); DME ( SGPropertyNode *node );
virtual ~DME (); virtual ~DME ();
@ -70,5 +68,4 @@ private:
class AudioIdent * _audioIdent; class AudioIdent * _audioIdent;
}; };
#endif // __INSTRUMENTS_DME_HXX #endif // __INSTRUMENTS_DME_HXX

View file

@ -31,7 +31,7 @@
* /environment/magnetic-variation-deg * /environment/magnetic-variation-deg
* /systems/electrical/outputs/gps * /systems/electrical/outputs/gps
* /instrumentation/gps/serviceable * /instrumentation/gps/serviceable
* *
* *
* Output properties: * Output properties:
* *
@ -64,7 +64,7 @@ public:
GPS (); GPS ();
virtual ~GPS (); virtual ~GPS ();
// SGSubsystem interface // SGSubsystem interface
virtual void init (); virtual void init ();
virtual void reinit (); virtual void reinit ();
virtual void update (double delta_time_sec); virtual void update (double delta_time_sec);
@ -72,7 +72,7 @@ public:
virtual void bind(); virtual void bind();
virtual void unbind(); virtual void unbind();
// RNAV interface // RNAV interface
virtual SGGeod position(); virtual SGGeod position();
virtual double trackDeg(); virtual double trackDeg();
virtual double groundSpeedKts(); virtual double groundSpeedKts();
@ -93,51 +93,51 @@ private:
class Config class Config
{ {
public: public:
Config(); Config();
void bind(GPS* aOwner, SGPropertyNode* aCfg); void bind(GPS* aOwner, SGPropertyNode* aCfg);
bool turnAnticipationEnabled() const { return _enableTurnAnticipation; } bool turnAnticipationEnabled() const { return _enableTurnAnticipation; }
/** /**
* Desired turn rate in degrees/second. From this we derive the turn * Desired turn rate in degrees/second. From this we derive the turn
* radius and hence how early we need to anticipate it. * radius and hence how early we need to anticipate it.
*/ */
double turnRateDegSec() const { return _turnRate; } double turnRateDegSec() const { return _turnRate; }
/** /**
* Distance at which we switch to next waypoint. * Distance at which we switch to next waypoint.
*/ */
double overflightDistanceNm() const { return _overflightDistance; } double overflightDistanceNm() const { return _overflightDistance; }
/** /**
* Distance at which we arm overflight sequencing. Once inside this * Distance at which we arm overflight sequencing. Once inside this
* distance, a change of the wp1 'TO' flag to false will be considered * distance, a change of the wp1 'TO' flag to false will be considered
* overlight of the wp. * overlight of the wp.
*/ */
double overflightArmDistanceNm() const { return _overflightArmDistance; } double overflightArmDistanceNm() const { return _overflightArmDistance; }
/** /**
* abs angle at which we arm overflight sequencing. * abs angle at which we arm overflight sequencing.
*/ */
double overflightArmAngleDeg() const { return _overflightArmAngle; } double overflightArmAngleDeg() const { return _overflightArmAngle; }
/** /**
* Time before the next WP to activate an external annunciator * Time before the next WP to activate an external annunciator
*/ */
double waypointAlertTime() const { return _waypointAlertTime; } double waypointAlertTime() const { return _waypointAlertTime; }
bool requireHardSurface() const { return _requireHardSurface; } bool requireHardSurface() const { return _requireHardSurface; }
bool cdiDeflectionIsAngular() const { return (_cdiMaxDeflectionNm <= 0.0); } bool cdiDeflectionIsAngular() const { return (_cdiMaxDeflectionNm <= 0.0); }
double cdiDeflectionLinearPeg() const double cdiDeflectionLinearPeg() const
{ {
assert(_cdiMaxDeflectionNm > 0.0); assert(_cdiMaxDeflectionNm > 0.0);
return _cdiMaxDeflectionNm; return _cdiMaxDeflectionNm;
} }
bool driveAutopilot() const { return _driveAutopilot; } bool driveAutopilot() const { return _driveAutopilot; }
bool courseSelectable() const { return _courseSelectable; } bool courseSelectable() const { return _courseSelectable; }
/** /**
* Select whether we fly the leg track between waypoints, or * Select whether we fly the leg track between waypoints, or
@ -149,34 +149,34 @@ private:
bool followLegTrackToFix() const { return _followLegTrackToFix; } bool followLegTrackToFix() const { return _followLegTrackToFix; }
private: private:
bool _enableTurnAnticipation; bool _enableTurnAnticipation;
// desired turn rate in degrees per second // desired turn rate in degrees per second
double _turnRate; double _turnRate;
// distance from waypoint to arm overflight sequencing (in nm) // distance from waypoint to arm overflight sequencing (in nm)
double _overflightDistance; double _overflightDistance;
// distance from waypoint to arm overflight sequencing (in nm) // distance from waypoint to arm overflight sequencing (in nm)
double _overflightArmDistance; double _overflightArmDistance;
//abs angle from course to waypoint to arm overflight sequencing (in deg) //abs angle from course to waypoint to arm overflight sequencing (in deg)
double _overflightArmAngle; double _overflightArmAngle;
// time before reaching a waypoint to trigger annunciator light/sound // time before reaching a waypoint to trigger annunciator light/sound
// (in seconds) // (in seconds)
double _waypointAlertTime; double _waypointAlertTime;
// should we require a hard-surfaced runway when filtering? // should we require a hard-surfaced runway when filtering?
bool _requireHardSurface; bool _requireHardSurface;
double _cdiMaxDeflectionNm; double _cdiMaxDeflectionNm;
// should we drive the autopilot directly or not? // should we drive the autopilot directly or not?
bool _driveAutopilot; bool _driveAutopilot;
// is selected-course-deg read to set desired-course or not? // is selected-course-deg read to set desired-course or not?
bool _courseSelectable; bool _courseSelectable;
// do we fly direct to fixes, or follow the leg track closely? // do we fly direct to fixes, or follow the leg track closely?
bool _followLegTrackToFix; bool _followLegTrackToFix;
@ -185,10 +185,10 @@ private:
class SearchFilter : public FGPositioned::Filter class SearchFilter : public FGPositioned::Filter
{ {
public: public:
virtual bool pass(FGPositioned* aPos) const; virtual bool pass(FGPositioned* aPos) const;
virtual FGPositioned::Type minType() const; virtual FGPositioned::Type minType() const;
virtual FGPositioned::Type maxType() const; virtual FGPositioned::Type maxType() const;
}; };
/** reset all output properties to default / non-service values */ /** reset all output properties to default / non-service values */
@ -219,20 +219,20 @@ private:
* valid or not. */ * valid or not. */
bool isScratchPositionValid() const; bool isScratchPositionValid() const;
FGPositionedRef positionedFromScratch() const; FGPositionedRef positionedFromScratch() const;
#if FG_210_COMPAT #if FG_210_COMPAT
void setScratchFromPositioned(FGPositioned* aPos, int aIndex); void setScratchFromPositioned(FGPositioned* aPos, int aIndex);
void setScratchFromCachedSearchResult(); void setScratchFromCachedSearchResult();
void setScratchFromRouteWaypoint(int aIndex); void setScratchFromRouteWaypoint(int aIndex);
/** Add airport-specific information to a scratch result */ /** Add airport-specific information to a scratch result */
void addAirportToScratch(FGAirport* aAirport); void addAirportToScratch(FGAirport* aAirport);
FGPositioned::Filter* createFilter(FGPositioned::Type aTy); FGPositioned::Filter* createFilter(FGPositioned::Type aTy);
/** Search kernel - called each time we step through a result */ /** Search kernel - called each time we step through a result */
void performSearch(); void performSearch();
// command handlers // command handlers
void loadRouteWaypoint(); void loadRouteWaypoint();
void loadNearest(); void loadNearest();
@ -242,7 +242,7 @@ private:
void defineWaypoint(); void defineWaypoint();
void insertWaypointAtIndex(int aIndex); void insertWaypointAtIndex(int aIndex);
void removeWaypointAtIndex(int aIndex); void removeWaypointAtIndex(int aIndex);
// tied-property getter/setters // tied-property getter/setters
double getScratchDistance() const; double getScratchDistance() const;
double getScratchMagBearing() const; double getScratchMagBearing() const;
@ -250,13 +250,13 @@ private:
bool getScratchHasNext() const; bool getScratchHasNext() const;
#endif #endif
// command handlers // command handlers
void selectLegMode(); void selectLegMode();
void selectOBSMode(flightgear::Waypt* waypt); void selectOBSMode(flightgear::Waypt* waypt);
void directTo(); void directTo();
// tied-property getter/setters // tied-property getter/setters
void setCommand(const char* aCmd); void setCommand(const char* aCmd);
const char* getCommand() const { return ""; } const char* getCommand() const { return ""; }
@ -310,22 +310,22 @@ private:
/** helper, tie the lat/lon/elev of a SGGeod to the named children of aNode */ /** helper, tie the lat/lon/elev of a SGGeod to the named children of aNode */
void tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef, void tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef,
const char* lonStr, const char* latStr, const char* altStr); const char* lonStr, const char* latStr, const char* altStr);
/** helper, tie a SGGeod to proeprties, but read-only */ /** helper, tie a SGGeod to proeprties, but read-only */
void tieSGGeodReadOnly(SGPropertyNode* aNode, SGGeod& aRef, void tieSGGeodReadOnly(SGPropertyNode* aNode, SGGeod& aRef,
const char* lonStr, const char* latStr, const char* altStr); const char* lonStr, const char* latStr, const char* altStr);
// FlightPlan::Delegate // FlightPlan::Delegate
virtual void currentWaypointChanged(); virtual void currentWaypointChanged();
virtual void waypointsChanged(); virtual void waypointsChanged();
virtual void cleared(); virtual void cleared();
virtual void endOfFlightPlan(); virtual void endOfFlightPlan();
void sequence(); void sequence();
void routeManagerFlightPlanChanged(SGPropertyNode*); void routeManagerFlightPlanChanged(SGPropertyNode*);
void routeActivated(SGPropertyNode*); void routeActivated(SGPropertyNode*);
// members // members
SGPropertyNode_ptr _gpsNode; SGPropertyNode_ptr _gpsNode;
SGPropertyNode_ptr _currentWayptNode; SGPropertyNode_ptr _currentWayptNode;
SGPropertyNode_ptr _magvar_node; SGPropertyNode_ptr _magvar_node;
@ -340,13 +340,13 @@ private:
SGPropertyNode_ptr _magnetic_bug_error_node; SGPropertyNode_ptr _magnetic_bug_error_node;
SGPropertyNode_ptr _eastWestVelocity; SGPropertyNode_ptr _eastWestVelocity;
SGPropertyNode_ptr _northSouthVelocity; SGPropertyNode_ptr _northSouthVelocity;
// SGPropertyNode_ptr _route_active_node; // SGPropertyNode_ptr _route_active_node;
SGPropertyNode_ptr _route_current_wp_node; SGPropertyNode_ptr _route_current_wp_node;
SGPropertyNode_ptr _routeDistanceNm; SGPropertyNode_ptr _routeDistanceNm;
SGPropertyNode_ptr _routeETE; SGPropertyNode_ptr _routeETE;
SGPropertyNode_ptr _desiredCourseNode; SGPropertyNode_ptr _desiredCourseNode;
double _selectedCourse; double _selectedCourse;
double _desiredCourse; double _desiredCourse;
@ -367,7 +367,7 @@ private:
* and not to worry about electrical power or similar. * and not to worry about electrical power or similar.
*/ */
bool _defaultGPSMode; bool _defaultGPSMode;
std::string _mode; std::string _mode;
Config _config; Config _config;
std::string _name; std::string _name;
@ -377,12 +377,12 @@ private:
SGGeod _indicated_pos; SGGeod _indicated_pos;
double _legDistanceNm; double _legDistanceNm;
// scratch data // scratch data
SGGeod _scratchPos; SGGeod _scratchPos;
SGPropertyNode_ptr _scratchNode; SGPropertyNode_ptr _scratchNode;
bool _scratchValid; bool _scratchValid;
#if FG_210_COMPAT #if FG_210_COMPAT
// search data // search data
int _searchResultIndex; int _searchResultIndex;
std::string _searchQuery; std::string _searchQuery;
FGPositioned::Type _searchType; FGPositioned::Type _searchType;
@ -392,8 +392,8 @@ private:
bool _searchHasNext; ///< is there a result after this one? bool _searchHasNext; ///< is there a result after this one?
bool _searchNames; ///< set if we're searching names instead of idents bool _searchNames; ///< set if we're searching names instead of idents
#endif #endif
// turn data // turn data
bool _computeTurnData; ///< do we need to update the turn data? bool _computeTurnData; ///< do we need to update the turn data?
bool _anticipateTurn; ///< are we anticipating the next turn or not? bool _anticipateTurn; ///< are we anticipating the next turn or not?
bool _inTurn; // is a turn in progress? bool _inTurn; // is a turn in progress?
@ -409,14 +409,14 @@ private:
flightgear::WayptRef _prevWaypt; flightgear::WayptRef _prevWaypt;
flightgear::WayptRef _currentWaypt; flightgear::WayptRef _currentWaypt;
// autopilot drive properties // autopilot drive properties
SGPropertyNode_ptr _apDrivingFlag; SGPropertyNode_ptr _apDrivingFlag;
SGPropertyNode_ptr _apTrueHeading; SGPropertyNode_ptr _apTrueHeading;
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
flightgear::FlightPlanRef _route; flightgear::FlightPlanRef _route;
SGPropertyChangeCallback<GPS> _callbackFlightPlanChanged; SGPropertyChangeCallback<GPS> _callbackFlightPlanChanged;
SGPropertyChangeCallback<GPS> _callbackRouteActivated; SGPropertyChangeCallback<GPS> _callbackRouteActivated;
}; };

View file

@ -44,26 +44,26 @@
class GSDI : public SGSubsystem class GSDI : public SGSubsystem
{ {
public: public:
GSDI(SGPropertyNode *node); GSDI(SGPropertyNode *node);
virtual ~GSDI(); virtual ~GSDI();
virtual void init(); virtual void init();
virtual void update(double dt); virtual void update(double dt);
private: private:
std::string _name; std::string _name;
unsigned int _num; unsigned int _num;
SGPropertyNode_ptr _serviceableN; SGPropertyNode_ptr _serviceableN;
SGPropertyNode_ptr _headingN; SGPropertyNode_ptr _headingN;
SGPropertyNode_ptr _ubodyN; SGPropertyNode_ptr _ubodyN;
SGPropertyNode_ptr _vbodyN; SGPropertyNode_ptr _vbodyN;
SGPropertyNode_ptr _wind_speedN; SGPropertyNode_ptr _wind_speedN;
SGPropertyNode_ptr _wind_dirN; SGPropertyNode_ptr _wind_dirN;
SGPropertyNode_ptr _drift_uN; SGPropertyNode_ptr _drift_uN;
SGPropertyNode_ptr _drift_vN; SGPropertyNode_ptr _drift_vN;
SGPropertyNode_ptr _drift_speedN; SGPropertyNode_ptr _drift_speedN;
SGPropertyNode_ptr _drift_angleN; SGPropertyNode_ptr _drift_angleN;
}; };
#endif // _INSTRUMENTS_GSDI_HXX #endif // _INSTRUMENTS_GSDI_HXX

View file

@ -34,9 +34,7 @@
*/ */
class HeadingIndicator : public SGSubsystem class HeadingIndicator : public SGSubsystem
{ {
public: public:
HeadingIndicator ( SGPropertyNode *node ); HeadingIndicator ( SGPropertyNode *node );
HeadingIndicator (); HeadingIndicator ();
virtual ~HeadingIndicator (); virtual ~HeadingIndicator ();
@ -48,7 +46,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
Gyro _gyro; Gyro _gyro;
double _last_heading_deg; double _last_heading_deg;
@ -62,7 +59,6 @@ private:
SGPropertyNode_ptr _heading_out_node; SGPropertyNode_ptr _heading_out_node;
SGPropertyNode_ptr _heading_bug_error_node; SGPropertyNode_ptr _heading_bug_error_node;
SGPropertyNode_ptr _heading_bug_node; SGPropertyNode_ptr _heading_bug_node;
}; };
#endif // __INSTRUMENTS_HEADING_INDICATOR_HXX #endif // __INSTRUMENTS_HEADING_INDICATOR_HXX

View file

@ -32,9 +32,7 @@
*/ */
class HeadingIndicatorDG : public SGSubsystem class HeadingIndicatorDG : public SGSubsystem
{ {
public: public:
HeadingIndicatorDG ( SGPropertyNode *node ); HeadingIndicatorDG ( SGPropertyNode *node );
HeadingIndicatorDG (); HeadingIndicatorDG ();
virtual ~HeadingIndicatorDG (); virtual ~HeadingIndicatorDG ();
@ -46,7 +44,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
Gyro _gyro; Gyro _gyro;
double _last_heading_deg, _last_indicated_heading_dg; double _last_heading_deg, _last_indicated_heading_dg;

View file

@ -34,9 +34,7 @@
*/ */
class HeadingIndicatorFG : public SGSubsystem class HeadingIndicatorFG : public SGSubsystem
{ {
public: public:
HeadingIndicatorFG ( SGPropertyNode *node ); HeadingIndicatorFG ( SGPropertyNode *node );
HeadingIndicatorFG (); HeadingIndicatorFG ();
virtual ~HeadingIndicatorFG (); virtual ~HeadingIndicatorFG ();
@ -48,24 +46,20 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
Gyro _gyro; Gyro _gyro;
double _last_heading_deg; double _last_heading_deg;
std::string name; std::string name;
int num; int num;
SGPropertyNode_ptr _offset_node; SGPropertyNode_ptr _offset_node;
SGPropertyNode_ptr _heading_in_node; SGPropertyNode_ptr _heading_in_node;
SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _heading_out_node; SGPropertyNode_ptr _heading_out_node;
SGPropertyNode_ptr _electrical_node; SGPropertyNode_ptr _electrical_node;
SGPropertyNode_ptr _error_node; SGPropertyNode_ptr _error_node;
SGPropertyNode_ptr _nav1_error_node; SGPropertyNode_ptr _nav1_error_node;
SGPropertyNode_ptr _off_node; SGPropertyNode_ptr _off_node;
}; };
#endif // __INSTRUMENTS_HEADING_INDICATOR_HXX #endif // __INSTRUMENTS_HEADING_INDICATOR_HXX

View file

@ -50,9 +50,7 @@ class SGInterpTable;
*/ */
class InstVerticalSpeedIndicator : public SGSubsystem class InstVerticalSpeedIndicator : public SGSubsystem
{ {
public: public:
InstVerticalSpeedIndicator ( SGPropertyNode *node ); InstVerticalSpeedIndicator ( SGPropertyNode *node );
virtual ~InstVerticalSpeedIndicator (); virtual ~InstVerticalSpeedIndicator ();
@ -61,7 +59,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
std::string _name; std::string _name;
int _num; int _num;

View file

@ -28,18 +28,17 @@
class FGInstrumentMgr : public SGSubsystemGroup class FGInstrumentMgr : public SGSubsystemGroup
{ {
public: public:
FGInstrumentMgr (); FGInstrumentMgr ();
virtual ~FGInstrumentMgr (); virtual ~FGInstrumentMgr ();
virtual void init(); virtual void init();
virtual InitStatus incrementalInit(); virtual InitStatus incrementalInit();
private: private:
bool build (SGPropertyNode* config_props); bool build (SGPropertyNode* config_props);
bool _explicitGps; bool _explicitGps;
std::vector<std::string> _instruments; std::vector<std::string> _instruments;
}; };

View file

@ -140,17 +140,17 @@ public:
inline void set_rotation( double rot ) { rotation = rot; } inline void set_rotation( double rot ) { rotation = rot; }
inline bool get_power_btn() const { return power_btn; } inline bool get_power_btn() const { return power_btn; }
inline void set_power_btn( bool val ) { inline void set_power_btn( bool val ) {
power_btn = val; power_btn = val;
} }
inline bool get_audio_btn() const { return audio_btn; } inline bool get_audio_btn() const { return audio_btn; }
inline void set_audio_btn( bool val ) { inline void set_audio_btn( bool val ) {
audio_btn = val; audio_btn = val;
} }
inline double get_vol_btn() const { return vol_btn; } inline double get_vol_btn() const { return vol_btn; }
inline void set_vol_btn( double val ) { inline void set_vol_btn( double val ) {
if ( val < 0.0 ) val = 0.0; if ( val < 0.0 ) val = 0.0;
if ( val > 1.0 ) val = 1.0; if ( val > 1.0 ) val = 1.0;
vol_btn = val; vol_btn = val;
} }
inline bool get_adf_btn() const { return adf_btn; } inline bool get_adf_btn() const { return adf_btn; }
inline void set_adf_btn( bool val ) { adf_btn = val; } inline void set_adf_btn( bool val ) { adf_btn = val; }
@ -166,7 +166,7 @@ public:
// outputs // outputs
inline int get_freq () const { return freq; } inline int get_freq () const { return freq; }
inline void set_freq( int f ) { inline void set_freq( int f ) {
freq = f; freq = f;
need_update = true; need_update = true;
} }
int get_stby_freq () const; int get_stby_freq () const;
@ -185,5 +185,4 @@ public:
inline bool get_et_ann() const { return et_ann; } inline bool get_et_ann() const { return et_ann; }
}; };
#endif // _FG_KR_87_HXX #endif // _FG_KR_87_HXX

View file

@ -40,9 +40,7 @@
*/ */
class MagCompass : public SGSubsystem class MagCompass : public SGSubsystem
{ {
public: public:
MagCompass ( SGPropertyNode *node); MagCompass ( SGPropertyNode *node);
MagCompass (); MagCompass ();
virtual ~MagCompass (); virtual ~MagCompass ();
@ -52,7 +50,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
double _rate_degps; double _rate_degps;
std::string _name; std::string _name;
@ -71,7 +68,6 @@ private:
SGPropertyNode_ptr _y_accel_node; SGPropertyNode_ptr _y_accel_node;
SGPropertyNode_ptr _z_accel_node; SGPropertyNode_ptr _z_accel_node;
SGPropertyNode_ptr _out_node; SGPropertyNode_ptr _out_node;
}; };
#endif // __INSTRUMENTS_MAG_COMPASS_HXX #endif // __INSTRUMENTS_MAG_COMPASS_HXX

View file

@ -33,7 +33,6 @@ class SGSampleGroup;
class FGMarkerBeacon : public AbstractInstrument class FGMarkerBeacon : public AbstractInstrument
{ {
// Inputs // Inputs
SGPropertyNode_ptr lon_node; SGPropertyNode_ptr lon_node;
SGPropertyNode_ptr lat_node; SGPropertyNode_ptr lat_node;
@ -57,7 +56,6 @@ class FGMarkerBeacon : public AbstractInstrument
SGSharedPtr<SGSampleGroup> _sgr; SGSharedPtr<SGSampleGroup> _sgr;
public: public:
enum fgMkrBeacType { enum fgMkrBeacType {
NOBEACON = 0, NOBEACON = 0,
INNER, INNER,

View file

@ -1255,7 +1255,7 @@ class MK_VIII : public SGSubsystem
void get_altitude_above_field (Parameter<double> *parameter); void get_altitude_above_field (Parameter<double> *parameter);
void update_above_field_callout (); void update_above_field_callout ();
bool is_bank_angle (double abs_roll_angle, double bias); bool is_bank_angle (double abs_roll_angle, double bias);
bool is_high_bank_angle (); bool is_high_bank_angle ();
unsigned int get_bank_angle_alerts (); unsigned int get_bank_angle_alerts ();

View file

@ -35,9 +35,7 @@
class MasterReferenceGyro : public SGSubsystem class MasterReferenceGyro : public SGSubsystem
{ {
public: public:
MasterReferenceGyro ( SGPropertyNode *node ); MasterReferenceGyro ( SGPropertyNode *node );
MasterReferenceGyro (); MasterReferenceGyro ();
virtual ~MasterReferenceGyro (); virtual ~MasterReferenceGyro ();
@ -49,7 +47,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
static const double gravity; //conversion factor static const double gravity; //conversion factor
std::string _name; std::string _name;

View file

@ -34,7 +34,8 @@
class SGSampleGroup; class SGSampleGroup;
class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener class FGNavRadio : public AbstractInstrument,
public SGPropertyChangeListener
{ {
SGPropertyNode_ptr _radio_node; SGPropertyNode_ptr _radio_node;
@ -53,7 +54,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
SGPropertyNode_ptr cdi_serviceable_node; SGPropertyNode_ptr cdi_serviceable_node;
SGPropertyNode_ptr gs_serviceable_node; SGPropertyNode_ptr gs_serviceable_node;
SGPropertyNode_ptr tofrom_serviceable_node; SGPropertyNode_ptr tofrom_serviceable_node;
// property outputs // property outputs
SGPropertyNode_ptr fmt_freq_node; // formated frequency SGPropertyNode_ptr fmt_freq_node; // formated frequency
SGPropertyNode_ptr fmt_alt_freq_node; // formated alternate frequency SGPropertyNode_ptr fmt_alt_freq_node; // formated alternate frequency
@ -106,7 +107,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
SGPropertyNode_ptr gps_course_node; SGPropertyNode_ptr gps_course_node;
SGPropertyNode_ptr gps_xtrack_error_nm_node; SGPropertyNode_ptr gps_xtrack_error_nm_node;
SGPropertyNode_ptr _magvarNode; SGPropertyNode_ptr _magvarNode;
// realism setting, are false courses and GS lobes enabled? // realism setting, are false courses and GS lobes enabled?
SGPropertyNode_ptr falseCoursesEnabledNode; SGPropertyNode_ptr falseCoursesEnabledNode;
@ -117,7 +118,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
double _last_freq; double _last_freq;
FGNavRecordRef _navaid; FGNavRecordRef _navaid;
FGNavRecordRef _gs; FGNavRecordRef _gs;
double target_radial; double target_radial;
double effective_range; double effective_range;
double target_gs; double target_gs;
@ -142,16 +143,16 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
double _gsDirect; double _gsDirect;
class AudioIdent * _audioIdent; class AudioIdent * _audioIdent;
bool updateWithPower(double aDt); bool updateWithPower(double aDt);
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8 // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
double adjustNavRange( double stationElev, double aircraftElev, double adjustNavRange( double stationElev, double aircraftElev,
double nominalRange ); double nominalRange );
// model standard ILS service volumes as per AIM 1-1-9 // model standard ILS service volumes as per AIM 1-1-9
double adjustILSRange( double stationElev, double aircraftElev, double adjustILSRange( double stationElev, double aircraftElev,
double offsetDegrees, double distance ); double offsetDegrees, double distance );
void updateAudio( double dt ); void updateAudio( double dt );
@ -160,16 +161,15 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
void updateGPSSlaved(); void updateGPSSlaved();
void updateCDI(double dt); void updateCDI(double dt);
void updateFormattedFrequencies(); void updateFormattedFrequencies();
void clearOutputs(); void clearOutputs();
FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz); FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz);
// implement SGPropertyChangeListener
virtual void valueChanged (SGPropertyNode * prop);
public:
// implement SGPropertyChangeListener
virtual void valueChanged (SGPropertyNode * prop);
public:
FGNavRadio(SGPropertyNode *node); FGNavRadio(SGPropertyNode *node);
~FGNavRadio(); ~FGNavRadio();
@ -182,5 +182,4 @@ public:
void updateNav(); void updateNav();
}; };
#endif // _FG_NAVRADIO_HXX #endif // _FG_NAVRADIO_HXX

View file

@ -802,48 +802,51 @@ void GS::display( NavIndicator & navIndicator )
/* ------------- The NavRadio implementation ---------------------- */ /* ------------- The NavRadio implementation ---------------------- */
class NavRadioImpl : public NavRadio { class NavRadioImpl : public NavRadio
{
public: public:
NavRadioImpl( SGPropertyNode_ptr node ); NavRadioImpl( SGPropertyNode_ptr node );
virtual ~NavRadioImpl(); virtual ~NavRadioImpl();
virtual void update( double dt );
virtual void init();
virtual void update( double dt );
virtual void init();
private: private:
void search(); void search();
class Legacy { class Legacy {
public: public:
Legacy( NavRadioImpl * navRadioImpl ) : _navRadioImpl( navRadioImpl ) {} Legacy( NavRadioImpl * navRadioImpl ) : _navRadioImpl( navRadioImpl ) {}
void init(); void init();
void update( double dt ); void update( double dt );
private:
NavRadioImpl * _navRadioImpl;
SGPropertyNode_ptr is_valid_node;
SGPropertyNode_ptr nav_serviceable_node;
SGPropertyNode_ptr nav_id_node;
SGPropertyNode_ptr id_c1_node;
SGPropertyNode_ptr id_c2_node;
SGPropertyNode_ptr id_c3_node;
SGPropertyNode_ptr id_c4_node;
} _legacy;
const static int VOR_COMPONENT = 0; private:
const static int LOC_COMPONENT = 1; NavRadioImpl * _navRadioImpl;
const static int GS_COMPONENT = 2; SGPropertyNode_ptr is_valid_node;
SGPropertyNode_ptr nav_serviceable_node;
SGPropertyNode_ptr nav_id_node;
SGPropertyNode_ptr id_c1_node;
SGPropertyNode_ptr id_c2_node;
SGPropertyNode_ptr id_c3_node;
SGPropertyNode_ptr id_c4_node;
} _legacy;
std::string _name; const static int VOR_COMPONENT = 0;
int _num; const static int LOC_COMPONENT = 1;
SGPropertyNode_ptr _rootNode; const static int GS_COMPONENT = 2;
FrequencyFormatter _useFrequencyFormatter;
FrequencyFormatter _stbyFrequencyFormatter; std::string _name;
std::vector<NavRadioComponent*> _components; int _num;
NavIndicator _navIndicator; SGPropertyNode_ptr _rootNode;
double _stationTTL; FrequencyFormatter _useFrequencyFormatter;
double _frequency; FrequencyFormatter _stbyFrequencyFormatter;
PropertyObject<bool> _cdiDisconnected; std::vector<NavRadioComponent*> _components;
PropertyObject<std::string> _navType; NavIndicator _navIndicator;
double _stationTTL;
double _frequency;
PropertyObject<bool> _cdiDisconnected;
PropertyObject<std::string> _navType;
}; };
NavRadioImpl::NavRadioImpl( SGPropertyNode_ptr node ) : NavRadioImpl::NavRadioImpl( SGPropertyNode_ptr node ) :

View file

@ -27,10 +27,11 @@
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
namespace Instrumentation { namespace Instrumentation {
class NavRadio : public SGSubsystem class NavRadio : public SGSubsystem
{ {
public: public:
static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode ); static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode );
}; };
} }

View file

@ -1,7 +1,7 @@
// Radar Altimeter // Radar Altimeter
// //
// Written by Vivian MEAZZA, started Feb 2008. // Written by Vivian MEAZZA, started Feb 2008.
// //
// //
// Copyright (C) 2008 Vivain MEAZZA - vivian.meazza@lineone.net // Copyright (C) 2008 Vivain MEAZZA - vivian.meazza@lineone.net
// //
@ -31,39 +31,35 @@
class RadarAltimeter : public SGSubsystem class RadarAltimeter : public SGSubsystem
{ {
public: public:
RadarAltimeter ( SGPropertyNode *node ); RadarAltimeter ( SGPropertyNode *node );
virtual ~RadarAltimeter (); virtual ~RadarAltimeter ();
private: private:
virtual void init (); virtual void init ();
virtual void update (double dt); virtual void update (double dt);
void update_altitude(); void update_altitude();
void updateSetHeight(); void updateSetHeight();
double getDistanceAntennaToHit(const SGVec3d& h) const; double getDistanceAntennaToHit(const SGVec3d& h) const;
SGVec3d getCartAntennaPos()const; SGVec3d getCartAntennaPos()const;
SGVec3d rayVector(double az, double el) const; SGVec3d rayVector(double az, double el) const;
SGPropertyNode_ptr _Instrument; SGPropertyNode_ptr _Instrument;
SGPropertyNode_ptr _user_alt_agl_node; SGPropertyNode_ptr _user_alt_agl_node;
SGPropertyNode_ptr _rad_alt_warning_node; SGPropertyNode_ptr _rad_alt_warning_node;
SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _serviceable_node;
SGPropertyNode_ptr _sceneryLoaded; SGPropertyNode_ptr _sceneryLoaded;
SGVec3d _antennaOffset; // in aircraft local XYZ frame SGVec3d _antennaOffset; // in aircraft local XYZ frame
std::string _name; std::string _name;
int _num; int _num;
double _time; double _time;
double _interval; double _interval;
double _min_radalt; double _min_radalt;
}; };
#endif // _INST_AGRADAR_HXX #endif // _INST_AGRADAR_HXX

View file

@ -30,9 +30,7 @@
*/ */
class SlipSkidBall : public SGSubsystem class SlipSkidBall : public SGSubsystem
{ {
public: public:
SlipSkidBall ( SGPropertyNode *node ); SlipSkidBall ( SGPropertyNode *node );
virtual ~SlipSkidBall (); virtual ~SlipSkidBall ();
@ -49,7 +47,6 @@ private:
SGPropertyNode_ptr _z_accel_node; SGPropertyNode_ptr _z_accel_node;
SGPropertyNode_ptr _out_node; SGPropertyNode_ptr _out_node;
SGPropertyNode_ptr _override_node; SGPropertyNode_ptr _override_node;
}; };
#endif // __INSTRUMENTS_SLIP_SKID_BALL_HXX #endif // __INSTRUMENTS_SLIP_SKID_BALL_HXX

View file

@ -31,11 +31,10 @@
* /instrumentation/"name"/indicated-ground-speed-kt * /instrumentation/"name"/indicated-ground-speed-kt
* /instrumentation/"name"/indicated-time-kt * /instrumentation/"name"/indicated-time-kt
*/ */
class TACAN : public SGSubsystem, public SGPropertyChangeListener class TACAN : public SGSubsystem,
public SGPropertyChangeListener
{ {
public:
public:
TACAN(SGPropertyNode *node); TACAN(SGPropertyNode *node);
virtual ~TACAN(); virtual ~TACAN();
@ -43,8 +42,7 @@ class TACAN : public SGSubsystem, public SGPropertyChangeListener
virtual void reinit (); virtual void reinit ();
virtual void update (double delta_time_sec); virtual void update (double delta_time_sec);
private: private:
void disabled(bool force = false); void disabled(bool force = false);
void search (double frequency, const SGGeod& pos); void search (double frequency, const SGGeod& pos);
@ -89,5 +87,4 @@ class TACAN : public SGSubsystem, public SGPropertyChangeListener
int _listener_active; int _listener_active;
}; };
#endif // __INSTRUMENTS_TACAN_HXX #endif // __INSTRUMENTS_TACAN_HXX

View file

@ -50,7 +50,6 @@ class SGSampleGroup;
class TCAS : public SGSubsystem class TCAS : public SGSubsystem
{ {
typedef enum typedef enum
{ {
AdvisoryClear = 0, /*< Clear of traffic */ AdvisoryClear = 0, /*< Clear of traffic */
@ -99,7 +98,7 @@ class TCAS : public SGSubsystem
typedef struct typedef struct
{ {
float Tau; /*< vertical/horizontal protection range in seconds */ float Tau; /*< vertical/horizontal protection range in seconds */
float DMOD; /*< horizontal protection range in nm */ float DMOD; /*< horizontal protection range in nm */
float ALIM; /*< vertical protection range in ft */ float ALIM; /*< vertical protection range in ft */
} Thresholds; } Thresholds;
@ -154,10 +153,10 @@ class TCAS : public SGSubsystem
class PropertiesHandler : public FGVoicePlayer::PropertiesHandler class PropertiesHandler : public FGVoicePlayer::PropertiesHandler
{ {
public: public:
PropertiesHandler (TCAS *) : PropertiesHandler (TCAS *) :
FGVoicePlayer::PropertiesHandler() {} FGVoicePlayer::PropertiesHandler() {}
PropertiesHandler (void) : FGVoicePlayer::PropertiesHandler() {} PropertiesHandler (void) : FGVoicePlayer::PropertiesHandler() {}
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -169,7 +168,7 @@ class TCAS : public SGSubsystem
{ {
public: public:
VoicePlayer (TCAS* tcas) : VoicePlayer (TCAS* tcas) :
FGVoicePlayer(&tcas->properties_handler, "tcas") {} FGVoicePlayer(&tcas->properties_handler, "tcas") {}
~VoicePlayer (void) {} ~VoicePlayer (void) {}
@ -177,22 +176,22 @@ class TCAS : public SGSubsystem
struct struct
{ {
Voice* pTrafficTraffic; Voice* pTrafficTraffic;
Voice* pClimb; Voice* pClimb;
Voice* pClimbNow; Voice* pClimbNow;
Voice* pClimbCrossing; Voice* pClimbCrossing;
Voice* pClimbIncrease; Voice* pClimbIncrease;
Voice* pDescend; Voice* pDescend;
Voice* pDescendNow; Voice* pDescendNow;
Voice* pDescendCrossing; Voice* pDescendCrossing;
Voice* pDescendIncrease; Voice* pDescendIncrease;
Voice* pClear; Voice* pClear;
Voice* pAdjustVSpeed; Voice* pAdjustVSpeed;
Voice* pMaintVSpeed; Voice* pMaintVSpeed;
Voice* pMonitorVSpeed; Voice* pMonitorVSpeed;
Voice* pLevelOff; Voice* pLevelOff;
Voice* pTestOk; Voice* pTestOk;
Voice* pTestFail; Voice* pTestFail;
} Voices; } Voices;
private: private:
SGPropertyNode_ptr nodeSoundFilePrefix; SGPropertyNode_ptr nodeSoundFilePrefix;
@ -275,7 +274,7 @@ class TCAS : public SGSubsystem
bool newTargets; bool newTargets;
TrackerTargets targets; TrackerTargets targets;
}; };
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// TCAS::AdvisoryGenerator ////////////////////////////////////////////////// // TCAS::AdvisoryGenerator //////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -342,7 +341,7 @@ class TCAS : public SGSubsystem
#ifdef FEATURE_TCAS_DEBUG_THREAT_DETECTOR #ifdef FEATURE_TCAS_DEBUG_THREAT_DETECTOR
int checkCount; int checkCount;
#endif // of FEATURE_TCAS_DEBUG_THREAT_DETECTOR #endif // of FEATURE_TCAS_DEBUG_THREAT_DETECTOR
SGPropertyNode_ptr nodeLat; SGPropertyNode_ptr nodeLat;
SGPropertyNode_ptr nodeLon; SGPropertyNode_ptr nodeLon;
SGPropertyNode_ptr nodePressureAlt; SGPropertyNode_ptr nodePressureAlt;

View file

@ -27,7 +27,8 @@
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/props/tiedpropertylist.hxx> #include <simgear/props/tiedpropertylist.hxx>
class Transponder : public AbstractInstrument, public SGPropertyChangeListener class Transponder : public AbstractInstrument,
public SGPropertyChangeListener
{ {
public: public:
Transponder(SGPropertyNode *node); Transponder(SGPropertyNode *node);
@ -37,20 +38,18 @@ public:
void update (double dt) override; void update (double dt) override;
void bind() override; void bind() override;
void unbind() override; void unbind() override;
protected: protected:
bool isPowerSwitchOn() const override; bool isPowerSwitchOn() const override;
private: private:
enum Mode enum Mode {
{
MODE_A = 0, MODE_A = 0,
MODE_C, MODE_C,
MODE_S MODE_S
}; };
enum KnobPosition enum KnobPosition {
{
KNOB_OFF = 0, KNOB_OFF = 0,
KNOB_STANDBY, KNOB_STANDBY,
KNOB_TEST, KNOB_TEST,
@ -58,7 +57,7 @@ private:
KNOB_ON, KNOB_ON,
KNOB_ALT KNOB_ALT
}; };
// annunciators, for KT-70 compatibility only // annunciators, for KT-70 compatibility only
// these should be replaced with conditionals in the instrument // these should be replaced with conditionals in the instrument
bool getFLAnnunciator() const; bool getFLAnnunciator() const;
@ -67,7 +66,7 @@ private:
bool getOnAnnunciator() const; bool getOnAnnunciator() const;
bool getStandbyAnnunciator() const; bool getStandbyAnnunciator() const;
bool getReplyAnnunciator() const; bool getReplyAnnunciator() const;
// Inputs // Inputs
SGPropertyNode_ptr _pressureAltitude_node; SGPropertyNode_ptr _pressureAltitude_node;
SGPropertyNode_ptr _autoGround_node; SGPropertyNode_ptr _autoGround_node;
@ -77,13 +76,13 @@ private:
SGPropertyNode_ptr _knob_node; SGPropertyNode_ptr _knob_node;
SGPropertyNode_ptr _idCode_node; SGPropertyNode_ptr _idCode_node;
SGPropertyNode_ptr _digit_node[4]; SGPropertyNode_ptr _digit_node[4];
simgear::TiedPropertyList _tiedProperties; simgear::TiedPropertyList _tiedProperties;
SGPropertyNode_ptr _identBtn_node; SGPropertyNode_ptr _identBtn_node;
bool _identMode = false; bool _identMode = false;
bool _kt70Compat; bool _kt70Compat;
// Outputs // Outputs
SGPropertyNode_ptr _altitude_node; SGPropertyNode_ptr _altitude_node;
SGPropertyNode_ptr _altitudeValid_node; SGPropertyNode_ptr _altitudeValid_node;
@ -101,9 +100,9 @@ private:
std::string _altitudeSourcePath; std::string _altitudeSourcePath;
std::string _autoGroundPath; std::string _autoGroundPath;
std::string _airspeedSourcePath; std::string _airspeedSourcePath;
void valueChanged (SGPropertyNode *) override; void valueChanged (SGPropertyNode *) override;
int setMinMax(int val); int setMinMax(int val);
}; };

View file

@ -20,7 +20,7 @@
/** /**
* Model an electric-powered turn indicator. * Model an electric-powered turn indicator.
* *
* This class does not model the slip/skid ball; that is properly * This class does not model the slip/skid ball; that is properly
* a separate instrument. * a separate instrument.
* *
* Input properties: * Input properties:
@ -37,9 +37,7 @@
*/ */
class TurnIndicator : public SGSubsystem class TurnIndicator : public SGSubsystem
{ {
public: public:
TurnIndicator ( SGPropertyNode *node ); TurnIndicator ( SGPropertyNode *node );
virtual ~TurnIndicator (); virtual ~TurnIndicator ();
@ -50,7 +48,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
Gyro _gyro; Gyro _gyro;
double _last_rate; double _last_rate;
@ -61,7 +58,6 @@ private:
SGPropertyNode_ptr _yaw_rate_node; SGPropertyNode_ptr _yaw_rate_node;
SGPropertyNode_ptr _electric_current_node; SGPropertyNode_ptr _electric_current_node;
SGPropertyNode_ptr _rate_out_node; SGPropertyNode_ptr _rate_out_node;
}; };
#endif // __INSTRUMENTS_TURN_INDICATOR_HXX #endif // __INSTRUMENTS_TURN_INDICATOR_HXX

View file

@ -33,9 +33,7 @@
*/ */
class VerticalSpeedIndicator : public SGSubsystem class VerticalSpeedIndicator : public SGSubsystem
{ {
public: public:
VerticalSpeedIndicator ( SGPropertyNode *node ); VerticalSpeedIndicator ( SGPropertyNode *node );
virtual ~VerticalSpeedIndicator (); virtual ~VerticalSpeedIndicator ();
@ -44,7 +42,6 @@ public:
virtual void update (double dt); virtual void update (double dt);
private: private:
double _casing_pressure_Pa = 0.0; double _casing_pressure_Pa = 0.0;
double _casing_airmass_kg = 0.0; double _casing_airmass_kg = 0.0;
double _casing_density_kgpm3 = 0.0; double _casing_density_kgpm3 = 0.0;
@ -61,7 +58,6 @@ private:
SGPropertyNode_ptr _speed_fpm_node; SGPropertyNode_ptr _speed_fpm_node;
SGPropertyNode_ptr _speed_mps_node; SGPropertyNode_ptr _speed_mps_node;
SGPropertyNode_ptr _speed_kts_node; SGPropertyNode_ptr _speed_kts_node;
}; };
#endif // __INSTRUMENTS_VERTICAL_SPEED_INDICATOR_HXX #endif // __INSTRUMENTS_VERTICAL_SPEED_INDICATOR_HXX

View file

@ -21,13 +21,11 @@
#include <simgear/props/PropertyInterpolationMgr.hxx> #include <simgear/props/PropertyInterpolationMgr.hxx>
class FGInterpolator: class FGInterpolator : public simgear::PropertyInterpolationMgr
public simgear::PropertyInterpolationMgr
{ {
public: public:
FGInterpolator(); FGInterpolator();
~FGInterpolator(); ~FGInterpolator();
}; };
#endif /* FG_INTERPOLATOR_HXX_ */ #endif /* FG_INTERPOLATOR_HXX_ */

View file

@ -55,20 +55,17 @@ public:
*/ */
static bool isMultiplayerRequested(); static bool isMultiplayerRequested();
private: private:
void add_channel(const std::string& config); void add_channel(const std::string& config);
FGProtocol* parse_port_config( const std::string& cfgstr ); FGProtocol* parse_port_config( const std::string& cfgstr );
private: private:
// define the global I/O channel list // define the global I/O channel list
//io_container global_io_list; //io_container global_io_list;
typedef std::vector< FGProtocol* > ProtocolVec; typedef std::vector< FGProtocol* > ProtocolVec;
ProtocolVec io_channels; ProtocolVec io_channels;
SGPropertyNode_ptr _realDeltaTime; SGPropertyNode_ptr _realDeltaTime;
}; };
#endif // _FG_IO_HXX #endif // _FG_IO_HXX

View file

@ -127,7 +127,7 @@ inline SGPropertyNode * fgGetNode (const std::string & path, bool create = false
* @return The node, or 0 if none exists and none was created. * @return The node, or 0 if none exists and none was created.
*/ */
extern SGPropertyNode * fgGetNode (const char * path, extern SGPropertyNode * fgGetNode (const char * path,
int index, bool create = false); int index, bool create = false);
/** /**
* Get a property node with separate index. * Get a property node with separate index.
@ -144,7 +144,7 @@ extern SGPropertyNode * fgGetNode (const char * path,
* @return The node, or 0 if none exists and none was created. * @return The node, or 0 if none exists and none was created.
*/ */
inline SGPropertyNode * fgGetNode (const std::string & path, inline SGPropertyNode * fgGetNode (const std::string & path,
int index, bool create = false) int index, bool create = false)
{ {
return fgGetNode(path.c_str(), index, create ); return fgGetNode(path.c_str(), index, create );
} }
@ -179,7 +179,7 @@ inline bool fgHasNode (const std::string & path)
* any given in the string). * any given in the string).
*/ */
extern void fgAddChangeListener (SGPropertyChangeListener * listener, extern void fgAddChangeListener (SGPropertyChangeListener * listener,
const char * path); const char * path);
/** /**
* Add a listener to a node. * Add a listener to a node.
@ -190,7 +190,7 @@ extern void fgAddChangeListener (SGPropertyChangeListener * listener,
* any given in the string). * any given in the string).
*/ */
inline void fgAddChangeListener (SGPropertyChangeListener * listener, inline void fgAddChangeListener (SGPropertyChangeListener * listener,
const std::string & path) const std::string & path)
{ {
fgAddChangeListener( listener, path.c_str() ); fgAddChangeListener( listener, path.c_str() );
} }
@ -205,7 +205,7 @@ inline void fgAddChangeListener (SGPropertyChangeListener * listener,
* any given in the string). * any given in the string).
*/ */
extern void fgAddChangeListener (SGPropertyChangeListener * listener, extern void fgAddChangeListener (SGPropertyChangeListener * listener,
const char * path, int index); const char * path, int index);
/** /**
* Add a listener to a node. * Add a listener to a node.
@ -216,7 +216,7 @@ extern void fgAddChangeListener (SGPropertyChangeListener * listener,
* any given in the string). * any given in the string).
*/ */
inline void fgAddChangeListener (SGPropertyChangeListener * listener, inline void fgAddChangeListener (SGPropertyChangeListener * listener,
const std::string & path, int index) const std::string & path, int index)
{ {
fgAddChangeListener( listener, path.c_str(), index ); fgAddChangeListener( listener, path.c_str(), index );
} }
@ -417,7 +417,7 @@ inline double fgGetDouble (const std::string & name, double defaultValue = 0.0)
* @return The property's value as a string, or the default value provided. * @return The property's value as a string, or the default value provided.
*/ */
extern const char * fgGetString (const char * name, extern const char * fgGetString (const char * name,
const char * defaultValue = ""); const char * defaultValue = "");
/** /**
* Get a string value for a property. * Get a string value for a property.
@ -721,7 +721,7 @@ extern void fgUntie (const char * name);
* @param name The property name to tie (full path). * @param name The property name to tie (full path).
* @param getter The getter function, or 0 if the value is unreadable. * @param getter The getter function, or 0 if the value is unreadable.
* @param setter The setter function, or 0 if the value is unmodifiable. * @param setter The setter function, or 0 if the value is unmodifiable.
* @param useDefault true if the setter should be invoked with any existing * @param useDefault true if the setter should be invoked with any existing
* property value should be; false if the old value should be * property value should be; false if the old value should be
* discarded; defaults to true. * discarded; defaults to true.
*/ */
@ -731,9 +731,9 @@ fgTie (const char * name, V (*getter)(), void (*setter)(V) = 0,
bool useDefault = true) bool useDefault = true)
{ {
if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter), if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter),
useDefault)) useDefault))
SG_LOG(SG_GENERAL, SG_WARN, SG_LOG(SG_GENERAL, SG_WARN,
"Failed to tie property " << name << " to functions"); "Failed to tie property " << name << " to functions");
} }
@ -751,7 +751,7 @@ fgTie (const char * name, V (*getter)(), void (*setter)(V) = 0,
* setter functions. * setter functions.
* @param getter The getter function, or 0 if the value is unreadable. * @param getter The getter function, or 0 if the value is unreadable.
* @param setter The setter function, or 0 if the value is unmodifiable. * @param setter The setter function, or 0 if the value is unmodifiable.
* @param useDefault true if the setter should be invoked with any existing * @param useDefault true if the setter should be invoked with any existing
* property value should be; false if the old value should be * property value should be; false if the old value should be
* discarded; defaults to true. * discarded; defaults to true.
*/ */
@ -761,12 +761,12 @@ fgTie (const char * name, int index, V (*getter)(int),
void (*setter)(int, V) = 0, bool useDefault = true) void (*setter)(int, V) = 0, bool useDefault = true)
{ {
if (!globals->get_props()->tie(name, if (!globals->get_props()->tie(name,
SGRawValueFunctionsIndexed<V>(index, SGRawValueFunctionsIndexed<V>(index,
getter, getter,
setter), setter),
useDefault)) useDefault))
SG_LOG(SG_GENERAL, SG_WARN, SG_LOG(SG_GENERAL, SG_WARN,
"Failed to tie property " << name << " to indexed functions"); "Failed to tie property " << name << " to indexed functions");
} }
@ -785,7 +785,7 @@ fgTie (const char * name, int index, V (*getter)(int),
* unreadable. * unreadable.
* @param setter The object's setter method, or 0 if the value is * @param setter The object's setter method, or 0 if the value is
* unmodifiable. * unmodifiable.
* @param useDefault true if the setter should be invoked with any existing * @param useDefault true if the setter should be invoked with any existing
* property value should be; false if the old value should be * property value should be; false if the old value should be
* discarded; defaults to true. * discarded; defaults to true.
*/ */
@ -795,10 +795,10 @@ fgTie (const char * name, T * obj, V (T::*getter)() const,
void (T::*setter)(V) = 0, bool useDefault = true) void (T::*setter)(V) = 0, bool useDefault = true)
{ {
if (!globals->get_props()->tie(name, if (!globals->get_props()->tie(name,
SGRawValueMethods<T,V>(*obj, getter, setter), SGRawValueMethods<T,V>(*obj, getter, setter),
useDefault)) useDefault))
SG_LOG(SG_GENERAL, SG_WARN, SG_LOG(SG_GENERAL, SG_WARN,
"Failed to tie property " << name << " to object methods"); "Failed to tie property " << name << " to object methods");
} }
@ -817,24 +817,24 @@ fgTie (const char * name, T * obj, V (T::*getter)() const,
* setter methods. * setter methods.
* @param getter The getter method, or 0 if the value is unreadable. * @param getter The getter method, or 0 if the value is unreadable.
* @param setter The setter method, or 0 if the value is unmodifiable. * @param setter The setter method, or 0 if the value is unmodifiable.
* @param useDefault true if the setter should be invoked with any existing * @param useDefault true if the setter should be invoked with any existing
* property value should be; false if the old value should be * property value should be; false if the old value should be
* discarded; defaults to true. * discarded; defaults to true.
*/ */
template <class T, class V> template <class T, class V>
inline void inline void
fgTie (const char * name, T * obj, int index, fgTie (const char * name, T * obj, int index,
V (T::*getter)(int) const, void (T::*setter)(int, V) = 0, V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
bool useDefault = true) bool useDefault = true)
{ {
if (!globals->get_props()->tie(name, if (!globals->get_props()->tie(name,
SGRawValueMethodsIndexed<T,V>(*obj, SGRawValueMethodsIndexed<T,V>(*obj,
index, index,
getter, getter,
setter), setter),
useDefault)) useDefault))
SG_LOG(SG_GENERAL, SG_WARN, SG_LOG(SG_GENERAL, SG_WARN,
"Failed to tie property " << name << " to indexed object methods"); "Failed to tie property " << name << " to indexed object methods");
} }

View file

@ -20,30 +20,28 @@
class FGLogger : public SGSubsystem class FGLogger : public SGSubsystem
{ {
public: public:
// Implementation of SGSubsystem // Implementation of SGSubsystem
virtual void init (); virtual void init ();
virtual void reinit (); virtual void reinit ();
virtual void bind (); virtual void bind ();
virtual void unbind (); virtual void unbind ();
virtual void update (double dt); virtual void update (double dt);
private: private:
/**
* A single instance of a log file (the logger can contain many).
*/
struct Log {
Log ();
/** std::vector<SGPropertyNode_ptr> nodes;
* A single instance of a log file (the logger can contain many). std::unique_ptr<sg_ofstream> output;
*/ long interval_ms;
struct Log { double last_time_ms;
Log (); char delimiter;
};
std::vector<SGPropertyNode_ptr> nodes;
std::unique_ptr<sg_ofstream> output;
long interval_ms;
double last_time_ms;
char delimiter;
};
std::vector< std::unique_ptr<Log> > _logs;
std::vector< std::unique_ptr<Log> > _logs;
}; };
#endif // __LOGGER_HXX #endif // __LOGGER_HXX

View file

@ -11,7 +11,7 @@
#include <osg/Switch> #include <osg/Switch>
#include <memory> #include <memory>
#include <simgear/structure/subsystem_mgr.hxx> // for SGSubsystem #include <simgear/structure/subsystem_mgr.hxx> // for SGSubsystem
// Don't pull in the headers, since we don't need them here. // Don't pull in the headers, since we don't need them here.
@ -21,32 +21,32 @@ class FGFX;
class FGAircraftModel : public SGSubsystem class FGAircraftModel : public SGSubsystem
{ {
public: public:
FGAircraftModel ();
virtual ~FGAircraftModel ();
FGAircraftModel (); virtual void init ();
virtual ~FGAircraftModel (); virtual void shutdown ();
virtual void reinit ();
virtual void init (); virtual void bind ();
virtual void shutdown (); virtual void unbind ();
virtual void reinit (); virtual void update (double dt);
virtual void bind (); virtual SGModelPlacement * get3DModel() { return _aircraft.get(); }
virtual void unbind (); virtual SGVec3d& getVelocity() { return _velocity; }
virtual void update (double dt);
virtual SGModelPlacement * get3DModel() { return _aircraft.get(); }
virtual SGVec3d& getVelocity() { return _velocity; }
static const char* subsystemName() { return "aircraft-model"; } static const char* subsystemName() { return "aircraft-model"; }
private: private:
void deinit (); void deinit ();
std::unique_ptr<SGModelPlacement> _aircraft; std::unique_ptr<SGModelPlacement> _aircraft;
std::unique_ptr<SGModelPlacement> _interior; std::unique_ptr<SGModelPlacement> _interior;
SGVec3d _velocity;
SGSharedPtr<FGFX> _fx;
SGPropertyNode_ptr _speed_n; SGVec3d _velocity;
SGPropertyNode_ptr _speed_e; SGSharedPtr<FGFX> _fx;
SGPropertyNode_ptr _speed_d;
SGPropertyNode_ptr _speed_n;
SGPropertyNode_ptr _speed_e;
SGPropertyNode_ptr _speed_d;
}; };
#endif // __ACMODEL_HXX #endif // __ACMODEL_HXX

View file

@ -9,7 +9,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <simgear/compiler.h> // for SG_USING_STD #include <simgear/compiler.h> // for SG_USING_STD
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
// Don't pull in headers, since we don't need them here. // Don't pull in headers, since we don't need them here.
@ -23,88 +23,87 @@ class SGModelPlacement;
class FGModelMgr : public SGSubsystem class FGModelMgr : public SGSubsystem
{ {
public: public:
/**
* A dynamically-placed model using properties.
*
* The model manager uses the property nodes to update the model's
* position and orientation; any of the property node pointers may
* be set to zero to avoid update. Normally, a caller should
* load the model by instantiating SGModelPlacement with the path
* to the model or its XML wrapper, then assign any relevant
* property node pointers.
*
* @see SGModelPlacement
* @see FGModelMgr#add_instance
*/
struct Instance
{
Instance ();
virtual ~Instance ();
SGModelPlacement * model;
SGPropertyNode_ptr node;
SGPropertyNode_ptr lon_deg_node;
SGPropertyNode_ptr lat_deg_node;
SGPropertyNode_ptr elev_ft_node;
SGPropertyNode_ptr roll_deg_node;
SGPropertyNode_ptr pitch_deg_node;
SGPropertyNode_ptr heading_deg_node;
bool shadow;
};
/** FGModelMgr ();
* A dynamically-placed model using properties. virtual ~FGModelMgr ();
*
* The model manager uses the property nodes to update the model's
* position and orientation; any of the property node pointers may
* be set to zero to avoid update. Normally, a caller should
* load the model by instantiating SGModelPlacement with the path
* to the model or its XML wrapper, then assign any relevant
* property node pointers.
*
* @see SGModelPlacement
* @see FGModelMgr#add_instance
*/
struct Instance
{
Instance ();
virtual ~Instance ();
SGModelPlacement * model;
SGPropertyNode_ptr node;
SGPropertyNode_ptr lon_deg_node;
SGPropertyNode_ptr lat_deg_node;
SGPropertyNode_ptr elev_ft_node;
SGPropertyNode_ptr roll_deg_node;
SGPropertyNode_ptr pitch_deg_node;
SGPropertyNode_ptr heading_deg_node;
bool shadow;
};
FGModelMgr (); virtual void init ();
virtual ~FGModelMgr (); virtual void shutdown ();
virtual void init (); virtual void bind ();
virtual void shutdown (); virtual void unbind ();
virtual void update (double dt);
virtual void bind (); virtual void add_model (SGPropertyNode * node);
virtual void unbind ();
virtual void update (double dt);
virtual void add_model (SGPropertyNode * node); /**
* Add an instance of a dynamic model to the manager.
/** *
* Add an instance of a dynamic model to the manager. * NOTE: pointer ownership is transferred to the model manager!
* *
* NOTE: pointer ownership is transferred to the model manager! * The caller is responsible for setting up the Instance structure
* * as required. The model manager will continuously update the
* The caller is responsible for setting up the Instance structure * location and orientation of the model based on the current
* as required. The model manager will continuously update the * values of the properties.
* location and orientation of the model based on the current */
* values of the properties. virtual void add_instance (Instance * instance);
*/
virtual void add_instance (Instance * instance);
/** /**
* Remove an instance of a dynamic model from the manager. * Remove an instance of a dynamic model from the manager.
* *
* NOTE: the manager will delete the instance as well. * NOTE: the manager will delete the instance as well.
*/ */
virtual void remove_instance (Instance * instance); virtual void remove_instance (Instance * instance);
static const char* subsystemName() { return "model-manager"; } static const char* subsystemName() { return "model-manager"; }
private: private:
/** /**
* Listener class that adds models at runtime. * Listener class that adds models at runtime.
*/ */
class Listener : public SGPropertyChangeListener class Listener : public SGPropertyChangeListener
{ {
public: public:
Listener(FGModelMgr *mgr) : _mgr(mgr) {} Listener(FGModelMgr *mgr) : _mgr(mgr) {}
virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child); virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child);
virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child); virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child);
private: private:
FGModelMgr * _mgr; FGModelMgr * _mgr;
}; };
SGPropertyNode_ptr _models; SGPropertyNode_ptr _models;
std::unique_ptr<Listener> _listener; std::unique_ptr<Listener> _listener;
std::vector<Instance *> _instances; std::vector<Instance *> _instances;
}; };
#endif // __MODELMGR_HXX #endif // __MODELMGR_HXX

Some files were not shown because too many files have changed in this diff Show more