FlightGear next
AINotifications.hxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: AINotifications.hxx
3 * SPDX-FileComment: Emesary notifications for AI system
4 * SPDX-FileCopyrightText: Richard Harrison; April 2020.
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#pragma once
9
10#include <simgear/emesary/Emesary.hxx>
11#include <simgear/math/SGMath.hxx>
12
13
14class NearestCarrierToNotification : public simgear::Emesary::INotification
15{
16public:
17 explicit NearestCarrierToNotification(SGGeod _comparisonPosition) : position(),
18 comparisonPosition(_comparisonPosition),
19 heading(0),
20 vckts(0),
21 deckheight(0),
22 distanceMeters(std::numeric_limits<double>::max()),
23 carrier(0)
24 {
25 }
26
27 /*virtual ~NearestCarrierToNotification()
28 {
29 if (position)
30 delete position;
31 position = 0;
32 }*/
33 const char* GetType() override { return "NearestCarrierToNotification"; }
34
35 const SGGeod* GetPosition() const { return position; }
36 double GetHeading() const { return heading; }
37 double GetVckts() const { return vckts; }
38 double GetDeckheight() const { return deckheight; }
39 const class FGAICarrier* GetCarrier() const { return carrier; }
40 double GetDistanceMeters() const { return distanceMeters; }
41 std::string GetCarrierIdent() const { return carrierIdent; }
42 double GetDistanceToMeters(const SGGeod& pos) const
43 {
44 if (carrier)
45 return SGGeodesy::distanceM(comparisonPosition, pos);
46 else
47 return std::numeric_limits<double>::max() - 1;
48 }
49
50 void SetPosition(SGGeod* _position) { position = _position; }
51
52 void SetHeading(double _heading) { heading = _heading; }
53 void SetVckts(double _vckts) { vckts = _vckts; }
54 void SetDeckheight(double _deckheight) { deckheight = _deckheight; }
55
56 void SetCarrier(FGAICarrier* _carrier, SGGeod* _position)
57 {
58 carrier = _carrier;
59 distanceMeters = SGGeodesy::distanceM(comparisonPosition, *_position);
60 position = _position;
61 }
62 void SetDistanceMeters(double _distanceMeters) { distanceMeters = _distanceMeters; }
63 void SetCarrierIdent(const std::string& _carrierIdent) { carrierIdent = _carrierIdent; }
64
65 SGPropertyNode_ptr GetViewPositionLatNode() { return viewPositionLatDegNode; }
66 SGPropertyNode_ptr GetViewPositionLonNode() { return viewPositionLonDegNode; }
67 SGPropertyNode_ptr GetViewPositionAltNode() { return viewPositionAltFtNode; }
68
69 void SetViewPositionLatNode(SGPropertyNode_ptr _viewPositionLatNode) { viewPositionLatDegNode = _viewPositionLatNode; }
70 void SetViewPositionLonNode(SGPropertyNode_ptr _viewPositionLonNode) { viewPositionLonDegNode = _viewPositionLonNode; }
71 void SetViewPositionAltNode(SGPropertyNode_ptr _viewPositionAltNode) { viewPositionAltFtNode = _viewPositionAltNode; }
72
73
74protected:
75 SGGeod* position;
77
78 SGPropertyNode_ptr viewPositionLatDegNode;
79 SGPropertyNode_ptr viewPositionLonDegNode;
80 SGPropertyNode_ptr viewPositionAltFtNode;
81
82 double heading;
83 double vckts;
84 double deckheight;
86 std::string carrierIdent;
88};
SGPropertyNode_ptr GetViewPositionLatNode()
SGPropertyNode_ptr GetViewPositionAltNode()
SGPropertyNode_ptr viewPositionLatDegNode
void SetViewPositionLatNode(SGPropertyNode_ptr _viewPositionLatNode)
void SetViewPositionLonNode(SGPropertyNode_ptr _viewPositionLonNode)
double GetDistanceToMeters(const SGGeod &pos) const
SGPropertyNode_ptr GetViewPositionLonNode()
void SetCarrier(FGAICarrier *_carrier, SGGeod *_position)
void SetViewPositionAltNode(SGPropertyNode_ptr _viewPositionAltNode)
NearestCarrierToNotification(SGGeod _comparisonPosition)
void SetHeading(double _heading)
const char * GetType() override
SGPropertyNode_ptr viewPositionLonDegNode
void SetPosition(SGGeod *_position)
const class FGAICarrier * GetCarrier() const
SGPropertyNode_ptr viewPositionAltFtNode
void SetDeckheight(double _deckheight)
std::string GetCarrierIdent() const
void SetDistanceMeters(double _distanceMeters)
const SGGeod * GetPosition() const
void SetCarrierIdent(const std::string &_carrierIdent)