本文整理匯總了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);
}
示例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)));
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
示例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();
}
}
示例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);
}
示例10: addChild
import me.legrange.panstamp.Endpoint; //導入依賴的package包/類
@Override
void addChild(Endpoint ep) {
EndpointNode epn = new EndpointNode(ep);
addToTree(epn, this);
epn.start();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}