Skip to content

Commit

Permalink
Support Phoenix "RobotEnable" field
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Dec 18, 2023
1 parent 9d4919f commit 6672f72
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
20 changes: 1 addition & 19 deletions src/hub/dataSources/HistoricalDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Log from "../../shared/log/Log";
import { PHOENIX_ENABLED_KEY, getOrDefault } from "../../shared/log/LogUtil";
import LoggableType from "../../shared/log/LoggableType";
import WorkerManager from "../WorkerManager";

/** A provider of historical log data (i.e. all the data is returned at once). */
Expand Down Expand Up @@ -123,11 +121,7 @@ export class HistoricalDataSource {
if (this.status === HistoricalDataSourceStatus.Error || this.status === HistoricalDataSourceStatus.Stopped) {
return;
}
let log = Log.fromSerialized(response);
if (path.endsWith(".hoot")) {
HistoricalDataSource.addPhoenixRobotEnable(log);
}
decodedLogs[i] = log;
decodedLogs[i] = Log.fromSerialized(response);
completedCount++;
if (completedCount === fileContents.length && this.status === HistoricalDataSourceStatus.Decoding) {
// All decodes finised
Expand Down Expand Up @@ -160,18 +154,6 @@ export class HistoricalDataSource {
// https://www.desmos.com/calculator/86u4rnu8ob
return 0.5 - 0.5 / (0.1 * time + 1);
}

/** For Phoenix logs, compile data from all devices to create a new field with the robot's enabled status. */
private static addPhoenixRobotEnable(log: Log) {
let enabledFieldRegex = /^Phoenix6\/.+\/DeviceEnable$/;
let enabledFields = log.getFieldKeys().filter((key) => enabledFieldRegex.test(key));
log.getTimestamps(enabledFields).forEach((timestamp) => {
let disabled = enabledFields.every(
(field) => getOrDefault(log, field, LoggableType.String, timestamp, "Disabled") !== "Enabled"
);
log.putBoolean(PHOENIX_ENABLED_KEY, timestamp, !disabled);
});
}
}

export enum HistoricalDataSourceStatus {
Expand Down
3 changes: 1 addition & 2 deletions src/shared/log/LogUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ export const MAX_SEARCH_RESULTS = 128;
export const MERGE_PREFIX = "Log";
export const MERGE_MAX_FILES = 10;
export const SEPARATOR_REGEX = new RegExp(/\/|:|_/);
export const PHOENIX_ENABLED_KEY = "Phoenix6/RobotEnable";
export const ENABLED_KEYS = withMergedKeys([
"/DriverStation/Enabled",
"NT:/AdvantageKit/DriverStation/Enabled",
"DS:enabled",
"NT:/FMSInfo/FMSControlData",
"/DSLog/Status/DSDisabled",
PHOENIX_ENABLED_KEY
"RobotEnable" // Phoenix
]);
export const ALLIANCE_KEYS = withMergedKeys([
"/DriverStation/AllianceStation",
Expand Down

0 comments on commit 6672f72

Please sign in to comment.