Commits

Joshua Bonsink committed ed64a72

Improved GUI

Comments (0)

Files changed (1)

         groupbox_scenario.setTitle("Scenario settings")
         self.vbox_mode.addWidget(groupbox_scenario)        
         grid_groupbox_scenario = QtGui.QGridLayout()
+        grid_groupbox_scenario.setSpacing(10)
         hbox_groupbox_scenario = QtGui.QHBoxLayout(groupbox_scenario)
         hbox_groupbox_scenario.addLayout(grid_groupbox_scenario)        
         label = QtGui.QLabel(groupbox_scenario)    
         label.setText("Scenario")    
-        grid_groupbox_scenario.addWidget(label, 0, 0, 1, 1)        
-        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
-        grid_groupbox_scenario.addItem(spacerItem, 0, 1, 1, 1)        
+        grid_groupbox_scenario.addWidget(label, 0, 0)             
+        
         self.scenario = QtGui.QComboBox(groupbox_scenario)            
         self.scenario.addItem("Select a scenario")
         self.scenario.addItem(DDOS_FLOODING)
         self.scenario.addItem(KEYLOGGER)
         self.scenario.addItem(SPAMMING)
         self.scenario.activated['QString'].connect(self.scenarioSelected)        
-        grid_groupbox_scenario.addWidget(self.scenario, 0, 0, 1, 2)
-        
-        # --- Simulation Implementation groupbox --- #
-        groupbox_implementation = QtGui.QGroupBox()      
-        groupbox_implementation.setTitle("Simulation Implementation")
-        self.vbox_mode.addWidget(groupbox_implementation)        
-        grid_groupbox_implementation = QtGui.QGridLayout()
-        hbox_groupbox_implementation = QtGui.QHBoxLayout(groupbox_implementation)
-        hbox_groupbox_implementation.addLayout(grid_groupbox_implementation)        
-        label = QtGui.QLabel(groupbox_implementation)    
-        label.setText("implementation")    
-        grid_groupbox_implementation.addWidget(label, 0, 0, 1, 1)        
-        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
-        grid_groupbox_implementation.addItem(spacerItem, 0, 1, 1, 1)        
-        self.implementation = QtGui.QComboBox(groupbox_implementation)                    
-        self.implementation.addItem("Default")
-        self.implementation.addItem("Visual")         
-        grid_groupbox_implementation.addWidget(self.implementation, 0, 0, 1, 2)
-        
+        grid_groupbox_scenario.addWidget(self.scenario, 0, 1)
+                    
         # --- Mode settings groupbox --- #
         groupbox_mode = QtGui.QGroupBox()      
         groupbox_mode.setTitle("Mode settings")
         self.groupbox_pure.setTitle("Pure Simulation settings")
         self.vbox_mode.addWidget(self.groupbox_pure)        
         grid_groupbox_pure = QtGui.QGridLayout()                        
+        grid_groupbox_pure.setSpacing(10)
         hbox_groupbox_pure = QtGui.QHBoxLayout(self.groupbox_pure)
         hbox_groupbox_pure.addLayout(grid_groupbox_pure)        
         self.pure_exp = QtGui.QComboBox(self.groupbox_pure)    
         self.pure_exp.addItem("Static Route Experiment")
         self.pure_exp.addItem("Topology Experiment")                                
         self.pure_exp.activated['QString'].connect(self.experimentSelected)    
-        grid_groupbox_pure.addWidget(self.pure_exp, 0, 0, 1, 2)        
-
+        grid_groupbox_pure.addWidget(self.pure_exp, 0, 1)                           
+        label = QtGui.QLabel(self.groupbox_pure)    
+        label.setText("Simulation Implementation")    
+        grid_groupbox_pure.addWidget(label, 1, 0)
+        self.implementation = QtGui.QComboBox(self.groupbox_pure)                    
+        self.implementation.addItem("Default")
+        self.implementation.addItem("Visual")         
+        grid_groupbox_pure.addWidget(self.implementation, 1, 1)
+        label = QtGui.QLabel(self.groupbox_pure) 
+        label.setText("Export NetAnim compatible XML")
+        grid_groupbox_pure.addWidget(label, 2, 0)
+        self.export_to_xml = QtGui.QCheckBox(self.groupbox_pure)
+        grid_groupbox_pure.addWidget(self.export_to_xml, 2, 1)
+        label = QtGui.QLabel(self.groupbox_pure) 
+        label.setText("XML file name")
+        grid_groupbox_pure.addWidget(label, 3, 0)
+        self.xml_name = QtGui.QLineEdit(self.groupbox_pure)
+        grid_groupbox_pure.addWidget(self.xml_name, 3, 1)
+        
         self.groupbox_emulation.hide()
         self.groupbox_netns3.hide()
         self.groupbox_pure.hide()
         cmd = 'sudo python ./emulate.py -s ' + scenario + ' -r botmaster'    
         os.system("gnome-terminal -e 'bash -c \"" + cmd + "; exec bash\"'")
     
-    def startSim(self, mode, scenario, experiment, duration, topo_file = None, net_settings = None, dot_file = None, bt_file = None):
+    def startSim(self, mode, scenario, experiment, duration, topo_file = None, net_settings = None, dot_file = None, bt_file = None, xport_xml = False):
         cmd = 'sudo ./sim --mode ' + mode + ' -s ' + scenario + ' -e ' + experiment + ' -t ' + str(duration)
         
         if topo_file != None:
         if self.implementation.itemText ( self.implementation.currentIndex() ) == 'Visual':
             cmd += ' --SimulatorImpl=Visual'
         
+        if xport_xml:
+            cmd += ' --ExportXML=' + self.xml_name.text()
+        
         print cmd         
         
         self.opened_terminal += 1
             executable = QtCore.QString('xterm -hold -into ' + str(self.container4.winId()) + ' -e "' + str(cmd) + '"')     
             self.processTerminal2.start(executable)
             self.tab_widget.insertTab(3, self.tab_terminal2, "Terminal")            
+            
+        self.tab_widget.setCurrentIndex(3)
         
     def startScenario(self, settings_type, attack):        
         open_f = choseCorrectFile(settings_type)
         elif mode == EMULATION:            
             self.startEmulation(scenario)            
         elif mode == NETNS3:
-            experiment = self.netns3_exp.itemText( self.netns3_exp.currentIndex() )            
+            experiment = self.netns3_exp.itemText( self.netns3_exp.currentIndex() )      
+            
+            if experiment == "Select an experiment":
+                QtGui.QMessageBox.information(self, 'Error', '''You have not specified the experiment.''',
+                QtGui.QMessageBox.Ok)   
+                  
             if experiment == "Complex Network Experiment":
                 self.startSim('netns3', scenario, COMPLEX, self.complex_duration.value(), 
                     self.complex_topo_file_location.text(), self.complex_net_settings_location.text(), 
             
         elif mode == PURE_SIM:                     
             experiment = self.pure_exp.itemText( self.pure_exp.currentIndex() )            
+            
+            if experiment == "Select an experiment":
+                QtGui.QMessageBox.information(self, 'Error', '''You have not specified the experiment.''',
+                QtGui.QMessageBox.Ok)   
+            
             if experiment == "Complex Network Experiment":
                 self.startSim('sim', scenario, COMPLEX, self.complex_duration.value(), 
                     self.complex_topo_file_location.text(), self.complex_net_settings_location.text(), 
-                    self.complex_dot_file_location.text(), self.complex_backtraf_location.text())
+                    self.complex_dot_file_location.text(), self.complex_backtraf_location.text(),
+                     self.export_to_xml.isChecked())
             elif experiment == "Manual Topology Background Traffic Experiment":
                 self.startSim('sim', scenario, MANUAL_TOPO_BT, self.manual_bt_duration.value(), 
                     self.manual_bt_topo_file_location.text(), self.manual_bt_net_settings_location.text(), 
-                    self.manual_bt_dot_file_location.text(), self.manual_bt_back_traf_location.text())                
+                    self.manual_bt_dot_file_location.text(), self.manual_bt_back_traf_location.text(),
+                    self.export_to_xml.isChecked())                
             elif experiment == "Manual Topology Experiment":
                 self.startSim('sim', scenario, MANUAL_TOPO, self.manual_duration.value(), 
-                    self.manual_topo_file_location.text(), self.manual_net_settings_location.text())            
+                    self.manual_topo_file_location.text(), self.manual_net_settings_location.text(),
+                    self.export_to_xml.isChecked())            
             elif experiment == "Static Route Experiment":
-                self.startSim('sim', scenario, STATIC_ROUTE, self.static_duration.value())  
+                self.startSim('sim', scenario, STATIC_ROUTE, self.static_duration.value(),
+                self.export_to_xml.isChecked())  
             elif experiment == "Topology Experiment":
                 self.startSim('sim', scenario, TOPOLOGY, self.topo_duration.value(), 
-                    self.topo_file_location.text())                
+                    self.topo_file_location.text(), self.export_to_xml.isChecked())                
                         
 def main():
     
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.