Skip to content

Commit 3956571

Browse files
committed
add wait for value loop
1 parent e3c1af4 commit 3956571

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/java/org/phoebus/pvws/EpicsWebSocketServerApplication.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,20 @@ public String pvget(@RequestParam String name) {
6868
final WebSocketPV pv = new WebSocketPV(name, null);
6969
String ret;
7070
try {
71-
pv.start();
72-
VType lastValue = pv.get();
71+
72+
// TODO make these configurable?
73+
int maxAttempts = 100;
74+
int retryDelay = 50;
75+
76+
VType lastValue = null;
77+
78+
for (int i = 0; i< maxAttempts; i++) {
79+
Thread.sleep(retryDelay);
80+
lastValue = pv.get();
81+
if (lastValue != null) break;
82+
System.out.println("value is" + lastValue + "attempt no " + i);
83+
}
84+
7385
System.out.println("value is" + lastValue);
7486
ret = Vtype2Json.toJson(name, lastValue, null, true, true);
7587
} catch (final Exception ex) {

0 commit comments

Comments
 (0)