# HG changeset patch # User Mohit P. Tahiliani # Date 1435196761 25200 # Node ID 1133a20204c67640ef82b2490d5474a01f2a0f4f # Parent fb2b8e22f5f4e26d53699cbf99dd8b3a23866929 fix command-line argument handling in mixed-wireless.py example diff -r fb2b8e22f5f4 -r 1133a20204c6 examples/wireless/mixed-wireless.py --- a/examples/wireless/mixed-wireless.py Wed Jun 24 18:54:29 2015 +0200 +++ b/examples/wireless/mixed-wireless.py Wed Jun 24 18:46:01 2015 -0700 @@ -72,13 +72,15 @@ def main(argv): # - # First, we declare and initialize a few local variables that control some + # First, we initialize a few local variables that control some # simulation parameters. - # - backboneNodes = 10 - infraNodes = 2 - lanNodes = 2 - stopTime = 20 + # + + cmd = ns.core.CommandLine() + cmd.backboneNodes = 10 + cmd.infraNodes = 2 + cmd.lanNodes = 2 + cmd.stopTime = 20 # # Simulation defaults are typically set next, before command line @@ -92,18 +94,23 @@ # system so that they can be overridden with flags such as # "--backboneNodes=20" # - cmd = ns.core.CommandLine() - cmd.AddValue("backboneNodes", "number of backbone nodes", str(backboneNodes)) - cmd.AddValue("infraNodes", "number of leaf nodes", str(infraNodes)) - cmd.AddValue("lanNodes", "number of LAN nodes", str(lanNodes)) - cmd.AddValue("stopTime", "simulation stop time(seconds)", str(stopTime)) - + + cmd.AddValue("backboneNodes", "number of backbone nodes") + cmd.AddValue("infraNodes", "number of leaf nodes") + cmd.AddValue("lanNodes", "number of LAN nodes") + cmd.AddValue("stopTime", "simulation stop time(seconds)") + # # The system global variables and the local values added to the argument # system can be overridden by command line arguments by using this call. # cmd.Parse(argv) + backboneNodes = int(cmd.backboneNodes) + infraNodes = int(cmd.infraNodes) + lanNodes = int(cmd.lanNodes) + stopTime = int(cmd.stopTime) + if (stopTime < 10): print "Use a simulation stop time >= 10 seconds" exit(1)