use of org.yamcs.studio.core.model.ParameterCatalogue in project yamcs-studio by yamcs.
the class ShowPVInfoAction method loadParameterInfoAndShowDialog.
/**
* Gets detailed information on yamcs parameters. We do this one-by-one,
* because otherwise we risk having one invalid parameter spoil the whole
* bunch. Idealy we would rewrite this API a bit on yamcs server, so we
* avoid the use of a latch.
*/
private void loadParameterInfoAndShowDialog(List<PVInfo> pvInfos) {
List<PVInfo> yamcsPvs = new ArrayList<>();
for (PVInfo pvInfo : pvInfos) if (pvInfo.isYamcsParameter())
yamcsPvs.add(pvInfo);
// Start a worker thread that will show the dialog when a response for
// all yamcs parameters arrived
new Thread() {
@Override
public void run() {
CountDownLatch latch = new CountDownLatch(yamcsPvs.size());
// Another reason why we should have futures
for (PVInfo pvInfo : pvInfos) {
if (!pvInfo.isYamcsParameter()) {
latch.countDown();
continue;
}
ParameterCatalogue catalogue = ParameterCatalogue.getInstance();
catalogue.requestParameterDetail(pvInfo.getYamcsQualifiedName()).whenComplete((data, exc) -> {
if (exc == null) {
try {
ParameterInfo response = ParameterInfo.parseFrom(data);
pvInfo.setParameterInfo(response);
latch.countDown();
} catch (InvalidProtocolBufferException e) {
log.log(Level.SEVERE, "Failed to decode server message", e);
}
} else {
pvInfo.setParameterInfoException(exc.getMessage());
latch.countDown();
}
});
}
try {
latch.await();
targetPart.getSite().getShell().getDisplay().asyncExec(() -> showDialog(pvInfos));
} catch (InterruptedException e) {
targetPart.getSite().getShell().getDisplay().asyncExec(() -> {
log.log(Level.SEVERE, "Could not fetch Yamcs parameter info", e);
MessageDialog.openError(null, "Could Not Fetch Yamcs Parameter Info", "Interrupted while fetching yamcs parameter info");
});
}
}
}.start();
}
use of org.yamcs.studio.core.model.ParameterCatalogue in project yamcs-studio by yamcs.
the class YamcsPlugin method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
TimeEncoding.setUp();
yamcsClient = new YamcsClient(getProductString(), true);
yamcsClient.addConnectionListener(new UIConnectionListener());
ManagementCatalogue managementCatalogue = new ManagementCatalogue();
catalogues.put(ManagementCatalogue.class, managementCatalogue);
addYamcsConnectionListener(managementCatalogue);
registerCatalogue(new TimeCatalogue());
registerCatalogue(new ParameterCatalogue());
registerCatalogue(new CommandingCatalogue());
registerCatalogue(new AlarmCatalogue());
registerCatalogue(new EventCatalogue());
registerCatalogue(new LinkCatalogue());
registerCatalogue(new ArchiveCatalogue());
}
use of org.yamcs.studio.core.model.ParameterCatalogue in project yamcs-studio by yamcs.
the class YamcsVType method getUnits.
@Override
public String getUnits() {
ParameterCatalogue catalogue = ParameterCatalogue.getInstance();
String unit = catalogue.getCombinedUnit(pval.getId());
return (unit == null) ? "" : unit;
}
Aggregations