initial version
This commit is contained in:
27
sensors/dummy/AccelerometerSensorDummy.h
Normal file
27
sensors/dummy/AccelerometerSensorDummy.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef ACCELEROMETERSENSORDUMMY_H
|
||||
#define ACCELEROMETERSENSORDUMMY_H
|
||||
|
||||
#include "../AccelerometerSensor.h"
|
||||
|
||||
class AccelerometerSensorDummy : public AccelerometerSensor {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** singleton access */
|
||||
static AccelerometerSensorDummy& get() {
|
||||
static AccelerometerSensorDummy acc;
|
||||
return acc;
|
||||
}
|
||||
|
||||
void start() override {
|
||||
//throw "todo";
|
||||
}
|
||||
|
||||
void stop() override {
|
||||
throw "todo";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // ACCELEROMETERSENSORDUMMY_H
|
||||
92
sensors/dummy/WiFiSensorDummy.h
Normal file
92
sensors/dummy/WiFiSensorDummy.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#ifndef WIFISENSORDUMMY_H
|
||||
#define WIFISENSORDUMMY_H
|
||||
|
||||
#include "../WiFiSensor.h"
|
||||
#include <thread>
|
||||
|
||||
#include <Indoor/geo/Point3.h>
|
||||
#include <Indoor/sensors/radio/model/LogDistanceModel.h>
|
||||
|
||||
#include <Indoor/grid/Grid.h>
|
||||
#include <Indoor/grid/factory/v2/GridFactory.h>
|
||||
|
||||
|
||||
class WiFiSensorDummy : public WiFiSensor {
|
||||
|
||||
private:
|
||||
|
||||
bool enabled;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/** singleton access */
|
||||
static WiFiSensorDummy& get() {
|
||||
static WiFiSensorDummy wifi;
|
||||
return wifi;
|
||||
}
|
||||
|
||||
|
||||
void start() override {
|
||||
|
||||
enabled = true;
|
||||
std::thread t(&WiFiSensorDummy::simulate, this);
|
||||
t.detach();
|
||||
|
||||
}
|
||||
|
||||
void stop() override {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
struct DummyAP {
|
||||
std::string mac;
|
||||
Point2 pos;
|
||||
DummyAP(const std::string mac, const Point2 pos) : mac(mac), pos(pos) {;}
|
||||
};
|
||||
|
||||
void simulate() {
|
||||
|
||||
std::vector<DummyAP> aps;
|
||||
aps.push_back(DummyAP("00:00:00:00:00:01", Point2(0, 0)));
|
||||
aps.push_back(DummyAP("00:00:00:00:00:02", Point2(20, 0)));
|
||||
aps.push_back(DummyAP("00:00:00:00:00:03", Point2(10, 20)));
|
||||
|
||||
float deg = 0;
|
||||
|
||||
while(enabled) {
|
||||
|
||||
// wait
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
||||
// circle-run around center
|
||||
deg += M_PI * 0.4;
|
||||
|
||||
const float cx = 10;
|
||||
const float cy = 10;
|
||||
const float rad = 5;
|
||||
|
||||
const float x = cx + std::sin(deg) * rad;
|
||||
const float y = cy + std::cos(deg) * rad;
|
||||
|
||||
// construct scan data
|
||||
WiFiSensorData scan;
|
||||
for (DummyAP& ap : aps) {
|
||||
const float dist = ap.pos.getDistance(Point2(x, y));
|
||||
const float rssi = LogDistanceModel::distanceToRssi(-40, 1.5, dist);
|
||||
scan.entries.push_back(WiFiSensorDataEntry(ap.mac, rssi));
|
||||
}
|
||||
|
||||
// call
|
||||
informListeners(scan);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // WIFISENSORDUMMY_H
|
||||
Reference in New Issue
Block a user