4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_VEGA_SWITCH_STATE_HPP
25 #define XCSOAR_VEGA_SWITCH_STATE_HPP
27 struct VegaSwitchState
{
28 static constexpr unsigned INVALID
= -1;
31 INPUT_FLAP_POSITIVE
= 0,
33 INPUT_FLAP_NEGATIVE
= 2,
34 INPUT_SPEED_COMMAND
= 3,
35 INPUT_GEAR_EXTENDED
= 5,
36 INPUT_AIRBRAKE_NOT_LOCKED
= 6,
37 INPUT_ACKNOWLEDGE
= 8,
40 INPUT_AIRBRAKE_LOCKED
= 21,
41 INPUT_USER_SWITCH_UP
= 23,
42 INPUT_USER_SWITCH_MIDDLE
= 24,
43 INPUT_USER_SWITCH_DOWN
= 25,
48 OUTPUT_FLAP_LANDING
= 7,
51 static constexpr unsigned INPUT_MASK_FLAP_POSITIVE
= 1 << INPUT_FLAP_POSITIVE
;
52 static constexpr unsigned INPUT_MASK_FLAP_ZERO
= 1 << INPUT_FLAP_ZERO
;
53 static constexpr unsigned INPUT_MASK_FLAP_NEGATIVE
= 1 << INPUT_FLAP_NEGATIVE
;
54 static constexpr unsigned INPUT_MASK_SC
= 1 << INPUT_SPEED_COMMAND
;
55 static constexpr unsigned INPUT_MASK_GEAR_EXTENDED
= 1 << INPUT_GEAR_EXTENDED
;
56 static constexpr unsigned INPUT_MASK_AIRBRAKE_NOT_LOCKED
= 1 << INPUT_AIRBRAKE_NOT_LOCKED
;
57 static constexpr unsigned INPUT_MASK_ACK
= 1 << INPUT_ACKNOWLEDGE
;
58 static constexpr unsigned INPUT_MASK_REP
= 1 << INPUT_REPEAT
;
59 static constexpr unsigned INPUT_MASK_AIRBRAKE_LOCKED
= 1 << INPUT_AIRBRAKE_LOCKED
;
60 static constexpr unsigned INPUT_MASK_USER_SWITCH_UP
= 1 << INPUT_USER_SWITCH_UP
;
61 static constexpr unsigned INPUT_MASK_USER_SWITCH_MIDDLE
= 1 << INPUT_USER_SWITCH_MIDDLE
;
62 static constexpr unsigned INPUT_MASK_USER_SWITCH_DOWN
= 1 << INPUT_USER_SWITCH_DOWN
;
63 static constexpr unsigned OUTPUT_MASK_CIRCLING
= 1 << OUTPUT_CIRCLING
;
64 static constexpr unsigned OUTPUT_MASK_FLAP_LANDING
= 1 << OUTPUT_FLAP_LANDING
;
66 unsigned inputs
, outputs
;
68 constexpr bool IsDefined() const {
69 return inputs
!= 0 || outputs
!= 0;
76 void Complement(const VegaSwitchState
&add
) {
81 constexpr bool GetFlapPositive() const {
82 return inputs
& INPUT_MASK_FLAP_POSITIVE
;
85 constexpr bool GetFlapZero() const {
86 return inputs
& INPUT_MASK_FLAP_ZERO
;
89 constexpr bool GetFlapNegative() const {
90 return inputs
& INPUT_MASK_FLAP_NEGATIVE
;
93 constexpr bool GetSpeedCommand() const {
94 return inputs
& INPUT_MASK_SC
;
97 constexpr bool GetGearExtended() const {
98 return inputs
& INPUT_MASK_GEAR_EXTENDED
;
101 constexpr bool GetAirbrakeNotLocked() const {
102 return inputs
& INPUT_MASK_AIRBRAKE_NOT_LOCKED
;
105 constexpr bool GetAcknowledge() const {
106 return inputs
& INPUT_MASK_ACK
;
109 constexpr bool GetRepeat() const {
110 return inputs
& INPUT_MASK_REP
;
113 constexpr bool GetAirbrakeLocked() const {
114 return inputs
& INPUT_MASK_AIRBRAKE_LOCKED
;
117 constexpr bool GetUserSwitchUp() const {
118 return inputs
& INPUT_MASK_USER_SWITCH_UP
;
121 constexpr bool GetUserSwitchMiddle() const {
122 return inputs
& INPUT_MASK_USER_SWITCH_MIDDLE
;
125 constexpr bool GetUserSwitchDown() const {
126 return inputs
& INPUT_MASK_USER_SWITCH_DOWN
;
129 constexpr bool GetCircling() const {
130 return outputs
& OUTPUT_MASK_CIRCLING
;
133 constexpr bool GetFlapLanding() const {
134 return outputs
& OUTPUT_MASK_FLAP_LANDING
;