-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: swurl <[email protected]>
- Loading branch information
Showing
15 changed files
with
322 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import QFRCDashboard | |
|
||
Row { | ||
id: tv | ||
z: 4 | ||
z: 5 | ||
|
||
property alias menuAnim: menuAnim | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file alias="Warning">icons/warn.svg</file> | ||
<file alias="Information">icons/info.svg</file> | ||
<file alias="Critical">icons/crit.svg</file> | ||
</qresource> | ||
</RCC> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot; | ||
|
||
import java.util.LinkedList; | ||
import java.util.Queue; | ||
|
||
import edu.wpi.first.networktables.NetworkTable; | ||
import edu.wpi.first.networktables.NetworkTableEntry; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
|
||
/** Class for interacting with QFRCDashboard. */ | ||
public class QFRCLib { | ||
public enum ErrorLevel { | ||
Information, | ||
Warning, | ||
Critical | ||
} | ||
|
||
private static class Error { | ||
private final String m_message; | ||
private final ErrorLevel m_level; | ||
|
||
public Error(String message, ErrorLevel level) { | ||
m_message = message; | ||
m_level = level; | ||
} | ||
|
||
public String getMessage() { | ||
return m_message; | ||
} | ||
|
||
public ErrorLevel getLevel() { | ||
return m_level; | ||
} | ||
} | ||
|
||
private static final NetworkTableInstance inst = NetworkTableInstance.getDefault(); | ||
private static final NetworkTable table = inst.getTable("QFRCDashboard"); | ||
|
||
private static final NetworkTableEntry tabEntry = table.getEntry("Tab"); | ||
private static final NetworkTableEntry errorsEntry = table.getEntry("Errors"); | ||
|
||
private static final Queue<Error> errors = new LinkedList<>(); | ||
private static int errorHistoryLength = 5; | ||
|
||
/** | ||
* Reports an error or info to be displayed on the dashboard. | ||
* @param level The error level (info, warning, critical) | ||
* @param message The error message. | ||
*/ | ||
public static void reportError(ErrorLevel level, String message) { | ||
Error e = new Error(message, level); | ||
errors.offer(e); | ||
if (errors.size() > errorHistoryLength) { | ||
errors.poll(); | ||
} | ||
|
||
publishErrors(); | ||
} | ||
|
||
private static void publishErrors() { | ||
String[] array = new String[errors.size() * 2]; | ||
int i = 0; | ||
for (Error e : errors) { | ||
array[i] = e.getLevel().toString(); | ||
++i; | ||
array[i] = e.getMessage().toString(); | ||
++i; | ||
} | ||
errorsEntry.setStringArray(array); | ||
} | ||
|
||
/** | ||
* Sets the length of the error queue. | ||
* @param length The length of the error queue. | ||
*/ | ||
public static void setErrorHistoryLength(int length) { | ||
errorHistoryLength = length; | ||
while (errors.size() > errorHistoryLength) { | ||
errors.poll(); | ||
} | ||
} | ||
|
||
/** | ||
* Sets the dashboard to the specified tab. | ||
* @param tabName The tab to switch to. | ||
* @apiNote This is a no-op if the specified tab does not exist. | ||
*/ | ||
public static void setTab(String tabName) { | ||
tabEntry.setString(tabName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.