| 1 | /* |
| 2 | * SPDX-License-Identifier: CC0-1.0 |
| 3 | * |
| 4 | * tacan.hxx - Models a TACAN (Tactical Air Navigation) Radio |
| 5 | * Written by David Megginson, started 2003. |
| 6 | * |
| 7 | * This file is in the Public Domain and comes with no warranty. |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | |
| 12 | |
| 13 | #pragma once |
| 14 | |
| 15 | #include <simgear/props/props.hxx> |
| 16 | #include <simgear/structure/subsystem_mgr.hxx> |
| 17 | |
| 18 | |
| 19 | /** |
| 20 | * Model a TACAN radio. |
| 21 | * |
| 22 | * Input properties: |
| 23 | * |
| 24 | * /position/longitude-deg |
| 25 | * /position/latitude-deg |
| 26 | * /position/altitude-ft |
| 27 | * /heading |
| 28 | * /systems/electrical/outputs/TACAN |
| 29 | * /instrumentation/"name"/serviceable |
| 30 | * /instrumentation/"name"/frequencies/selected-mhz |
| 31 | * |
| 32 | * Output properties: |
| 33 | * |
| 34 | * /instrumentation/"name"/in-range |
| 35 | * /instrumentation/"name"/indicated-distance-nm |
| 36 | * /instrumentation/"name"/indicated-ground-speed-kt |
| 37 | * /instrumentation/"name"/indicated-time-kt |
| 38 | */ |
| 39 | class TACAN : public SGSubsystem, |
| 40 | public SGPropertyChangeListener |
| 41 | { |
| 42 | public: |
| 43 | TACAN(SGPropertyNode *node); |
| 44 | virtual ~TACAN(); |
| 45 | |
| 46 | // Subsystem API. |
| 47 | void init() override; |
| 48 | void reinit() override; |
| 49 | void update(double delta_time_sec) override; |
| 50 | |
| 51 | // Subsystem identification. |
| 52 | static const char* staticSubsystemClassId() { return "tacan"; } |
| 53 | |
| 54 | private: |
| 55 | void disabled(bool force = false); |
| 56 | |
| 57 | void search (double frequency, const SGGeod& pos); |
| 58 | double searchChannel (const std::string& channel); |
| 59 | void valueChanged (SGPropertyNode *); |
| 60 | |
| 61 | std::string _name; |
| 62 | unsigned int _num; |
| 63 | |
| 64 | SGPropertyNode_ptr _heading_node; |
| 65 | SGPropertyNode_ptr _serviceable_node; |
| 66 | SGPropertyNode_ptr _electrical_node; |
| 67 | SGPropertyNode_ptr _frequency_node; |
| 68 | SGPropertyNode_ptr _display_node; |
| 69 | SGPropertyNode_ptr _x_shift_node; |
| 70 | SGPropertyNode_ptr _y_shift_node; |
| 71 | |
| 72 | SGPropertyNode_ptr _in_range_node; |
| 73 | SGPropertyNode_ptr _distance_node; |
| 74 | SGPropertyNode_ptr _speed_node; |
| 75 | SGPropertyNode_ptr _time_node; |
| 76 | SGPropertyNode_ptr _bearing_node; |
| 77 | SGPropertyNode_ptr _ident_node; |
| 78 | SGPropertyNode_ptr _name_node; |
| 79 | |
| 80 | SGPropertyNode_ptr _channel_node; |
| 81 | SGPropertyNode_ptr _channel_in0_node; |
| 82 | SGPropertyNode_ptr _channel_in1_node; |
| 83 | SGPropertyNode_ptr _channel_in2_node; |
| 84 | SGPropertyNode_ptr _channel_in3_node; |
| 85 | SGPropertyNode_ptr _channel_in4_node; |
| 86 | |
| 87 | bool _was_disabled; |
| 88 | bool _new_frequency; |
| 89 | std::string _channel; |
| 90 | double _last_distance_nm; |
| 91 | double _frequency_mhz; |
| 92 | double _time_before_search_sec; |
| 93 | |
| 94 | FGNavRecordRef _active_station; |
| 95 | |
| 96 | int _listener_active; |
| 97 | }; |