Skip to content

Commit 2e925e7

Browse files
committed
Indicator parameter for performance overload
1 parent c2a605e commit 2e925e7

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/main/java/heronarts/lx/mixer/LXMixerEngine.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ public final LXMixerEngine removeListener(Listener listener) {
9696

9797
private final AddBlend addBlend;
9898

99+
private static final double PERFORMANCE_WARNING_TIMEOUT = 1000;
100+
101+
private double performanceWarningMs = 0;
102+
103+
public final BooleanParameter performanceWarning =
104+
new BooleanParameter("Warning", false)
105+
.setDescription("Set to true if there is excessive CPU usage");
106+
99107
public final DiscreteParameter focusedChannel =
100108
new DiscreteParameter("Channel", 1)
101109
.setDescription("Which channel is currently focused in the UI");
@@ -1067,7 +1075,11 @@ public void loop(LXEngine.Frame render, double deltaMs) {
10671075
} else {
10681076
channel.performanceWarningFrameCount = 0;
10691077
}
1070-
channel.performanceWarning.setValue(channel.performanceWarningFrameCount >= 5);
1078+
final boolean performanceWarning = channel.performanceWarningFrameCount >= 5;
1079+
channel.performanceWarning.setValue(performanceWarning);
1080+
if (performanceWarning) {
1081+
this.performanceWarningMs = PERFORMANCE_WARNING_TIMEOUT;
1082+
}
10711083
}
10721084

10731085
// Step 3: blend the channel buffers down
@@ -1247,6 +1259,14 @@ public void loop(LXEngine.Frame render, double deltaMs) {
12471259
// Mark the cue active state of the buffer
12481260
render.setCueOn(cueBusActive);
12491261
render.setAuxOn(auxBusActive);
1262+
1263+
// Set top-level performance warning flag
1264+
if (this.performanceWarningMs > 0) {
1265+
this.performanceWarning.setValue(true);
1266+
this.performanceWarningMs -= deltaMs;
1267+
} else {
1268+
this.performanceWarning.setValue(false);
1269+
}
12501270
}
12511271

12521272
public void removeRemoteControls(LXComponent component) {

0 commit comments

Comments
 (0)