diff --git a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java index 365d0ab5be..ddb81de2e8 100644 --- a/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java +++ b/app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java @@ -68,6 +68,8 @@ public class RTTank extends Canvas /** Is the scale displayed or not. */ private volatile boolean scale_visible = true; + protected final AtomicBoolean needUpdate = new AtomicBoolean(true); + /** Listener to {@link PlotPart}s, triggering refresh of canvas */ protected final PlotPartListener plot_part_listener = new PlotPartListener() { @@ -117,14 +119,22 @@ public RTTank() widthProperty().addListener(resize_listener); heightProperty().addListener(resize_listener); - // 50Hz default throttle + // 20Hz default throttle update_throttle = new UpdateThrottle(50, TimeUnit.MILLISECONDS, () -> { - plot_image = updateImageBuffer(); - redrawSafely(); + if (needUpdate.getAndSet(false)){ + plot_image = updateImageBuffer(); // This will return null if image buffer instantiation times out + if(plot_image != null){ + redrawSafely(); + } + else{ + requestUpdate(); + } + } }); } + /** Update the dormant time between updates * @param dormant_time How long throttle remains dormant after a trigger * @param unit Units for the dormant period @@ -196,8 +206,8 @@ public void setLogScale(final boolean logscale) } /** Set value range - * @param low - * @param high + * @param low Lower limit + * @param high Upper limit */ public void setRange(final double low, final double high) { @@ -306,6 +316,7 @@ else if (scale.isLogarithmic()) // by mellguth2, https://github.com/ControlSyste /** Request a complete redraw of the plot */ final public void requestUpdate() { + needUpdate.set(true); update_throttle.trigger(); }