本文整理汇总了Java中org.dsa.iot.dslink.node.actions.ActionResult类的典型用法代码示例。如果您正苦于以下问题:Java ActionResult类的具体用法?Java ActionResult怎么用?Java ActionResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionResult类属于org.dsa.iot.dslink.node.actions包,在下文中一共展示了ActionResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeDiscoverAction
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void makeDiscoverAction() {
Action act = new Action(Permission.READ, new Handler<ActionResult>() {
public void handle(ActionResult event) {
discover();
}
});
Node anode = node.getChild("discover");
if (anode == null) node.createChild("discover").setAction(act).build().setSerializable(false);
else anode.setAction(act);
// act = new Action(Permission.READ, new Handler<ActionResult>() {
// public void handle(ActionResult event) {
// update();
// }
// });
// anode = node.getChild("update");
// if (anode == null) node.createChild("update").setAction(act).build().setSerializable(false);
// else anode.setAction(act);
}
示例2: handle
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的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);
}
示例3: makeImportAction
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void makeImportAction(final Node fnode) {
Action act = new Action(Permission.READ, new Handler<ActionResult>(){
@Override
public void handle(ActionResult event) {
handleImport(fnode, event);
}
});
act.addParameter(new Parameter("Name", ValueType.STRING));
act.addParameter(new Parameter("JSON", ValueType.STRING).setEditorType(EditorType.TEXT_AREA));
Node anode = fnode.getChild(ACTION_IMPORT, true);
if (anode == null) {
fnode.createChild(ACTION_IMPORT, true).setAction(act).build().setSerializable(false);
} else {
anode.setAction(act);
}
}
示例4: handleImport
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void handleImport(Node fnode, ActionResult event) {
String name = event.getParameter("Name", ValueType.STRING).getString();
String jsonStr = event.getParameter("JSON", ValueType.STRING).getString();
JsonObject children = new JsonObject(jsonStr);
Node child = fnode.createChild(name, true).build();
try {
Method deserMethod = Deserializer.class.getDeclaredMethod("deserializeNode", Node.class, JsonObject.class);
deserMethod.setAccessible(true);
deserMethod.invoke(conn.link.deserializer, child, children);
SlaveFolder bd = new SlaveFolder(conn, child, root);
bd.restoreLastSession();
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.debug("", e);
child.delete(false);
}
}
示例5: edit
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的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();
}
示例6: makeStopAction
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void makeStopAction() {
Action act = new Action(Permission.READ, new Handler<ActionResult>() {
public void handle(ActionResult event) {
if (reconnectFuture != null) {
reconnectFuture.cancel(false);
}
stop();
}
});
Node anode = node.getChild("stop", true);
if (anode == null)
node.createChild("stop", true).setAction(act).build().setSerializable(false);
else
anode.setAction(act);
}
示例7: makeImportAction
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void makeImportAction() {
Action act = new Action(Permission.READ, new Handler<ActionResult>(){
@Override
public void handle(ActionResult event) {
handleImport(event);
}
});
act.addParameter(new Parameter("Name", ValueType.STRING));
act.addParameter(new Parameter("JSON", ValueType.STRING).setEditorType(EditorType.TEXT_AREA));
Node anode = node.getChild(ACTION_IMPORT, true);
if (anode == null) {
node.createChild(ACTION_IMPORT, true).setAction(act).build().setSerializable(false);
} else {
anode.setAction(act);
}
}
示例8: handleImport
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void handleImport(ActionResult event) {
String name = event.getParameter("Name", ValueType.STRING).getString();
String jsonStr = event.getParameter("JSON", ValueType.STRING).getString();
JsonObject children = new JsonObject(jsonStr);
Node child = node.createChild(name, true).build();
try {
Method deserMethod = Deserializer.class.getDeclaredMethod("deserializeNode", Node.class, JsonObject.class);
deserMethod.setAccessible(true);
deserMethod.invoke(link.deserializer, child, children);
SlaveFolder bd = new SlaveNode(this, child);
bd.restoreLastSession();
} catch (SecurityException | IllegalArgumentException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
LOGGER.debug("", e);
child.delete(false);
}
}
示例9: handle
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
public void handle(ActionResult event) {
Action act = getAddSerialConnectionAction();
Node anode = node.getChild(ACTION_ADD_SERIAL_CONNECTION, true);
if (anode == null) {
anode = node.createChild(ACTION_ADD_SERIAL_CONNECTION, true).setAction(act).build();
anode.setSerializable(false);
} else {
anode.setAction(act);
}
for (ModbusConnection conn : connections) {
anode = conn.node.getChild(ACTION_EDIT, true);
if (anode != null) {
act = conn.getEditAction();
anode.setAction(act);
}
}
}
示例10: handle
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
public void handle(ActionResult event) {
String name = event.getParameter(ATTR_NAME, ValueType.STRING).getString();
int slaveid = event.getParameter(ModbusConnection.ATTR_SLAVE_ID, ValueType.NUMBER).getNumber().intValue();
intervalInMs = (long) (event.getParameter(ModbusConnection.ATTR_POLLING_INTERVAL, ValueType.NUMBER)
.getNumber().doubleValue() * 1000);
boolean zerofail = event.getParameter(ModbusConnection.ATTR_ZERO_ON_FAILED_POLL, ValueType.BOOL).getBool();
boolean batchpoll = event.getParameter(ModbusConnection.ATTR_USE_BATCH_POLLING, ValueType.BOOL).getBool();
boolean contig = event.getParameter(ModbusConnection.ATTR_CONTIGUOUS_BATCH_REQUEST_ONLY, ValueType.BOOL)
.getBool();
node.setAttribute(ModbusConnection.ATTR_SLAVE_ID, new Value(slaveid));
node.setAttribute(ModbusConnection.ATTR_POLLING_INTERVAL, new Value(intervalInMs));
node.setAttribute(ModbusConnection.ATTR_ZERO_ON_FAILED_POLL, new Value(zerofail));
node.setAttribute(ModbusConnection.ATTR_USE_BATCH_POLLING, new Value(batchpoll));
node.setAttribute(ModbusConnection.ATTR_CONTIGUOUS_BATCH_REQUEST_ONLY, new Value(contig));
conn.getLink().handleEdit(root);
if (!name.equals(node.getName())) {
rename(name);
} else {
checkDeviceConnected();
makeEditAction();
}
}
示例11: makeRemoveAction
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void makeRemoveAction() {
Action act = new Action(Permission.READ, new Handler<ActionResult>() {
public void handle(ActionResult event) {
remove();
}
});
Node anode = node.getChild("remove");
if (anode == null) node.createChild("remove").setAction(act).build().setSerializable(false);
else anode.setAction(act);
}
示例12: makeEditAction
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
void makeEditAction() {
Action act = new Action(Permission.READ, new Handler<ActionResult>() {
public void handle(ActionResult event) {
edit(event);
}
});
act.addParameter(new Parameter("Name", ValueType.STRING, new Value(node.getName())));
if (isSerial) {
Set<String> portids = link.getCOMPorts();
if (portids.size() > 0) {
if (portids.contains(node.getAttribute("COM Port").getString())) {
act.addParameter(new Parameter("COM Port", ValueType.makeEnum(portids), node.getAttribute("COM Port")));
act.addParameter(new Parameter("COM Port (manual entry)", ValueType.STRING));
} else {
act.addParameter(new Parameter("COM Port", ValueType.makeEnum(portids)));
act.addParameter(new Parameter("COM Port (manual entry)", ValueType.STRING, node.getAttribute("COM Port")));
}
} else {
act.addParameter(new Parameter("COM Port", ValueType.STRING, node.getAttribute("COM Port")));
}
act.addParameter(new Parameter("Baud Rate", ValueType.NUMBER, node.getAttribute("Baud Rate")));
act.addParameter(new Parameter("Data Bits", ValueType.NUMBER, node.getAttribute("Data Bits")));
act.addParameter(new Parameter("Stop Bits", ValueType.NUMBER, node.getAttribute("Stop Bits")));
act.addParameter(new Parameter("Parity", ValueType.NUMBER, node.getAttribute("Parity")));
} else {
act.addParameter(new Parameter("Host", ValueType.STRING, node.getAttribute("Host")));
act.addParameter(new Parameter("Port", ValueType.NUMBER, node.getAttribute("Port")));
}
act.addParameter(new Parameter("Master Address", ValueType.NUMBER, node.getAttribute("Master Address")));
act.addParameter(new Parameter("Outstation Address", ValueType.NUMBER, node.getAttribute("Outstation Address")));
double defint = node.getAttribute("Event Polling Interval").getNumber().doubleValue() / 1000;
act.addParameter(new Parameter("Event Polling Interval", ValueType.NUMBER, new Value(defint)));
double defsint = node.getAttribute("Static Polling Interval").getNumber().doubleValue() / 1000;
act.addParameter(new Parameter("Static Polling Interval", ValueType.NUMBER, new Value(defsint)));
Node anode = node.getChild("edit");
if (anode == null) node.createChild("edit").setAction(act).build().setSerializable(false);
else anode.setAction(act);
}
示例13: makePortScanAction
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
private void makePortScanAction() {
Action act = new Action(Permission.READ, new Handler<ActionResult>() {
public void handle(ActionResult event) {
doPortScan();
}
});
node.createChild("scan for serial ports").setAction(act).build().setSerializable(false);
}
示例14: getTransportType
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
public IpTransportType getTransportType(ActionResult event) {
IpTransportType transtype;
try {
transtype = IpTransportType
.valueOf(event.getParameter(ATTRIBUTE_TRANSPORT_TYPE, ValueType.STRING).getString().toUpperCase());
return transtype;
} catch (Exception e) {
LOGGER.error("invalid transport type");
LOGGER.debug("error: ", e);
return null;
}
}
示例15: edit
import org.dsa.iot.dslink.node.actions.ActionResult; //导入依赖的package包/类
@Override
public void edit(ActionResult event) {
String name = event.getParameter(ATTRIBUTE_NAME, ValueType.STRING).getString();
if (!name.equals(node.getName())) {
rename(name);
}
this.setEditAction();
}