| 1 | /* |
| 2 | * SPDX-License-Identifier: CC0-1.0 |
| 3 | * |
| 4 | * |
| 5 | * Written by David Megginson, started 2002. |
| 6 | * |
| 7 | * Last Edited by Benedikt Wolf 2023 - ported to electrically-powered |
| 8 | * |
| 9 | * This file is in the Public Domain and comes with no warranty. |
| 10 | */ |
| 11 | |
| 12 | #pragma once |
| 13 | |
| 14 | #ifndef __cplusplus |
| 15 | # error This library requires C++ |
| 16 | #endif |
| 17 | |
| 18 | #include <Instrumentation/AbstractInstrument.hxx> |
| 19 | |
| 20 | #include "gyro.hxx" |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * Model an electrically-powered attitude indicator. |
| 25 | * |
| 26 | * Config: |
| 27 | * gyro/spin-up-sec If given, seconds to spin up until power-norm (from 0->100%) |
| 28 | * gyro/spin-down-sec If given, seconds the gyro will loose spin without power (from 100%->0) |
| 29 | * |
| 30 | * Input properties: |
| 31 | * |
| 32 | * /instrumentation/"name"/config/tumble-flag |
| 33 | * /instrumentation/"name"/serviceable |
| 34 | * /instrumentation/"name"/caged-flag |
| 35 | * /instrumentation/"name"/tumble-norm |
| 36 | * /orientation/pitch-deg |
| 37 | * /orientation/roll-deg |
| 38 | * /systems/electrical/outputs/attitude-indicator-electric |
| 39 | * |
| 40 | * Output properties: |
| 41 | * |
| 42 | * /instrumentation/"name"/indicated-pitch-deg |
| 43 | * /instrumentation/"name"/indicated-roll-deg |
| 44 | * /instrumentation/"name"/tumble-norm |
| 45 | * /instrumentation/"name"/off-flag |
| 46 | */ |
| 47 | class AttitudeIndicatorElectric : public AbstractInstrument |
| 48 | { |
| 49 | public: |
| 50 | AttitudeIndicatorElectric ( SGPropertyNode *node ); |
| 51 | virtual ~AttitudeIndicatorElectric (); |
| 52 | |
| 53 | // Subsystem API. |
| 54 | void init() override; |
| 55 | void reinit() override; |
| 56 | void update(double dt) override; |
| 57 | |
| 58 | // Subsystem identification. |
| 59 | static const char* staticSubsystemClassId() { return "attitude-indicator-electric"; } |
| 60 | |
| 61 | private: |
| 62 | Gyro _gyro; |
| 63 | double _gyro_spin_up, _gyro_spin_down; |
| 64 | |
| 65 | SGPropertyNode_ptr _tumble_flag_node; |
| 66 | SGPropertyNode_ptr _caged_node; |
| 67 | SGPropertyNode_ptr _tumble_node; |
| 68 | SGPropertyNode_ptr _pitch_in_node; |
| 69 | SGPropertyNode_ptr _roll_in_node; |
| 70 | SGPropertyNode_ptr _pitch_int_node; |
| 71 | SGPropertyNode_ptr _roll_int_node; |
| 72 | SGPropertyNode_ptr _pitch_out_node; |
| 73 | SGPropertyNode_ptr _roll_out_node; |
| 74 | SGPropertyNode_ptr _off_node; |
| 75 | SGPropertyNode_ptr _spin_node, _gyro_spin_up_node, _gyro_spin_down_node; |
| 76 | |
| 77 | double spin_thresh; |
| 78 | double max_roll_error; |
| 79 | double max_pitch_error; |
| 80 | }; |