Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOGL-9183: Round of the microseconds to seconds for time difference #93

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion C/services/notification/notification_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,13 @@ bool NotificationInstance::handleState(bool evalRet)
// Calculate time diff
timersub(&now_tv, &m_lastSentTv, &diffTimeTv);

// round up the seconds If microseconds are greater than or equal to 500000
if (diffTimeTv.tv_usec >= 500000)
{
diffTimeTv.tv_sec = diffTimeTv.tv_sec + 1;
diffTimeTv.tv_usec = 0;
}

switch(nType.type)
{
case NotificationInstance::OneShot:
Expand All @@ -804,7 +811,10 @@ bool NotificationInstance::handleState(bool evalRet)
// Set state depends on evalRet
setTriggered = evalRet;
// Try sending "triggered" when evaluation is true
ret = evalRet && timercmp(&diffTimeTv, &nType.retriggerTimeTv, >=);
if ( ( nType.retriggerTimeTv.tv_sec > 0) && (m_lastSentTv.tv_sec == now_tv.tv_sec))
ret = false;
else
ret = evalRet && timercmp(&diffTimeTv, &nType.retriggerTimeTv, >=);
break;

default:
Expand Down