-
Notifications
You must be signed in to change notification settings - Fork 1
Update controller selection #22
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
Conversation
Co-authored-by: Adam Mitz <mitza@objectcomputing.com>
Co-authored-by: Adam Mitz <mitza@objectcomputing.com>
| ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: TimerHandler::handle_timeout: timer id %d does NOT exist\n", | ||
| timer_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is TimerId a type that can be logged with %d on all platforms? It may need a cast or a different log formatter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, TimerId is an alias for long so it can be logged with %d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACE's logger will pass through %d to snprintf unchanged. %d takes an int so on some systems it will read a 4-byte integer from the varargs but the long is 8 bytes.
https://en.cppreference.com/w/cpp/io/c/printf.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like ACE's %q logger format will cover long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's one option, but it doesn't match long on all platforms. %q is always 8 bytes and long is sometimes 8 bytes. So when using %q the parameter will need to be widened (or stay the same) to be always 8 bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case long is 4 bytes, wouldn't it be implicitly widened similar to assigning an integer of a smaller type to a variable of a bigger type? Perhaps it works differently than the assignment operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's using varargs, so there is no parameter type.
Co-authored-by: Adam Mitz <mitza@objectcomputing.com>
Problem:
Power device relies on the Heartbeat messages from microgrid controllers to determine its active controller. Heartbeat's period is 1 second. If a Heartbeat is not received from a selected (or active) controller within 3 seconds since the last Heartbeat, the selected controller is considered disappearing and the power device starts a process to select a new selected controller. Current implementation schedule (or reschedule if the timer already exists) a timer with expiration of 3 seconds to detect missed Heartbeats. The default timer queue used by
ACE_Reactor,ACE_Timer_Heap, is having an issue with this setup: missed Heartbeat timers fire even though the Heartbeats are still received from the active controller. This happens around time when the timer Id returned byACE_Timer_Heaphas reached its limit and wrapped around.Solution:
ACE_Timer_Hashfor the ACE reactor --ACE_Timer_Hashdoesn't seem to have the same issue.tms::ActiveMicrogridControllerStatetopic to power devices that gives the CLI updates on their selected controller