fixed some issues
some new helper methods added listener-support to offline-reader
This commit is contained in:
@@ -22,6 +22,16 @@ struct WiFiMeasurements {
|
||||
return res;
|
||||
}
|
||||
|
||||
/** get the measurements for the given MAC [if available] otherwise null */
|
||||
WiFiMeasurement* getForMac(const MACAddress& mac) {
|
||||
for (WiFiMeasurement& m : entries) {
|
||||
if (m.getAP().getMAC() == mac) {
|
||||
return &m;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // WIFIMEASUREMENTS_H
|
||||
|
||||
@@ -17,7 +17,7 @@ class WiFiObserverFree : public WiFiProbability {
|
||||
|
||||
private:
|
||||
|
||||
const float sigma = 8.0f;
|
||||
const float sigma;
|
||||
|
||||
const float sigmaPerSecond = 3.0f;
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
const Timestamp age = curTime - entry.getTimestamp();
|
||||
|
||||
Assert::isTrue(age.ms() >= 0, "found a negative wifi measurement age. this does not make sense");
|
||||
//Assert::isTrue(age.ms() <= 40000, "found a 40 second old wifi measurement. maybe there is a coding error?");
|
||||
Assert::isTrue(age.ms() <= 60000, "found a 60 second old wifi measurement. maybe there is a coding error?");
|
||||
|
||||
// sigma grows with measurement age
|
||||
const float sigma = this->sigma + this->sigmaPerSecond * age.sec();
|
||||
|
||||
@@ -60,12 +60,12 @@ public:
|
||||
}
|
||||
|
||||
/** load AP information from the floorplan. use the given fixed TXP/EXP/WAF for all APs */
|
||||
void loadAPs(const Floorplan::IndoorMap* map, const float txp = -40.0f, const float exp = 2.5f, const float waf = -8.0f) {
|
||||
void loadAPs(const Floorplan::IndoorMap* map, const float txp = -40.0f, const float exp = 2.5f, const float waf = -8.0f, const bool assertSafe = true) {
|
||||
|
||||
for (const Floorplan::Floor* floor : map->floors) {
|
||||
for (const Floorplan::AccessPoint* ap : floor->accesspoints) {
|
||||
const APEntry ape(ap->getPos(floor), txp, exp, waf);
|
||||
addAP(MACAddress(ap->mac), ape);
|
||||
addAP(MACAddress(ap->mac), ape, assertSafe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,15 @@ struct WiFiFingerprint {
|
||||
|
||||
}
|
||||
|
||||
/** get all measurements for the given MAC */
|
||||
std::vector<WiFiMeasurement> getAllForMAC(const MACAddress& mac) const {
|
||||
std::vector<WiFiMeasurement> res;
|
||||
for (const WiFiMeasurement& m : measurements.entries) {
|
||||
if (m.getAP().getMAC() == mac) {res.push_back(m);}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/** serialize */
|
||||
void write(std::ostream& out) const {
|
||||
out << "pos: " << pos_m.x << " " << pos_m.y << " " << pos_m.z << "\n";
|
||||
|
||||
@@ -15,22 +15,37 @@ class WiFiFingerprints {
|
||||
|
||||
private:
|
||||
|
||||
/** the file to save the calibration model to */
|
||||
std::string file;
|
||||
// /** the file to save the calibration model to */
|
||||
// std::string file;
|
||||
|
||||
/** all fingerprints (position -> measurements) within the model */
|
||||
std::vector<WiFiFingerprint> fingerprints;
|
||||
|
||||
public:
|
||||
|
||||
WiFiFingerprints(const std::string& file) : file(file) {
|
||||
load();
|
||||
/** empty ctor */
|
||||
WiFiFingerprints() {
|
||||
|
||||
}
|
||||
|
||||
/** ctor from file */
|
||||
WiFiFingerprints(const std::string& file) {
|
||||
load(file);
|
||||
}
|
||||
|
||||
const std::vector<WiFiFingerprint>& getFingerprints() const {
|
||||
return fingerprints;
|
||||
}
|
||||
|
||||
std::vector<WiFiFingerprint>& getFingerprints() {
|
||||
return fingerprints;
|
||||
}
|
||||
|
||||
/** attach the given fingerprint */
|
||||
void add(const WiFiFingerprint& fp) {
|
||||
fingerprints.push_back(fp);
|
||||
}
|
||||
|
||||
/** get all fingerprints that measured exactly the given mac [no VAP grouping] */
|
||||
const std::vector<WiFiFingerprint> getFingerprintsFor(const MACAddress& mac) const {
|
||||
|
||||
@@ -58,7 +73,7 @@ public:
|
||||
}
|
||||
|
||||
/** deserialize the model */
|
||||
void load() {
|
||||
void load(const std::string& file) {
|
||||
|
||||
// open and check
|
||||
std::ifstream inp(file.c_str());
|
||||
@@ -87,7 +102,7 @@ public:
|
||||
|
||||
|
||||
/** serialize the model */
|
||||
void save() {
|
||||
void save(const std::string& file) {
|
||||
|
||||
// open and check
|
||||
std::ofstream out(file.c_str());
|
||||
|
||||
Reference in New Issue
Block a user