All Classes Functions
MFDDataLaunchMFD.hpp
1 // ==============================================================
2 // ORBITER MODULE: LaunchMFD
3 // Part of the ORBITER SDK
4 //
5 // Copyright (C) 2004 rjcroy - robust time based pitch autopilot (borrowed code)
6 // Copyright (C) 2004 Dave "Daver" Rowbotham - conversion of rjcroy's autopolot to C++ (borrowed code)
7 // Copyright (C) 2004 Erik H. "Sputnik" Anderson - conversion of the autopilot to energy based (borrowed code)
8 // Copyright (C) 2007 "Vanguard" - dressing up azimuth calcualtions into an MFD (author)
9 // Copyright (C) 2007 Pawel "She'da'Lier" Stiasny - yaw error visual representation (contributor)
10 // Copyright (C) 2008 Mohd "Computerex" Ali - borrowed his code (multiple vessels support) (borrowed code)
11 // Copyright (C) 2008 Chris "Kwan" Jeppesen - borrowed his code (peg guidance) (borrowed code)
12 // Copyright (C) 2008 Steve "agentgonzo" Arch - peg integration, offplane correction, compass, hud display (co-developer)
13 // Copyright (C) 2007-2012 Szymon "Enjo" Ender - everything else ;> (author and maintainer)
14 // All rights reserved
15 //
16 // MFDData.h - class holding seperate data of individual vessels
17 // Authors - Szymon "Enjo" Ender
18 //
19 // This module calculates the appropriate launch azimuth given
20 // desired orbital inclination and desired orbit altitude. This
21 // MFD takes the planets rotation into account, which provides a
22 // much more accurate azimuth. The calculations are performed
23 // 'on the fly' (technically and methaphorically), meaning that
24 // you get info about necessary course corrections.
25 //
26 // This file is part of LaunchMFD.
27 //
28 // LaunchMFD is free software: you can redistribute it and/or modify
29 // it under the terms of the GNU General Public License as published by
30 // the Free Software Foundation, either version 3 of the License, or
31 // (at your option) any later version.
32 //
33 // LaunchMFD is distributed in the hope that it will be useful,
34 // but WITHOUT ANY WARRANTY; without even the implied warranty of
35 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 // GNU General Public License for more details.
37 //
38 // You should have received a copy of the GNU General Public License
39 // along with LaunchMFD. If not, see <http://www.gnu.org/licenses/>.
40 // ==============================================================
41 
42 #ifndef __MFDDATALAUNCHMFD_H
43 #define __MFDDATALAUNCHMFD_H
44 
45 #include "globals.h"
46 #include "Types.hpp"
47 #include "BODYPHYS_ORB.h"
48 #include "TGTPARAM_ORB.h"
49 #include "LaunchMFD.h"
50 #include "FlightDirector.h"
51 #include "PEG/PEGNormal.h"
52 #include "PEG/PEGDirectAscentStd.h"
53 #include "PEG/PEGDirectAscentSynchro.h"
54 #include "PEG/PEGMulti.h"
55 #include "EnergyPitchProgram.hpp"
56 #include "ShipVariables.h"
57 #include "StagingDetector.hpp"
58 #include "GreatCircle.h"
59 
60 #include <multipleVesselsMFD/MFDData.hpp>
61 #include <Systems/Point.hpp>
62 
63 #include "Autopilot/AutopilotType.hpp"
64 #include "OffPlaneCorrector/OffPlaneCorrector.hpp"
65 #include "OffPlaneCorrector/OffPlaneCorrectorStandard.hpp"
66 #include "OffPlaneCorrector/OffPlaneCorrectorDirectAscent.hpp"
67 #include "Autopilot/PIDAP.hpp"
68 #include "Autopilot/PitchProgramReader.h"
69 
70 #include "MovementParams.h"
71 
72 enum View
73 {
74  AZIMUTH,
75  DIRECT_ASCENT,
76  COMPASS
77 };
78 
79 enum NavMode
80 {
81  NAV_STANDARD,
82  NAV_DIRECT_ASCENT
83 };
84 
86 
90 class MFDDataLaunchMFD : public EnjoLib::MFDGoodies::MFDData
91 {
92 public:
94 
98  MFDDataLaunchMFD (VESSEL * vessel);
99 
101 
106  void Update();
107  void ReactOnShipStatus();
108  double GetCurrentAlt() const;
109  double GetAzimuth() const;
110  double GetAutomaticAlt(OBJHANDLE hRef);
111  void SwitchAutopilot( AutopilotType type );
112 
113 
114  AutopilotType GetAutopilotType() const;
115  void MECO();
116  void MainEngineOn( double level = 1 );
117  double GetYaw();
118  void CheckLatitudeVsInclination();
119  void UpdateTgtParam();
120  void CheckPlanetChange();
121  TGTPARAM_ORB & GetTgtParam();
122  bool IsInAtmosphere() const;
123  double GetTargetPitch();
124  double GetTimeSinceLaunch() const;
125  bool IsStopConditionPitch() const;
126  double GetTMECO() const;
127  NavMode GetNavMode() const;
128  OffPlaneCorrector * GetOffPlaneCorrector();
129  char * GetTargetStr() const;
130  const std::string & GetTargetStdStr() const;
131  const MovementParams & GetMovParams() const;
132  void SetTargetStr( const std::string & tgt );
133  OBJHANDLE GetTargetBody() const;
134  VESSEL * GetTargetVessel() const;
135  const ShipVariables & GetShipVariables() const;
136  ShipVariables & GetShipVariablesRW();
137  void ChangeCompassDisplayMode();
138  void SetPEGApses();
139  void SwitchAzimuth();
140  double GetMi() const;
141 
142  //bool active;
143  bool CutEngines;
144  bool launched;
145  bool half_ov_reached;
146  bool tgt_set;
147  bool hud;
148  bool newAtmosphericModel;
149  bool drawPitchError;
150 
151  double InclinationFactor;
152  int AltitudeFactor;
153  bool m_ManualAlt;
154  double PeA, ApA;
155  int AzimuthLock;
156 
157  OBJHANDLE hRef;
158 
159  TGTPARAM_ORB m_tgtParam;
160  BODYPHYS_ORB m_bodyPhys;
161 
162  FlightDirector flightDirector;
163  PEGNormal peg;
164  PEGDirectAscentStd pegDA;
165  PEGDirectAscentSynchro pegDAS;
166  PEGMulti pegMulti;
167  GreatCircle m_greatCircle;
168 
169  double start_time;
170 
171  View pageView;
172  PIDAP m_pidAP;
173  PitchProgramReader m_pitchProgram;
174  EnergyPitchProgram m_energyProgram;
175 
176  LaunchCompass::DisplayMode m_compassDisplayMode;
177  bool m_daSynchroOrbit;
178  bool m_useOffplaneCorrector;
179 
180 private:
181  double calculate_azimuth();
182  void CalcAzimuthLock();
183  void DetectStaging();
184  void ReadConfig();
185 
186  // TGTPARAM CheckTgtPosition();
187 
188  StagingDetector m_stageDetector;
189  ShipVariables m_shipVariables;
190  OffPlaneCorrectorStandard m_offPlaneCorrStandard;
191  OffPlaneCorrectorDirectAscent m_offPlaneCorrDA;
192  AutopilotType autopilotType;
193  MovementParams m_mov;
194 
195 
196  const std::string m_tagPitchProgramEnergy;
197 
198 
199  bool m_energyBased;
200  bool m_justReachedOrbit;
201  bool m_recordTMECO;
202  unsigned m_numStage;
203  unsigned m_numStageSaved;
204  bool m_stageSaved;
205  double final_vel_module;
206  double m_azimuth;
207 
208  std::string strTarget;
209 };
210 
211 
212 
213 #endif