|
|
|
@ -272,7 +272,17 @@ int Server::receive_data()
|
|
|
|
|
* Recherche un point de coordonnées (x;y;z) dans la liste reference_point_list, retourne true s'il existe, false sinon. */
|
|
|
|
|
bool Server::pointExists(const float &x, const float &y, const float &z)const
|
|
|
|
|
{
|
|
|
|
|
return pointExists(reference_point_list, Point(x, y, z)) ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointExists(&float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
bool ret = pointExists(reference_point_list, Point(x, y, z)) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointExists(&float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -281,7 +291,17 @@ bool Server::pointExists(const float &x, const float &y, const float &z)const
|
|
|
|
|
* Recherche un Point dans la liste reference_point_list, retourne true s'il existe, false sinon. */
|
|
|
|
|
bool Server::pointExists(const Point &p)const
|
|
|
|
|
{
|
|
|
|
|
return pointExists(reference_point_list, p) ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointExists(&Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
bool ret = pointExists(reference_point_list, p) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointExists(&Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -289,7 +309,17 @@ bool Server::pointExists(const Point &p)const
|
|
|
|
|
/* Recherche un point de coordonnées (x;y;z) dans la liste "point_list", retourne true s'il existe, false sinon. */
|
|
|
|
|
bool Server::pointExists(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const
|
|
|
|
|
{
|
|
|
|
|
return pointExists(point_list, Point(x, y, z)) ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointExists(&vector<ReferencePoint>, &float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
bool ret = pointExists(point_list, Point(x, y, z)) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointExists(&vector<ReferencePoint>, &float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -297,11 +327,24 @@ bool Server::pointExists(const vector<ReferencePoint> &point_list, const float &
|
|
|
|
|
/* Recherche un Point dans la liste "point_list", retourne true s'il existe, false sinon. */
|
|
|
|
|
bool Server::pointExists(const vector<ReferencePoint> &point_list, const Point &p) const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointExists(&vector<ReferencePoint>, &Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0 ; i < point_list.size() ; i++)
|
|
|
|
|
if (p == point_list[i].getCoordinates())
|
|
|
|
|
return true;
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointExists(&vector<ReferencePoint>, &Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointExists(&vector<ReferencePoint>, &Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -311,7 +354,17 @@ bool Server::pointExists(const vector<ReferencePoint> &point_list, const Point &
|
|
|
|
|
/* Do not forget to call pointExists() before this one */
|
|
|
|
|
unsigned int Server::pointIndex(const float &x, const float &y, const float &z)const
|
|
|
|
|
{
|
|
|
|
|
return pointIndex(reference_point_list, Point(x, y, z)) ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointIndex(&float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int ret = pointIndex(reference_point_list, Point(x, y, z)) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointIndex(&float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -319,25 +372,58 @@ unsigned int Server::pointIndex(const float &x, const float &y, const float &z)c
|
|
|
|
|
/* Do not forget to call pointExists() before this one */
|
|
|
|
|
unsigned int Server::pointIndex(const Point &p)const
|
|
|
|
|
{
|
|
|
|
|
return pointIndex(reference_point_list, p) ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointIndex(&Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int ret = pointIndex(reference_point_list, p) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointIndex(&Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int Server::pointIndex(const vector<ReferencePoint> &point_list, const float &x, const float &y, const float &z) const
|
|
|
|
|
{
|
|
|
|
|
return pointIndex(point_list, Point(x, y, z)) ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointIndex(&vector<ReferencePoint>, &float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int ret = pointIndex(point_list, Point(x, y, z)) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointIndex(&vector<ReferencePoint>, &float, &float, &float)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int Server::pointIndex(const vector<ReferencePoint> &point_list, const Point &p) const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::pointIndex(&vector<ReferencePoint>, &Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0 ; i < reference_point_list.size() ; i++)
|
|
|
|
|
if (p == reference_point_list[i].getCoordinates())
|
|
|
|
|
return i;
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointIndex(&vector<ReferencePoint>, &Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
return i ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::pointIndex(&vector<ReferencePoint>, &Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return 0; // Should never happen
|
|
|
|
|
}
|
|
|
|
@ -346,32 +432,57 @@ unsigned int Server::pointIndex(const vector<ReferencePoint> &point_list, const
|
|
|
|
|
|
|
|
|
|
bool Server::apExists(const string &ap_addr)const
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::apExists()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
string str;
|
|
|
|
|
|
|
|
|
|
for (i = 0 ; i < access_point_list.size() ; i++){
|
|
|
|
|
str=access_point_list[i].getApAddr();
|
|
|
|
|
const int length=str.length();
|
|
|
|
|
for(int j=0; j < length; ++j)
|
|
|
|
|
{
|
|
|
|
|
str[j] = std::tolower(str[j]);
|
|
|
|
|
}
|
|
|
|
|
for (i = 0 ; i < access_point_list.size() ; i++)
|
|
|
|
|
if (str == ap_addr)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
for (unsigned int i = 0 ; i < access_point_list.size() ; i++)
|
|
|
|
|
{
|
|
|
|
|
str = access_point_list[i].getApAddr() ;
|
|
|
|
|
const int length = str.length() ;
|
|
|
|
|
for (int j = 0 ; j < length ; ++j)
|
|
|
|
|
str[j] = std::tolower(str[j]) ;
|
|
|
|
|
for (i = 0 ; i < access_point_list.size() ; i++)
|
|
|
|
|
if (str == ap_addr)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::apExists()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
return true ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::apExists()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return false ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int Server::apIndex(const string &ap_addr)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::apIndex()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0 ; i < access_point_list.size() ; i++)
|
|
|
|
|
if (access_point_list[i].getApAddr() == ap_addr)
|
|
|
|
|
return i;
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::apIndex()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::apIndex()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return 0; // Should never happen
|
|
|
|
|
}
|
|
|
|
@ -383,6 +494,12 @@ unsigned int Server::apIndex(const string &ap_addr)const
|
|
|
|
|
*/
|
|
|
|
|
vector<Point> Server::getkClosestInSs(const vector<Measurement> &m, const unsigned int &k)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::getkClosestInSs(&vector<Measurement>, &unsigned int)" << endl ;
|
|
|
|
|
cout << "//<-- Server::getkClosestInSs(&vector<Measurement>, &unsigned int)" << endl ;
|
|
|
|
|
fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return getkClosestInSs(m, k, NULL) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -394,6 +511,10 @@ vector<Point> Server::getkClosestInSs(const vector<Measurement> &m, const unsign
|
|
|
|
|
*/
|
|
|
|
|
vector<Point> Server::getkClosestInSs(const vector<Measurement> &m, const unsigned int &k, const Point *point_ignored)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::getkClosestInSs(&vector<Measurement>, &unsigned int, *Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int i, j, min_idx;
|
|
|
|
|
vector<float> distances_vector;
|
|
|
|
|
vector<Point> points_vector;
|
|
|
|
@ -475,6 +596,10 @@ vector<Point> Server::getkClosestInSs(const vector<Measurement> &m, const unsign
|
|
|
|
|
cout << distances_vector[i] << " : " << points_vector[i] << endl ;
|
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::getkClosestInSs(&vector<Measurement>, &unsigned int, *Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return points_vector;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -482,7 +607,17 @@ vector<Point> Server::getkClosestInSs(const vector<Measurement> &m, const unsign
|
|
|
|
|
|
|
|
|
|
Point Server::getkWeightedInSs(const vector<Measurement> &m, const unsigned int &k)const
|
|
|
|
|
{
|
|
|
|
|
return getkWeightedInSs(m, k, NULL) ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::getkWeightedInSs(&vector<Measurement>, &unsigned int)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
Point ret = getkWeightedInSs(m, k, NULL) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::getkWeightedInSs(&vector<Measurement>, &unsigned int)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -491,6 +626,10 @@ Point Server::getkWeightedInSs(const vector<Measurement> &m, const unsigned int
|
|
|
|
|
*/
|
|
|
|
|
Point Server::getkWeightedInSs(const vector<Measurement> &m, const unsigned int &k, const Point *point_ignored)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::getkWeightedInSs(&vector<Measurement>, &unsigned int, *Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int i, j;
|
|
|
|
|
vector<float> distances_vector;
|
|
|
|
|
vector<Point> points_vector;
|
|
|
|
@ -543,6 +682,10 @@ Point Server::getkWeightedInSs(const vector<Measurement> &m, const unsigned int
|
|
|
|
|
ret.setY(y);
|
|
|
|
|
ret.setZ(z);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::getkWeightedInSs(&vector<Measurement>, &unsigned int, *Point)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -550,6 +693,10 @@ Point Server::getkWeightedInSs(const vector<Measurement> &m, const unsigned int
|
|
|
|
|
|
|
|
|
|
Point Server::kPointsAverage(const vector<Point> &vp)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::kPointsAverage()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
float x=0, y=0, z=0;
|
|
|
|
|
Point p;
|
|
|
|
@ -564,6 +711,10 @@ Point Server::kPointsAverage(const vector<Point> &vp)const
|
|
|
|
|
p.setY(y / (float) vp.size());
|
|
|
|
|
p.setZ(z / (float) vp.size());
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::kPointsAverage()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -571,6 +722,10 @@ Point Server::kPointsAverage(const vector<Point> &vp)const
|
|
|
|
|
|
|
|
|
|
Point Server::fbcm(const vector<Measurement> &m, const int &client_idx)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::fbcm()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
Point ret(0, 0, 0);
|
|
|
|
|
vector<string> addr;
|
|
|
|
|
vector<float> dist_vect;
|
|
|
|
@ -619,6 +774,10 @@ Point Server::fbcm(const vector<Measurement> &m, const int &client_idx)const
|
|
|
|
|
dist_vect.clear();
|
|
|
|
|
centres.clear();
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::fbcm()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
/* Return position */
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
@ -626,6 +785,10 @@ Point Server::fbcm(const vector<Measurement> &m, const int &client_idx)const
|
|
|
|
|
/*second version of fbcm with as parameter vector<Measurement> &m and a list of friis index*/
|
|
|
|
|
Point Server::fbcm_friis( const vector<Measurement> &m, const vector<float> friis_idx_list)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::fbcm_friis()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
Point ret(0, 0, 0);
|
|
|
|
|
vector<string> addr;
|
|
|
|
|
vector<float> dist_vect;
|
|
|
|
@ -673,7 +836,12 @@ Point Server::fbcm_friis( const vector<Measurement> &m, const vector<float> frii
|
|
|
|
|
addr.clear();
|
|
|
|
|
dist_vect.clear();
|
|
|
|
|
centres.clear();
|
|
|
|
|
cout<<"RESULTAT DU FRBHM ---> "<<ret<<endl;
|
|
|
|
|
cout << "RESULTAT DU FRBHM ---> " << ret << endl ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::fbcm_friis()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
/* Return position */
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
@ -681,6 +849,10 @@ Point Server::fbcm_friis( const vector<Measurement> &m, const vector<float> frii
|
|
|
|
|
|
|
|
|
|
Point Server::interlink(const vector<Measurement> &m, const int &client_idx)const
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::interlink()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
Point ret(0, 0, 0);
|
|
|
|
|
vector<string> addr;
|
|
|
|
|
vector<float> dist_vect;
|
|
|
|
@ -726,6 +898,10 @@ Point Server::interlink(const vector<Measurement> &m, const int &client_idx)cons
|
|
|
|
|
|
|
|
|
|
/* Return position */
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::interlink()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -734,14 +910,30 @@ Point Server::interlink(const vector<Measurement> &m, const int &client_idx)cons
|
|
|
|
|
* Crée la liste des points de référence dans la liste reference_point_list. */
|
|
|
|
|
void Server::makeReferencePointListFromFile(const string &filename)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::makePointListFromFile(&string)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
makePointListFromFile(reference_point_list, filename, true) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::makePointListFromFile(&string)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Server::makePointListFromFile(vector<ReferencePoint> &dest_point_list, const string &filename)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::makePointListFromFile(&vector<ReferencePoint>, &string)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
makePointListFromFile(dest_point_list, filename, true) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::makePointListFromFile(&vector<ReferencePoint>, &string)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -752,6 +944,10 @@ void Server::makePointListFromFile(vector<ReferencePoint> &dest_point_list, cons
|
|
|
|
|
*/
|
|
|
|
|
void Server::makePointListFromFile(vector<ReferencePoint> &dest_point_list, const string &filename, const bool uniq_point)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::makePointListFromFile(&vector<ReferencePoint>, &string, bool)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
ifstream input_file ; // Flux d'entrée du fichier.
|
|
|
|
|
char buffer[BUFFER_LENGTH]; // Buffer lu dans le fichier.
|
|
|
|
|
string cpp_buffer ; // Buffer au format string.
|
|
|
|
@ -858,12 +1054,20 @@ void Server::makePointListFromFile(vector<ReferencePoint> &dest_point_list, cons
|
|
|
|
|
|
|
|
|
|
input_file.close();
|
|
|
|
|
infos.clear() ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::makePointListFromFile(&vector<ReferencePoint>, &string, bool)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Server::makeApListFromFile(const string &filename)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::makeApListFromFile()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
ifstream input_file;
|
|
|
|
|
char buffer[BUFFER_LENGTH];
|
|
|
|
|
vector<string> ap_infos;
|
|
|
|
@ -914,12 +1118,20 @@ void Server::makeApListFromFile(const string &filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
input_file.close();
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::makeApListFromFile()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Server::makeTopologyFromFile(const string &filename)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::makeTopologyFromFile()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
ifstream input_file ;
|
|
|
|
|
char buffer[BUFFER_LENGTH] ;
|
|
|
|
|
vector<string> infos ;
|
|
|
|
@ -967,12 +1179,20 @@ void Server::makeTopologyFromFile(const string &filename)
|
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
|
input_file.close() ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::makeTopologyFromFile()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Server::makeWaypointDistancesFromFile(const string &filename)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::makeWaypointDistancesFromFile()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
ifstream input_file ;
|
|
|
|
|
char buffer[BUFFER_LENGTH] ;
|
|
|
|
|
vector<string> infos ;
|
|
|
|
@ -1103,6 +1323,11 @@ void Server::makeWaypointDistancesFromFile(const string &filename)
|
|
|
|
|
|
|
|
|
|
cout << endl ;
|
|
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::makeWaypointDistancesFromFile()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1111,7 +1336,15 @@ void Server::makeWaypointDistancesFromFile(const string &filename)
|
|
|
|
|
* Affiche la liste des points de référence (reference_point_list). */
|
|
|
|
|
void Server::printReferencePointList()
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::printReferencePointList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
printPointList(reference_point_list) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::printReferencePointList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1119,22 +1352,42 @@ void Server::printReferencePointList()
|
|
|
|
|
/* Affiche une liste de points (point_list). */
|
|
|
|
|
void Server::printPointList(vector<ReferencePoint> &point_list)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::printPointList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0 ; i < point_list.size() ; i++)
|
|
|
|
|
cout << point_list[i] << endl ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::printPointList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Server::printAccessPointList()
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::printAccessPointList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0 ; i < access_point_list.size() ; i++)
|
|
|
|
|
cout << access_point_list[i] << endl;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::printAccessPointList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Server::computeFriisFromRefList()
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::computeFriisFromRefList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
vector<float> friis_idx_list;
|
|
|
|
|
Point pt_coords, ap_coords;
|
|
|
|
|
float ap_power, ap_gain, calib_gain = 2, const_term, mes_power, friis_sum;
|
|
|
|
@ -1172,11 +1425,21 @@ void Server::computeFriisFromRefList()
|
|
|
|
|
|
|
|
|
|
friis_idx_list.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::computeFriisFromRefList()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Deuxième version de computeFriisFromRefList qui prend en entrée un point et retourne la liste d'index de friis équivalent*/
|
|
|
|
|
vector<float> Server::computeFriisFromRefList(const Point &p, const vector<Measurement> &m)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::computeFriisFromRefList(&Point, &vector<Measurement>)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
vector<float> friis_idx_list;
|
|
|
|
|
Point pt_coords, ap_coords;
|
|
|
|
|
float ap_power, ap_gain, calib_gain = 2, const_term, mes_power/*, friis_sum*/;
|
|
|
|
@ -1212,6 +1475,10 @@ vector<float> Server::computeFriisFromRefList(const Point &p, const vector<Measu
|
|
|
|
|
}
|
|
|
|
|
for (unsigned int k=0; k < friis_idx_list.size();k++)
|
|
|
|
|
cout<<"friis_idx_list"<< k <<": "<<friis_idx_list[k]<<endl;//
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::computeFriisFromRefList(&Point, &vector<Measurement>)" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return friis_idx_list;
|
|
|
|
|
}
|
|
|
|
@ -1221,21 +1488,31 @@ vector<float> Server::computeFriisFromRefList(const Point &p, const vector<Measu
|
|
|
|
|
/* Ajoute un client (ClientInfo) à la liste "client_list", et renvoie une référence sur l'élément ajouté. */
|
|
|
|
|
ClientInfo& Server::createClient()
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::createClient()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
client_list.push_back(ClientInfo()) ;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::createClient()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
return client_list.back() ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Localise le client d'identifiant "client_id" en appliquant l'algorithme voulu. */
|
|
|
|
|
void Server::monitorClient(const unsigned int &client_id, ALGORITHM algo)
|
|
|
|
|
void Server::monitorClient(const unsigned int &client_id, const ALGORITHM &algo)
|
|
|
|
|
{
|
|
|
|
|
Point pointFastViterbi;
|
|
|
|
|
vector<float> friisFromList;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//--> Server::monitorClient()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
|
|
|
|
|
Point pointFastViterbi;
|
|
|
|
|
vector<float> friisFromList;
|
|
|
|
|
|
|
|
|
|
vector<Point>
|
|
|
|
|
&E_current = client_list[client_id].getRef_viterbi_Ecurrent(),
|
|
|
|
|
&E_previous = client_list[client_id].getRef_viterbi_Eprevious() ;
|
|
|
|
@ -1243,6 +1520,9 @@ void Server::monitorClient(const unsigned int &client_id, ALGORITHM algo)
|
|
|
|
|
if (VITERBI_N < 2)
|
|
|
|
|
{
|
|
|
|
|
cerr << "monitorClient() : N ne peut être inférieur à 2 !" << endl ;
|
|
|
|
|
#ifdef DEBUG_T
|
|
|
|
|
cout << "//<-- Server::monitorClient()" << endl ; fflush(stdout) ;
|
|
|
|
|
#endif // DEBUG_T
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|