Skip to content

Commit

Permalink
Merge pull request #1181 from IMRCLab/bugfix_usd
Browse files Browse the repository at this point in the history
USD deck: parser and plotter improvements
  • Loading branch information
krichardsson authored Jan 9, 2023
2 parents af96c07 + ba8eade commit 45d07a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/deck/drivers/src/usddeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ TCHAR* f_gets_without_comments (
while (n < len - 1) { /* Read characters until buffer gets filled */
f_read(fp, &c, 1, &rc);
if (rc != 1) {
break;
*p = 0;
return 0; /* When no data read (eof or error), return with error. */
}
if (c == '\n') {
if (isPureComment){
Expand All @@ -441,7 +442,7 @@ TCHAR* f_gets_without_comments (
}
}
*p = 0;
return n ? buff : 0; /* When no data read (eof or error), return with error. */
return buff;
}


Expand Down Expand Up @@ -636,8 +637,13 @@ static void usdLogTask(void* prm)
cfg->numBytes = 0;
while (true) {
line = f_gets_without_comments(readBuffer, sizeof(readBuffer), &logFile);
if (!line || strncmp(line, "on:", 3) == 0)
if (!line || strncmp(line, "on:", 3) == 0) {
break;
}
// skip lines that do not have at least two characters (1 for group, 1 for '.', 1 for name)
if (strlen(line) <= 3) {
continue;
}
char *group = line;
char *name = 0;
for (int i = 0; i < strlen(line); ++i) {
Expand Down
8 changes: 4 additions & 4 deletions tools/usdlog/plot_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ def showAnnotation(data, sel):
start_time = min(start_time, data['timestamp'][0])

# new figure
fig, ax = plt.subplots(len(data_usd.keys()),1,sharex=True)
fig, ax = plt.subplots(len(data_usd.keys()),1,sharex=True,squeeze=False)

for k, (event_name, data) in enumerate(data_usd.items()):
# print(k, event_name)
t = (data['timestamp'] - start_time) / 1000
ax[k].scatter(t, t*0)
ax[k].set_title(event_name)
ax[k,0].scatter(t, t*0)
ax[k,0].set_title(event_name)

print(data.keys())

crs = mplcursors.cursor(ax[k],hover=True)

crs.connect("add", functools.partial(showAnnotation, data))

ax[-1].set_xlabel('Time [s]')
ax[-1,0].set_xlabel('Time [s]')


plt.show()

0 comments on commit 45d07a2

Please sign in to comment.