Skip to content

Commit 0e16c31

Browse files
committed
Snapshot view updates: indicate action result, refactor/code cleanup
1 parent 85eef3c commit 0e16c31

File tree

3 files changed

+118
-86
lines changed

3 files changed

+118
-86
lines changed

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/SaveAndRestoreService.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818

1919
package org.phoebus.applications.saveandrestore.ui;
2020

21-
import com.fasterxml.jackson.annotation.JsonInclude;
22-
import com.fasterxml.jackson.databind.DeserializationFeature;
23-
import com.fasterxml.jackson.databind.ObjectMapper;
24-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
2521
import org.epics.vtype.VType;
2622
import org.phoebus.applications.saveandrestore.client.SaveAndRestoreClient;
2723
import org.phoebus.applications.saveandrestore.client.SaveAndRestoreClientImpl;
@@ -68,15 +64,10 @@ public class SaveAndRestoreService {
6864
private static SaveAndRestoreService instance;
6965

7066
private final SaveAndRestoreClient saveAndRestoreClient;
71-
private final ObjectMapper objectMapper;
7267

7368
private SaveAndRestoreService() {
7469
saveAndRestoreClient = new SaveAndRestoreClientImpl();
7570
executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
76-
objectMapper = new ObjectMapper();
77-
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
78-
objectMapper.registerModule(new JavaTimeModule());
79-
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
8071
}
8172

8273
public static SaveAndRestoreService getInstance() {
@@ -396,7 +387,7 @@ public List<SnapshotItem> takeSnapshotFromArchiver(String configurationNodeId, I
396387
snapshotItem.setConfigPv(configPv);
397388
snapshotItem.setValue(readFromArchiver(configPv.getPvName(), _time));
398389
if (configPv.getReadbackPvName() != null) {
399-
snapshotItem.setValue(readFromArchiver(configPv.getReadbackPvName(), _time));
390+
snapshotItem.setReadbackValue(readFromArchiver(configPv.getReadbackPvName(), _time));
400391
}
401392
snapshotItems.add(snapshotItem);
402393
});
@@ -418,13 +409,18 @@ private VType readFromArchiver(String pvName, Instant time) {
418409
}
419410
// Prepend "archiver://"
420411
pvName = "archive://" + pvName + "(" + TimestampFormats.SECONDS_FORMAT.format(time) + ")";
412+
PV pv = null;
413+
VType pvValue = null;
421414
try {
422-
PV pv = PVPool.getPV(pvName);
423-
VType pvValue = pv.read();
424-
PVPool.releasePV(pv);
425-
return pvValue == null ? VDisconnectedData.INSTANCE : pvValue;
415+
pv = PVPool.getPV(pvName);
416+
pvValue = pv.read();
426417
} catch (Exception e) {
427-
return VDisconnectedData.INSTANCE;
418+
Logger.getLogger(SaveAndRestoreService.class.getName()).log(Level.WARNING, "Failed to read " + pvName, e);
419+
} finally {
420+
if (pv != null) {
421+
PVPool.releasePV(pv);
422+
}
428423
}
424+
return pvValue == null ? VDisconnectedData.INSTANCE : pvValue;
429425
}
430426
}

0 commit comments

Comments
 (0)