aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/datetime/alarm-queue-simple.h2
-rw-r--r--src/alarm-queue-simple.cpp24
2 files changed, 19 insertions, 7 deletions
diff --git a/include/datetime/alarm-queue-simple.h b/include/datetime/alarm-queue-simple.h
index af1145a..d191aec 100644
--- a/include/datetime/alarm-queue-simple.h
+++ b/include/datetime/alarm-queue-simple.h
@@ -47,7 +47,7 @@ private:
std::vector<Appointment> find_current_alarms() const;
void check_alarms();
- std::set<std::string> m_triggered;
+ std::set<std::pair<std::string,DateTime>> m_triggered;
const std::shared_ptr<Clock> m_clock;
const std::shared_ptr<Planner> m_planner;
const std::shared_ptr<WakeupTimer> m_timer;
diff --git a/src/alarm-queue-simple.cpp b/src/alarm-queue-simple.cpp
index 00608c9..2e36380 100644
--- a/src/alarm-queue-simple.cpp
+++ b/src/alarm-queue-simple.cpp
@@ -79,7 +79,8 @@ void SimpleAlarmQueue::requeue()
// kick any current alarms
for (auto current : find_current_alarms())
{
- m_triggered.insert(current.uid);
+ const std::pair<std::string,DateTime> trig {current.uid, current.begin};
+ m_triggered.insert(trig);
m_alarm_reached(current);
}
@@ -103,16 +104,26 @@ bool SimpleAlarmQueue::find_next_alarm(Appointment& setme) const
const auto now = m_clock->localtime();
const auto beginning_of_minute = now.add_full (0, 0, 0, 0, 0, -now.seconds());
- for(const auto& walk : m_planner->appointments().get())
+ const auto appointments = m_planner->appointments().get();
+ g_message ("planner has %zu appointments in it", (size_t)appointments.size());
+
+ for(const auto& walk : appointments)
{
- if (m_triggered.count(walk.uid)) // did we already use this one?
+ const std::pair<std::string,DateTime> trig {walk.uid, walk.begin};
+ if (m_triggered.count(trig)) {
+ g_message ("skipping; already used");
continue;
+ }
- if (walk.begin < beginning_of_minute) // has this one already passed?
+ if (walk.begin < beginning_of_minute) { // has this one already passed?
+ g_message ("skipping; too old");
continue;
+ }
- if (found && (tmp.begin < walk.begin)) // do we already have a better match?
+ if (found && (tmp.begin < walk.begin)) { // do we already have a better match?
+ g_message ("skipping; bad match");
continue;
+ }
tmp = walk;
found = true;
@@ -133,7 +144,8 @@ std::vector<Appointment> SimpleAlarmQueue::find_current_alarms() const
for(const auto& walk : m_planner->appointments().get())
{
- if (m_triggered.count(walk.uid)) // did we already use this one?
+ const std::pair<std::string,DateTime> trig {walk.uid, walk.begin};
+ if (m_triggered.count(trig)) // did we already use this one?
continue;
if (!DateTime::is_same_minute(now, walk.begin))
continue;