use of org.yamcs.api.YamcsApiException in project yamcs-studio by yamcs.
the class ArchiveIndexReceiver method getIndex.
public void getIndex(TimeInterval interval) {
if (receiving) {
log.info("already receiving data");
return;
}
ArchiveCatalogue catalogue = ArchiveCatalogue.getInstance();
catalogue.downloadIndexes(interval, data -> {
try {
IndexResult response = IndexResult.parseFrom(data);
log.fine(String.format("Received %d archive records", response.getRecordsCount()));
archiveView.receiveArchiveRecords(response);
} catch (InvalidProtocolBufferException e) {
throw new YamcsApiException("Failed to decode server message", e);
}
}).whenComplete((data, exc) -> {
if (exc == null) {
log.info("Done receiving archive records.");
archiveView.receiveArchiveRecordsFinished();
receiving = false;
} else {
archiveView.receiveArchiveRecordsError(exc.toString());
}
});
}
use of org.yamcs.api.YamcsApiException in project yamcs-studio by yamcs.
the class ImportPastCommandsDialog method okPressed.
@Override
protected void okPressed() {
YamcsClient yamcsClient = YamcsPlugin.getYamcsClient();
if (yamcsClient == null) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Could not import commands\n", "Disconnected from Yamcs");
return;
}
getButton(IDialogConstants.OK_ID).setEnabled(false);
long start = TimeEncoding.fromCalendar(RCPUtils.toCalendar(startDate, startTime));
long stop = TimeEncoding.fromCalendar(RCPUtils.toCalendar(stopDate, stopTime));
TimeInterval interval = new TimeInterval(start, stop);
ArchiveCatalogue catalogue = ArchiveCatalogue.getInstance();
catalogue.downloadCommands(interval, data -> {
try {
CommandHistoryEntry commandHistoryEntry = CommandHistoryEntry.parseFrom(data);
Display.getDefault().asyncExec(() -> {
cmdhistView.processCommandHistoryEntry(commandHistoryEntry);
});
} catch (InvalidProtocolBufferException e) {
throw new YamcsApiException("Failed to decode server message", e);
}
}).whenComplete((data, exc) -> {
if (exc == null) {
Display.getDefault().asyncExec(() -> {
ImportPastCommandsDialog.super.okPressed();
});
} else {
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
});
}
Aggregations