Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}

Expand Down
Loading