當前位置: 首頁>>代碼示例>>Java>>正文


Java Endpoint類代碼示例

本文整理匯總了Java中me.legrange.panstamp.Endpoint的典型用法代碼示例。如果您正苦於以下問題:Java Endpoint類的具體用法?Java Endpoint怎麽用?Java Endpoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Endpoint類屬於me.legrange.panstamp包,在下文中一共展示了Endpoint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatValue

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
public static  String formatValue(Endpoint ep) throws NetworkException {
    List<String> units = ep.getUnits();
    String unit = "";
    Object val;
    if (ep.hasValue()) {
        val = ep.getValue();
        if (!units.isEmpty()) {
            unit = units.get(0);
            val = ep.getValue(unit);
        }
        if (val instanceof Double) {
            return String.format("%.1f %s", ((Double) val), unit);
        }
        if (val instanceof Boolean) {
            return ((Boolean) val) ? "on" : "off";
        }
    }
    else {
        val = "<unknown>";
    }
    return String.format("%s%s", val.toString(), unit);
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:23,代碼來源:Format.java

示例2: toState

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
/**
 * convert the value value for and endpoint to a state message
 * 
 * @param ep
 *            The endpoint for which the value is converted
 * @param val
 *            The value being converted
 * @return a new State object for the value
 */
static State toState(Endpoint<?> ep, Object val) throws ValueException {
    switch (ep.getType()) {
        case STRING:
            return new StringType(val.toString());
        case NUMBER:
            return new DecimalType(((Double) val));
        case INTEGER:
            return new DecimalType(((Long) val));
        case BINARY:
            return ((Boolean) val) ? OnOffType.ON : OnOffType.OFF;
        default:
            throw new ValueException(String.format("Unsupported panStamp endpoint type '%s' for endpoint %s. BUG!",
                    ep.getType(), toString(ep)));
    }
}
 
開發者ID:openhab,項目名稱:openhab1-addons,代碼行數:25,代碼來源:PanStampConversions.java

示例3: getConfigs

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
/**
 * Return all available binding configs for the given endpoint
 *
 * @param ep
 *            The endpoint for which configs are requested.
 * @return The configs found.
 */
private List<PanStampBindingConfig<?>> getConfigs(Endpoint<?> ep) {
    List<PanStampBindingConfig<?>> configs = new ArrayList<PanStampBindingConfig<?>>();
    Register reg = ep.getRegister();
    PanStamp ps = reg.getDevice();
    for (PanStampBindingProvider prov : providers) {
        for (String itemName : prov.getItemNames()) {
            PanStampBindingConfig<?> conf = prov.getConfig(itemName);
            if ((conf.getAddress() == ps.getAddress() && (conf.getRegister() == reg.getId())
                    && conf.getEndpoint().equals(ep.getName()))) {
                configs.add(conf);
            }
        }
    }
    return configs;
}
 
開發者ID:openhab,項目名稱:openhab1-addons,代碼行數:23,代碼來源:PanStampBinding.java

示例4: getEndpointChart

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
public JFrame getEndpointChart(Endpoint ep) {
    JFrame frame = endpointCharts.get(ep);
    if (frame == null) {
        frame = frameChart(new EndpointChart(model.getEndpointDataSet(ep)));
        endpointCharts.put(ep, frame);
    }
    return frame;
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:9,代碼來源:ChartFactory.java

示例5: yAxisName

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
private static String yAxisName(Endpoint ep) {
    List<String> units = ep.getUnits();
    if (units.isEmpty()) {
        return ep.getName();
    }
    return String.format("%s (%s)", ep.getName(), units.get(0));
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:8,代碼來源:EndpointChart.java

示例6: getSelectedEndpoint

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
/**
 * Determine which endpoint, if any, is currently selected in the tree view.
 * A endpoint is considered selected if a endpoint node is selected.
 *
 * @return The selected endpoint, or null if none is selected.
 */
private Endpoint getSelectedEndpoint() {
    NetworkTreeNode node = getSelectedNode();
    if (node != null) {
        if (node.getType() == NetworkTreeNode.Type.ENDPOINT) {
            return ((EndpointNode) node).getEndpoint();
        }
    }
    return null;
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:16,代碼來源:Menus.java

示例7: getEndpointIcon

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
/**
 * Find the most fitting icon for the given endpoint
 */
static Icon getEndpointIcon(Endpoint ep) {
    String name = ep.getName();
    String val = null;
    if (name != null) {
        val = findForName(name.toLowerCase().trim());
    }
    if (val == null) {
        val = ep.isOutput() ? DEFAULT_OUTPUT : DEFAULT_INPUT;
    }
    return getIcon(val);
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:15,代碼來源:IconMap.java

示例8: start

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
@Override
protected synchronized void start() {
    getRegister().addListener(this);
    for (Endpoint ep : getRegister().getEndpoints()) {
        EndpointNode epn = new EndpointNode(ep);
        addToTree(epn, this);
        epn.start();
    }
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:10,代碼來源:RegisterNode.java

示例9: update

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
void update(Register reg) {
    if (reg.getEndpoints().size() != getRegister().getEndpoints().size()) {
        
        for (Endpoint ep : getRegister().getEndpoints()) {
            EndpointNode epn = new EndpointNode(ep);
            addToTree(epn, this);
            epn.start();
        }
        reload();
    }
    setUserObject(reg);
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:13,代碼來源:RegisterNode.java

示例10: addChild

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
@Override
void addChild(Endpoint ep) {
    EndpointNode epn = new EndpointNode(ep);
    addToTree(epn, this);
    epn.start();

}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:8,代碼來源:RegisterNode.java

示例11: EndpointDataSet

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
public EndpointDataSet(Endpoint ep, String unit) {
    this.ep = ep;
    if (unit == null) { 
        List<String> units = ep.getUnits();
        if (!units.isEmpty()) {
            unit = units.get(0);
        }
    }
    this.unit = unit;
    ep.addListener(this);
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:12,代碼來源:EndpointDataSet.java

示例12: asDouble

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
private double asDouble(Endpoint ep) {
    try {
        switch (ep.getType()) {
            case BINARY:
                Boolean b = (Boolean) ep.getValue();
                return b ? 1.0 : 0.0;
            case INTEGER:
                Integer i;
                if (unit == null) {
                    i = (Integer) ep.getValue();
                } else {
                    i = (Integer) ep.getValue(unit);
                }
                return i.doubleValue();
            case NUMBER:
                Double d;
                if (unit == null) {
                    d = (Double) ep.getValue();
                } else {
                    d = (Double) ep.getValue(unit);
                }
                return d;
            case STRING:
            case BYTE_ARRAY :
                return 0.0;
        }
    } catch (NetworkException e) {
        
    }
    return 0.0;
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:32,代碼來源:EndpointDataSet.java

示例13: getDataSet

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
public EndpointDataSet getDataSet(Endpoint ep) {
    EndpointDataSet ds = sets.get(ep);
    if (ds == null) {
        ds = addDataSet(ep);
    }
    return ds;
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:8,代碼來源:EndpointCollector.java

示例14: addDataSet

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
private EndpointDataSet addDataSet(Endpoint ep) {
    EndpointDataSet ds = new EndpointDataSet(ep);
    sets.put(ep, ds);
    
    ep.addListener(ds);
    return ds;
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:8,代碼來源:EndpointCollector.java

示例15: add

import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
private void add(Register reg) {
    if (reg.getDevice().getNetwork().isOpen()) {
        add(String.format("Learnt of register %d for device %d", reg.getId(), reg.getDevice().getAddress()));
    }
    reg.addListener(registerL);
    for (Endpoint ep : reg.getEndpoints()) {
        add(ep);
    }
}
 
開發者ID:GideonLeGrange,項目名稱:panstamp-tools,代碼行數:10,代碼來源:EndpointTableModel.java


注:本文中的me.legrange.panstamp.Endpoint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。