Skip to content

Commit f0759be

Browse files
authored
Merge pull request #3752 from ControlSystemStudio/CSSTUDIO-3655
Retry image buffer instantiation on timeout
2 parents 1a41496 + 7e2a3fb commit f0759be

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

  • app/rtplot/src/main/java/org/csstudio/javafx/rtplot

app/rtplot/src/main/java/org/csstudio/javafx/rtplot/RTTank.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public class RTTank extends Canvas
6868
/** Is the scale displayed or not. */
6969
private volatile boolean scale_visible = true;
7070

71+
protected final AtomicBoolean needUpdate = new AtomicBoolean(true);
72+
7173
/** Listener to {@link PlotPart}s, triggering refresh of canvas */
7274
protected final PlotPartListener plot_part_listener = new PlotPartListener()
7375
{
@@ -117,14 +119,22 @@ public RTTank()
117119
widthProperty().addListener(resize_listener);
118120
heightProperty().addListener(resize_listener);
119121

120-
// 50Hz default throttle
122+
// 20Hz default throttle
121123
update_throttle = new UpdateThrottle(50, TimeUnit.MILLISECONDS, () ->
122124
{
123-
plot_image = updateImageBuffer();
124-
redrawSafely();
125+
if (needUpdate.getAndSet(false)){
126+
plot_image = updateImageBuffer(); // This will return null if image buffer instantiation times out
127+
if(plot_image != null){
128+
redrawSafely();
129+
}
130+
else{
131+
requestUpdate();
132+
}
133+
}
125134
});
126135
}
127136

137+
128138
/** Update the dormant time between updates
129139
* @param dormant_time How long throttle remains dormant after a trigger
130140
* @param unit Units for the dormant period
@@ -196,8 +206,8 @@ public void setLogScale(final boolean logscale)
196206
}
197207

198208
/** Set value range
199-
* @param low
200-
* @param high
209+
* @param low Lower limit
210+
* @param high Upper limit
201211
*/
202212
public void setRange(final double low, final double high)
203213
{
@@ -306,6 +316,7 @@ else if (scale.isLogarithmic()) // by mellguth2, https://github.com/ControlSyste
306316
/** Request a complete redraw of the plot */
307317
final public void requestUpdate()
308318
{
319+
needUpdate.set(true);
309320
update_throttle.trigger();
310321
}
311322

0 commit comments

Comments
 (0)