Skip to content

Commit 63f8128

Browse files
committed
Begin development of full DS Lite build
1 parent 99c7917 commit 63f8128

18 files changed

Lines changed: 166 additions & 122 deletions

File tree

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ export ASCOPE_DISTRIBUTION=WPILIB
6262
export ASCOPE_DISTRIBUTION=LITE
6363
```
6464

65+
- **Lite (Driver Station) Distribution:**
66+
67+
```bash
68+
export ASCOPE_DISTRIBUTION=LITEDS
69+
```
70+
6571
## Available NPM Tasks
6672

6773
The following tasks are defined in `package.json` to assist with development:

docs/docusaurus-embed.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import config from "./docusaurus.config";
99

10-
const isLite = process.env.ASCOPE_DISTRIBUTION === "LITE";
10+
const isLite = process.env.ASCOPE_DISTRIBUTION === "LITE" || process.env.ASCOPE_DISTRIBUTION === "LITEDS";
1111
const configEmbed = Object.assign(config, {
1212
future: {
1313
experimental_router: "hash"

rollup.config.mjs

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import replaceRegEx from "rollup-plugin-re";
1818

1919
const isWpilib = process.env.ASCOPE_DISTRIBUTION === "WPILIB";
2020
const isLite = process.env.ASCOPE_DISTRIBUTION === "LITE";
21+
const isLiteDS = process.env.ASCOPE_DISTRIBUTION === "LITEDS";
2122
const licenseHeader =
2223
"// Copyright (c) 2021-2026 Littleton Robotics\n// http://github.com/Mechanical-Advantage\n//\n// Use of this source code is governed by a BSD\n// license that can be found in the LICENSE file\n// at the resources directory of this application.\n";
2324

@@ -30,7 +31,7 @@ function bundle(input, output, isMain, isXRClient, external = []) {
3031
return {
3132
input: "src/" + input,
3233
output: {
33-
file: (isLite ? "lite/static/" : "") + "bundles/" + output,
34+
file: (isLite || isLiteDS ? "lite/static/" : "") + "bundles/" + output,
3435
format: isMain ? "cjs" : "es",
3536
banner: licenseHeader
3637
},
@@ -51,7 +52,7 @@ function bundle(input, output, isMain, isXRClient, external = []) {
5152
}),
5253
terser()
5354
]
54-
: isLite
55+
: isLite || isLiteDS
5556
? [
5657
getBabelOutputPlugin({
5758
presets: [["@babel/preset-env", { modules: false }]],
@@ -65,7 +66,7 @@ function bundle(input, output, isMain, isXRClient, external = []) {
6566
replace({
6667
preventAssignment: true,
6768
values: {
68-
__distribution__: isWpilib ? "WPILib" : isLite ? "Lite" : "FRC6328",
69+
__distribution__: isWpilib ? "WPILib" : isLite ? "Lite" : isLiteDS ? "LiteDS" : "FRC6328",
6970
__version__: packageJson.version,
7071
__build_date__: new Date().toLocaleString("en-US", {
7172
timeZone: "UTC",
@@ -108,56 +109,59 @@ function bundle(input, output, isMain, isXRClient, external = []) {
108109
};
109110
}
110111

111-
const mainBundles = isLite
112-
? [bundle("main/lite/main.ts", "main.js", false, false)]
113-
: [
114-
bundle("main/electron/main.ts", "main.js", true, false, [
115-
"electron",
116-
"electron-fetch",
117-
"fs",
118-
"jsonfile",
119-
"net",
120-
"os",
121-
"ws",
122-
"http",
123-
"path",
124-
"basic-ftp",
125-
"download",
126-
"youtube-dl-exec",
127-
"tesseract.js",
128-
"lzma-native",
129-
"@rev-robotics/revlog-converter"
130-
]),
131-
bundle("preload.ts", "preload.js", true, false, ["electron"])
132-
];
112+
const mainBundles =
113+
isLite || isLiteDS
114+
? [bundle("main/lite/main.ts", "main.js", false, false)]
115+
: [
116+
bundle("main/electron/main.ts", "main.js", true, false, [
117+
"electron",
118+
"electron-fetch",
119+
"fs",
120+
"jsonfile",
121+
"net",
122+
"os",
123+
"ws",
124+
"http",
125+
"path",
126+
"basic-ftp",
127+
"download",
128+
"youtube-dl-exec",
129+
"tesseract.js",
130+
"lzma-native",
131+
"@rev-robotics/revlog-converter"
132+
]),
133+
bundle("preload.ts", "preload.js", true, false, ["electron"])
134+
];
133135
const largeRendererBundles = [
134136
bundle("hub/hub.ts", "hub.js", false, false),
135-
...(isLite ? [] : [bundle("satellite.ts", "satellite.js", false, false)])
137+
...(isLite || isLiteDS ? [] : [bundle("satellite.ts", "satellite.js", false, false)])
136138
];
137139
const smallRendererBundles = [
138140
bundle("editRange.ts", "editRange.js", false, false),
139141
bundle("unitConversion.ts", "unitConversion.js", false, false),
140142
bundle("renameTab.ts", "renameTab.js", false, false),
141-
bundle("editFov.ts", "editFov.js", false, false),
143+
...(isLiteDS ? [] : [bundle("editFov.ts", "editFov.js", false, false)]),
142144
bundle("sourceListHelp.ts", "sourceListHelp.js", false, false),
143145
bundle("betaWelcome.ts", "betaWelcome.js", false, false),
144-
bundle("preferences.ts", "preferences.js", false, false),
146+
...(isLiteDS ? [] : [bundle("preferences.ts", "preferences.js", false, false)]),
145147
bundle("licenses.ts", "licenses.js", false, false),
146148
bundle("download.ts", "download.js", false, false),
147-
...(isLite
149+
...(isLite || isLiteDS
148150
? [bundle("uploadAsset.ts", "uploadAsset.js", false, false)]
149151
: [bundle("export.ts", "export.js", false, false)])
150152
];
151-
const workerBundles = [
152-
bundle("hub/dataSources/csv/csvWorker.ts", "hub$csvWorker.js", false, false),
153-
bundle("hub/dataSources/rlog/rlogWorker.ts", "hub$rlogWorker.js", false, false),
154-
bundle("hub/dataSources/roadrunnerlog/roadRunnerWorker.ts", "hub$roadRunnerWorker.js", false, false),
155-
bundle("hub/dataSources/wpilog/wpilogWorker.ts", "hub$wpilogWorker.js", false, false),
156-
bundle("hub/dataSources/dslog/dsLogWorker.ts", "hub$dsLogWorker.js", false, false),
157-
...(isLite ? [] : [bundle("hub/exportWorker.ts", "hub$exportWorker.js", false, false)]),
158-
bundle("shared/renderers/field3d/workers/loadField.ts", "shared$loadField.js", false, false),
159-
bundle("shared/renderers/field3d/workers/loadRobot.ts", "shared$loadRobot.js", false, false)
160-
];
153+
const workerBundles = isLiteDS
154+
? [bundle("hub/dataSources/wpilog/wpilogWorker.ts", "hub$wpilogWorker.js", false, false)]
155+
: [
156+
bundle("hub/dataSources/csv/csvWorker.ts", "hub$csvWorker.js", false, false),
157+
bundle("hub/dataSources/rlog/rlogWorker.ts", "hub$rlogWorker.js", false, false),
158+
bundle("hub/dataSources/roadrunnerlog/roadRunnerWorker.ts", "hub$roadRunnerWorker.js", false, false),
159+
bundle("hub/dataSources/wpilog/wpilogWorker.ts", "hub$wpilogWorker.js", false, false),
160+
bundle("hub/dataSources/dslog/dsLogWorker.ts", "hub$dsLogWorker.js", false, false),
161+
...(isLite ? [] : [bundle("hub/exportWorker.ts", "hub$exportWorker.js", false, false)]),
162+
bundle("shared/renderers/field3d/workers/loadField.ts", "shared$loadField.js", false, false),
163+
bundle("shared/renderers/field3d/workers/loadRobot.ts", "shared$loadRobot.js", false, false)
164+
];
161165
const xrBundles = [
162166
bundle("xrClient/xrClient.ts", "xrClient.js", false, true),
163167
bundle("xrControls.ts", "xrControls.js", false, false)
@@ -187,12 +191,12 @@ export default (cliArgs) => {
187191
if (cliArgs.configSmallRenderers === true) return smallRendererBundles;
188192
if (cliArgs.configWorkers === true) return workerBundles;
189193
if (cliArgs.configXR === true) {
190-
if (isLite) process.exit();
194+
if (isLite || isLiteDS) process.exit();
191195
return xrBundles;
192196
}
193197
if (cliArgs.configRunOwletDownload === true) return runOwletDownload;
194198

195-
return isLite
199+
return isLite || isLiteDS
196200
? [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles]
197201
: [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles, ...xrBundles];
198202
};

src/betaWelcome.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// license that can be found in the LICENSE file
66
// at the root directory of this project.
77

8-
import { Distribution, DISTRIBUTION } from "./shared/buildConstants";
8+
import { IS_LITE } from "./shared/buildConstants";
99

1010
const CHECKBOXES = Array.from(document.getElementsByTagName("input")) as HTMLInputElement[];
1111
const CONTINUE_BUTTON = document.getElementsByTagName("button")[0] as HTMLButtonElement;
@@ -43,9 +43,9 @@ window.addEventListener("message", (event) => {
4343

4444
window.addEventListener("load", () => {
4545
Array.from(document.getElementsByClassName("desktop-only")).forEach((element) => {
46-
(element as HTMLElement).hidden = DISTRIBUTION === Distribution.Lite;
46+
(element as HTMLElement).hidden = IS_LITE;
4747
});
4848
Array.from(document.getElementsByClassName("lite-only")).forEach((element) => {
49-
(element as HTMLElement).hidden = DISTRIBUTION !== Distribution.Lite;
49+
(element as HTMLElement).hidden = !IS_LITE;
5050
});
5151
});

src/download.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// license that can be found in the LICENSE file
66
// at the root directory of this project.
77

8-
import { DISTRIBUTION, Distribution } from "./shared/buildConstants";
8+
import { IS_LITE } from "./shared/buildConstants";
99
import { USB_ADDRESS } from "./shared/IPAddresses";
1010
import NamedMessage from "./shared/NamedMessage";
1111
import Preferences from "./shared/Preferences";
@@ -27,7 +27,7 @@ let messagePort: MessagePort | null = null;
2727
let platform: string = "";
2828
let preferences: Preferences | null = null;
2929

30-
let address: string = DISTRIBUTION === Distribution.Lite ? window.location.hostname : "";
30+
let address: string = IS_LITE ? window.location.hostname : "";
3131
let loading = true;
3232
let startTime: number | null = null;
3333
let alertIsError = false;
@@ -63,7 +63,7 @@ function handleMainMessage(message: NamedMessage) {
6363
preferences = message.data;
6464
let path = "";
6565
if (preferences) {
66-
if (DISTRIBUTION !== Distribution.Lite) {
66+
if (!IS_LITE) {
6767
address = preferences.usb ? USB_ADDRESS : preferences.robotAddress;
6868
// https://github.com/Mechanical-Advantage/AdvantageScope/issues/167
6969
address = address
@@ -334,11 +334,7 @@ DOWNLOAD_BUTTON.addEventListener("click", save);
334334
window.addEventListener("keydown", (event) => {
335335
if (event.code === "Enter") {
336336
save();
337-
} else if (
338-
DISTRIBUTION !== Distribution.Lite &&
339-
event.key === "a" &&
340-
(platform === "darwin" ? event.metaKey : event.ctrlKey)
341-
) {
337+
} else if (!IS_LITE && event.key === "a" && (platform === "darwin" ? event.metaKey : event.ctrlKey)) {
342338
if (filenames.length === selectedFiles.length) {
343339
// Deselect all
344340
selectedFiles = [];
@@ -357,6 +353,6 @@ window.addEventListener("keydown", (event) => {
357353
}
358354
});
359355
window.addEventListener("load", () => {
360-
(DOWNLOAD_BUTTON.children[0] as HTMLElement).hidden = DISTRIBUTION === Distribution.Lite;
361-
(DOWNLOAD_BUTTON.children[1] as HTMLElement).hidden = DISTRIBUTION !== Distribution.Lite;
356+
(DOWNLOAD_BUTTON.children[0] as HTMLElement).hidden = IS_LITE;
357+
(DOWNLOAD_BUTTON.children[1] as HTMLElement).hidden = !IS_LITE;
362358
});

src/hub/Sidebar.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// license that can be found in the LICENSE file
66
// at the root directory of this project.
77

8-
import { Distribution, DISTRIBUTION } from "../shared/buildConstants";
8+
import { Distribution, DISTRIBUTION, IS_LITE } from "../shared/buildConstants";
99
import { SidebarState } from "../shared/HubState";
1010
import LogFieldTree from "../shared/log/LogFieldTree";
1111
import LoggableType from "../shared/log/LoggableType";
@@ -136,7 +136,7 @@ export default class Sidebar {
136136
Array.from(menuBar.getElementsByTagName("button")).forEach((button, index) => {
137137
let active = false;
138138
button.addEventListener("click", () => {
139-
if (active && DISTRIBUTION !== Distribution.Lite) {
139+
if (active && !IS_LITE) {
140140
active = false;
141141
window.sendMainMessage("close-app-menu", {
142142
index: index
@@ -432,11 +432,18 @@ export default class Sidebar {
432432

433433
// Add new list
434434
let tree = window.log.getFieldTree();
435-
let rootKeys = Object.keys(tree);
435+
let rootKeys = Object.keys(tree).filter((x) => !x.startsWith("."));
436436
if (rootKeys.length === 1 && tree[rootKeys[0]].fullKey === null) {
437437
// If only one table, use it as the root
438438
tree = tree[rootKeys[0]].children;
439439
}
440+
if (DISTRIBUTION === Distribution.LiteDS) {
441+
// Repeat for DS to use "NT:/Dscomm/" as the root
442+
let rootKeys = Object.keys(tree).filter((x) => !x.startsWith("."));
443+
if (rootKeys.length === 1 && tree[rootKeys[0]].fullKey === null) {
444+
tree = tree[rootKeys[0]].children;
445+
}
446+
}
440447
Object.keys(tree)
441448
.filter((key) => !this.HIDDEN_KEYS.includes(key))
442449
.sort((a, b) => this.sortKeys(a, b, true))

src/hub/Tabs.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { TabsState } from "../shared/HubState";
99
import LineGraphFilter from "../shared/LineGraphFilter";
1010
import TabType, { getDefaultTabTitle, getTabIcon } from "../shared/TabType";
11+
import { Distribution, DISTRIBUTION } from "../shared/buildConstants";
1112
import { getAutonomousKey, getEnabledKey } from "../shared/log/LogUtil";
1213
import ConsoleRenderer from "../shared/renderers/ConsoleRenderer";
1314
import DocumentationRenderer from "../shared/renderers/DocumentationRenderer";
@@ -290,11 +291,19 @@ export default class Tabs {
290291
});
291292

292293
// Add default tabs
293-
this.addTab(TabType.Documentation);
294-
this.addTab(TabType.LineGraph);
295-
this.addTab(TabType.Field2d);
296-
this.addTab(TabType.Field3d);
297-
this.setSelected(1);
294+
if (DISTRIBUTION === Distribution.LiteDS) {
295+
this.addTab(TabType.Documentation);
296+
this.addTab(TabType.LineGraph);
297+
this.addTab(TabType.Console);
298+
this.addTab(TabType.Joysticks);
299+
this.setSelected(1);
300+
} else {
301+
this.addTab(TabType.Documentation);
302+
this.addTab(TabType.LineGraph);
303+
this.addTab(TabType.Field2d);
304+
this.addTab(TabType.Field3d);
305+
this.setSelected(1);
306+
}
298307

299308
// Scroll management
300309
this.tabsScrollSensor = new ScrollSensor(

src/hub/controllers/Field3dController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { BuiltIn3dFields } from "../../shared/AdvantageScopeAssets";
99
import { SourceListItemState, SourceListOptionValueConfig, SourceListState } from "../../shared/SourceListConfig";
10-
import { DISTRIBUTION, Distribution } from "../../shared/buildConstants";
10+
import { IS_LITE } from "../../shared/buildConstants";
1111
import {
1212
APRIL_TAG_16H5_COUNT,
1313
APRIL_TAG_36H11_COUNT,
@@ -55,7 +55,7 @@ export default class Field3dController implements TabController {
5555
this.FIELD_SELECT = settings.getElementsByClassName("field-select")[0] as HTMLSelectElement;
5656

5757
// Set up XR button
58-
if (DISTRIBUTION === Distribution.Lite) {
58+
if (IS_LITE) {
5959
Array.from(settings.getElementsByClassName("xr-control")).forEach((element) => {
6060
let htmlElement = element as HTMLElement;
6161
htmlElement.parentElement?.removeChild(htmlElement);

src/hub/dataSources/nt4/NT4.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { Decoder, Encoder } from "@msgpack/msgpack";
99

1010
export const NT4_PORTS_DEFAULT = [5810];
11+
export const NT4_PORTS_DS = [6767];
1112

1213
const typestrIdxLookup: { [id: string]: number } = {
1314
boolean: 0,

src/hub/dataSources/nt4/NT4Source.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
// license that can be found in the LICENSE file
66
// at the root directory of this project.
77

8-
import { Distribution, DISTRIBUTION } from "../../../shared/buildConstants";
8+
import { Distribution, DISTRIBUTION, IS_LITE } from "../../../shared/buildConstants";
99
import Log from "../../../shared/log/Log";
1010
import { getEnabledKey, getURCLKeys, PHOTON_PREFIX, PROTO_PREFIX, STRUCT_PREFIX } from "../../../shared/log/LogUtil";
1111
import LoggableType from "../../../shared/log/LoggableType";
1212
import ProtoDecoder from "../../../shared/log/ProtoDecoder";
1313
import { checkArrayType } from "../../../shared/util";
1414
import { LiveDataSource, LiveDataSourceStatus } from "../LiveDataSource";
1515
import CustomSchemas from "../schema/CustomSchemas";
16-
import { NT4_Client, NT4_PORTS_DEFAULT, NT4_Topic } from "./NT4";
16+
import { NT4_Client, NT4_PORTS_DEFAULT, NT4_PORTS_DS, NT4_Topic } from "./NT4";
1717
import NT4Tuner from "./NT4Tuner";
1818

1919
export const WPILOG_PREFIX = "NT:";
@@ -197,8 +197,8 @@ export default class NT4Source extends LiveDataSource {
197197
this.log = new Log();
198198
this.client = new NT4_Client(
199199
address,
200-
NT4_PORTS_DEFAULT,
201-
DISTRIBUTION === Distribution.Lite ? "AdvantageScopeLite" : "AdvantageScope",
200+
DISTRIBUTION === Distribution.LiteDS ? NT4_PORTS_DS : NT4_PORTS_DEFAULT,
201+
IS_LITE ? "AdvantageScopeLite" : "AdvantageScope",
202202
(topic: NT4_Topic) => {
203203
// Announce
204204
if (!this.log) return;

0 commit comments

Comments
 (0)