75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
#ifndef _SERVER_HH_
|
|
#define _SERVER_HH_
|
|
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
#include "clientinfo.hh"
|
|
#include "referencepoint.hh"
|
|
#include "accesspoint.hh"
|
|
#include "point.hh"
|
|
#include "measurement.hh"
|
|
|
|
using namespace std;
|
|
using std::string;
|
|
|
|
#define DEFAULT_IP "127.0.0.1"
|
|
#define DEFAULT_LISTEN_PORT 7777
|
|
#define LIGHT_SPEED 300000000
|
|
#define MINMAX_STEP 0.5
|
|
#define MINMAX_X_START -1
|
|
#define MINMAX_Y_START -1
|
|
#define MINMAX_X_STOP 15
|
|
#define MINMAX_Y_STOP 45
|
|
#define BUFFER_LENGTH 1024
|
|
#define DEFAULT_Z 3
|
|
#define DEFAULT_VITERBI_K 5
|
|
|
|
class Server
|
|
{
|
|
protected:
|
|
vector<ClientInfo> client_list;
|
|
vector<ReferencePoint> reference_point_list;
|
|
vector<AccessPoint> access_point_list;
|
|
struct sockaddr_in server_addr;
|
|
int sockListen;
|
|
int sockSend;
|
|
|
|
public:
|
|
Server();
|
|
Server(string ip_addr, int listen_port, int send_port);
|
|
~Server();
|
|
void send_to_client(int cl);
|
|
int receive_data();
|
|
bool pointExists(float x, float y, float z)const;
|
|
unsigned int pointIndex(float x, float y, float z)const;
|
|
bool pointExists(Point p)const;
|
|
bool apExists(string ap_addr)const;
|
|
unsigned int apIndex(string ap_addr)const;
|
|
unsigned int pointIndex(Point p)const;
|
|
vector<Point> getkClosestInSs(vector<Measurement> m, unsigned int k, bool ignore_point, Point point_ignored)const;
|
|
Point getkWeightedInSs(vector<Measurement> m, unsigned int k, bool ignore_point, Point point_ignored)const;
|
|
Point kPointsAverage(vector<Point> vp)const;
|
|
Point fbcm(vector<Measurement> m, int client_idx)const;
|
|
Point interlink(vector<Measurement> m, int client_idx)const;
|
|
void makeReferencePointListFromFile(string filename);
|
|
void makeApListFromFile(string filename);
|
|
void printReferencePointList();
|
|
void printAccessPointList();
|
|
void computeFriisFromRefList();
|
|
unsigned int getNbReferencePoints()const { return reference_point_list.size(); };
|
|
/* For experimentation purpose only ! */
|
|
void radar_exp();
|
|
};
|
|
|
|
#endif
|