2012-02-06 16:44:09 +01:00
|
|
|
/*
|
2013-05-29 18:43:35 +02:00
|
|
|
* This file is part of the Owl Positioning System (OwlPS) project.
|
|
|
|
* It is subject to the copyright notice and license terms in the
|
|
|
|
* COPYRIGHT.t2t file found in the top-level directory of this
|
|
|
|
* distribution and at
|
|
|
|
* http://code.lm7.fr/p/owlps/source/tree/master/COPYRIGHT.t2t
|
|
|
|
* No part of the OwlPS Project, including this file, may be copied,
|
|
|
|
* modified, propagated, or distributed except according to the terms
|
|
|
|
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
|
|
|
|
* distributed along with this file, either separately or by replacing
|
2013-06-22 23:30:17 +02:00
|
|
|
* this notice by the COPYRIGHT.t2t file's contents.
|
2012-02-06 16:44:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-06-14 21:54:26 +02:00
|
|
|
#include "capturepoint.hh"
|
2011-12-27 15:52:13 +01:00
|
|
|
#include "stock.hh"
|
|
|
|
#include "posexcept.hh"
|
2008-04-11 10:11:29 +02:00
|
|
|
|
2010-01-04 17:10:42 +01:00
|
|
|
using namespace std ;
|
|
|
|
|
|
|
|
|
Incorporation de la dernière version de Julien
Extrait de son courriel :
« Par rapport à la précédente j'ai surtout corrigé des bugs. »
Note : la version du listener portable sur Fonera, envoyée en même temps
par Julien, viendra plus tard (le temps que je l'incorpore).
Détail des changements après analyse du code :
aggregator : correction de bogues.
positioning :
* Ajout d'un fichier de config format boost (cfg/config.cfg).
* Makefile : implantation des cibles "install" et "uninstall" ; la cible
"astyle" devient "style".
* accesspoint.{hh,cc}, area.cc, measurement.hh, point.{hh,cc},
referencepoint.{hh,cc} : cosmétique.
* owlps-positioning.c : correction de la lecture du fichier de config
(ajout d'une option permettant de spécifier un fichier alternatif).
* server.cc : essentiellement correction des requêtes.
* libowlps-positioning.{hh,cc} : passage de "unsigned long long" à
"uint64_t" comme type de retour de timeval_to_ms().
writeInDb :
* Ajout de la gestion d'un fichier de config.
* Ajout de deux scripts pour la BDD.
git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@96 785a6c6c-259e-4ff1-8b91-dc31627914f0
2009-07-01 15:39:58 +02:00
|
|
|
|
2011-08-01 19:40:42 +02:00
|
|
|
/* *** Operations *** */
|
|
|
|
|
|
|
|
|
2013-06-14 21:54:26 +02:00
|
|
|
double CapturePoint::friis_constant_term() const
|
2011-08-01 19:40:42 +02:00
|
|
|
{
|
|
|
|
double wavelength =
|
|
|
|
static_cast<double>(PosUtil::LIGHT_SPEED) / frequency ;
|
|
|
|
return antenna_gain + 20 * log10(wavelength) - 20 * log10(4 * M_PI) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-29 14:40:50 +01:00
|
|
|
/**
|
2013-06-14 21:54:26 +02:00
|
|
|
* @param trx The transmitter CP.
|
2013-05-30 21:23:05 +02:00
|
|
|
* @returns The percentage of calibration packets sent by `trx` and
|
2013-06-14 21:54:26 +02:00
|
|
|
* received by the CP.
|
2013-05-30 21:23:05 +02:00
|
|
|
* @returns 0 if no packet were received from `trx.`
|
2011-12-29 14:40:50 +01:00
|
|
|
*/
|
2013-06-14 21:54:26 +02:00
|
|
|
float CapturePoint::
|
|
|
|
received_calibration_from_cp(const CapturePoint &trx) const
|
2011-12-27 15:52:13 +01:00
|
|
|
{
|
|
|
|
if (this == &trx)
|
2011-12-29 14:40:50 +01:00
|
|
|
return 100 ;
|
2011-12-27 15:52:13 +01:00
|
|
|
|
2013-06-14 21:54:26 +02:00
|
|
|
// If no reference point is associated with trx, no CP received
|
2011-12-27 15:52:13 +01:00
|
|
|
// any calibration from it:
|
|
|
|
const ReferencePoint *ref_trx ;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ref_trx = &Stock::get_reference_point(trx.coordinates) ;
|
|
|
|
}
|
|
|
|
catch (element_not_found &e)
|
|
|
|
{
|
2011-12-29 14:40:50 +01:00
|
|
|
return 0 ;
|
2011-12-27 15:52:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if trx sent a calibration request:
|
|
|
|
const vector<CalibrationRequest*> &ref_requests =
|
|
|
|
ref_trx->get_requests(trx.mac_addr) ;
|
|
|
|
if (ref_requests.empty())
|
2011-12-29 14:40:50 +01:00
|
|
|
return 0 ;
|
2011-12-27 15:52:13 +01:00
|
|
|
|
2011-12-29 14:40:50 +01:00
|
|
|
// Count the number of messages sent by trx and the number of
|
2013-06-14 21:54:26 +02:00
|
|
|
// messages actually received by the CP:
|
2011-12-29 14:40:50 +01:00
|
|
|
unsigned int
|
|
|
|
received_packets = 0,
|
|
|
|
expected_packets = 0 ;
|
2013-10-02 22:22:20 +02:00
|
|
|
for (auto cr = ref_requests.begin() ; cr != ref_requests.end() ; ++cr)
|
2011-12-29 14:40:50 +01:00
|
|
|
{
|
|
|
|
const Measurement *const measurement =
|
|
|
|
(*cr)->get_measurement(mac_addr) ;
|
|
|
|
if (! measurement)
|
|
|
|
continue ;
|
2012-02-03 11:58:31 +01:00
|
|
|
received_packets += measurement->get_nb_ss() ;
|
2011-12-29 14:40:50 +01:00
|
|
|
expected_packets += (*cr)->get_nb_packets() ;
|
|
|
|
}
|
2011-12-27 15:52:13 +01:00
|
|
|
|
2012-05-29 13:43:04 +02:00
|
|
|
if (expected_packets == 0)
|
|
|
|
return 0 ;
|
|
|
|
|
2011-12-29 14:40:50 +01:00
|
|
|
// Compute the score (percent):
|
|
|
|
float score = received_packets * 100.0 / expected_packets ;
|
|
|
|
return score ;
|
2011-12-27 15:52:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-01 19:40:42 +02:00
|
|
|
|
2010-01-16 12:23:07 +01:00
|
|
|
/* *** Operators *** */
|
Incorporation de la dernière version de Julien
Extrait de son courriel :
« Par rapport à la précédente j'ai surtout corrigé des bugs. »
Note : la version du listener portable sur Fonera, envoyée en même temps
par Julien, viendra plus tard (le temps que je l'incorpore).
Détail des changements après analyse du code :
aggregator : correction de bogues.
positioning :
* Ajout d'un fichier de config format boost (cfg/config.cfg).
* Makefile : implantation des cibles "install" et "uninstall" ; la cible
"astyle" devient "style".
* accesspoint.{hh,cc}, area.cc, measurement.hh, point.{hh,cc},
referencepoint.{hh,cc} : cosmétique.
* owlps-positioning.c : correction de la lecture du fichier de config
(ajout d'une option permettant de spécifier un fichier alternatif).
* server.cc : essentiellement correction des requêtes.
* libowlps-positioning.{hh,cc} : passage de "unsigned long long" à
"uint64_t" comme type de retour de timeval_to_ms().
writeInDb :
* Ajout de la gestion d'un fichier de config.
* Ajout de deux scripts pour la BDD.
git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@96 785a6c6c-259e-4ff1-8b91-dc31627914f0
2009-07-01 15:39:58 +02:00
|
|
|
|
2009-12-11 13:52:21 +01:00
|
|
|
|
2013-06-14 21:54:26 +02:00
|
|
|
CapturePoint& CapturePoint::operator=(const CapturePoint &source)
|
2009-12-11 17:56:31 +01:00
|
|
|
{
|
2010-03-05 17:24:18 +01:00
|
|
|
if (this == &source)
|
2009-12-11 17:56:31 +01:00
|
|
|
return *this ;
|
2009-12-11 13:52:21 +01:00
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
this->WifiDevice::operator=(source) ;
|
|
|
|
coordinates = source.coordinates ;
|
|
|
|
frequency = source.frequency ;
|
2010-06-10 15:57:03 +02:00
|
|
|
friis_index = source.friis_index ;
|
Incorporation de la dernière version de Julien
Extrait de son courriel :
« Par rapport à la précédente j'ai surtout corrigé des bugs. »
Note : la version du listener portable sur Fonera, envoyée en même temps
par Julien, viendra plus tard (le temps que je l'incorpore).
Détail des changements après analyse du code :
aggregator : correction de bogues.
positioning :
* Ajout d'un fichier de config format boost (cfg/config.cfg).
* Makefile : implantation des cibles "install" et "uninstall" ; la cible
"astyle" devient "style".
* accesspoint.{hh,cc}, area.cc, measurement.hh, point.{hh,cc},
referencepoint.{hh,cc} : cosmétique.
* owlps-positioning.c : correction de la lecture du fichier de config
(ajout d'une option permettant de spécifier un fichier alternatif).
* server.cc : essentiellement correction des requêtes.
* libowlps-positioning.{hh,cc} : passage de "unsigned long long" à
"uint64_t" comme type de retour de timeval_to_ms().
writeInDb :
* Ajout de la gestion d'un fichier de config.
* Ajout de deux scripts pour la BDD.
git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@96 785a6c6c-259e-4ff1-8b91-dc31627914f0
2009-07-01 15:39:58 +02:00
|
|
|
|
2009-12-11 17:56:31 +01:00
|
|
|
return *this ;
|
|
|
|
}
|
2009-12-11 13:52:21 +01:00
|
|
|
|
|
|
|
|
2013-06-14 21:54:26 +02:00
|
|
|
bool CapturePoint::operator==(const CapturePoint &source) const
|
2009-12-11 13:52:21 +01:00
|
|
|
{
|
2010-03-05 17:24:18 +01:00
|
|
|
if (this == &source)
|
2009-12-11 17:56:31 +01:00
|
|
|
return true ;
|
|
|
|
|
2009-12-11 13:52:21 +01:00
|
|
|
return
|
2010-03-05 17:24:18 +01:00
|
|
|
this->WifiDevice::operator==(source) &&
|
|
|
|
coordinates == source.coordinates &&
|
2010-06-10 15:57:03 +02:00
|
|
|
frequency == source.frequency &&
|
|
|
|
friis_index == source.friis_index ;
|
2010-05-21 10:35:15 +02:00
|
|
|
}
|
2008-04-11 10:11:29 +02:00
|
|
|
|
Incorporation de la dernière version de Julien
Extrait de son courriel :
« Par rapport à la précédente j'ai surtout corrigé des bugs. »
Note : la version du listener portable sur Fonera, envoyée en même temps
par Julien, viendra plus tard (le temps que je l'incorpore).
Détail des changements après analyse du code :
aggregator : correction de bogues.
positioning :
* Ajout d'un fichier de config format boost (cfg/config.cfg).
* Makefile : implantation des cibles "install" et "uninstall" ; la cible
"astyle" devient "style".
* accesspoint.{hh,cc}, area.cc, measurement.hh, point.{hh,cc},
referencepoint.{hh,cc} : cosmétique.
* owlps-positioning.c : correction de la lecture du fichier de config
(ajout d'une option permettant de spécifier un fichier alternatif).
* server.cc : essentiellement correction des requêtes.
* libowlps-positioning.{hh,cc} : passage de "unsigned long long" à
"uint64_t" comme type de retour de timeval_to_ms().
writeInDb :
* Ajout de la gestion d'un fichier de config.
* Ajout de deux scripts pour la BDD.
git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@96 785a6c6c-259e-4ff1-8b91-dc31627914f0
2009-07-01 15:39:58 +02:00
|
|
|
|
|
|
|
|
2013-06-14 21:54:26 +02:00
|
|
|
ostream &operator<<(ostream &os, const CapturePoint &cp)
|
2008-04-11 10:11:29 +02:00
|
|
|
{
|
2009-12-11 13:52:21 +01:00
|
|
|
os
|
2013-06-14 21:54:26 +02:00
|
|
|
<< "Coordinates: " << cp.coordinates << '\n'
|
|
|
|
<< "Frequency: " << cp.frequency << " Hz" << '\n'
|
|
|
|
<< "Friis index: " << cp.friis_index << '\n'
|
|
|
|
<< (WifiDevice) cp ;
|
2009-12-11 13:52:21 +01:00
|
|
|
|
|
|
|
return os ;
|
2008-04-11 10:11:29 +02:00
|
|
|
}
|