gui - initial support for emane configuration per node and interface
This commit is contained in:
parent
08922f267a
commit
9f5495ba10
5 changed files with 41 additions and 20 deletions
|
@ -36,15 +36,15 @@ public interface ICoreClient {
|
|||
|
||||
boolean setServiceFile(CoreNode node, String serviceName, ServiceFile serviceFile) throws IOException;
|
||||
|
||||
GetConfig getEmaneModelConfig(CoreNode node, String model) throws IOException;
|
||||
|
||||
GetConfig getEmaneConfig(CoreNode node) throws IOException;
|
||||
|
||||
GetEmaneModels getEmaneModels() throws IOException;
|
||||
|
||||
boolean setEmaneConfig(CoreNode node, List<ConfigOption> options) throws IOException;
|
||||
|
||||
boolean setEmaneModelConfig(CoreNode node, String model, List<ConfigOption> options) throws IOException;
|
||||
GetConfig getEmaneModelConfig(Integer id, String model) throws IOException;
|
||||
|
||||
boolean setEmaneModelConfig(Integer id, String model, List<ConfigOption> options) throws IOException;
|
||||
|
||||
boolean isRunning();
|
||||
|
||||
|
|
|
@ -238,10 +238,10 @@ public class CoreRestClient implements ICoreClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public GetConfig getEmaneModelConfig(CoreNode node, String model) throws IOException {
|
||||
public GetConfig getEmaneModelConfig(Integer id, String model) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId));
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("node", node.getId().toString());
|
||||
args.put("node", id.toString());
|
||||
args.put("name", model);
|
||||
return WebUtils.getJson(url, GetConfig.class, args);
|
||||
}
|
||||
|
@ -264,10 +264,10 @@ public class CoreRestClient implements ICoreClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setEmaneModelConfig(CoreNode node, String model, List<ConfigOption> options) throws IOException {
|
||||
public boolean setEmaneModelConfig(Integer id, String model, List<ConfigOption> options) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId));
|
||||
SetEmaneModelConfig setEmaneModelConfig = new SetEmaneModelConfig();
|
||||
setEmaneModelConfig.setNode(node.getId());
|
||||
setEmaneModelConfig.setNode(id);
|
||||
setEmaneModelConfig.setName(model);
|
||||
setEmaneModelConfig.setValues(options);
|
||||
return WebUtils.putJson(url, setEmaneModelConfig);
|
||||
|
|
|
@ -48,6 +48,8 @@ public class NodeDetails extends ScrollPane {
|
|||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
setPrefWidth(500);
|
||||
}
|
||||
|
||||
public void setNode(CoreNode node) {
|
||||
|
@ -67,8 +69,12 @@ public class NodeDetails extends ScrollPane {
|
|||
|
||||
addSeparator();
|
||||
|
||||
addRow("X", node.getPosition().getX().toString());
|
||||
addRow("Y", node.getPosition().getY().toString());
|
||||
if (node.getPosition().getX() != null) {
|
||||
addRow("X", node.getPosition().getX().toString());
|
||||
}
|
||||
if (node.getPosition().getY() != null) {
|
||||
addRow("Y", node.getPosition().getY().toString());
|
||||
}
|
||||
|
||||
for (CoreLink link : controller.getNetworkGraph().getGraph().getIncidentEdges(node)) {
|
||||
CoreNode linkedNode;
|
||||
|
@ -87,13 +93,23 @@ public class NodeDetails extends ScrollPane {
|
|||
|
||||
addSeparator();
|
||||
if (linkedNode.getType() == NodeType.EMANE) {
|
||||
addButton(linkedNode.getName(), event -> controller.getNodeEmaneDialog().showDialog(linkedNode));
|
||||
String emaneModel = linkedNode.getEmane();
|
||||
String linkedLabel = String.format("%s - %s", linkedNode.getName(), emaneModel);
|
||||
addButton(linkedLabel, event -> controller.getNodeEmaneDialog()
|
||||
.displayEmaneModelConfig(linkedNode.getId(), emaneModel));
|
||||
String nodeLabel = String.format("%s - %s", node.getName(), emaneModel);
|
||||
addButton(nodeLabel, event -> controller.getNodeEmaneDialog()
|
||||
.displayEmaneModelConfig(node.getId(), emaneModel));
|
||||
String interfaceLabel = String.format("%s - %s", coreInterface.getName(), emaneModel);
|
||||
Integer interfaceId = 1000 * node.getId() + coreInterface.getId();
|
||||
addButton(interfaceLabel, event -> controller.getNodeEmaneDialog()
|
||||
.displayEmaneModelConfig(interfaceId, emaneModel));
|
||||
}
|
||||
|
||||
if (linkedNode.getType() == NodeType.WLAN) {
|
||||
addButton(linkedNode.getName(), event -> controller.getNodeWlanDialog().showDialog(linkedNode));
|
||||
}
|
||||
addInterface(coreInterface);
|
||||
addInterface(coreInterface, linkedNode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,7 +148,8 @@ public class NodeDetails extends ScrollPane {
|
|||
GridPane.setMargin(separator, new Insets(10, 0, 0, 0));
|
||||
}
|
||||
|
||||
private void addInterface(CoreInterface coreInterface) {
|
||||
private void addInterface(CoreInterface coreInterface, CoreNode linkedNode) {
|
||||
addRow("Linked To", linkedNode.getName());
|
||||
addRow("Interface", coreInterface.getName());
|
||||
if (coreInterface.getMac() != null) {
|
||||
addRow("MAC", coreInterface.getMac());
|
||||
|
|
|
@ -68,26 +68,30 @@ public class NodeEmaneDialog extends StageDialog {
|
|||
}
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
logger.error("error getting emane model config", ex);
|
||||
Toast.error("error getting emane model config", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void emaneModelButtonHandler(ActionEvent event) {
|
||||
String model = modelCombo.getSelectionModel().getSelectedItem();
|
||||
displayEmaneModelConfig(coreNode.getId(), model);
|
||||
}
|
||||
|
||||
public void displayEmaneModelConfig(Integer id, String model) {
|
||||
try {
|
||||
GetConfig getConfig = getCoreClient().getEmaneModelConfig(coreNode, model);
|
||||
GetConfig getConfig = getCoreClient().getEmaneModelConfig(id, model);
|
||||
logger.debug("emane model config: {}", getConfig);
|
||||
String title = String.format("%s %s Config", coreNode.getName(), model);
|
||||
String title = String.format("EMANE(%s) %s Config", id, model);
|
||||
getController().getConfigDialog().showDialog(title, getConfig, () -> {
|
||||
List<ConfigOption> options = getController().getConfigDialog().getOptions();
|
||||
try {
|
||||
getCoreClient().setEmaneModelConfig(coreNode, model, options);
|
||||
getCoreClient().setEmaneModelConfig(id, model, options);
|
||||
} catch (IOException ex) {
|
||||
logger.error("set emane model config error", ex);
|
||||
Toast.error("set emane model config error", ex);
|
||||
}
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
logger.error("error getting emane model config", ex);
|
||||
Toast.error("error getting emane model config", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ def set_emane_model_config(session_id):
|
|||
session = core_utils.get_session(coreemu, session_id)
|
||||
data = request.get_json() or {}
|
||||
model_name = data["name"]
|
||||
node_id = data.get("node")
|
||||
node_id = data["node"]
|
||||
values = data["values"]
|
||||
config = {x["name"]: x["value"] for x in values}
|
||||
session.emane.set_model_config(node_id, model_name, config)
|
||||
|
@ -63,7 +63,7 @@ def get_emane_config(session_id):
|
|||
@api.route("/sessions/<int:session_id>/emane/model/config")
|
||||
def get_emane_model_config(session_id):
|
||||
session = core_utils.get_session(coreemu, session_id)
|
||||
node_id = core_utils.get_node_id(request.args.get("node"))
|
||||
node_id = core_utils.get_node_id(request.args["node"])
|
||||
|
||||
model_name = request.args["name"]
|
||||
model = session.emane.models[model_name]
|
||||
|
|
Loading…
Reference in a new issue