| 1 | /* |
| 2 | * SPDX-License-Identifier: CC0-1.0 |
| 3 | * |
| 4 | * heading_indicator_fg.hxx - an electrically-powered fluxgate compass. |
| 5 | * Written by David Megginson, started 2002. |
| 6 | * |
| 7 | * This file is in the Public Domain and comes with no warranty. |
| 8 | */ |
| 9 | |
| 10 | #pragma once |
| 11 | |
| 12 | #ifndef __cplusplus |
| 13 | # error This library requires C++ |
| 14 | #endif |
| 15 | |
| 16 | #include <simgear/props/props.hxx> |
| 17 | |
| 18 | #include <Instrumentation/AbstractInstrument.hxx> |
| 19 | |
| 20 | #include "gyro.hxx" |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * Model an electrically-powered fluxgate compass |
| 25 | * |
| 26 | * Input properties: |
| 27 | * |
| 28 | * /instrumentation/"name"/serviceable |
| 29 | * /instrumentation/"name"/spin |
| 30 | * /instrumentation/"name"/offset-deg |
| 31 | * /orientation/heading-deg |
| 32 | * /systems/electrical/outputs/"name"["number"] |
| 33 | * |
| 34 | * Output properties: |
| 35 | * |
| 36 | * /instrumentation/"name"/indicated-heading-deg |
| 37 | */ |
| 38 | class HeadingIndicatorFG : public AbstractInstrument |
| 39 | { |
| 40 | public: |
| 41 | HeadingIndicatorFG ( SGPropertyNode *node ); |
| 42 | HeadingIndicatorFG (); |
| 43 | virtual ~HeadingIndicatorFG (); |
| 44 | |
| 45 | // Subsystem API. |
| 46 | //void bind() override; |
| 47 | void init() override; |
| 48 | void reinit() override; |
| 49 | //void unbind() override; |
| 50 | void update(double dt) override; |
| 51 | |
| 52 | // Subsystem identification. |
| 53 | static const char* staticSubsystemClassId() { return "heading-indicator-fg"; } |
| 54 | |
| 55 | private: |
| 56 | Gyro _gyro; |
| 57 | double _last_heading_deg; |
| 58 | |
| 59 | SGPropertyNode_ptr _offset_node; |
| 60 | SGPropertyNode_ptr _heading_in_node; |
| 61 | SGPropertyNode_ptr _serviceable_node; |
| 62 | SGPropertyNode_ptr _heading_out_node; |
| 63 | SGPropertyNode_ptr _electrical_node; |
| 64 | SGPropertyNode_ptr _error_node; |
| 65 | SGPropertyNode_ptr _nav1_error_node; |
| 66 | SGPropertyNode_ptr _off_node; |
| 67 | SGPropertyNode_ptr _spin_node; |
| 68 | }; |