minor code changes

This commit is contained in:
k-a-z-u
2017-12-06 17:09:54 +01:00
parent 63bc2f3046
commit ade2425fbd
2 changed files with 45 additions and 18 deletions

View File

@@ -26,8 +26,13 @@ namespace Distribution {
Normal(const T mu, const T sigma) : 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) { 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 */ /** get probability for the given value */
T getProbability(const T val) const { T getProbability(const T val) const {
const T b = -0.5 * ((val-mu)/sigma) * ((val-mu)/sigma); const T b = -0.5 * ((val-mu)/sigma) * ((val-mu)/sigma);

View File

@@ -75,13 +75,25 @@ namespace Offline {
thread.join(); 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: private:
/** background loop */ /** background loop */
void loop() { void loop() {
// get all sensor events from the offline file // 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) // reference time (system vs. first-event)
Timestamp tsRef1 = Timestamp::fromMS(events.front().ts); Timestamp tsRef1 = Timestamp::fromMS(events.front().ts);
@@ -104,8 +116,20 @@ namespace Offline {
if (diff.ms() > 0) {std::this_thread::sleep_for(std::chrono::milliseconds(diff.ms()));} if (diff.ms() > 0) {std::this_thread::sleep_for(std::chrono::milliseconds(diff.ms()));}
} }
// event index trigger(ts, e);
const size_t idx = e.idx;
}
// done
enabled = false;
}
void trigger(const Timestamp ts, const Entry& e) {
const int idx = e.idx;
#warning "some sensors todo:" #warning "some sensors todo:"
switch(e.type) { switch(e.type) {
@@ -124,13 +148,11 @@ namespace Offline {
} }
// done
enabled = false;
}
}; };
} }
#endif // FILEPLAYER_H #endif // FILEPLAYER_H