2020import edu .wpi .first .cscore .CameraServerJNI ;
2121import edu .wpi .first .networktables .NetworkTable ;
2222import edu .wpi .first .networktables .ProtobufPublisher ;
23+ import edu .wpi .first .wpilibj .Alert ;
24+ import edu .wpi .first .wpilibj .Alert .AlertType ;
2325import java .io .IOException ;
2426import java .nio .file .FileStore ;
2527import java .nio .file .Files ;
@@ -62,6 +64,9 @@ private record NetworkTraffic(double sentBitRate, double recvBitRate) {}
6264 .getProtobufTopic (CameraServerJNI .getHostname (), DeviceMetrics .proto )
6365 .publish ();
6466
67+ private final Alert thermalThrottlingAlert =
68+ new Alert ("PhotonAlerts" , "Thermal throttling detected!" , AlertType .kWarning );
69+
6570 private SystemInfo si ;
6671 private CentralProcessor cpu ;
6772 private OperatingSystem os ;
@@ -140,7 +145,7 @@ protected SystemMonitor() {
140145 }
141146
142147 /**
143- * Returns a comma-separated list of addtional thermal zone types that should be checked to get
148+ * Returns a comma-separated list of additional thermal zone types that should be checked to get
144149 * the CPU temperature on Unix systems. The temperature will be reported for the first temperature
145150 * zone with a type that matches an item of this list. If the CPU temperature isn't being
146151 * reported correctly for a coprocessor, override this method to return a string with type
@@ -210,6 +215,8 @@ private void publishMetrics() {
210215
211216 metricPublisher .set (metrics );
212217
218+ thermalThrottlingAlert .set (this .isThermallyThrottling ());
219+
213220 if (writeMetricsToLog ) {
214221 logMetrics (metrics );
215222 }
@@ -446,6 +453,16 @@ public String getCpuThrottleReason() {
446453 return "" ;
447454 }
448455
456+ /**
457+ * Returns true if the device is currently experiencing thermal throttling. Platforms that support
458+ * thermal throttling detection will override this method.
459+ *
460+ * @return true if thermally throttling, false otherwise.
461+ */
462+ public boolean isThermallyThrottling () {
463+ return false ;
464+ }
465+
449466 /**
450467 * Returns the total GPU memory in MiB.
451468 *
@@ -562,4 +579,4 @@ private double timeIt(StringBuilder sb, Supplier<String> source) {
562579 sb .append (String .format (" %7.3f ms >> %s\n " , delta , resp ));
563580 return delta ;
564581 }
565- }
582+ }
0 commit comments