2012-02-06 16:44:09 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
2012-11-03 14:52:33 +01:00
|
|
|
* OwlPS is a project of the University of Franche-Comte
|
2012-02-06 16:44:09 +01:00
|
|
|
* (Université de Franche-Comté), France.
|
2012-11-03 14:52:33 +01:00
|
|
|
*
|
|
|
|
* Copyright © Université de Franche-Comté 2007-2012.
|
|
|
|
*
|
|
|
|
* Corresponding author: Matteo Cypriani <mcy@lm7.fr>
|
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*
|
|
|
|
* This software is governed by the CeCILL license under French law and
|
|
|
|
* abiding by the rules of distribution of free software. You can use,
|
|
|
|
* modify and/or redistribute the software under the terms of the CeCILL
|
|
|
|
* license as circulated by CEA, CNRS and INRIA at the following URL:
|
|
|
|
* http://www.cecill.info
|
|
|
|
*
|
|
|
|
* As a counterpart to the access to the source code and rights to copy,
|
|
|
|
* modify and redistribute granted by the license, users are provided
|
|
|
|
* only with a limited warranty and the software's authors, the holder
|
|
|
|
* of the economic rights, and the successive licensors have only
|
|
|
|
* limited liability.
|
|
|
|
*
|
|
|
|
* In this respect, the user's attention is drawn to the risks
|
|
|
|
* associated with loading, using, modifying and/or developing or
|
|
|
|
* reproducing the software by the user in light of its specific status
|
|
|
|
* of free software, that may mean that it is complicated to manipulate,
|
|
|
|
* and that also therefore means that it is reserved for developers and
|
|
|
|
* experienced professionals having in-depth computer knowledge. Users
|
|
|
|
* are therefore encouraged to load and test the software's suitability
|
|
|
|
* as regards their requirements in conditions enabling the security of
|
|
|
|
* their systems and/or data to be ensured and, more generally, to use
|
|
|
|
* and operate it in the same conditions as regards security.
|
|
|
|
*
|
|
|
|
* The fact that you are presently reading this means that you have had
|
|
|
|
* knowledge of the CeCILL license and that you accept its terms.
|
|
|
|
*
|
|
|
|
***********************************************************************
|
2012-02-06 16:44:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-04-11 10:11:29 +02:00
|
|
|
#include "accesspoint.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 ;
|
2011-12-27 15:52:13 +01:00
|
|
|
using std::tr1::unordered_map ;
|
2010-01-04 17:10:42 +01: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
|
|
|
|
2011-08-01 19:40:42 +02:00
|
|
|
/* *** Operations *** */
|
|
|
|
|
|
|
|
|
|
|
|
double AccessPoint::friis_constant_term() const
|
|
|
|
{
|
|
|
|
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
|
|
|
/**
|
|
|
|
* @param trx The transmitter AP.
|
|
|
|
* @returns The percentage of calibration packets sent by \em trx and
|
|
|
|
* received by the AP.
|
|
|
|
* @returns 0 if no packet were received from \em trx.
|
|
|
|
*/
|
|
|
|
float AccessPoint::
|
2011-12-27 15:52:13 +01:00
|
|
|
received_calibration_from_ap(const AccessPoint &trx) const
|
|
|
|
{
|
|
|
|
if (this == &trx)
|
2011-12-29 14:40:50 +01:00
|
|
|
return 100 ;
|
2011-12-27 15:52:13 +01:00
|
|
|
|
|
|
|
// If no reference point is associated with trx, no AP received
|
|
|
|
// 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
|
|
|
|
// messages actually received by the AP:
|
|
|
|
unsigned int
|
|
|
|
received_packets = 0,
|
|
|
|
expected_packets = 0 ;
|
2011-12-27 15:52:13 +01:00
|
|
|
for (vector<CalibrationRequest*>::const_iterator 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
|
|
|
|
2011-07-30 20:38:42 +02:00
|
|
|
AccessPoint& AccessPoint::operator=(const AccessPoint &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
|
|
|
|
|
|
|
|
2010-03-05 17:24:18 +01:00
|
|
|
bool AccessPoint::operator==(const AccessPoint &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
|
|
|
|
|
|
|
|
2008-04-30 11:36:55 +02:00
|
|
|
ostream &operator<<(ostream &os, const AccessPoint &ap)
|
2008-04-11 10:11:29 +02:00
|
|
|
{
|
2009-12-11 13:52:21 +01:00
|
|
|
os
|
2010-01-13 15:29:44 +01:00
|
|
|
<< "Coordinates: " << ap.coordinates << '\n'
|
|
|
|
<< "Frequency: " << ap.frequency << " Hz" << '\n'
|
2010-06-10 15:57:03 +02:00
|
|
|
<< "Friis index: " << ap.friis_index << '\n'
|
2009-12-11 17:56:31 +01:00
|
|
|
<< (WifiDevice) ap ;
|
2009-12-11 13:52:21 +01:00
|
|
|
|
|
|
|
return os ;
|
2008-04-11 10:11:29 +02:00
|
|
|
}
|