ITS
denMessageTableForwarding.cpp
Go to the documentation of this file.
2 
4 {
5  memset(&m_denm, 0, sizeof m_denm);
6  m_T_F_Validity = -1;
7  m_T_Forwarding = -1;
8  m_gps = gps;
9  qsrand(time(NULL));
10  m_thread = new QThread;
11  QObject::connect(m_thread, SIGNAL(started()), this, SLOT(execute()));
12 }
13 
15 {
16  this->m_denm = messageTable.denm();
17  this->m_T_F_Validity = messageTable.m_T_F_Validity;
18  this->m_T_Forwarding = messageTable.m_T_Forwarding;
19  this->m_actionID = messageTable.actionID();
20  this->m_encodedDENM = messageTable.encodedDENM();
21  this->m_gps = messageTable.m_gps;
22  this->m_thread = messageTable.m_thread;
23 }
24 
26 {
27  this->m_denm = other.m_denm;
28  this->m_T_F_Validity = other.m_T_F_Validity;
29  this->m_T_Forwarding = other.m_T_Forwarding;
30  this->m_actionID = other.actionID();
31  this->m_encodedDENM = other.encodedDENM();
32  this->m_gps = other.m_gps;
33  this->m_thread = other.m_thread;
34 
35  return *this;
36 }
37 
39 {
42 
43  QObject::connect(m_validity, SIGNAL(T_F_ValiditySignal()), this, SLOT(endOfT_F_Validity()));
44  QObject::connect(m_forwarding, SIGNAL(T_ForwardingSignal()), this, SLOT(endOfT_Forwarding()));
45  QObject::connect(this, SIGNAL(DENMForwarded()), m_forwarding, SLOT(endOfT_Forwarding()));
46 
47  if(m_validity->timer() > -1)
48  {
50  QTimer::singleShot(m_validity->timer(), m_validity, SLOT(endOfT_F_Validity()));
51  }
52 
53  if(m_forwarding->timer() > -1)
54  {
56  QTimer::singleShot(m_forwarding->timer(), m_forwarding, SLOT(endOfT_Forwarding()));
57  }
58 }
59 
61 {
62  setT_F_Validity(-1);
63  setT_Forwarding(-1);
64 }
65 
67 {
68  /* 1) Stop T_Forwarding timer. */
70 
71  /* 2) Delete DENM entry from the forwarding message table. */
73 }
74 
76 {
77  printf("endOfT_Forwarding\n");
78  /* 1) Check if the forwarding ITS-S is located in the relevance area or the destination area. */
80  {
81  /* 1) a. If not, omit the execution of further steps. */
82  qDebug() << "Not in area";
83  return;
84  }
85  /* 1) b. Otherwise, continue operation. */
86 
87  /* 2) Pass reconstructed DENM to ITS networking & transport layer. */
88  qDebug() << "Emit T_ForwardingSignal";
90 
91  /* 3) Restart timer T_Forwarding. */
92  if(m_T_Forwarding > -1)
93  {
95  QTimer::singleShot(m_forwarding->timer(), m_forwarding, SLOT(endOfT_Forwarding()));
96  emit DENMForwarded();
97  }
98 }
99 
101 {
103 
104  qDebug() << "\n\n\n\ndest.lat =" << destination.latitude << "\nmypo.lat =" << myPosition.latitude;
105  qDebug() << "dest.lon =" << destination.longitude << "\nmypo.lon =" << myPosition.longitude;
106  if(relevanceDistance)
107  {
108  switch (*relevanceDistance)
109  {
111  if(destination.positionConfidenceEllipse.semiMinorConfidence < (50 * 100)||
112  destination.positionConfidenceEllipse.semiMinorConfidence < (50 * 100))
113  {
116  }
117  break;
119  if(destination.positionConfidenceEllipse.semiMinorConfidence < (100 * 100) ||
120  destination.positionConfidenceEllipse.semiMinorConfidence < (100 * 100))
121  {
124  }
125  break;
127  if(destination.positionConfidenceEllipse.semiMinorConfidence < (200 * 100) ||
128  destination.positionConfidenceEllipse.semiMinorConfidence < (200 * 100))
129  {
132  }
133  break;
135  if(destination.positionConfidenceEllipse.semiMinorConfidence < (500 * 100) ||
136  destination.positionConfidenceEllipse.semiMinorConfidence < (500 * 100))
137  {
140  }
141  break;
143  if(destination.positionConfidenceEllipse.semiMinorConfidence < (1000 * 100) ||
144  destination.positionConfidenceEllipse.semiMinorConfidence < (1000 * 100))
145  {
148  }
149  break;
151  if(destination.positionConfidenceEllipse.semiMinorConfidence < (5000 * 100) ||
152  destination.positionConfidenceEllipse.semiMinorConfidence < (5000 * 100))
153  {
156  }
157  break;
159  if(destination.positionConfidenceEllipse.semiMinorConfidence < (10000 * 100) ||
160  destination.positionConfidenceEllipse.semiMinorConfidence < (10000 * 100))
161  {
164  }
165  break;
167  return true;
168  break;
169  default:
170  break;
171  }
172  qDebug() << "RelevanceDistance =" << *relevanceDistance;
173  }
174 
175  double x, y;
176  x = diameter(myPosition.longitude, destination.longitude, circAtLat((myPosition.latitude + destination.latitude)/2));
177  qDebug() << "x =" << x;
178  y = LAT2METER*((myPosition.latitude - destination.latitude)/10000000.);
179  qDebug() << "y =" << y;
180  y *= y<0?-1:1;
181  qDebug() << "y =" << y;
182  qDebug() << "distanceA =" << destination.positionConfidenceEllipse.semiMajorConfidence;
183  qDebug() << "distanceB =" << destination.positionConfidenceEllipse.semiMinorConfidence;
184  double inArea;
187  inArea = f(x, y, destination.positionConfidenceEllipse.semiMajorConfidence,
188  0, shape_circle);
189  else
194 
195  qDebug() << "inArea =" << inArea;
196  return inArea >= 0;
197 }
void setTimer(qint64 t)
setTimer Set the timer.
SemiAxisLength_t semiMinorConfidence
ActionID_t actionID() const
actionID DENM&#39;s ActionID getter.
bool inRelevanceArea(ReferencePosition_t destination, RelevanceDistance_t *relevanceDistance)
inRelevanceArea Check if the ITS-S is in relevance area.
DecentralizedEnvironmentalNotificationMessage_t denm
Definition: DENM.h:25
void endOfT_F_Validity()
endOfT_F_Validity Slot used when T_F_Validity expires.
HeadingValue_t semiMajorOrientation
QByteArray encodedDENM() const
encodedDENM Encoded DENM getter.
denMessageTableForwarding & operator=(const denMessageTableForwarding &other)
operator= Affectation operator.
SemiAxisLength_t semiMajorConfidence
void endOfT_Forwarding()
endOfT_Forwarding Slot used when T_Forwarding expires.
#define LAT2METER
Definition: api.h:23
denMessageTableForwarding(FakeGPSProvider *gps)
denMessageTableForwarding denMessageTableForwarding constructor.
PosConfidenceEllipse_t positionConfidenceEllipse
ParameterGPS & data()
data GPS data getter.
void execute()
execute Execution of the timers.
RelevanceDistance_t * relevanceDistance
DENM_t denm() const
denm DENM getter.
void DENMForwarded()
DENMForwarded Signal used when a DENM is forwarded.
long RelevanceDistance_t
quint64 circAtLat(long l)
circAtLat Compute the circumference at a latitude.
Definition: api.cpp:211
void setT_F_Validity(qint64 t)
setT_F_Validity Set the T_F_Validity.
ReferencePosition_t referencePosition() const
referencePosition ITS-S position getter.
Definition: ParameterGPS.h:81
void T_ForwardingSignal(ActionID_t)
T_ForwardingSignal Signal when T_Forwarding expires.
qint64 timer() const
timer Timer getter.
ReferencePosition_t eventPosition
double f(long x, long y, double lengthA, double lengthB, e_shape shape)
f Compute the f function.
Definition: api.cpp:236
void setT_Forwarding(qint32 t)
setT_Forwarding Set the T_Forwarding.
DEN Message Table Forwarding.
void T_F_ValiditySignal(ActionID_t)
T_F_ValiditySignal Signal when T_F_Validity expires.
~denMessageTableForwarding()
~denMessageTableForwarding denMessageTableForwarding destructor.
unsigned int diameter(long begin, long end, quint64 circ)
diameter Compute the distance between two point on the same latitude.
Definition: api.cpp:220
denMessageTableForwardingThread * m_forwarding
denMessageTableForwardingThread * m_validity