minor code changes
This commit is contained in:
@@ -26,8 +26,13 @@ namespace Distribution {
|
||||
Normal(const T mu, const T sigma) :
|
||||
mu(mu), sigma(sigma), _a(1.0 / (sigma * std::sqrt(2.0 * M_PI))), gen(RANDOM_SEED), dist(mu,sigma) {
|
||||
|
||||
#warning "analyze issue when coping an existing distribution and using draw() afterwards. this seems to yield issues"
|
||||
|
||||
}
|
||||
|
||||
/** do not allow copy. this will not work as expected for std::normal_distribution when using draw() ?! */
|
||||
//Normal(const Normal& o) = delete;
|
||||
|
||||
/** get probability for the given value */
|
||||
T getProbability(const T val) const {
|
||||
const T b = -0.5 * ((val-mu)/sigma) * ((val-mu)/sigma);
|
||||
|
||||
@@ -75,13 +75,25 @@ namespace Offline {
|
||||
thread.join();
|
||||
}
|
||||
|
||||
|
||||
/** manual ticking */
|
||||
int tickPos = 0;
|
||||
void tick() {
|
||||
const std::vector<Entry>& events = reader->getEntries();
|
||||
const Entry& e = events[tickPos];
|
||||
trigger(Timestamp::fromMS(e.ts), e);
|
||||
++tickPos;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
/** background loop */
|
||||
void loop() {
|
||||
|
||||
// get all sensor events from the offline file
|
||||
const std::vector<Entry> events = reader->getEntries();
|
||||
const std::vector<Entry>& events = reader->getEntries();
|
||||
|
||||
// reference time (system vs. first-event)
|
||||
Timestamp tsRef1 = Timestamp::fromMS(events.front().ts);
|
||||
@@ -104,10 +116,22 @@ namespace Offline {
|
||||
if (diff.ms() > 0) {std::this_thread::sleep_for(std::chrono::milliseconds(diff.ms()));}
|
||||
}
|
||||
|
||||
// event index
|
||||
const size_t idx = e.idx;
|
||||
trigger(ts, e);
|
||||
|
||||
#warning "some sensors todo:"
|
||||
}
|
||||
|
||||
// done
|
||||
enabled = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void trigger(const Timestamp ts, const Entry& e) {
|
||||
|
||||
const int idx = e.idx;
|
||||
|
||||
#warning "some sensors todo:"
|
||||
switch(e.type) {
|
||||
case Sensor::ACC: listener->onAccelerometer(ts, reader->getAccelerometer()[idx].data); break;
|
||||
case Sensor::BARO: listener->onBarometer(ts, reader->getBarometer()[idx].data); break;
|
||||
@@ -124,13 +148,11 @@ namespace Offline {
|
||||
|
||||
}
|
||||
|
||||
// done
|
||||
enabled = false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // FILEPLAYER_H
|
||||
|
||||
Reference in New Issue
Block a user