| 1 | /* |
| 2 | * SPDX-License-Identifier: CC0-1.0 |
| 3 | * |
| 4 | * altimeter.hxx - an altimeter tied to the static port. |
| 5 | * Written by David Megginson, started 2002. |
| 6 | * Updated by John Denker to match changes in altimeter.cxx in 2007 |
| 7 | * |
| 8 | * This file is in the Public Domain and comes with no warranty. |
| 9 | */ |
| 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | #include <simgear/props/props.hxx> |
| 14 | #include <simgear/props/tiedpropertylist.hxx> |
| 15 | #include <simgear/structure/subsystem_mgr.hxx> |
| 16 | #include <Environment/atmosphere.hxx> |
| 17 | |
| 18 | |
| 19 | /** |
| 20 | * Model a barometric altimeter tied to the static port. |
| 21 | * |
| 22 | * Input properties: |
| 23 | * |
| 24 | * /instrumentation/<name>/serviceable |
| 25 | * /instrumentation/<name>/setting-inhg |
| 26 | * <static_pressure> |
| 27 | * |
| 28 | * Output properties: |
| 29 | * |
| 30 | * /instrumentation/<name>/indicated-altitude-ft |
| 31 | */ |
| 32 | class Altimeter : public SGSubsystem |
| 33 | { |
| 34 | public: |
| 35 | Altimeter (SGPropertyNode *node, const std::string& aDefaultName, double quantum = 0); |
| 36 | virtual ~Altimeter (); |
| 37 | |
| 38 | // Subsystem API. |
| 39 | void bind() override; |
| 40 | void init() override; |
| 41 | void reinit() override; |
| 42 | void unbind() override; |
| 43 | void update(double dt) override; |
| 44 | |
| 45 | // Subsystem identification. |
| 46 | static const char* staticSubsystemClassId() { return "altimeter"; } |
| 47 | |
| 48 | double getSettingInHg() const; |
| 49 | void setSettingInHg( double value ); |
| 50 | double getSettingHPa() const; |
| 51 | void setSettingHPa( double value ); |
| 52 | |
| 53 | private: |
| 54 | std::string _name; |
| 55 | int _num; |
| 56 | SGPropertyNode_ptr _rootNode; |
| 57 | std::string _static_pressure; |
| 58 | double _tau; |
| 59 | double _quantum; |
| 60 | double _kollsman; |
| 61 | double _raw_PA; |
| 62 | double _settingInHg; |
| 63 | bool _encodeModeC; |
| 64 | bool _encodeModeS; |
| 65 | |
| 66 | SGPropertyNode_ptr _serviceable_node; |
| 67 | SGPropertyNode_ptr _pressure_node; |
| 68 | SGPropertyNode_ptr _press_alt_node; |
| 69 | SGPropertyNode_ptr _mode_c_node; |
| 70 | SGPropertyNode_ptr _mode_s_node; |
| 71 | SGPropertyNode_ptr _transponder_node; |
| 72 | SGPropertyNode_ptr _altitude_node; |
| 73 | |
| 74 | FGAltimeter _altimeter; |
| 75 | |
| 76 | simgear::TiedPropertyList _tiedProperties; |
| 77 | }; |