3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "TaskAdvanceSmart.hpp"
24 #include "Task/Points/TaskPoint.hpp"
25 #include "Points/StartPoint.hpp"
26 #include "Points/AATPoint.hpp"
27 #include "Points/IntermediatePoint.hpp"
28 #include "Task/Factory/TaskFactoryConstraints.hpp"
30 TaskAdvanceSmart::TaskAdvanceSmart()
31 :state(TaskAdvance::MANUAL
),
32 start_requires_arm(false)
37 TaskAdvanceSmart::SetFactoryConstraints(const TaskFactoryConstraints
&constraints
)
39 start_requires_arm
= constraints
.start_requires_arm
;
43 TaskAdvanceSmart::CheckReadyToAdvance(const TaskPoint
&tp
,
44 const AircraftState
&aircraft
,
45 const bool x_enter
, const bool x_exit
)
47 const bool state_ready
= IsStateReady(tp
, aircraft
, x_enter
, x_exit
);
50 request_armed
= false;
52 if (tp
.GetType() == TaskPointType::START
) {
53 const StartPoint
&sp
= (const StartPoint
&)tp
;
54 if (start_requires_arm
) {
56 state
= TaskAdvance::START_ARMED
;
58 state
= TaskAdvance::START_DISARMED
;
59 if (sp
.IsInSector(aircraft
))
62 return armed
&& state_ready
;
64 state
= TaskAdvance::AUTO
;
67 } else if (tp
.GetType() == TaskPointType::AAT
) {
69 state
= TaskAdvance::TURN_ARMED
;
71 state
= TaskAdvance::TURN_DISARMED
;
75 return armed
&& state_ready
;
76 } else if (tp
.IsIntermediatePoint()) {
77 state
= TaskAdvance::AUTO
;
85 TaskAdvanceSmart::GetState() const
91 TaskAdvanceSmart::UpdateState()
94 case TaskAdvance::START_ARMED
:
96 state
= TaskAdvance::START_DISARMED
;
99 case TaskAdvance::START_DISARMED
:
101 state
= TaskAdvance::START_ARMED
;
104 case TaskAdvance::TURN_ARMED
:
106 state
= TaskAdvance::TURN_DISARMED
;
109 case TaskAdvance::TURN_DISARMED
:
111 state
= TaskAdvance::TURN_ARMED
;