Qt Virtual Chart Table (QVCT)
CDataCourseValidity.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QDateTime>
21 
22 // QVCT
23 #include "QVCTRuntime.hpp"
25 
26 
27 //------------------------------------------------------------------------------
28 // CONSTRUCTORS / DESTRUCTOR
29 //------------------------------------------------------------------------------
30 
32  : fdTimeLastBearing( UNDEFINED_VALUE )
33  , fdErrorBearing( UNDEFINED_VALUE )
34  , bInvalidBearing( false )
35  , fdTimeLastSpeed( UNDEFINED_VALUE )
36  , fdErrorSpeed( UNDEFINED_VALUE )
37  , bInvalidSpeed( false )
38  , fdTimeLastSpeedVertical( UNDEFINED_VALUE )
39  , fdErrorSpeedVertical( UNDEFINED_VALUE )
40  , bInvalidSpeedVertical( false )
41 {}
42 
44  : GroundCourseValidity()
45  , ApparentCourseValidity()
46 {}
47 
49  const CDataCourseValidity& _roDataCourseValidityApparent )
50  : GroundCourseValidity( _roDataCourseValidityGround )
51  , ApparentCourseValidity( _roDataCourseValidityApparent )
52 {}
53 
54 //------------------------------------------------------------------------------
55 // METHODS
56 //------------------------------------------------------------------------------
57 
58 //
59 // GETTERS
60 //
61 
63 {
64  if( bInvalidBearing ) return false;
65  if( fdErrorBearing != UNDEFINED_VALUE && fdErrorBearing > QVCTRuntime::useSettings()->getMaxErrorBearing() ) return false;
66  if( fdTimeLastBearing != UNDEFINED_VALUE && microtime() - fdTimeLastBearing > QVCTRuntime::useSettings()->getMaxAgeBearing() ) return false;
67  return true;
68 }
69 
71 {
72  if( bInvalidSpeed ) return false;
73  if( fdErrorSpeed != UNDEFINED_VALUE && fdErrorSpeed > QVCTRuntime::useSettings()->getMaxErrorSpeed() ) return false;
74  if( fdTimeLastSpeed != UNDEFINED_VALUE && microtime() - fdTimeLastSpeed > QVCTRuntime::useSettings()->getMaxAgeSpeed() ) return false;
75  return true;
76 }
77 
79 {
80  if( bInvalidSpeedVertical ) return false;
81  if( fdErrorSpeedVertical != UNDEFINED_VALUE && fdErrorSpeedVertical > QVCTRuntime::useSettings()->getMaxErrorSpeedVertical() ) return false;
82  if( fdTimeLastSpeedVertical != UNDEFINED_VALUE && microtime() - fdTimeLastSpeedVertical > QVCTRuntime::useSettings()->getMaxAgeSpeedVertical() ) return false;
83  return true;
84 }
85 
Course data validity.
bool bInvalidBearing
Bearing (forced) invalidity status.
double fdErrorSpeedVertical
Vertical speed error, in meters per second.
double fdTimeLastSpeed
Horizontal speed last-set time, in seconds from Unix epoch.
double fdTimeLastSpeedVertical
Vertical speed last-set time, in seconds from Unix epoch.
bool isValidSpeedVertical() const
Returns the vertical speed's (global) validity status.
bool isValidSpeed() const
Returns the horizontal speed's (global) validity status.
double fdTimeLastBearing
Bearing last-set time, in seconds from Unix epoch.
bool isValidBearing() const
Returns the bearing's (global) validity status.
bool bInvalidSpeed
Horizontal speed (forced) invalidity status.
bool bInvalidSpeedVertical
Vertical speed (forced) invalidity status.
double fdErrorBearing
Bearing error, in meters.
double fdErrorSpeed
Horizontal speed error, in meters per second.
static constexpr double UNDEFINED_VALUE
static CSettings * useSettings()
double microtime()
Returns the system time with microseconds resolution, in seconds.
Definition: main.cpp:30