16 :
FactGroup(1000,
":/json/Vehicle/GPSFact.json", parent)
28 _staleTimer.setSingleShot(
true);
29 _staleTimer.setInterval(GNSS_INTEGRITY_STALE_TIMEOUT_MS);
30 connect(&_staleTimer, &QTimer::timeout,
this, &VehicleGPSAggregateFactGroup::_onStaleTimeout);
48void VehicleGPSAggregateFactGroup::_updateAggregates()
53void VehicleGPSAggregateFactGroup::_onIntegrityUpdated()
60void VehicleGPSAggregateFactGroup::_onStaleTimeout()
68void VehicleGPSAggregateFactGroup::_clearConnections()
70 for (
const auto& c : _connections) {
71 QObject::disconnect(c);
76int VehicleGPSAggregateFactGroup::_valueOrInvalid(
Fact* fact)
86 const int val = v.toInt(&ok);
90 return (val == 255) ? -1 : val;
93int VehicleGPSAggregateFactGroup::_mergeWorst(
int a,
int b)
98int VehicleGPSAggregateFactGroup::_mergeAuthentication(
int a,
int b)
101 auto getWeight = [](
int val) {
113 return (getWeight(a) >= getWeight(b)) ? a : b;
118 const int spoof1 = _valueOrInvalid(gps1 ? gps1->
spoofingState() :
nullptr);
119 const int spoof2 = _valueOrInvalid(gps2 ? gps2->
spoofingState() :
nullptr);
120 const int jam1 = _valueOrInvalid(gps1 ? gps1->
jammingState() :
nullptr);
121 const int jam2 = _valueOrInvalid(gps2 ? gps2->
jammingState() :
nullptr);
125 const int spoofMerged = _mergeWorst(spoof1, spoof2);
126 const int jamMerged = _mergeWorst(jam1, jam2);
127 const int authMerged = _mergeAuthentication(auth1, auth2);
129 _spoofingStateFact.
setRawValue(spoofMerged == -1 ? 255 : spoofMerged);
130 _jammingStateFact.
setRawValue(jamMerged == -1 ? 255 : jamMerged);
131 _authenticationStateFact.
setRawValue(authMerged == -1 ? 255 : authMerged);
Used to group Facts together into an object hierarachy.
void _addFact(Fact *fact, const QString &name)
A Fact is used to hold a single value within the system.
void setRawValue(const QVariant &value)
QVariant rawValue() const
Value after translation.
VehicleGPSAggregateFactGroup(QObject *parent=nullptr)
void updateFromGps(VehicleGPSFactGroup *gps1, VehicleGPSFactGroup *gps2)
void bindToGps(VehicleGPSFactGroup *gps1, VehicleGPSFactGroup *gps2)
Fact * authenticationState()
void gnssIntegrityReceived()