当前位置: 首页>>代码示例>>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;未经允许,请勿转载。