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 #include "Protection.hpp"
25 #include "MainWindow.hpp"
26 #include "Gauge/GlueGaugeVario.hpp"
27 #include "Interface.hpp"
28 #include "Components.hpp"
29 #include "Computer/GlideComputer.hpp"
30 #include "CalculationThread.hpp"
31 #include "MergeThread.hpp"
32 #include "DrawThread.hpp"
33 #include "Blackboard/DeviceBlackboard.hpp"
42 if (merge_thread
!= NULL
)
43 merge_thread
->Trigger();
47 * Triggers a GPS update resulting in a run of the calculation thread
52 if (calculation_thread
== NULL
)
55 calculation_thread
->Trigger();
61 if (calculation_thread
!= NULL
)
62 calculation_thread
->ForceTrigger();
68 assert(CommonInterface::main_window
!= NULL
);
70 CommonInterface::main_window
->SendGPSUpdate();
76 assert(CommonInterface::main_window
!= NULL
);
78 CommonInterface::main_window
->FullRedraw();
82 TriggerCalculatedUpdate()
84 assert(CommonInterface::main_window
!= NULL
);
86 CommonInterface::main_window
->SendCalculatedUpdate();
90 TriggerAirspaceWarning()
92 assert(CommonInterface::main_window
!= NULL
);
94 CommonInterface::main_window
->SendAirspaceWarning();
98 CreateCalculationThread()
100 assert(glide_computer
!= NULL
);
102 /* copy settings to DeviceBlackboard */
103 device_blackboard
->ReadComputerSettings(CommonInterface::GetComputerSettings());
105 /* create and run MergeThread, because GlideComputer's first
106 iteration depends on MergeThread's results */
107 merge_thread
= new MergeThread(*device_blackboard
);
108 merge_thread
->FirstRun();
110 /* initialise the GlideComputer and run the first iteration */
111 glide_computer
->ReadBlackboard(device_blackboard
->Basic());
112 glide_computer
->ReadComputerSettings(device_blackboard
->GetComputerSettings());
113 glide_computer
->ProcessGPS(true);
115 /* copy GlideComputer results to DeviceBlackboard */
116 device_blackboard
->ReadBlackboard(glide_computer
->Calculated());
118 calculation_thread
= new CalculationThread(*glide_computer
);
119 calculation_thread
->SetComputerSettings(CommonInterface::GetComputerSettings());
125 assert(CommonInterface::main_window
!= NULL
);
126 assert(calculation_thread
!= NULL
);
128 /* not suspending MergeThread, because it does not access shared
129 unprotected data structures */
131 CommonInterface::main_window
->SuspendThreads();
132 calculation_thread
->Suspend();
138 assert(calculation_thread
!= NULL
);
139 assert(CommonInterface::main_window
!= NULL
);
141 calculation_thread
->Resume();
142 CommonInterface::main_window
->ResumeThreads();