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
{
public:
FGFX();
virtual ~FGFX();
FGFX ();
virtual ~FGFX ();
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
}
virtual void init();
virtual void reinit();
virtual void bind();
virtual void unbind();
virtual void update(double dt);
};
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

View file

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

View file

@ -15,7 +15,7 @@ class SGPath;
*
* Allows to store performance data for later reuse/retrieval. Just
* a simple map for now.
*
*
* @author Thomas F<EFBFBD>rster <t.foerster@biologie.hu-berlin.de>
*/
//TODO provide std::map interface?
@ -41,6 +41,7 @@ public:
PerformanceData* getDefaultPerformance() const;
static const char* subsystemName() { return "aircraft-performance-db"; }
private:
void load(const SGPath& path);
@ -49,13 +50,13 @@ private:
typedef std::map<std::string, PerformanceData*> PerformanceDataDict;
PerformanceDataDict _db;
const std::string& findAlias(const std::string& acType) const;
typedef std::pair<std::string, std::string> StringPair;
/// 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
/// partial matches when merging - the first matching alias is used.
/// 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
/// partial matches when merging - the first matching alias is used.
std::vector<StringPair> _aliases;
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -40,8 +40,8 @@ namespace FGXMLAutopilot {
* <li>an optional periodical definition</li>
* </ul>
*/
class AnalogComponent : public Component {
class AnalogComponent : public Component
{
private:
/**
* @brief a flag signalling that the output property value shall be fed back
@ -77,7 +77,7 @@ protected:
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
*/
AnalogComponent();
@ -104,8 +104,8 @@ protected:
/**
* @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
input value if disabled and feedback-if-disabled is true
* is disabled. Analog components feed back it's output value to the active
input value if disabled and feedback-if-disabled is true
*/
virtual void disabled( double dt );
@ -115,10 +115,10 @@ protected:
* 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
* 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 {
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;
@ -134,7 +134,7 @@ protected:
value = clamp( value );
for( simgear::PropertyList::iterator it = _output_list.begin();
it != _output_list.end(); ++it)
(*it)->setDoubleValue( value );
(*it)->setDoubleValue( value );
}
public:
@ -143,11 +143,11 @@ public:
inline void AnalogComponent::disabled( double dt )
{
if( _feedback_if_disabled && ! _output_list.empty() ) {
InputValue * input;
if( (input = _valueInput.get_active() ) != NULL )
input->set_value( _output_list[0]->getDoubleValue() );
}
if( _feedback_if_disabled && ! _output_list.empty() ) {
InputValue * input;
if( (input = _valueInput.get_active() ) != NULL )
input->set_value( _output_list[0]->getDoubleValue() );
}
}
}

View file

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

View file

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

View file

@ -26,19 +26,19 @@
/**
* @brief Model an autopilot system by implementing a SGSubsystemGroup
*
*
*/
class FGXMLAutopilotGroup : public SGSubsystemGroup
{
public:
static FGXMLAutopilotGroup * createInstance(const std::string& nodeName);
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 removeAutopilot( const std::string & name ) = 0;
protected:
FGXMLAutopilotGroup() : SGSubsystemGroup("FGXMLAutopilotGroup") {}
};
#endif // _XMLAUTO_HXX

View file

@ -35,17 +35,15 @@ namespace FGXMLAutopilot {
/**
* @brief Base class for other autopilot components
*/
class Component : public SGSubsystem {
class Component : public SGSubsystem
{
private:
SGSharedPtr<const SGCondition> _condition;
SGPropertyNode_ptr _enable_prop;
std::string * _enable_value;
bool _enabled;
protected:
virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name,
SGPropertyNode& prop_root );
@ -55,10 +53,10 @@ protected:
*/
virtual void update( double dt );
/**
/**
* @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
* 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
been enabled. Set to false for every subsequent call.
* @param dt the elapsed time since the last call
@ -71,21 +69,20 @@ protected:
*/
virtual void disabled( double dt ) {}
/**
/**
* @brief debug flag, true if this component should generate some useful output
* on every iteration
*/
bool _debug;
/**
/**
* @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.
*/
bool _honor_passive;
public:
/**
* @brief A constructor for an empty Component.
*/
@ -124,7 +121,7 @@ public:
* &lt;enable&gt; section
* @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.
*
* If a &lt;prop&gt; is defined and no &lt;value&gt; is defined, the property
@ -139,6 +136,6 @@ public:
bool isPropertyEnabled();
};
}
#endif // COMPONENT_HXX

View file

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

View file

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

View file

@ -34,7 +34,7 @@ protected:
/**
* @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.
* @param configNode the property node containing the configuration
* @param configNode the property node containing the configuration
*/
virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name,
@ -54,7 +54,7 @@ public:
/**
* @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.
* @param configNode the property node containing the configuration
* @param configNode the property node containing the configuration
*/
bool configure( SGPropertyNode& prop_root,
SGPropertyNode& cfg );
@ -63,12 +63,14 @@ public:
/**
* @brief A simple flipflop implementation
*/
class FlipFlop : public Logic {
class FlipFlop : public Logic
{
public:
protected:
/**
* @brief Over-rideable hook method to allow derived classes to refine top-level
* node parsing.
* node parsing.
* @param aName
* @param aNode
* @return true if the node was handled, false otherwise.
@ -77,10 +79,10 @@ protected:
const std::string& cfg_name,
SGPropertyNode& prop_root );
/**
/**
* @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
* 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
been enabled. Set to false for every subsequent call.
* @param dt the elapsed time since the last call
@ -88,11 +90,10 @@ protected:
void update( bool firstTime, double dt );
private:
/**
/**
* @brief Pointer to the actual flip flop implementation
*/
SGSharedPtr<FlipFlopImplementation> _implementation;
};
}

View file

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

View file

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

View file

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

View file

@ -44,8 +44,8 @@ namespace FGXMLAutopilot {
* 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
*/
class Predictor : public AnalogComponent {
class Predictor : public AnalogComponent
{
private:
double _last_value;
double _average;
@ -53,9 +53,9 @@ private:
InputValueList _filter_gain;
protected:
virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name,
SGPropertyNode& prop_root );
virtual bool configure( SGPropertyNode& cfg_node,
const std::string& cfg_name,
SGPropertyNode& prop_root );
public:
Predictor();

View file

@ -35,127 +35,128 @@ class PropertyWatcher;
/**
* Top level route manager class
*
*
*/
class FGRouteMgr : public SGSubsystem,
class FGRouteMgr : public SGSubsystem,
public flightgear::FlightPlan::Delegate
{
public:
FGRouteMgr();
~FGRouteMgr();
FGRouteMgr();
~FGRouteMgr();
void init ();
void postinit ();
void bind ();
void unbind ();
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();
void init ();
void postinit ();
void bind ();
void unbind ();
void update (double dt);
/**
* 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);
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();
/**
* 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:
bool commandDefineUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root);
bool commandDeleteUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root);
flightgear::FlightPlanRef _plan;
time_t _takeoffTime;
time_t _touchdownTime;
// automatic inputs
SGPropertyNode_ptr magvar;
// automatic outputs
// automatic outputs
SGPropertyNode_ptr departure; ///< departure airport information
SGPropertyNode_ptr destination; ///< destination airport information
SGPropertyNode_ptr alternate; ///< alternate airport information
SGPropertyNode_ptr cruise; ///< cruise information
SGPropertyNode_ptr totalDistance;
SGPropertyNode_ptr distanceToGo;
SGPropertyNode_ptr ete;
SGPropertyNode_ptr elapsedFlightTime;
SGPropertyNode_ptr active;
SGPropertyNode_ptr airborne;
SGPropertyNode_ptr wp0;
SGPropertyNode_ptr wp1;
SGPropertyNode_ptr wpn;
SGPropertyNode_ptr _pathNode;
SGPropertyNode_ptr _currentWpt;
/**
/**
* Signal property to notify people that the route was edited
*/
SGPropertyNode_ptr _edited;
/**
* Signal property to notify when the last waypoint is reached
*/
SGPropertyNode_ptr _finished;
SGPropertyNode_ptr _flightplanChanged;
void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance);
/**
* retrieve the cached path distance along a leg
*/
double cachedLegPathDistanceM(int index) const;
double cachedWaypointPathTotalDistance(int index) const;
class InputListener : public SGPropertyChangeListener {
public:
InputListener(FGRouteMgr *m) : mgr(m) {}
@ -167,47 +168,47 @@ private:
SGPropertyNode_ptr input;
SGPropertyNode_ptr weightOnWheels;
SGPropertyNode_ptr groundSpeed;
InputListener *listener;
SGPropertyNode_ptr mirror;
SGPropertyNode_ptr mirror;
/**
* Helper to keep various pieces of state in sync when the route is
* modified (waypoints added, inserted, removed). Notably, this fires the
* 'edited' signal.
*/
virtual void waypointsChanged();
void update_mirror();
virtual void currentWaypointChanged();
// tied getters and setters
// tied getters and setters
std::string getDepartureICAO() const;
std::string getDepartureName() const;
void setDepartureICAO(const std::string& aIdent);
std::string getDepartureRunway() const;
void setDepartureRunway(const std::string& aIdent);
std::string getSID() const;
void setSID(const std::string& aIdent);
std::string getDestinationICAO() const;
std::string getDestinationName() const;
void setDestinationICAO(const std::string& aIdent);
std::string getDestinationRunway() const;
void setDestinationRunway(const std::string& aIdent);
std::string getApproach() const;
void setApproach(const std::string& aIdent);
std::string getSTAR() const;
void setSTAR(const std::string& aIdent);
double getDepartureFieldElevation() const;
double getDestinationFieldElevation() const;
double getDepartureFieldElevation() const;
double getDestinationFieldElevation() const;
int getCruiseAltitudeFt() const;
void setCruiseAltitudeFt(int ft);
@ -226,5 +227,4 @@ private:
void setAlternate(const std::string &icao);
};
#endif // _ROUTE_MGR_HXX

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -36,16 +36,17 @@
class FGODGauge;
class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener {
class wxRadarBg : public SGSubsystem,
public SGPropertyChangeListener
{
public:
wxRadarBg(SGPropertyNode *node);
wxRadarBg();
virtual ~wxRadarBg();
virtual void init();
virtual void shutdown();
virtual void update(double dt);
virtual void valueChanged(SGPropertyNode *);
@ -75,7 +76,7 @@ protected:
double elevation;
double bumpiness;
double elapsed_time;
}ground_echo;
} ground_echo;
typedef std::vector <ground_echo*> ground_echo_vector_type;
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;
}
#endif // _INST_WXRADAR_HXX

View file

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

View file

@ -38,62 +38,60 @@ class SGSky;
*/
class FGEnvironmentMgr : public SGSubsystemGroup
{
public:
enum {
MAX_CLOUD_LAYERS = 5
};
enum {
MAX_CLOUD_LAYERS = 5
};
FGEnvironmentMgr ();
virtual ~FGEnvironmentMgr ();
FGEnvironmentMgr ();
virtual ~FGEnvironmentMgr ();
virtual InitStatus incrementalInit ();
virtual void reinit ();
virtual void shutdown ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
virtual InitStatus incrementalInit ();
virtual void reinit ();
virtual void shutdown ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
/**
* Get the environment information for the plane's current position.
*/
virtual FGEnvironment getEnvironment () const;
/**
* Get the environment information for the plane's current position.
*/
virtual FGEnvironment getEnvironment () 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;
/**
* 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:
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);
void updateClosestAirport();
FGEnvironment * _environment; // always the same, for now
FGClouds *fgClouds;
bool _cloudLayersDirty;
simgear::TiedPropertyList _tiedProperties;
SGPropertyChangeListener * _3dCloudsEnableListener;
SGSky* _sky;
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
FGClouds *fgClouds;
bool _cloudLayersDirty;
simgear::TiedPropertyList _tiedProperties;
SGPropertyChangeListener * _3dCloudsEnableListener;
SGSky* _sky;
};
#endif // _ENVIRONMENT_MGR_HXX

View file

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

View file

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

View file

@ -171,6 +171,7 @@ public:
typedef std::vector<LiveMetarProperties_ptr> MetarPropertiesList;
MetarPropertiesList::iterator findMetarAtPath(const string &propPath);
protected:
void bind();
void unbind();
@ -189,7 +190,6 @@ protected:
simgear::TiedPropertyList _tiedProperties;
MetarPropertiesList _metarProperties;
MetarRequester* _requester;
};
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:
NoaaMetarRealWxController( SGPropertyNode_ptr rootNode );
@ -410,6 +411,7 @@ public:
virtual ~NoaaMetarRealWxController()
{
}
private:
std::string noaa_base_url;
};

View file

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

View file

@ -4,7 +4,7 @@
// 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
// by Ian Forster-Lewis, University of Cambridge, 26th December 2007
//
@ -38,50 +38,50 @@ using std::string;
#include <simgear/props/tiedpropertylist.hxx>
class FGRidgeLift : public SGSubsystem {
class FGRidgeLift : public SGSubsystem
{
public:
FGRidgeLift();
~FGRidgeLift();
FGRidgeLift();
~FGRidgeLift();
virtual void bind();
virtual void unbind();
virtual void update(double dt);
virtual void init();
virtual void bind();
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_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_slope( int index ) const { return slope[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_lon_deg( int index ) const { return probe_lon_deg[index]; };
inline double get_slope( int index ) const { return slope[index]; };
private:
static const double dist_probe_m[5];
static const double dist_probe_m[5];
double strength;
double timer;
double strength;
double timer;
double probe_lat_deg[5];
double probe_lon_deg[5];
double probe_elev_m[5];
double probe_lat_deg[5];
double probe_lon_deg[5];
double probe_elev_m[5];
double slope[4];
double slope[4];
double lift_factor;
double lift_factor;
SGPropertyNode_ptr _enabled_node;
SGPropertyNode_ptr _ridge_lift_fps_node;
SGPropertyNode_ptr _enabled_node;
SGPropertyNode_ptr _ridge_lift_fps_node;
SGPropertyNode_ptr _surface_wind_from_deg_node;
SGPropertyNode_ptr _surface_wind_speed_node;
SGPropertyNode_ptr _surface_wind_from_deg_node;
SGPropertyNode_ptr _surface_wind_speed_node;
SGPropertyNode_ptr _user_altitude_agl_ft_node;
SGPropertyNode_ptr _user_longitude_node;
SGPropertyNode_ptr _user_latitude_node;
SGPropertyNode_ptr _ground_elev_node;
SGPropertyNode_ptr _user_altitude_agl_ft_node;
SGPropertyNode_ptr _user_longitude_node;
SGPropertyNode_ptr _user_latitude_node;
SGPropertyNode_ptr _ground_elev_node;
simgear::TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
};
#endif // _FG_RidgeLift_HXX

View file

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

View file

@ -1,7 +1,7 @@
// terrainsampler.hxx --
// terrainsampler.hxx --
//
// 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
//
// Copyright (C) 2010 Curtis Olson
@ -26,11 +26,12 @@
#include <simgear/structure/subsystem_mgr.hxx>
namespace Environment {
class TerrainSampler : public SGSubsystemGroup
{
public:
TerrainSampler() : SGSubsystemGroup("TerrainSampler") {}
static TerrainSampler * createInstance( SGPropertyNode_ptr rootNode );
static TerrainSampler * createInstance( SGPropertyNode_ptr rootNode );
};
} // namespace

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -41,36 +41,36 @@ class FGAIManager;
class FDMShell : public SGSubsystem
{
public:
FDMShell();
~FDMShell() override;
void init() override;
void shutdown() override;
void reinit() override;
void postinit() override;
void bind() override;
void unbind() override;
void update(double dt) override;
FDMShell();
~FDMShell() override;
void init() override;
void shutdown() override;
void reinit() override;
void postinit() override;
void bind() override;
void unbind() override;
void update(double dt) override;
FGInterface* getInterface() const;
static const char* subsystemName() { return "flight"; }
private:
void createImplementation();
TankPropertiesList _tankProperties;
SGSharedPtr<FGInterface> _impl;
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 _density_slugft, _data_logging, _replay_master;
SGPropertyNode_ptr _initialFdmProperties;
private:
void createImplementation();
TankPropertiesList _tankProperties;
SGSharedPtr<FGInterface> _impl;
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 _density_slugft, _data_logging, _replay_master;
SGPropertyNode_ptr _initialFdmProperties;
SGSharedPtr<FGAIManager> _ai_mgr;
SGPropertyNode_ptr _max_radius_nm;

View file

@ -99,35 +99,37 @@ class FGAIAircraft;
* life/visibility, computes the track if the
* position has changed.
*/
class TrackComputer {
class TrackComputer
{
public:
inline TrackComputer( double & track, double & path, const SGGeod & position ) :
_track( track ),
_path( path ),
_position( 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( double & track, double & path, const SGGeod & position ) :
_track( track ),
_path( path ),
_position( 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;
}
}
private:
double & _track;
double & _path;
const SGGeod & _position;
const SGGeod _prevPosition;
double & _track;
double & _path;
const SGGeod & _position;
const SGGeod _prevPosition;
};
// 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
// initialization until scenery can be loaded and we know the true
// ground elevation.
@ -220,16 +222,14 @@ class FGInterface : public SGSubsystem {
void set_A_Z_pilot(double z)
{ _set_Accels_Pilot_Body(_state.a_pilot_body_v[0], _state.a_pilot_body_v[1], z); }
protected:
int _calc_multiloop (double dt);
// deliberately not virtual so that
// FGInterface constructor will call
// the right version
// deliberately not virtual so that
// FGInterface constructor will call
// the right version
void _setup();
void _busdump(void);
@ -245,92 +245,92 @@ protected:
void _update_ground_elev_at_pos( void );
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[1] = dy;
_state.d_cg_rp_body_v[2] = dz;
_state.d_cg_rp_body_v[0] = dx;
_state.d_cg_rp_body_v[1] = dy;
_state.d_cg_rp_body_v[2] = dz;
}
inline void _set_Accels_Local( double north, double east, double down ) {
_state.v_dot_local_v[0] = north;
_state.v_dot_local_v[1] = east;
_state.v_dot_local_v[2] = down;
_state.v_dot_local_v[0] = north;
_state.v_dot_local_v[1] = east;
_state.v_dot_local_v[2] = down;
}
inline void _set_Accels_Body( double u, double v, double w ) {
_state.v_dot_body_v[0] = u;
_state.v_dot_body_v[1] = v;
_state.v_dot_body_v[2] = w;
_state.v_dot_body_v[0] = u;
_state.v_dot_body_v[1] = v;
_state.v_dot_body_v[2] = w;
}
inline void _set_Accels_CG_Body( double x, double y, double z ) {
_state.a_cg_body_v[0] = x;
_state.a_cg_body_v[1] = y;
_state.a_cg_body_v[2] = z;
_state.a_cg_body_v[0] = x;
_state.a_cg_body_v[1] = y;
_state.a_cg_body_v[2] = 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[1] = y;
_state.a_pilot_body_v[2] = z;
_state.a_pilot_body_v[0] = x;
_state.a_pilot_body_v[1] = y;
_state.a_pilot_body_v[2] = 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[1] = y;
_state.n_cg_body_v[2] = z;
_state.n_cg_body_v[0] = x;
_state.n_cg_body_v[1] = y;
_state.n_cg_body_v[2] = z;
}
void _set_Nlf(double n) { _state.nlf=n; }
inline void _set_Velocities_Local( double north, double east, double down ){
_state.v_local_v[0] = north;
_state.v_local_v[1] = east;
_state.v_local_v[2] = down;
_state.v_local_v[0] = north;
_state.v_local_v[1] = east;
_state.v_local_v[2] = 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[1] = east;
_state.v_local_rel_ground_v[2] = down;
_state.v_local_rel_ground_v[0] = north;
_state.v_local_rel_ground_v[1] = east;
_state.v_local_rel_ground_v[2] = down;
}
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[1] = east;
_state.v_local_airmass_v[2] = down;
_state.v_local_airmass_v[0] = north;
_state.v_local_airmass_v[1] = east;
_state.v_local_airmass_v[2] = down;
}
inline void _set_Velocities_Body( double u, double v, double w) {
_state.v_body_v[0] = u;
_state.v_body_v[1] = v;
_state.v_body_v[2] = w;
_state.v_body_v[0] = u;
_state.v_body_v[1] = v;
_state.v_body_v[2] = w;
}
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_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_Omega_Body( double p, double q, double r ) {
_state.omega_body_v[0] = p;
_state.omega_body_v[1] = q;
_state.omega_body_v[2] = r;
_state.omega_body_v[0] = p;
_state.omega_body_v[1] = q;
_state.omega_body_v[2] = r;
}
inline void _set_Euler_Rates( double phi, double theta, double psi ) {
_state.euler_rates_v[0] = phi;
_state.euler_rates_v[1] = theta;
_state.euler_rates_v[2] = psi;
_state.euler_rates_v[0] = phi;
_state.euler_rates_v[1] = theta;
_state.euler_rates_v[2] = psi;
}
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)
{
_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)
{
_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 ) {
_state.geocentric_rates_v[0] = lat;
_state.geocentric_rates_v[1] = lon;
_state.geocentric_rates_v[2] = rad;
_state.geocentric_rates_v[0] = lat;
_state.geocentric_rates_v[1] = lon;
_state.geocentric_rates_v[2] = rad;
}
inline void _set_Geocentric_Position( double lat, double lon, double rad ) {
_state.geocentric_position_v.setLatitudeRad(lat);
@ -363,9 +363,9 @@ protected:
_state.geodetic_position_v.setElevationFt(alt);
}
inline void _set_Euler_Angles( double phi, double theta, double psi ) {
_state.euler_angles_v[0] = phi;
_state.euler_angles_v[1] = theta;
_state.euler_angles_v[2] = psi;
_state.euler_angles_v[0] = phi;
_state.euler_angles_v[1] = theta;
_state.euler_angles_v[2] = psi;
}
// FIXME, for compatibility with JSBSim
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; }
public:
FGInterface();
FGInterface( double dt );
virtual ~FGInterface();
@ -403,31 +402,31 @@ public:
// Define the various supported flight models (many not yet implemented)
enum {
// Magic Carpet mode
FG_MAGICCARPET = 0,
// Magic Carpet mode
FG_MAGICCARPET = 0,
// The NASA LaRCsim (Navion) flight model
FG_LARCSIM = 1,
// The NASA LaRCsim (Navion) flight model
FG_LARCSIM = 1,
// Jon S. Berndt's new FDM written from the ground up in C++
FG_JSBSIM = 2,
// Jon S. Berndt's new FDM written from the ground up in C++
FG_JSBSIM = 2,
// Christian's hot air balloon simulation
FG_BALLOONSIM = 3,
// Christian's hot air balloon simulation
FG_BALLOONSIM = 3,
// Aeronautical DEvelopment AGEncy, Bangalore India
FG_ADA = 4,
// Aeronautical DEvelopment AGEncy, Bangalore India
FG_ADA = 4,
// The following aren't implemented but are here to spark
// thoughts and discussions, and maybe even action.
FG_ACM = 5,
FG_SUPER_SONIC = 6,
FG_HELICOPTER = 7,
FG_AUTOGYRO = 8,
FG_PARACHUTE = 9,
// The following aren't implemented but are here to spark
// thoughts and discussions, and maybe even action.
FG_ACM = 5,
FG_SUPER_SONIC = 6,
FG_HELICOPTER = 7,
FG_AUTOGYRO = 8,
FG_PARACHUTE = 9,
// Driven externally via a serial port, net, file, etc.
FG_EXTERNAL = 10
// Driven externally via a serial port, net, file, etc.
FG_EXTERNAL = 10
};
// initialization
@ -445,10 +444,10 @@ public:
virtual void set_Altitude(double alt); // triggers re-calc of AGL altitude
virtual void set_AltitudeAGL(double altagl); // and vice-versa
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) {
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
@ -456,44 +455,44 @@ public:
virtual void set_Mach_number(double mach);
virtual void set_Velocities_Local( double north, double east, double down );
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) {
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) {
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_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) {
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) {
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
virtual void set_Euler_Angles( double phi, double theta, double psi );
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) {
set_Euler_Angles(get_Phi(), theta, get_Psi());
set_Euler_Angles(get_Phi(), theta, get_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) {
set_Phi(phi * SGD_DEGREES_TO_RADIANS);
set_Phi(phi * SGD_DEGREES_TO_RADIANS);
}
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) {
set_Psi(psi * SGD_DEGREES_TO_RADIANS);
set_Psi(psi * SGD_DEGREES_TO_RADIANS);
}
// Flight Path
@ -507,8 +506,8 @@ public:
virtual void set_Density(double rho);
virtual void set_Velocities_Local_Airmass (double wnorth,
double weast,
double wdown );
double weast,
double wdown );
// ========== Mass properties and geometry values ==========
@ -604,10 +603,10 @@ public:
return _state.geocentric_position_v.getLatitudeRad();
}
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 {
return _state.geocentric_position_v.getRadiusFt();
return _state.geocentric_position_v.getRadiusFt();
}
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_Earth_position_angle() const {
return _state.earth_position_angle;
return _state.earth_position_angle;
}
inline double get_Runway_altitude() const { return _state.runway_altitude; }

View file

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

View file

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

View file

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

View file

@ -36,72 +36,73 @@
////////////////////////////////////////////////////////////////////////
// The Joystick Input Class
////////////////////////////////////////////////////////////////////////
class FGJoystickInput : public SGSubsystem,FGCommonInput {
class FGJoystickInput : public SGSubsystem,
FGCommonInput
{
public:
FGJoystickInput();
virtual ~FGJoystickInput();
FGJoystickInput();
virtual ~FGJoystickInput();
virtual void init();
virtual void postinit();
virtual void reinit();
virtual void update( double dt );
virtual void init();
virtual void postinit();
virtual void reinit();
virtual void update( double dt );
static const int MAX_JOYSTICKS = 16;
static const int MAX_JOYSTICK_AXES = _JS_MAX_AXES;
static const int MAX_JOYSTICK_BUTTONS = 32;
static const int MAX_JOYSTICKS = 16;
static const int MAX_JOYSTICK_AXES = _JS_MAX_AXES;
static const int MAX_JOYSTICK_BUTTONS = 32;
private:
/**
* @brief computeDeviceIndexName - compute the name including the index, based
* on the number of identically named devices. This is used to allow multiple
* different files for identical hardware, especially throttles
* @param name - the base joystick name
* @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
* @return
*/
std::string computeDeviceIndexName(const std::string &name, int lastIndex) const;
void _remove(bool all);
SGPropertyNode_ptr status_node;
/**
* @brief computeDeviceIndexName - compute the name including the index, based
* on the number of identically named devices. This is used to allow multiple
* different files for identical hardware, especially throttles
* @param name - the base joystick name
* @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
* @return
*/
std::string computeDeviceIndexName(const std::string &name, int lastIndex) const;
/**
* Settings for a single joystick axis.
*/
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;
};
void _remove(bool all);
SGPropertyNode_ptr status_node;
/**
* 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);
/**
* Settings for a single joystick axis.
*/
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.
*/
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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
// 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
// - the core GPS calculations such as position
// and waypoint sequencing are done (or should
// be done) by FG code.
// and waypoint sequencing are done (or should
// be done) by FG code.
//
// Written by David Luff, started 2005.
//
@ -34,36 +34,36 @@
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},
{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 {
KLN89_MODE_DISP,
KLN89_MODE_CRSR
KLN89_MODE_DISP,
KLN89_MODE_CRSR
};
enum KLN89DistanceUnits {
GPS_DIST_UNITS_NM = 0,
GPS_DIST_UNITS_KM
GPS_DIST_UNITS_NM = 0,
GPS_DIST_UNITS_KM
};
enum KLN89SpeedUnits {
GPS_VEL_UNITS_KT,
GPS_VEL_UNITS_KPH
GPS_VEL_UNITS_KT,
GPS_VEL_UNITS_KPH
};
enum KLN89AltitudeUnits {
GPS_ALT_UNITS_FT,
GPS_ALT_UNITS_M
GPS_ALT_UNITS_FT,
GPS_ALT_UNITS_M
};
enum KLN89PressureUnits {
GPS_PRES_UNITS_IN = 1,
GPS_PRES_UNITS_MB,
GPS_PRES_UNITS_HP
GPS_PRES_UNITS_IN = 1,
GPS_PRES_UNITS_MB,
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" };
*/
@ -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 kln89_page_list_type::iterator kln89_page_list_itr;
class KLN89 : public DCLGPS {
friend class KLN89Page;
friend class KLN89AptPage;
friend class KLN89VorPage;
friend class KLN89NDBPage;
friend class KLN89IntPage;
friend class KLN89UsrPage;
friend class KLN89ActPage;
friend class KLN89NavPage;
friend class KLN89FplPage;
friend class KLN89CalPage;
friend class KLN89SetPage;
friend class KLN89OthPage;
friend class KLN89AltPage;
friend class KLN89DirPage;
friend class KLN89NrstPage;
class KLN89 : public DCLGPS
{
friend class KLN89Page;
friend class KLN89AptPage;
friend class KLN89VorPage;
friend class KLN89NDBPage;
friend class KLN89IntPage;
friend class KLN89UsrPage;
friend class KLN89ActPage;
friend class KLN89NavPage;
friend class KLN89FplPage;
friend class KLN89CalPage;
friend class KLN89SetPage;
friend class KLN89OthPage;
friend class KLN89AltPage;
friend class KLN89DirPage;
friend class KLN89NrstPage;
public:
KLN89(RenderArea2D* instrument);
~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); }
KLN89(RenderArea2D* instrument);
~KLN89();
inline void SetSuaAlertEnabled(bool b) { _suaAlertEnabled = b; }
inline bool GetSuaAlertEnabled() { return(_suaAlertEnabled); }
inline void SetAltAlertEnabled(bool b) { _altAlertEnabled = b; }
inline bool GetAltAlertEnabled() { return(_altAlertEnabled); }
void bind();
void unbind();
void init();
void update(double dt);
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();
// 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; }
inline bool GetSuaAlertEnabled() { return(_suaAlertEnabled); }
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:
void ToggleOBSMode();
// Initiate Direct To operation to the supplied ID.
void DtoInitiate(const std::string& id);
void ToggleOBSMode();
//----------------------- Drawing functions which take CHARACTER units -------------------------
// Render string s in display field field at position x, y
// 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);
// Initiate Direct To operation to the supplied ID.
void DtoInitiate(const std::string& id);
// Draw a frequency as xxx.xx
void DrawFreq(double d, int field, int px, int py);
// Draw a time in seconds as hh:mm
// NOTE: px is RIGHT JUSTIFIED!
void DrawTime(double time, int field, int px, int py);
//----------------------- Drawing functions which take CHARACTER units -------------------------
// Render string s in display field field at position x, y
// 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);
// 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 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);
void DrawLatitude(double d, int field, int px, int py);
void DrawLongitude(double d, int field, int px, int py);
// ==================== 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 a frequency as xxx.xx
void DrawFreq(double d, int field, int px, int py);
// 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;
// Draw a time in seconds as hh:mm
// NOTE: px is RIGHT JUSTIFIED!
void DrawTime(double time, int field, int px, int py);
// 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 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 =============
// 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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -28,10 +28,11 @@
namespace Instrumentation {
class SignalQualityComputer : public SGReferenced {
class SignalQualityComputer : public SGReferenced
{
public:
virtual ~SignalQualityComputer();
virtual double computeSignalQuality( double distance_nm ) const = 0;
virtual ~SignalQualityComputer();
virtual double computeSignalQuality( double distance_nm ) const = 0;
};
typedef SGSharedPtr<SignalQualityComputer> SignalQualityComputerRef;
@ -39,7 +40,7 @@ typedef SGSharedPtr<SignalQualityComputer> SignalQualityComputerRef;
class CommRadio : public AbstractInstrument
{
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!
enum GPSWpType {
GPS_WP_APT = 0,
GPS_WP_VOR,
GPS_WP_NDB,
GPS_WP_INT,
GPS_WP_USR,
GPS_WP_VIRT // Used for virtual waypoints, such as the start of DTO operation.
GPS_WP_APT = 0,
GPS_WP_VOR,
GPS_WP_NDB,
GPS_WP_INT,
GPS_WP_USR,
GPS_WP_VIRT // Used for virtual waypoints, such as the start of DTO operation.
};
enum GPSAppWpType {
GPS_IAF, // Initial approach fix
GPS_IAP, // Waypoint on approach sequence that isn't any of the others.
GPS_FAF, // Final approach fix
GPS_MAP, // Missed approach point
GPS_MAHP, // Initial missed approach holding point.
GPS_IAF, // Initial approach fix
GPS_IAP, // Waypoint on approach sequence that isn't any of the others.
GPS_FAF, // Final approach fix
GPS_MAP, // Missed approach point
GPS_MAHP, // Initial missed approach holding point.
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_APP_NONE // Not part of the approach sequence - the default.
@ -74,18 +74,18 @@ std::ostream& operator << (std::ostream& os, GPSAppWpType type);
struct GPSWaypoint {
GPSWaypoint();
GPSWaypoint(const std::string& aIdent, float lat, float lon, GPSWpType aType);
static GPSWaypoint* createFromPositioned(const FGPositioned* aFix);
GPSWaypoint(const std::string& aIdent, float lat, float lon, GPSWpType aType);
static GPSWaypoint* createFromPositioned(const FGPositioned* aFix);
~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 id;
float lat; // Radians
float lon; // Radians
GPSWpType type;
GPSAppWpType appType; // only used for waypoints that are part of an approach sequence
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;
float lat; // Radians
float lon; // Radians
GPSWpType type;
GPSAppWpType appType; // only used for waypoints that are part of an approach sequence
};
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::const_iterator gps_waypoint_map_const_iterator;
class GPSFlightPlan {
class GPSFlightPlan
{
public:
std::vector<GPSWaypoint*> waypoints;
inline bool IsEmpty() { return waypoints.empty(); }
std::vector<GPSWaypoint*> waypoints;
inline bool IsEmpty() { return waypoints.empty(); }
};
// TODO - probably de-public the internals of the next 2 classes and add some methods!
// Instrument approach procedure base class
class FGIAP {
class FGIAP
{
public:
FGIAP();
virtual ~FGIAP() = 0;
//protected:
FGIAP();
virtual ~FGIAP() = 0;
std::string _aptIdent; // The ident of the airport this approach is for
std::string _ident; // The approach ident.
std::string _name; // The full approach name.
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.
//protected:
std::string _aptIdent; // The ident of the airport this approach is for
std::string _ident; // The approach ident.
std::string _name; // The full approach name.
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
class FGNPIAP : public FGIAP {
class FGNPIAP : public FGIAP
{
public:
FGNPIAP();
~FGNPIAP();
FGNPIAP();
~FGNPIAP();
//private:
public:
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.
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.
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.
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.
};
typedef std::vector < FGIAP* > iap_list_type;
typedef std::map < std::string, iap_list_type > iap_map_type;
typedef iap_map_type::iterator iap_map_iterator;
// A class to encapsulate hr:min representation of time.
class ClockTime {
// A class to encapsulate hr:min representation of time.
class ClockTime
{
public:
ClockTime();
ClockTime(int hr, int min);
~ClockTime();
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 int min() const { return(_min); }
ClockTime operator+ (const ClockTime& t) {
int cumMin = _hr * 60 + _min + t.hr() * 60 + t.min();
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
// with the origin at the threshold and the runway aligned with the y axis.
class AlignedProjection {
class AlignedProjection
{
public:
AlignedProjection();
AlignedProjection(const SGGeod& centre, double heading);
@ -184,311 +188,312 @@ public:
SGGeod ConvertFromLocal(const SGVec3d& pt);
private:
SGGeod _origin; // lat/lon of local area origin (the threshold)
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.
SGGeod _origin; // lat/lon of local area origin (the threshold)
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.
};
// ------------------------------------------------------------------------------
// TODO - merge generic GPS functions instead and split out KLN specific stuff.
class DCLGPS : public SGSubsystem {
class DCLGPS : public SGSubsystem
{
public:
DCLGPS(RenderArea2D* instrument);
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);
DCLGPS(RenderArea2D* instrument);
virtual ~DCLGPS() = 0;
// 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:
// 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 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
// 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:
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).
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);
// 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;
// helper to implement the above FindFirstXXX methods
FGPositioned* FindTypedFirstById(const std::string& id, FGPositioned::Type ty, bool &multi, bool exact);
// 2D rendering area
RenderArea2D* _instrument;
// 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.
// 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
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 _lat_node;
SGPropertyNode_ptr _alt_node;
SGPropertyNode_ptr _grnd_speed_node;
SGPropertyNode_ptr _true_track_node;
SGPropertyNode_ptr _mag_track_node;
// Present position. (Radians)
double _lat, _lon;
// Present altitude (ft). (Yuk! but it saves converting ft->m->ft every update).
double _alt;
// Reported position as measured by GPS. For now this is the same
// as present position, but in the future we might want to model
// GPS lat and lon errors.
// Note - we can depriciate _gpsLat and _gpsLon if we implement error handling in FG
// gps code and not our own.
double _gpsLat, _gpsLon; //(Radians)
// 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
// plan leg and anything else that might be affected.
// TODO - sort FlightGear's initialisation order properly!!!
double _checkLat, _checkLon; // (Radians)
double _groundSpeed_ms; // filtered groundspeed (m/s)
double _groundSpeed_kts; // ditto in knots
double _track; // filtered true track (degrees)
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.
// This includes not receiving adequate signals, and not having an active flightplan entered.
bool _navFlagged;
// Positional functions copied from ATCutils that might get replaced
// INPUT in RADIANS, returns DEGREES!
// Magnetic
double GetMagHeadingFromTo(double latA, double lonA, double latB, double lonB);
// True
//double GetHeadingFromTo(double latA, double lonA, double latB, double lonB);
// Given two positions (lat & lon in RADIANS), get the HORIZONTAL separation (in meters)
//double GetHorizontalSeparation(double lat1, double lon1, double lat2, double lon2);
// Proper great circle positional functions from The Aviation Formulary
// Returns distance in Nm, input in RADIANS.
double GetGreatCircleDistance(double lat1, double lon1, double lat2, double lon2) const;
// Input in RADIANS, output in DEGREES.
// True
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)
// Note that d should be less that 1/4 Earth diameter!
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)
// Note that d should be less that 1/4 Earth diameter!
GPSWaypoint GetPositionOnRadial(const GPSWaypoint& wp1, double d, double h);
// Calculate the current cross-track deviation in nm.
// Returns zero if a sensible value cannot be calculated.
double CalcCrossTrackDeviation() const;
// Calculate the cross-track deviation between 2 arbitrary waypoints in nm.
// Returns zero if a sensible value cannot be calculated.
double CalcCrossTrackDeviation(const GPSWaypoint& wp1, const GPSWaypoint& wp2) const;
// Flightplans
// 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.
std::vector<GPSFlightPlan*> _flightPlans;
unsigned int _maxFlightPlans;
GPSFlightPlan* _activeFP;
// Modes of operation.
// 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.
bool _obsMode;
// _dto is set true for DTO operation
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).
bool _fullLegMode;
// In OBS mode we need to know the set OBS heading
int _obsHeading;
// Operational variables
GPSWaypoint _activeWaypoint;
GPSWaypoint _fromWaypoint;
float _dist2Act;
float _crosstrackDist; // UNITS ??????????
double _eta; // ETA in SECONDS to active waypoint.
// Desired track for active leg, true and magnetic, in degrees
double _dtkTrue, _dtkMag;
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 _departed; // Set when groundspeed first exceeds 30kts.
std::string _departureTimeString; // Ditto.
double _elapsedTime; // Elapsed time in seconds since departure
ClockTime _powerOnTime; // Time (hr:min) of unit power-up.
bool _powerOnTimerSet; // Indicates that we have set the above following power-up.
void SetPowerOnTimer();
SGPropertyNode_ptr _grnd_speed_node;
SGPropertyNode_ptr _true_track_node;
SGPropertyNode_ptr _mag_track_node;
// Present position. (Radians)
double _lat, _lon;
// Present altitude (ft). (Yuk! but it saves converting ft->m->ft every update).
double _alt;
// Reported position as measured by GPS. For now this is the same
// as present position, but in the future we might want to model
// GPS lat and lon errors.
// Note - we can depriciate _gpsLat and _gpsLon if we implement error handling in FG
// gps code and not our own.
double _gpsLat, _gpsLon; //(Radians)
// 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
// plan leg and anything else that might be affected.
// TODO - sort FlightGear's initialisation order properly!!!
double _checkLat, _checkLon; // (Radians)
double _groundSpeed_ms; // filtered groundspeed (m/s)
double _groundSpeed_kts; // ditto in knots
double _track; // filtered true track (degrees)
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.
// This includes not receiving adequate signals, and not having an active flightplan entered.
bool _navFlagged;
// Positional functions copied from ATCutils that might get replaced
// INPUT in RADIANS, returns DEGREES!
// Magnetic
double GetMagHeadingFromTo(double latA, double lonA, double latB, double lonB);
// True
//double GetHeadingFromTo(double latA, double lonA, double latB, double lonB);
// Given two positions (lat & lon in RADIANS), get the HORIZONTAL separation (in meters)
//double GetHorizontalSeparation(double lat1, double lon1, double lat2, double lon2);
// Proper great circle positional functions from The Aviation Formulary
// Returns distance in Nm, input in RADIANS.
double GetGreatCircleDistance(double lat1, double lon1, double lat2, double lon2) const;
// Input in RADIANS, output in DEGREES.
// True
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)
// Note that d should be less that 1/4 Earth diameter!
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)
// Note that d should be less that 1/4 Earth diameter!
GPSWaypoint GetPositionOnRadial(const GPSWaypoint& wp1, double d, double h);
// Calculate the current cross-track deviation in nm.
// Returns zero if a sensible value cannot be calculated.
double CalcCrossTrackDeviation() const;
// Calculate the cross-track deviation between 2 arbitrary waypoints in nm.
// Returns zero if a sensible value cannot be calculated.
double CalcCrossTrackDeviation(const GPSWaypoint& wp1, const GPSWaypoint& wp2) const;
// Flightplans
// 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.
std::vector<GPSFlightPlan*> _flightPlans;
unsigned int _maxFlightPlans;
GPSFlightPlan* _activeFP;
// Modes of operation.
// 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.
bool _obsMode;
// _dto is set true for DTO operation
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).
bool _fullLegMode;
// In OBS mode we need to know the set OBS heading
int _obsHeading;
// Operational variables
GPSWaypoint _activeWaypoint;
GPSWaypoint _fromWaypoint;
float _dist2Act;
float _crosstrackDist; // UNITS ??????????
double _eta; // ETA in SECONDS to active waypoint.
// Desired track for active leg, true and magnetic, in degrees
double _dtkTrue, _dtkMag;
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 _departed; // Set when groundspeed first exceeds 30kts.
std::string _departureTimeString; // Ditto.
double _elapsedTime; // Elapsed time in seconds since departure
ClockTime _powerOnTime; // Time (hr:min) of unit power-up.
bool _powerOnTimerSet; // Indicates that we have set the above following power-up.
void SetPowerOnTimer();
public:
void ResetPowerOnTimer();
// Set the alarm to go off at a given time.
inline void SetAlarm(int hr, int min) {
_alarmTime.set_hr(hr);
_alarmTime.set_min(min);
_alarmSet = true;
}
void ResetPowerOnTimer();
// Set the alarm to go off at a given time.
inline void SetAlarm(int hr, int min) {
_alarmTime.set_hr(hr);
_alarmTime.set_min(min);
_alarmSet = true;
}
protected:
ClockTime _alarmTime;
bool _alarmSet;
// Configuration that affects flightplan operation
bool _turnAnticipationEnabled;
ClockTime _alarmTime;
bool _alarmSet;
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:
simgear::TiedPropertyList _tiedProperties;
simgear::TiedPropertyList _tiedProperties;
};
#endif // _DCLGPS_HXX

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -34,7 +34,8 @@
class SGSampleGroup;
class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
class FGNavRadio : public AbstractInstrument,
public SGPropertyChangeListener
{
SGPropertyNode_ptr _radio_node;
@ -53,7 +54,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
SGPropertyNode_ptr cdi_serviceable_node;
SGPropertyNode_ptr gs_serviceable_node;
SGPropertyNode_ptr tofrom_serviceable_node;
// property outputs
SGPropertyNode_ptr fmt_freq_node; // formated 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_xtrack_error_nm_node;
SGPropertyNode_ptr _magvarNode;
// realism setting, are false courses and GS lobes enabled?
SGPropertyNode_ptr falseCoursesEnabledNode;
@ -117,7 +118,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
double _last_freq;
FGNavRecordRef _navaid;
FGNavRecordRef _gs;
double target_radial;
double effective_range;
double target_gs;
@ -142,16 +143,16 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
double _gsDirect;
class AudioIdent * _audioIdent;
bool updateWithPower(double aDt);
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
double adjustNavRange( double stationElev, double aircraftElev,
double nominalRange );
double nominalRange );
// model standard ILS service volumes as per AIM 1-1-9
double adjustILSRange( double stationElev, double aircraftElev,
double offsetDegrees, double distance );
double offsetDegrees, double distance );
void updateAudio( double dt );
@ -160,16 +161,15 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener
void updateGPSSlaved();
void updateCDI(double dt);
void updateFormattedFrequencies();
void clearOutputs();
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();
@ -182,5 +182,4 @@ public:
void updateNav();
};
#endif // _FG_NAVRADIO_HXX

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,7 @@
/**
* 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.
*
* Input properties:
@ -37,9 +37,7 @@
*/
class TurnIndicator : public SGSubsystem
{
public:
TurnIndicator ( SGPropertyNode *node );
virtual ~TurnIndicator ();
@ -50,7 +48,6 @@ public:
virtual void update (double dt);
private:
Gyro _gyro;
double _last_rate;
@ -61,7 +58,6 @@ private:
SGPropertyNode_ptr _yaw_rate_node;
SGPropertyNode_ptr _electric_current_node;
SGPropertyNode_ptr _rate_out_node;
};
#endif // __INSTRUMENTS_TURN_INDICATOR_HXX

View file

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

View file

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

View file

@ -55,20 +55,17 @@ public:
*/
static bool isMultiplayerRequested();
private:
void add_channel(const std::string& config);
FGProtocol* parse_port_config( const std::string& cfgstr );
private:
// define the global I/O channel list
//io_container global_io_list;
typedef std::vector< FGProtocol* > ProtocolVec;
ProtocolVec io_channels;
SGPropertyNode_ptr _realDeltaTime;
};
#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.
*/
extern SGPropertyNode * fgGetNode (const char * path,
int index, bool create = false);
int index, bool create = false);
/**
* 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.
*/
inline SGPropertyNode * fgGetNode (const std::string & path,
int index, bool create = false)
int index, bool create = false)
{
return fgGetNode(path.c_str(), index, create );
}
@ -179,7 +179,7 @@ inline bool fgHasNode (const std::string & path)
* any given in the string).
*/
extern void fgAddChangeListener (SGPropertyChangeListener * listener,
const char * path);
const char * path);
/**
* Add a listener to a node.
@ -190,7 +190,7 @@ extern void fgAddChangeListener (SGPropertyChangeListener * listener,
* any given in the string).
*/
inline void fgAddChangeListener (SGPropertyChangeListener * listener,
const std::string & path)
const std::string & path)
{
fgAddChangeListener( listener, path.c_str() );
}
@ -205,7 +205,7 @@ inline void fgAddChangeListener (SGPropertyChangeListener * listener,
* any given in the string).
*/
extern void fgAddChangeListener (SGPropertyChangeListener * listener,
const char * path, int index);
const char * path, int index);
/**
* Add a listener to a node.
@ -216,7 +216,7 @@ extern void fgAddChangeListener (SGPropertyChangeListener * listener,
* any given in the string).
*/
inline void fgAddChangeListener (SGPropertyChangeListener * listener,
const std::string & path, int index)
const std::string & path, int 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.
*/
extern const char * fgGetString (const char * name,
const char * defaultValue = "");
const char * defaultValue = "");
/**
* 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 getter The getter function, or 0 if the value is unreadable.
* @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
* discarded; defaults to true.
*/
@ -731,9 +731,9 @@ fgTie (const char * name, V (*getter)(), void (*setter)(V) = 0,
bool useDefault = true)
{
if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter),
useDefault))
useDefault))
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.
* @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 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
* 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)
{
if (!globals->get_props()->tie(name,
SGRawValueFunctionsIndexed<V>(index,
getter,
setter),
useDefault))
SGRawValueFunctionsIndexed<V>(index,
getter,
setter),
useDefault))
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.
* @param setter The object's 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
* 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)
{
if (!globals->get_props()->tie(name,
SGRawValueMethods<T,V>(*obj, getter, setter),
useDefault))
SGRawValueMethods<T,V>(*obj, getter, setter),
useDefault))
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.
* @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 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
* discarded; defaults to true.
*/
template <class T, class V>
inline void
inline void
fgTie (const char * name, T * obj, int index,
V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
bool useDefault = true)
{
if (!globals->get_props()->tie(name,
SGRawValueMethodsIndexed<T,V>(*obj,
index,
getter,
setter),
useDefault))
SGRawValueMethodsIndexed<T,V>(*obj,
index,
getter,
setter),
useDefault))
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
{
public:
// Implementation of SGSubsystem
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
// Implementation of SGSubsystem
virtual void init ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
private:
/**
* A single instance of a log file (the logger can contain many).
*/
struct Log {
Log ();
/**
* A single instance of a log file (the logger can contain many).
*/
struct Log {
Log ();
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<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;
};
#endif // __LOGGER_HXX

View file

@ -11,7 +11,7 @@
#include <osg/Switch>
#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.
@ -21,32 +21,32 @@ class FGFX;
class FGAircraftModel : public SGSubsystem
{
public:
FGAircraftModel ();
virtual ~FGAircraftModel ();
FGAircraftModel ();
virtual ~FGAircraftModel ();
virtual void init ();
virtual void shutdown ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
virtual SGModelPlacement * get3DModel() { return _aircraft.get(); }
virtual SGVec3d& getVelocity() { return _velocity; }
virtual void init ();
virtual void shutdown ();
virtual void reinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
virtual SGModelPlacement * get3DModel() { return _aircraft.get(); }
virtual SGVec3d& getVelocity() { return _velocity; }
static const char* subsystemName() { return "aircraft-model"; }
private:
void deinit ();
void deinit ();
std::unique_ptr<SGModelPlacement> _aircraft;
std::unique_ptr<SGModelPlacement> _interior;
SGVec3d _velocity;
SGSharedPtr<FGFX> _fx;
SGPropertyNode_ptr _speed_n;
SGPropertyNode_ptr _speed_e;
SGPropertyNode_ptr _speed_d;
SGVec3d _velocity;
SGSharedPtr<FGFX> _fx;
SGPropertyNode_ptr _speed_n;
SGPropertyNode_ptr _speed_e;
SGPropertyNode_ptr _speed_d;
};
#endif // __ACMODEL_HXX

View file

@ -9,7 +9,7 @@
#include <vector>
#include <memory>
#include <simgear/compiler.h> // for SG_USING_STD
#include <simgear/compiler.h> // for SG_USING_STD
#include <simgear/structure/subsystem_mgr.hxx>
// Don't pull in headers, since we don't need them here.
@ -23,88 +23,87 @@ class SGModelPlacement;
class FGModelMgr : public SGSubsystem
{
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;
};
/**
* 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 ();
virtual ~FGModelMgr ();
FGModelMgr ();
virtual ~FGModelMgr ();
virtual void init ();
virtual void shutdown ();
virtual void init ();
virtual void shutdown ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
virtual void add_model (SGPropertyNode * node);
virtual void add_model (SGPropertyNode * node);
/**
* Add an instance of a dynamic model to the 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
* location and orientation of the model based on the current
* values of the properties.
*/
virtual void add_instance (Instance * instance);
/**
* Add an instance of a dynamic model to the 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
* location and orientation of the model based on the current
* values of the properties.
*/
virtual void add_instance (Instance * instance);
/**
* Remove an instance of a dynamic model from the manager.
*
* NOTE: the manager will delete the instance as well.
*/
virtual void remove_instance (Instance * instance);
/**
* Remove an instance of a dynamic model from the manager.
*
* NOTE: the manager will delete the instance as well.
*/
virtual void remove_instance (Instance * instance);
static const char* subsystemName() { return "model-manager"; }
private:
/**
* Listener class that adds models at runtime.
*/
class Listener : public SGPropertyChangeListener
{
public:
Listener(FGModelMgr *mgr) : _mgr(mgr) {}
virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child);
virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child);
/**
* Listener class that adds models at runtime.
*/
class Listener : public SGPropertyChangeListener
{
public:
Listener(FGModelMgr *mgr) : _mgr(mgr) {}
virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child);
virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child);
private:
FGModelMgr * _mgr;
};
private:
FGModelMgr * _mgr;
};
SGPropertyNode_ptr _models;
std::unique_ptr<Listener> _listener;
SGPropertyNode_ptr _models;
std::unique_ptr<Listener> _listener;
std::vector<Instance *> _instances;
};
#endif // __MODELMGR_HXX

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