Skip to content

Commit

Permalink
Defined separate RESET_REQUESTED and RESET_COMPLETE notifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Sep 22, 2023
1 parent 771d5a5 commit c83b244
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
6 changes: 4 additions & 2 deletions python/fusion_engine_client/analysis/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,8 @@ def plot_events(self):
description_str.replace('<', '[').replace('>', ']').replace('\n', '<br>'),
])

if isinstance(message, EventNotificationMessage) and message.event_type == EventType.RESET:
if (isinstance(message, EventNotificationMessage) and
message.event_type in (EventType.RESET_REQUESTED, EventType.RESET_COMPLETE)):
if system_time_ns in times_before_resets:
rows[-1][2] = f'{(times_before_resets[system_time_ns]):.3f}'

Expand Down Expand Up @@ -2125,7 +2126,8 @@ def extract_times_before_reset(self):
get_time_before_reset = False

# Check if event is a reset.
if entry.type == MessageType.EVENT_NOTIFICATION and payload.event_type == EventType.RESET:
if (entry.type == MessageType.EVENT_NOTIFICATION and
payload.event_type in (EventType.RESET_REQUESTED, EventType.RESET_COMPLETE)):
curr_reset_time = payload.get_system_time_ns()
get_time_before_reset = True
except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion python/fusion_engine_client/messages/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,11 @@ def calcsize(self) -> int:

class EventType(IntEnum):
LOG = 0
RESET = 1
RESET_REQUESTED = 1
CONFIG_CHANGE = 2
COMMAND = 3
COMMAND_RESPONSE = 4
RESET_COMPLETE = 1


class EventNotificationMessage(MessagePayload):
Expand Down
29 changes: 23 additions & 6 deletions src/point_one/fusion_engine/messages/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,20 @@ struct P1_ALIGNAS(4) EventNotificationMessage : public MessagePayload {
*/
LOG = 0,
/**
* Event indicating a device reset occurred. The event flags will be set to
* the requested reset bitmask, if applicable (see @ref ResetRequest). The
* payload will contain a string describing the cause of the reset.
* Event indicating a device reset has been requested.
*
* For certain devices and types of resets, it may take time to fully apply
* all reset actions and it may not be possible to complete immediately. A
* `RESET_REQUESTED` event indicates the start of the reset process, and
* `RESET_COMPLETE` indicates when all actions have finished. Other types
* of reset may complete immediately, in which case both `RESET_REQUESTED`
* and `RESET_COMPLETE` messages will be sent at the same time.
*
* The `flags` field in the message will be set to the requested reset
* bitmask, if applicable (see @ref ResetRequest). The payload will contain
* a string describing the cause of the reset.
*/
RESET = 1,
RESET_REQUESTED = 1,
/**
* Notification that the user configuration has been changed. Intended for
* diagnostic purposes.
Expand All @@ -506,15 +515,20 @@ struct P1_ALIGNAS(4) EventNotificationMessage : public MessagePayload {
* will receive the response itself.
*/
COMMAND_RESPONSE = 4,
/**
* Event indicating a requested reset has finished. See `RESET_REQUESTED`
* for more details.
*/
RESET_COMPLETE = 5,
};

static P1_CONSTEXPR_FUNC const char* to_string(EventType type) {
switch (type) {
case EventType::LOG:
return "Log";

case EventType::RESET:
return "Reset";
case EventType::RESET_REQUESTED:
return "Reset Requested";

case EventType::CONFIG_CHANGE:
return "Config Change";
Expand All @@ -525,6 +539,9 @@ struct P1_ALIGNAS(4) EventNotificationMessage : public MessagePayload {
case EventType::COMMAND_RESPONSE:
return "Command Response";

case EventType::RESET_COMPLETE:
return "Reset Complete";

default:
return "Unknown";
}
Expand Down

0 comments on commit c83b244

Please sign in to comment.