Created
June 7, 2012 14:26
-
-
Save oxitnik/2889079 to your computer and use it in GitHub Desktop.
code generators for gpss for network sim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#test | |
f = open("out.gpss.pp.txt","w+") | |
mode = "RENUM" #"GEN_SWQ" #"GEN_SW_CHAN" | |
if mode == "GEN_SW_CHAN": | |
sws = [ (10, 11), (10,12), (10,13), (10,14), (14,15), (14,16), \ | |
(20,21), (20,22), (20,23), (20,24), (10,20)] | |
for inp,out in sws: | |
f.write("7400 aS{0}S{1} SEIZE kS{0}S{1}\n".format(inp, out)) | |
f.write("7410 ADVANCE ADV_k\n") | |
f.write("7420 RELEASE kS{0}S{1}\n".format(inp, out)) | |
f.write("7430 TRANSFER ,SW{0}\n".format(out)) | |
f.write("7440 TERMINATE\n") | |
f.write("\n") | |
f.write("7400 aS{0}S{1} SEIZE kS{0}S{1}\n".format(out, inp)) | |
f.write("7410 ADVANCE ADV_k\n") | |
f.write("7420 RELEASE kS{0}S{1}\n".format(out, inp)) | |
f.write("7430 TRANSFER ,SW{0}\n".format(inp)) | |
f.write("7440 TERMINATE\n") | |
f.write("\n") | |
if mode == "GEN_SWQ": | |
sws = [10, 11 ,12, 13, 14, 15, 16, 20, 21, 22, 23, 24] | |
for sw in sws: | |
f.write("9700 GENERATE 5000\n") | |
f.write("9710 TRANSFER ,goS{0}queue1\n".format(sw)) | |
f.write("9720 goS{0}queue1 TEST NE CH$PQueueS{0}P1,0,goS{0}queue2\n".format(sw)) | |
f.write("9730 UNLINK PQueueS{0}P1,goS{0}test\n".format(sw)) | |
f.write("9740 TERMINATE\n") | |
f.write("9750 goS{0}queue2 TEST NE CH$PQueueS{0}P2,0,goS{0}queue3\n".format(sw)) | |
f.write("9760 UNLINK PQueueS{0}P2,goS{0}test\n".format(sw)) | |
f.write("9770 TERMINATE\n") | |
f.write("9780 goS{0}queue3 TEST NE CH$PQueueS{0}P3,0,goS{0}queue4\n".format(sw)) | |
f.write("9790 UNLINK PQueueS{0}P3,goS{0}test\n".format(sw)) | |
f.write("9800 TERMINATE\n".format(sw)) | |
f.write("9810 goS{0}queue4 TEST NE CH$PQueueS{0}P4,0,trm\n".format(sw)) | |
f.write("9820 UNLINK PQueueS{0}P4,goS{0}test\n".format(sw)) | |
f.write("9830 TERMINATE\n\n") | |
if mode == "RENUM": | |
orig_file = open("gpss.txt", "r") | |
linenum = 10 | |
for line in orig_file: | |
numend = 0 | |
for c in line: | |
if c in "0123456789": | |
numend += 1 | |
continue | |
else: | |
if c in " \t" and numend > 0: | |
f.write(str(linenum)) | |
f.write(line[numend:]) | |
linenum += 10 | |
else: | |
f.write(line) | |
break; | |
orig_file.close() | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment