Skip to content

Commit

Permalink
Save log path to be grabbed by akit
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Jan 26, 2022
1 parent 218cf95 commit 2f792c8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fixed handling of `null` values when calculating auto-axis range.
Added support for sending the current log file to Advantage Kit when starting robot code replay. Requires Advantage Kit v1.3.0 or later.
16 changes: 16 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const os = require("os")
const repository = "Mechanical-Advantage/AdvantageScope"
const prefsFileName = path.join(app.getPath("userData"), "prefs.json")
const stateFileName = "state-" + app.getVersion().replaceAll(".", '_') + ".json"
const lastOpenFileName = "akit-log-path.txt"
var iconPath = null
const defaultPrefs = {
address: "10.63.28.2",
Expand Down Expand Up @@ -77,6 +78,7 @@ app.whenReady().then(() => {
if (firstOpenPath != null) {
window.webContents.once("dom-ready", () => {
window.send("open-file", firstOpenPath)
recordOpenFile(path)
})
}

Expand All @@ -99,12 +101,24 @@ app.on("open-file", (_, path) => {
var window = createWindow()
window.webContents.once("dom-ready", () => {
window.send("open-file", path)
recordOpenFile(path)
})
} else { // Not running yet, open in first window
firstOpenPath = path
}
})

// Record open file path to temp file for robot program
function recordOpenFile(filePath) {
console.log(path.join(app.getPath("temp"), lastOpenFileName))
fs.writeFile(path.join(app.getPath("temp"), lastOpenFileName), filePath, () => { })
}

// Remove the open file path from temp file
app.on("quit", () => {
fs.unlink(path.join(app.getPath("temp"), lastOpenFileName), () => { })
})

// Create a new main window
var indexWindows = []
var lastIndexWindow = null
Expand Down Expand Up @@ -237,6 +251,7 @@ function setupMenu() {
files.then((files) => {
if (files.filePaths.length > 0) {
window.webContents.send("open-file", files.filePaths[0])
recordOpenFile(files.filePaths[0])
app.addRecentDocument(files.filePaths[0])
}
})
Expand Down Expand Up @@ -644,6 +659,7 @@ ipcMain.on("prompt-download-auto-open", (_, filePath) => {
downloadWindow.close()
lastIndexWindow.focus()
lastIndexWindow.send("open-file", filePath)
recordOpenFile(filePath)
}
})
})
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "advantage-scope",
"productName": "Advantage Scope",
"version": "1.13.2",
"version": "1.14.0",
"description": "Logging tool from FRC Team 6328.",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 2f792c8

Please sign in to comment.