| 1 | /* |
| 2 | * SPDX-License-Identifier: GPL-2.0+ |
| 3 | * SPDX-FileCopyrightText: 2008 (C) Vivain MEAZZA - [email protected] |
| 4 | * |
| 5 | * Radar Altimeter |
| 6 | * Written by Vivian MEAZZA, started Feb 2008. |
| 7 | * |
| 8 | * Copyright (C) 2008 Vivain MEAZZA - [email protected] |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of the |
| 13 | * License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 23 | */ |
| 24 | |
| 25 | #pragma once |
| 26 | |
| 27 | #include <simgear/structure/subsystem_mgr.hxx> |
| 28 | #include <simgear/props/props.hxx> |
| 29 | #include <simgear/math/SGMath.hxx> |
| 30 | |
| 31 | class RadarAltimeter : public SGSubsystem |
| 32 | { |
| 33 | public: |
| 34 | RadarAltimeter ( SGPropertyNode *node ); |
| 35 | virtual ~RadarAltimeter (); |
| 36 | |
| 37 | // Subsystem API. |
| 38 | void init() override; |
| 39 | void update(double dt) override; |
| 40 | |
| 41 | // Subsystem identification. |
| 42 | static const char* staticSubsystemClassId() { return "radar-altimeter"; } |
| 43 | |
| 44 | private: |
| 45 | void update_altitude(); |
| 46 | void updateSetHeight(); |
| 47 | |
| 48 | double getDistanceAntennaToHit(const SGVec3d& h) const; |
| 49 | SGVec3d getCartAntennaPos()const; |
| 50 | |
| 51 | SGVec3d rayVector(double az, double el) const; |
| 52 | |
| 53 | SGPropertyNode_ptr _Instrument; |
| 54 | SGPropertyNode_ptr _user_alt_agl_node; |
| 55 | SGPropertyNode_ptr _rad_alt_warning_node; |
| 56 | SGPropertyNode_ptr _serviceable_node; |
| 57 | SGPropertyNode_ptr _sceneryLoaded; |
| 58 | |
| 59 | SGVec3d _antennaOffset; // in aircraft local XYZ frame |
| 60 | |
| 61 | std::string _name; |
| 62 | int _num; |
| 63 | double _time; |
| 64 | double _interval; |
| 65 | |
| 66 | double _min_radalt; |
| 67 | }; |