Search in sources :

Example 1 with AlarmData

use of org.yamcs.protobuf.Alarms.AlarmData in project yamcs-studio by yamcs.

the class ActiveAlarmsView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    contentProvider = new ActiveAlarmsContentProvider();
    viewer.setContentProvider(contentProvider);
    viewer.setInput(contentProvider);
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.NONE);
    nameColumn.getColumn().setWidth(300);
    nameColumn.getColumn().setText("Alarm");
    nameColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((XtceTreeNode) element).getName();
        }
    });
    TreeViewerColumn triggeredColumn = new TreeViewerColumn(viewer, SWT.NONE);
    triggeredColumn.getColumn().setWidth(300);
    triggeredColumn.getColumn().setText("Date");
    triggeredColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof XtceAlarmNode) {
                AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
                return String.valueOf(alarmData.getTriggerValue().getGenerationTimeUTC());
            } else {
                return null;
            }
        }
    });
    TreeViewerColumn currentSeverityColumn = new TreeViewerColumn(viewer, SWT.NONE);
    currentSeverityColumn.getColumn().setWidth(300);
    currentSeverityColumn.getColumn().setText("Current Severity");
    currentSeverityColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof XtceAlarmNode) {
                AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
                return String.valueOf(alarmData.getCurrentValue().getMonitoringResult());
            } else {
                return null;
            }
        }
    });
    TreeViewerColumn triggeredSeverityColumn = new TreeViewerColumn(viewer, SWT.NONE);
    triggeredSeverityColumn.getColumn().setWidth(300);
    triggeredSeverityColumn.getColumn().setText("Severity");
    triggeredSeverityColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof XtceAlarmNode) {
                AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
                return String.valueOf(alarmData.getTriggerValue().getMonitoringResult());
            } else {
                return null;
            }
        }
    });
    TreeViewerColumn typeColumn = new TreeViewerColumn(viewer, SWT.NONE);
    typeColumn.getColumn().setWidth(300);
    typeColumn.getColumn().setText("Type");
    typeColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof XtceAlarmNode) {
                AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
                return "Out of Limits";
            } else {
                return null;
            }
        }
    });
    TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.NONE);
    valueColumn.getColumn().setWidth(300);
    valueColumn.getColumn().setText("Value");
    valueColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof XtceAlarmNode) {
                AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
                return alarmData.getTriggerValue().getEngValue().toString();
            } else {
                return null;
            }
        }
    });
    TreeViewerColumn violationsColumn = new TreeViewerColumn(viewer, SWT.NONE);
    violationsColumn.getColumn().setWidth(300);
    violationsColumn.getColumn().setText("Violations");
    violationsColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof XtceAlarmNode) {
                AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
                return String.valueOf(alarmData.getViolations());
            } else {
                return null;
            }
        }
    });
    GridLayoutFactory.fillDefaults().generateLayout(parent);
    viewer.getTree().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeItem item = (TreeItem) e.item;
            if (item.getItemCount() > 0) {
                item.setExpanded(!item.getExpanded());
                viewer.refresh();
            }
        }
    });
    viewer.addDoubleClickListener(event -> {
        IStructuredSelection sel = (IStructuredSelection) event.getSelection();
        Object selectedNode = sel.getFirstElement();
        viewer.setExpandedState(selectedNode, !viewer.getExpandedState(selectedNode));
    });
    getSite().setSelectionProvider(viewer);
    // Set initial state
    viewer.refresh();
    AlarmCatalogue.getInstance().addAlarmListener(this);
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AlarmData(org.yamcs.protobuf.Alarms.AlarmData)

Example 2 with AlarmData

use of org.yamcs.protobuf.Alarms.AlarmData in project yamcs-studio by yamcs.

the class AlarmCatalogue method onMessage.

@Override
public void onMessage(WebSocketSubscriptionData msg) {
    if (msg.hasAlarmData()) {
        AlarmData alarmData = msg.getAlarmData();
        alarmListeners.forEach(l -> l.processAlarmData(alarmData));
    }
}
Also used : AlarmData(org.yamcs.protobuf.Alarms.AlarmData)

Aggregations

AlarmData (org.yamcs.protobuf.Alarms.AlarmData)2 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1