Avionics
Dropship Simulator
Logo.cpp
Go to the documentation of this file.
1 #include "../Module.h"
2 #include <ctime>
3 
4 Logo::Logo(Bus* prmBus, Logger* prmLogger, float prmLatitude, float prmLongitude, float prmAltitudeFeet, float prmZenithDegrees) :Module(prmBus)
5 {
6  logger = prmLogger;
7  bus = prmBus;
8  latitude = prmLatitude;
9  longitude = prmLongitude;
10  altitudeFeet = prmAltitudeFeet;
11  zenithDegrees = prmZenithDegrees;
12 
13  sunrise = bus->GetComponentSetStatePtr("AAE97FDE-1AEB-4E21-8D66-29D55F500D61");
14  sunset = bus->GetComponentSetStatePtr("1EC47487-BCA5-4CD4-8E20-494D490906B0");
15  status = bus->GetComponentSetStatePtr("B9037C14-2DFE-41A4-9620-C593A30AF180");
16 
17  GetTimeZoneInformation(&tz);
19 
21  *status = 0.0f;
22 }
23 
24 void Logo::FrameMove(float fElapsed)
25 {
26  timeSinceLast += fElapsed;
27  if (timeSinceLast < 60.0f) return;
28  timeSinceLast = 0.0f;
29 
31  cTime = CTime(bus->Time);
32  float current = static_cast<float>(cTime.GetHour()) + static_cast<float>(cTime.GetMinute()) / 60.0f;
33 
34  t = time(nullptr);
35  lt = localtime(&t);
36 
37  *sunrise = solar.calculateSunrise(cTime.GetYear(), cTime.GetMonth(), cTime.GetDay(), -tz.Bias / 60, lt->tm_isdst);
38  *sunset = solar.calculateSunset(cTime.GetYear(), cTime.GetMonth(), cTime.GetDay(), tz.Bias / 60, lt->tm_isdst);
39  //float sunriseMin = fmodf(sunrise, 1.0f)*60.0f;
40  //float sunsetMin = fmodf(sunset, 1.0f)*60.0f;
41  // civil twilight 5:38 , sunset 20:52
42  // adjusted for altitude 5:35, 20:56
43 
45  if (current > *sunrise && current < *sunset && *status == 1.0f)
46  {
47  *status = 0.0f;
48  }
49  else if ((current <= *sunrise || current >= *sunset) && *status == 0.0f)
50  {
51  *status = 1.0f;
52  }
53 }
54 
56 {
58  *status = 0.0f;
59 }
Library::Solar solar
Definition: Module.h:405
CTime cTime
Definition: Module.h:406
~Logo()
Definition: Logo.cpp:55
Definition: Logger.h:5
float longitude
Definition: Module.h:395
TIME_ZONE_INFORMATION tz
Definition: Module.h:404
float * status
Definition: Module.h:400
Definition: Bus.h:12
time_t t
Definition: Module.h:402
float zenithDegrees
Definition: Module.h:395
Bus * bus
Definition: Module.h:394
Abstract base class for modules By definition, instruments don&#39;t do any of the work (they don&#39;t modif...
Definition: Module.h:11
float latitude
Definition: Module.h:395
float timeSinceLast
Definition: Module.h:396
Logger * logger
Definition: Module.h:393
float altitudeFeet
Definition: Module.h:395
float calculateSunrise(int year, int month, int day, int localOffset, int daylightSavings) const
Definition: Solar.h:27
void FrameMove(float fElapsedTime) override
Definition: Logo.cpp:24
float * GetComponentSetStatePtr(std::string guidStr)
Definition: Bus.cpp:109
Logo(Bus *prmBus, Logger *prmLogger, float prmLatitude, float prmLongitude, float prmAltitudeFeet, float prmZenithDegrees)
Definition: Logo.cpp:4
float * sunset
Definition: Module.h:399
float calculateSunset(int year, int month, int day, int localOffset, int daylightSavings) const
Definition: Solar.h:88
struct tm * lt
Definition: Module.h:403
_SYSTEMTIME Time
this section is required flight data (FDR)
Definition: Bus.h:39
float * sunrise
Definition: Module.h:398