SICS Device Status Gadget_135856370 - Gumtree/gumtree GitHub Wiki

Created by Tony Lam, last modified on Dec 09, 2009

Introduction

SICS device status gadget is a generic component for displaying dynamic components from the hipadabase tree. The layout of the gadget is follow:
icon (optional) device label current value unit (optional)
icon (optional) device label current value unit (optional)
...      

Adding Device To Gadget

To add devices for status monitoring programmatically, try:
gadget.getDeviceURIList().add(<URI>)
This gadget is also designed to be run with dashboard, so devices can be set via single string:
// Use comma separated uri string
gadget.setDeviceURIs("sics://hdb/sample/phi, sics://hdb/sample/chi")

Icon Support

To enable icon support, you need to supply "DeviceStatusGadget.SHOW_ICON" to the style, and set ILabelProvider to the gadget.

Other Support Style

Unit support is enabled by supplying "DeviceStatusGadget.SHOW_UNIT" to the style. You can also add a separator in between by adding empyt URI, for example:
// Use comma separated uri string
gadget.setDeviceURIs("sics://hdb/sample/phi, , sics://hdb/sample/chi")
Above will add a separator between motors phi and chi.

Examples

Fixed Gadget
You can create a fixed gadget for monitoring a set of predefined devices by subclassing this status widget:
public class WombatMotorStatusGadget extends DeviceStatusGadget {

    public WombatMotorStatusGadget(Composite parent, int style) {
        super(parent, SHOW_UNIT);
        setDeviceURIs("sics://hdb/sample/phi, sics://hdb/sample/chi");
    }

}
Image:attachments/135856370/136019975.png
To include icons:
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.gumtree.gumnix.sics.ui.widget.DeviceStatusGadget;

import au.gov.ansto.bragg.nbi.ui.internal.InternalImage;

public class ReactorSourceGadget extends DeviceStatusGadget {

    private static URI URI_POWER = URI.create("sics://hdb/instrument/source/power");

    private static URI URI_CNS_IN = URI.create("sics://hdb/instrument/source/cns_inlet_temp");

    private static URI URI_CNS_OUT = URI.create("sics://hdb/instrument/source/cns_outlet_temp");

    public ReactorSourceGadget(Composite parent, int style) {
        super(parent, SHOW_ICON | SHOW_UNIT);
        getDeviceURIList().add(URI_POWER);
        getDeviceURIList().add(URI_CNS_IN);
        getDeviceURIList().add(URI_CNS_OUT);
        setLabelProvider(new LabelProvider() {
            public Image getImage(Object element) {
                URI uri = (URI) element;
                if (uri.equals(URI_POWER)) {
                    return InternalImage.POWER_16.getImage();
                } else if (uri.equals(URI_CNS_IN)) {
                    return InternalImage.INLET_16.getImage();
                } else if (uri.equals(URI_CNS_OUT)) {
                    return InternalImage.OUTLET_16.getImage();
                }
                return null;
            }
            public String getText(Object element) {
                URI uri = (URI) element;
                if (uri.equals(URI_POWER)) {
                    return "Power";
                } else if (uri.equals(URI_CNS_IN)) {
                    return "CNS In";
                } else if (uri.equals(URI_CNS_OUT)) {
                    return "CNS Out";
                }
                return "";
            }
        });
    }

}
Image:attachments/135856370/136019976.png
Dashboard
This gadget can be used as custom SWT component, or embedded into the dashboard:
<dashboard title="Wombat Control" layoutConstraints="flowx">
  <widget classname="org.gumtree.gumnix.sics.ui.widget.DeviceStatusGadget" title="Status" style="4">
    <parameters>
      <deviceURIs>
        sics://hdb/sample/translate_x,
        sics://hdb/sample/rotate
      </deviceURIs>
    </parameters>
    </widget>
</dashboard>
Image:attachments/135856370/136019977.png
Style is set to 4 for showing unit.
Document generated by Confluence on Apr 01, 2015 00:11
⚠️ **GitHub.com Fallback** ⚠️