2010-03-22 13:47:19 +01:00
|
|
|
#include <cxxtest/TestSuite.h>
|
|
|
|
|
|
|
|
#include "interlinknetworks.hh"
|
|
|
|
|
|
|
|
class InterlinkNetworks_test: public CxxTest::TestSuite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
void test_distance(void)
|
|
|
|
{
|
2012-04-11 16:31:48 +02:00
|
|
|
TrilaterationAlgorithm *algo = new InterlinkNetworks() ;
|
2010-05-04 10:44:19 +02:00
|
|
|
|
|
|
|
// Initialise algo->request
|
2010-03-22 13:47:19 +01:00
|
|
|
char mobile_gain = 3, mobile_power = 15 ;
|
|
|
|
Mobile mobile("", "", mobile_gain, mobile_power) ;
|
2010-05-04 10:44:19 +02:00
|
|
|
Request request(&mobile) ;
|
|
|
|
algo->compute(request) ; // yes, that's ugly
|
2010-03-22 13:47:19 +01:00
|
|
|
|
|
|
|
char ap_gain = 5, ap_power = 20, ap_channel = 1 ;
|
2013-06-16 03:02:40 +02:00
|
|
|
CapturePoint ap(Point3D(), "", "", ap_gain, ap_power, ap_channel) ;
|
2010-03-22 13:47:19 +01:00
|
|
|
|
2013-06-17 18:19:38 +02:00
|
|
|
std::map<pkt_id_t, ss_t> ss_list ;
|
|
|
|
ss_list[1] = -42 ;
|
|
|
|
Measurement measurement(&ap) ;
|
|
|
|
measurement.add_ss_list(ss_list) ;
|
2010-03-22 13:47:19 +01:00
|
|
|
|
|
|
|
/* ** How to check ref_distance in Scilab? **
|
2010-06-10 15:35:55 +02:00
|
|
|
* C = 5 + 20 + 20 * log10(299792458 / 2412000000 / (4 * PI)) + 3
|
2010-03-22 13:47:19 +01:00
|
|
|
* L = -42
|
|
|
|
* ref_distance = 10^((C-L)/35)
|
|
|
|
*/
|
2010-06-10 15:35:55 +02:00
|
|
|
float ref_distance = 7.1519 ;
|
2010-03-22 13:47:19 +01:00
|
|
|
|
|
|
|
float computed_distance = algo->estimate_distance(measurement) ;
|
|
|
|
TS_ASSERT_DELTA(computed_distance, ref_distance, 0.0001) ;
|
|
|
|
|
|
|
|
delete algo ;
|
|
|
|
}
|
|
|
|
|
|
|
|
} ;
|