Skip to content

Small issues encountered in v1.2.0 #24

@Superdog-ccr

Description

@Superdog-ccr

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.

  1. In CodeGenerator.java, line 144:

    primaryServerGrp = device.nodesGroup;
    

    It seems like "interfaces" is missing. It causes an error such as when choosing node 1 and then choosing node 0.

  2. In CodeGenerator.java, lines 226 and 229
    the ipConfigCode Repeatedly generate x address.SetBase("NetID","NetMask").

    I think it might be a good idea to change the return value of device.getIPConfCode() to a pair to store firstLine and secondLine, then use a map to generate the code.

    Here's my code, maybe it can help you:

    In CodeGenerator.java:

     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");
         }
     }
    

    In Device.java

    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);
     }
    
  3. In both Dialog_ConfigureClient.java and Dialog_ConfigureServer.java,
    Node ID may get added repeatedly. I suggest clearing the comboBox_serverIndex before the for loop of adding items in the function setVisible:

     for (int i=0; i<this.totalNodes; i++) {
            this.comboBox_clientIndex.addItem("Node "+i);
     }
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions