| 1 | /* |
| 2 | * SPDX-License-Identifier: CC0-1.0 |
| 3 | * |
| 4 | * airspeed_indicator.hxx - a regular ASI tied to the static port. |
| 5 | * Written by David Megginson, started 2002. |
| 6 | * Last modified by Eric van den Berg, 24 Nov 2012 |
| 7 | * |
| 8 | * This file is in the Public Domain and comes with no warranty. |
| 9 | */ |
| 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | #ifndef __cplusplus |
| 14 | # error This library requires C++ |
| 15 | #endif |
| 16 | |
| 17 | #include <simgear/props/props.hxx> |
| 18 | #include <simgear/structure/subsystem_mgr.hxx> |
| 19 | |
| 20 | // forward decls |
| 21 | class FGEnvironmentMgr; |
| 22 | |
| 23 | /** |
| 24 | * Model an airspeed indicator tied to the pitot and static ports. |
| 25 | * |
| 26 | * Input properties: |
| 27 | * |
| 28 | * /instrumentation/"name"/serviceable |
| 29 | * "pitot_port"/total-pressure-inhg |
| 30 | * "static_port"/pressure-inhg |
| 31 | * /environment/density-slugft3 |
| 32 | * |
| 33 | * Output properties: |
| 34 | * |
| 35 | * /instrumentation/"name"/indicated-speed-kt |
| 36 | * /instrumentation/"name"/true-speed-kt |
| 37 | * /instrumentation/"name"/indicated-mach |
| 38 | */ |
| 39 | class AirspeedIndicator : public SGSubsystem |
| 40 | { |
| 41 | public: |
| 42 | AirspeedIndicator ( SGPropertyNode *node ); |
| 43 | virtual ~AirspeedIndicator (); |
| 44 | |
| 45 | // Subsystem API. |
| 46 | void init() override; |
| 47 | void reinit() override; |
| 48 | void update(double dt) override; |
| 49 | |
| 50 | // Subsystem identification. |
| 51 | static const char* staticSubsystemClassId() { return "airspeed-indicator"; } |
| 52 | |
| 53 | private: |
| 54 | void computeMach(); |
| 55 | |
| 56 | std::string _name; |
| 57 | unsigned int _num; |
| 58 | std::string _total_pressure; |
| 59 | std::string _static_pressure; |
| 60 | bool _has_overspeed; |
| 61 | std::string _pressure_alt_source; |
| 62 | double _ias_limit; |
| 63 | double _mach_limit; |
| 64 | double _alt_threshold; |
| 65 | |
| 66 | SGPropertyNode_ptr _ias_limit_node; |
| 67 | SGPropertyNode_ptr _mach_limit_node; |
| 68 | SGPropertyNode_ptr _alt_threshold_node; |
| 69 | SGPropertyNode_ptr _serviceable_node; |
| 70 | SGPropertyNode_ptr _total_pressure_node; |
| 71 | SGPropertyNode_ptr _static_pressure_node; |
| 72 | SGPropertyNode_ptr _density_node; |
| 73 | SGPropertyNode_ptr _speed_node; |
| 74 | SGPropertyNode_ptr _airspeed_limit; |
| 75 | SGPropertyNode_ptr _pressure_alt; |
| 76 | SGPropertyNode_ptr _mach_node; |
| 77 | SGPropertyNode_ptr _tas_node; |
| 78 | |
| 79 | FGEnvironmentMgr* _environmentManager; |
| 80 | }; |