Skip to content

Commit

Permalink
Fix URCL in logs and low bandwidth mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Sep 20, 2024
1 parent 796b00b commit 36671f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/hub/dataSources/HistoricalDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Log from "../../shared/log/Log";
import LogField from "../../shared/log/LogField";
import { AKIT_TIMESTAMP_KEYS, applyKeyPrefix } from "../../shared/log/LogUtil";
import { AKIT_TIMESTAMP_KEYS, applyKeyPrefix, getURCLKeys } from "../../shared/log/LogUtil";
import LoggableType from "../../shared/log/LoggableType";
import { calcMockProgress, createUUID, scaleValue, setsEqual } from "../../shared/util";

Expand Down Expand Up @@ -209,6 +209,7 @@ export class HistoricalDataSource {
// Normal behavior, use active fields
window.tabs.getActiveFields().forEach((field) => requestFields.add(field));
window.sidebar.getActiveFields().forEach((field) => requestFields.add(field));
getURCLKeys(window.log).forEach((field) => requestFields.add(field));
} else {
// Need to access all fields, load everything
this.log?.getFieldKeys().forEach((key) => {
Expand Down Expand Up @@ -251,10 +252,16 @@ export class HistoricalDataSource {
}
});

// Decode schemas first
// Decode schemas and URCL metadata first
let requestFieldsArray = Array.from(requestFields);
requestFieldsArray = [
...requestFieldsArray.filter((field) => field.includes("/.schema/")),
...requestFieldsArray.filter(
(field) =>
field.includes("/.schema/") ||
// A bit of a hack but it works
field.includes("URCL/Raw/Aliases") ||
field.includes("URCL/Raw/Persistent")
),
...requestFieldsArray.filter((field) => !field.includes("/.schema/"))
];

Expand Down
5 changes: 3 additions & 2 deletions src/hub/dataSources/nt4/NT4Source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Log from "../../../shared/log/Log";
import { PROTO_PREFIX, STRUCT_PREFIX, getEnabledKey } from "../../../shared/log/LogUtil";
import { PROTO_PREFIX, STRUCT_PREFIX, getEnabledKey, getURCLKeys } from "../../../shared/log/LogUtil";
import LoggableType from "../../../shared/log/LoggableType";
import ProtoDecoder from "../../../shared/log/ProtoDecoder";
import { checkArrayType } from "../../../shared/util";
Expand Down Expand Up @@ -84,7 +84,8 @@ export default class NT4Source extends LiveDataSource {
]),
...(enabledKey === undefined ? [] : [enabledKey]),
...window.tabs.getActiveFields(),
...window.sidebar.getActiveFields()
...window.sidebar.getActiveFields(),
...getURCLKeys(window.log)
].forEach((key) => {
// Compare to announced keys
announcedKeys.forEach((announcedKey) => {
Expand Down
7 changes: 7 additions & 0 deletions src/shared/log/LogUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ export function filterFieldByPrefixes(
return [...filteredFields];
}

export function getURCLKeys(log: Log): string[] {
return log.getFieldKeys().filter((key) => {
let wpilibType = log.getWpilibType(key);
return wpilibType !== null && wpilibType.startsWith("URCL");
});
}

export function getEnabledKey(log: Log): string | undefined {
return ENABLED_KEYS.find((key) => log.getFieldKeys().includes(key));
}
Expand Down

0 comments on commit 36671f7

Please sign in to comment.