本文整理汇总了Java中org.dsa.iot.dslink.node.value.Value类的典型用法代码示例。如果您正苦于以下问题:Java Value类的具体用法?Java Value怎么用?Java Value使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Value类属于org.dsa.iot.dslink.node.value包,在下文中一共展示了Value类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSet
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
private void handleSet(DataType type, int index, Value val) {
Buffer cmd = null;
if (type == DataType.AO) {
cmd = user.buildAnalogControlCommand(AppFeatures.DIRECT_OPERATE, index, val.getNumber().doubleValue());
} else if (type == DataType.BO) {
byte code = val.getBool().booleanValue() ? (byte) 1 : (byte) 0;
cmd = user.buildBinaryControlCommand(AppFeatures.DIRECT_OPERATE, index, code, 0, 0);
}
if (cmd != null) {
try {
user.sendSynch(cmd);
} catch (Exception e) {
LOGGER.debug("" ,e);
}
discover();
}
}
示例2: startPoll
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
private void startPoll() {
if (future != null) return;
long interval = node.getAttribute("Event Polling Interval").getNumber().longValue();
ScheduledThreadPoolExecutor stpe = Objects.getDaemonThreadPool();
future = stpe.scheduleWithFixedDelay(new Runnable() {
public void run() {
if (pollsSinceLastDiscover < pollsPerDiscover - 1) {
try {
LOGGER.debug("Sending Read Event Data Request");
user.sendSynch(user.buildReadEventDataMsg());
statnode.setValue(new Value("Connected"));
} catch (Exception e) {
statnode.setValue(new Value("Latest poll failed"));
LOGGER.debug("" ,e);
}
pollsSinceLastDiscover += 1;
} else {
discover();
pollsSinceLastDiscover = 0;
}
}
}, 0, interval, TimeUnit.MILLISECONDS);
}
示例3: IpConnectionWithDevice
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
IpConnectionWithDevice(ModbusLink link, final Node node) {
super(link, node);
node.setAttribute(ATTR_RESTORE_TYPE, new Value(SlaveFolder.ATTR_RESTORE_FOLDER));
statnode.getListener().setValueHandler(new Handler<ValuePair>() {
@Override
public void handle(ValuePair event) {
Value value = event.getCurrent();
for (SlaveNode sn : new HashSet<SlaveNode>(slaves)) {
if (sn.node != node && sn instanceof SlaveNodeWithConnection
&& ((SlaveNodeWithConnection) sn).connStatNode != null) {
((SlaveNodeWithConnection) sn).connStatNode.setValue(value);
}
}
}
});
}
示例4: getEditAction
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
@Override
Action getEditAction() {
Action act = new Action(Permission.READ, new EditHandler());
act.addParameter(new Parameter(ATTR_NAME, ValueType.STRING, new Value(node.getName())));
act.addParameter(new Parameter(ATTR_TRANSPORT_TYPE, ValueType.makeEnum(Util.enumNames(IpTransportType.class))));
act.addParameter(new Parameter(ATTR_HOST, ValueType.STRING, node.getAttribute(ATTR_HOST)));
act.addParameter(new Parameter(ATTR_PORT, ValueType.NUMBER, node.getAttribute(ATTR_PORT)));
act.addParameter(new Parameter(ATTR_TIMEOUT, ValueType.NUMBER, node.getAttribute(ATTR_TIMEOUT)));
act.addParameter(new Parameter(ATTR_RETRIES, ValueType.NUMBER, node.getAttribute(ATTR_RETRIES)));
act.addParameter(
new Parameter(ATTR_MAX_READ_BIT_COUNT, ValueType.NUMBER, node.getAttribute(ATTR_MAX_READ_BIT_COUNT)));
act.addParameter(new Parameter(ATTR_MAX_READ_REGISTER_COUNT, ValueType.NUMBER,
node.getAttribute(ATTR_MAX_READ_REGISTER_COUNT)));
act.addParameter(new Parameter(ATTR_MAX_WRITE_REGISTER_COUNT, ValueType.NUMBER,
node.getAttribute(ATTR_MAX_WRITE_REGISTER_COUNT)));
act.addParameter(
new Parameter(ATTR_DISCARD_DATA_DELAY, ValueType.NUMBER, node.getAttribute(ATTR_DISCARD_DATA_DELAY)));
act.addParameter(new Parameter(ATTR_USE_MULTIPLE_WRITE_COMMAND, ValueType.makeEnum(MULTIPLE_WRITE_COMMAND_OPTIONS),
node.getAttribute(ATTR_USE_MULTIPLE_WRITE_COMMAND)));
return act;
}
示例5: handle
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
public void handle(ActionResult event) {
String name = event.getParameter(ATTR_SLAVE_NAME, ValueType.STRING).getString();
Node deviceNode = node.createChild(name, true).build();
int slaveid = event.getParameter(ATTR_SLAVE_ID, ValueType.NUMBER).getNumber().intValue();
long intervalMs = (long) (event.getParameter(ATTR_POLLING_INTERVAL, ValueType.NUMBER).getNumber().intValue()
* 1000);
boolean zerofail = event.getParameter(ATTR_ZERO_ON_FAILED_POLL, ValueType.BOOL).getBool();
boolean batchpoll = event.getParameter(ATTR_USE_BATCH_POLLING, ValueType.BOOL).getBool();
boolean contig = event.getParameter(ATTR_CONTIGUOUS_BATCH_REQUEST_ONLY, ValueType.BOOL).getBool();
deviceNode.setAttribute(ATTR_SLAVE_ID, new Value(slaveid));
deviceNode.setAttribute(ATTR_POLLING_INTERVAL, new Value(intervalMs));
deviceNode.setAttribute(ATTR_ZERO_ON_FAILED_POLL, new Value(zerofail));
deviceNode.setAttribute(ATTR_USE_BATCH_POLLING, new Value(batchpoll));
deviceNode.setAttribute(ATTR_CONTIGUOUS_BATCH_REQUEST_ONLY, new Value(contig));
new SlaveNode(conn, deviceNode);
}
示例6: copyPoint
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
private Node copyPoint(Node pointNode, String name) {
Node pointNodeCopy = node.createChild(name, true).setValueType(pointNode.getValueType())
.setValue(pointNode.getValue()).build();
pointNodeCopy.setAttribute(ATTR_POINT_TYPE, pointNode.getAttribute(ATTR_POINT_TYPE));
pointNodeCopy.setAttribute(ATTR_OFFSET, pointNode.getAttribute(ATTR_OFFSET));
pointNodeCopy.setAttribute(ATTR_NUMBER_OF_REGISTERS, pointNode.getAttribute(ATTR_NUMBER_OF_REGISTERS));
pointNodeCopy.setAttribute(ATTR_DATA_TYPE, pointNode.getAttribute(ATTR_DATA_TYPE));
pointNodeCopy.setAttribute(ATTR_BIT, pointNode.getAttribute(ATTR_BIT));
pointNodeCopy.setAttribute(ATTR_SCALING, pointNode.getAttribute(ATTR_SCALING));
pointNodeCopy.setAttribute(ATTR_SCALING_OFFSET, pointNode.getAttribute(ATTR_SCALING_OFFSET));
pointNodeCopy.setAttribute(ATTR_WRITBLE, pointNode.getAttribute(ATTR_WRITBLE));
pointNodeCopy.setAttribute(ATTR_RESTORE_TYPE, new Value("point"));
setupPointActions(pointNodeCopy);
conn.getLink().setupPoint(pointNodeCopy, root);
return pointNodeCopy;
}
示例7: setEditAction
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
public void setEditAction() {
Action act = new Action(Permission.READ, new EditHandler());
act.addParameter(new Parameter(ATTRIBUTE_NAME, ValueType.STRING, new Value(node.getName())));
act.addParameter(
new Parameter(ATTRIBUTE_TRANSPORT_TYPE, ValueType.makeEnum(Util.enumNames(IpTransportType.class)),
node.getAttribute(ATTRIBUTE_TRANSPORT_TYPE)));
act.addParameter(new Parameter(ATTRIBUTE_PORT, ValueType.NUMBER, node.getAttribute(ATTRIBUTE_PORT)));
act.addParameter(new Parameter(ATTRIBUTE_SLAVE_ID, ValueType.NUMBER, node.getAttribute(ATTRIBUTE_SLAVE_ID)));
Node editNode = node.getChild(ACTION_EDIT, true);
if (editNode == null)
node.createChild(ACTION_EDIT, true).setAction(act).build().setSerializable(false);
else
editNode.setAction(act);
}
示例8: edit
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
@Override
public void edit(ActionResult event) {
String oldName = node.getName();
String oldTransType = node.getAttribute(ATTRIBUTE_TRANSPORT_TYPE).getString();
IpTransportType transtype = getTransportType(event);
int port = getTransportPort(event);
String name = event.getParameter(ATTRIBUTE_NAME, ValueType.STRING).getString();
int slaveid = event.getParameter(ATTRIBUTE_SLAVE_ID, ValueType.NUMBER).getNumber().intValue();
node.setAttribute(ATTRIBUTE_TRANSPORT_TYPE, new Value(transtype.toString()));
node.setAttribute(ATTRIBUTE_PORT, new Value(port));
node.setAttribute(ATTRIBUTE_SLAVE_ID, new Value(slaveid));
if (!name.equals(oldName)) {
rename(name);
}
if (!transtype.toString().equals(oldTransType)) {
switchListener(transtype, port);
}
this.setEditAction();
}
示例9: startListening
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
void startListening() {
if (listenerStpe != null) {
listenerStpe.execute(new Runnable() {
@Override
public void run() {
try {
statusNode.setValue(new Value(STATUS_START_LISTENING));
activeListener.start();
} catch (ModbusInitException e) {
e.printStackTrace();
}
}
});
}
}
示例10: stopListening
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
void stopListening() {
if (listenerStpe != null) {
listenerStpe.execute(new Runnable() {
@Override
public void run() {
try {
statusNode.setValue(new Value(STATUS_STOP_LISTENING));
activeListener.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
示例11: holdingRegisterWrite
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
@Override
public void holdingRegisterWrite(int offset, short oldValue, short newValue) {
if (oldValue != newValue) {
Node pointNode = offsetToPoint.get(offset);
DataType dataType = DataType.valueOf(pointNode.getAttribute(ATTRIBUTE_DATA_TYPE).getString());
if (dataType.isString()) {
ByteBuffer buffer = ByteBuffer.allocate(2);
buffer.putShort(newValue);
String str = new String(buffer.array(), StandardCharsets.UTF_8);
pointNode.setValue(new Value(str));
} else {
pointNode.setValue(new Value(newValue));
}
}
}
示例12: checkConnection
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
void checkConnection() {
synchronized (masterLock) {
boolean connected = (master != null) && master.isInitialized();
if (!connected) {
statnode.setValue(new Value(NODE_STATUS_CONNECTING));
if (master != null) {
try {
master.destroy();
link.masters.remove(master);
} catch (Exception e) {
}
}
master = null;
scheduleReconnect();
} else {
statnode.setValue(new Value(NODE_STATUS_CONNECTED));
}
}
}
示例13: scheduleReconnect
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
synchronized void scheduleReconnect() {
if (link.restoring || (reconnectFuture != null && !reconnectFuture.isDone())) {
return;
}
ScheduledThreadPoolExecutor reconnectStpe = Objects.getDaemonThreadPool();
reconnectFuture = reconnectStpe.schedule(new Runnable() {
@Override
public void run() {
Value stat = statnode.getValue();
if (stat == null || !(NODE_STATUS_CONNECTED.equals(stat.getString())
|| NODE_STATUS_SETTINGUP.equals(stat.getString()))) {
stop();
restoreLastSession();
}
}
}, retryDelay, TimeUnit.SECONDS);
if (retryDelay < RETRY_DELAY_MAX)
retryDelay += RETRY_DELAY_STEP;
}
示例14: getAddIpConnectionAction
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
private Action getAddIpConnectionAction() {
Action act = new Action(Permission.READ, new AddIpConnectionHandler());
act.addParameter(new Parameter(ModbusConnection.ATTR_CONNECTION_NAME, ValueType.STRING));
act.addParameter(new Parameter(ModbusConnection.ATTR_TRANSPORT_TYPE, ValueType.makeEnum("TCP", "UDP")));
act.addParameter(new Parameter(IpConnection.ATTR_HOST, ValueType.STRING, new Value("")));
act.addParameter(new Parameter(IpConnection.ATTR_PORT, ValueType.NUMBER, new Value(502)));
act.addParameter(new Parameter(ModbusConnection.ATTR_TIMEOUT, ValueType.NUMBER, new Value(500)));
act.addParameter(new Parameter(ModbusConnection.ATTR_RETRIES, ValueType.NUMBER, new Value(2)));
act.addParameter(new Parameter(ModbusConnection.ATTR_MAX_READ_BIT_COUNT, ValueType.NUMBER, new Value(2000)));
act.addParameter(
new Parameter(ModbusConnection.ATTR_MAX_READ_REGISTER_COUNT, ValueType.NUMBER, new Value(125)));
act.addParameter(
new Parameter(ModbusConnection.ATTR_MAX_WRITE_REGISTER_COUNT, ValueType.NUMBER, new Value(120)));
act.addParameter(new Parameter(ModbusConnection.ATTR_DISCARD_DATA_DELAY, ValueType.NUMBER, new Value(0)));
act.addParameter(
new Parameter(ModbusConnection.ATTR_USE_MULTIPLE_WRITE_COMMAND, ValueType.makeEnum(ModbusConnection.MULTIPLE_WRITE_COMMAND_OPTIONS), new Value(ModbusConnection.MULTIPLE_WRITE_COMMAND_DEFAULT)));
return act;
}
示例15: makeEditAction
import org.dsa.iot.dslink.node.value.Value; //导入依赖的package包/类
void makeEditAction() {
Action act = new Action(Permission.READ, new EditHandler());
act.addParameter(new Parameter(ModbusConnection.ATTR_SLAVE_NAME, ValueType.STRING, new Value(node.getName())));
act.addParameter(new Parameter(ModbusConnection.ATTR_SLAVE_ID, ValueType.NUMBER,
node.getAttribute(ModbusConnection.ATTR_SLAVE_ID)));
double defint = node.getAttribute(ModbusConnection.ATTR_POLLING_INTERVAL).getNumber().doubleValue() / 1000;
act.addParameter(new Parameter(ModbusConnection.ATTR_POLLING_INTERVAL, ValueType.NUMBER, new Value(defint)));
act.addParameter(new Parameter(ModbusConnection.ATTR_ZERO_ON_FAILED_POLL, ValueType.BOOL,
node.getAttribute(ModbusConnection.ATTR_ZERO_ON_FAILED_POLL)));
act.addParameter(new Parameter(ModbusConnection.ATTR_USE_BATCH_POLLING, ValueType.BOOL,
node.getAttribute(ModbusConnection.ATTR_USE_BATCH_POLLING)));
act.addParameter(new Parameter(ModbusConnection.ATTR_CONTIGUOUS_BATCH_REQUEST_ONLY, ValueType.BOOL,
node.getAttribute(ModbusConnection.ATTR_CONTIGUOUS_BATCH_REQUEST_ONLY)));
Node anode = node.getChild(ACTION_EDIT, true);
if (anode == null)
node.createChild(ACTION_EDIT, true).setAction(act).build().setSerializable(false);
else
anode.setAction(act);
}