Search in sources :

Example 1 with ParameterInfo

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);
}
Also used : ParameterInfo(org.yamcs.protobuf.Mdb.ParameterInfo) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId)

Example 2 with ParameterInfo

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);
}
Also used : PVConnectionInfo(org.yamcs.studio.css.core.pvmanager.PVConnectionInfo) NamedObjectList(org.yamcs.protobuf.Yamcs.NamedObjectList) ParameterInfo(org.yamcs.protobuf.Mdb.ParameterInfo)

Example 3 with ParameterInfo

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));
    });
}
Also used : PVConnectionInfo(org.yamcs.studio.css.core.pvmanager.PVConnectionInfo) ParameterInfo(org.yamcs.protobuf.Mdb.ParameterInfo)

Example 4 with ParameterInfo

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;
}
Also used : Pattern(java.util.regex.Pattern) AutoCompleteResult(org.csstudio.autocomplete.AutoCompleteResult) Matcher(java.util.regex.Matcher) ParameterInfo(org.yamcs.protobuf.Mdb.ParameterInfo) Proposal(org.csstudio.autocomplete.proposals.Proposal)

Example 5 with ParameterInfo

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());
        }
    });
}
Also used : TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ParameterInfo(org.yamcs.protobuf.Mdb.ParameterInfo) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) GridData(org.eclipse.swt.layout.GridData) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

ParameterInfo (org.yamcs.protobuf.Mdb.ParameterInfo)13 ArrayList (java.util.ArrayList)3 PVConnectionInfo (org.yamcs.studio.css.core.pvmanager.PVConnectionInfo)3 IOException (java.io.IOException)2 CoreException (org.eclipse.core.runtime.CoreException)2 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)2 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 NamedObjectId (org.yamcs.protobuf.Yamcs.NamedObjectId)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 AutoCompleteResult (org.csstudio.autocomplete.AutoCompleteResult)1