LoggingHelper.LogLogic("CodeGenerator : generating ip configuration code!");
Map<String,String> ipConfigMap = new HashMap<String,String>();
for (Device device : this.dialogConnection.devices) {
Pair<String,String> tmp= device.getIPConfCode();
if(ipConfigMap.get(tmp.getKey())!=null) {
ipConfigMap.put(tmp.getKey(), ipConfigMap.get(tmp.getKey())+tmp.getValue()+"\n");
}
else {
ipConfigMap.put(tmp.getKey(), tmp.getValue()+"\n");
}
}
for (Device device : this.dialogConnection.devices_csma) {
Pair<String,String> tmp=device.getIPConfCode();
if(ipConfigMap.get(tmp.getKey())!=null) {
ipConfigMap.put(tmp.getKey(), ipConfigMap.get(tmp.getKey())+tmp.getValue()+"\n");
}
else {
ipConfigMap.put(tmp.getKey(), tmp.getValue()+"\n");
}
}
public Pair<String,String> getIPConfCode() {
String firstLine = "", secondLine = "";
firstLine = "address.SetBase(\""+this.networkSettings.netId+"\",\""+this.networkSettings.netMask+"\");";
if (this.linkSettings.getLinkType() == LinkType.LINK_CSMA) {
secondLine = "Ipv4InterfaceContainer csmaInterfaces"+CSMA_INDEX+" = "+"address.Assign(csmaDevices"+CSMA_INDEX+");";
} else if (this.linkSettings.getLinkType() == LinkType.LINK_WIFI) {
secondLine = """
Ipv4InterfaceContainer interfacesSta_"""
+ this.linkSettings.getName() +
"""
= address.Assign(staDev_"""
+ this.linkSettings.getName() +
"""
);
Ipv4InterfaceContainer interfacesAp_"""
+ this.linkSettings.getName() +
"""
= address.Assign(apDev_"""
+ this.linkSettings.getName() +
"""
);
""";
} else {
secondLine = "Ipv4InterfaceContainer interfaces"+this.nodesGroup+" = "+"address.Assign(devices"+this.nodesGroup+");";
}
return new Pair<>(firstLine, secondLine);
}
Hi, I encountered a few problems while using v1.2.0. Since you are working on next release, Some of them may have been fixed already. If they are fixed, please ignore this issue.
In
CodeGenerator.java, line 144:It seems like
"interfaces"is missing. It causes an error such as when choosing node 1 and then choosing node 0.In
CodeGenerator.java, lines 226 and 229the
ipConfigCodeRepeatedly generate xaddress.SetBase("NetID","NetMask").I think it might be a good idea to change the return value of
device.getIPConfCode()to apairto storefirstLineandsecondLine, then use a map to generate the code.Here's my code, maybe it can help you:
In
CodeGenerator.java:In
Device.javaIn both
Dialog_ConfigureClient.javaandDialog_ConfigureServer.java,Node ID may get added repeatedly. I suggest clearing the
comboBox_serverIndexbefore the for loop of adding items in the functionsetVisible: