use of org.yamcs.protobuf.Mdb.ParameterInfo in project yamcs-studio by yamcs.
the class ParameterCatalogue method processMetaParameters.
public synchronized void processMetaParameters(List<ParameterInfo> metaParameters) {
log.info(String.format("Loaded %d parameters", metaParameters.size()));
this.metaParameters = new ArrayList<>(metaParameters);
this.metaParameters.sort((p1, p2) -> {
return p1.getQualifiedName().compareTo(p2.getQualifiedName());
});
for (ParameterInfo p : this.metaParameters) {
NamedObjectId id = NamedObjectId.newBuilder().setName(p.getQualifiedName()).build();
parametersById.put(id, p);
// Update unit index
if (p != null && p.hasType() && p.getType().getUnitSetCount() > 0) {
String combinedUnit = p.getType().getUnitSet(0).getUnit();
for (int i = 1; i < p.getType().getUnitSetCount(); i++) {
combinedUnit += " " + p.getType().getUnitSet(i).getUnit();
}
unitsById.put(id, combinedUnit);
}
}
parameterListeners.forEach(ParameterListener::mdbUpdated);
}
use of org.yamcs.protobuf.Mdb.ParameterInfo in project yamcs-studio by yamcs.
the class PVCatalogue method register.
public synchronized void register(YamcsPVReader pvReader) {
pvReadersById.put(pvReader.getId(), pvReader);
// Report current connection state
boolean connected = YamcsPlugin.getYamcsClient().isConnected();
ParameterInfo p = ParameterCatalogue.getInstance().getParameterInfo(pvReader.getId());
pvReader.processConnectionInfo(new PVConnectionInfo(connected, p));
// Register (pending) websocket request
NamedObjectList idList = pvReader.toNamedObjectList();
ParameterCatalogue.getInstance().subscribeParameters(idList);
}
use of org.yamcs.protobuf.Mdb.ParameterInfo in project yamcs-studio by yamcs.
the class PVCatalogue method reportConnectionState.
private void reportConnectionState() {
boolean connected = YamcsPlugin.getYamcsClient().isConnected();
pvReadersById.forEach((id, pvReader) -> {
ParameterInfo p = ParameterCatalogue.getInstance().getParameterInfo(id);
pvReader.processConnectionInfo(new PVConnectionInfo(connected, p));
});
}
use of org.yamcs.protobuf.Mdb.ParameterInfo in project yamcs-studio by yamcs.
the class ParameterContentProvider method listResult.
@Override
public AutoCompleteResult listResult(ContentDescriptor desc, int limit) {
String content = desc.getValue();
if (content.startsWith(ParameterContentParser.PARA_SOURCE)) {
content = content.substring(ParameterContentParser.PARA_SOURCE.length());
}
content = AutoCompleteHelper.trimWildcards(content);
Pattern namePattern = AutoCompleteHelper.convertToPattern(content);
namePattern = Pattern.compile(namePattern.pattern(), Pattern.CASE_INSENSITIVE);
AutoCompleteResult pvs = new AutoCompleteResult();
int matchCount = 0;
for (ParameterInfo para : ParameterCatalogue.getInstance().getMetaParameters()) {
Matcher m = namePattern.matcher(para.getQualifiedName());
if (m.find()) {
Proposal p = new Proposal(para.getQualifiedName(), false);
p.addStyle(ProposalStyle.getDefault(m.start(), m.end() - 1));
pvs.addProposal(p);
matchCount++;
if (matchCount >= limit)
break;
}
}
pvs.setCount(matchCount);
return pvs;
}
use of org.yamcs.protobuf.Mdb.ParameterInfo in project yamcs-studio by yamcs.
the class AddParameterPage method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
setControl(composite);
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.numColumns = 2;
gl.makeColumnsEqualWidth = false;
composite.setLayout(gl);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite tableWrapper1 = new Composite(composite, SWT.NONE);
contentProvider = new ParameterContentProvider();
trcl = new TreeColumnLayout();
tableWrapper1.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper1.setLayout(trcl);
namespaceTable = new TreeViewer(tableWrapper1, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
namespaceTable.getTree().setHeaderVisible(true);
namespaceTable.getTree().setLinesVisible(true);
// column container
TreeViewerColumn pathColumn = new TreeViewerColumn(namespaceTable, SWT.NONE);
pathColumn.getColumn().setText(COL_NAMESPACE);
pathColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
String namespace = (String) element;
return namespace;
}
});
trcl.setColumnData(pathColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
namespaceTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
contentProvider.setNamespace(null);
return;
}
contentProvider.setNamespace((String) sel.getFirstElement());
});
namespaceTable.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection sel = new IStructuredSelection() {
@Override
public boolean isEmpty() {
return false;
}
@Override
public List toList() {
return Arrays.asList(contentProvider.getElements(event));
}
@Override
public Object[] toArray() {
return contentProvider.getElements(event);
}
@Override
public int size() {
return contentProvider.getElements(event).length;
}
@Override
public Iterator iterator() {
return Arrays.asList(contentProvider.getElements(event)).iterator();
}
@Override
public Object getFirstElement() {
return null;
}
};
parameterTable.setSelection(sel);
}
});
namespaceTable.setContentProvider(new NamespaceContentProvider());
namespaceTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
String n1 = (String) o1;
String n2 = (String) o2;
return n1.compareTo(n2);
}
});
Composite tableWrapper2 = new Composite(composite, SWT.NONE);
tcl = new TableColumnLayout();
tableWrapper2.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper2.setLayout(tcl);
parameterTable = new TableViewer(tableWrapper2, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
parameterTable.getTable().setHeaderVisible(true);
parameterTable.getTable().setLinesVisible(true);
TableViewerColumn nameColumn = new TableViewerColumn(parameterTable, SWT.NONE);
nameColumn.getColumn().setText(COL_NAME);
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterInfo obj = (ParameterInfo) element;
return obj.getQualifiedName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
parameterTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
setParameter(new ArrayList<>());
return;
}
List<ParameterInfo> parameters = new ArrayList<>();
for (Object obj : sel.toArray()) {
parameters.add((ParameterInfo) obj);
}
setParameter(parameters);
setPageComplete(true);
});
parameterTable.setContentProvider(contentProvider);
parameterTable.setInput(contentProvider);
ParameterCatalogue.getInstance().getMetaParameters().forEach(pmtr -> {
for (NamedObjectId alias : pmtr.getAliasList()) {
String namespace = alias.getNamespace();
if (!namespace.startsWith("/"))
return;
if (!parameterInfos.containsKey(namespace)) {
parameterInfos.put(namespace, new ArrayList<>());
}
parameterInfos.get(namespace).add(pmtr);
String parentns = namespace.substring(0, namespace.lastIndexOf("/"));
while (!parentns.isEmpty()) {
if (!parameterInfos.containsKey(parentns)) {
parameterInfos.put(parentns, new ArrayList<>());
}
parentns = parentns.substring(0, parentns.lastIndexOf("/"));
}
}
});
namespaceTable.setInput(parameterInfos.keySet());
parameterTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
ParameterInfo n1 = (ParameterInfo) o1;
ParameterInfo n2 = (ParameterInfo) o2;
return n1.getQualifiedName().compareTo(n2.getQualifiedName());
}
});
}
Aggregations