test.py
来自「tinyos-2.0源代码!转载而已!要的尽管拿!」· Python 代码 · 共 43 行
PY
43 行
# This script is a simple TOSSIM test of dissemination.# It builds a 15x15 grid of nodes and has nodes start# disseminating two values (based on the TinyOS app).# It prints out when nodes receive new values, including# the dissemination key and sequence number. You should# be able to see how the implementation can resolve# multiple concurrent changes within the network as# well as more than one value being updated at a time.import TOSSIMimport syst = TOSSIM.Tossim([])m = t.mac();r = t.radio();t.init()#t.addChannel("LedsC", sys.stdout);#t.addChannel("AM", sys.stdout);#t.addChannel("TestDisseminationC", sys.stdout);t.addChannel("Dissemination", sys.stdout);#t.addChannel("Gain", sys.stdout);#t.addChannel("TossimPacketModelC", sys.stdout);print (dir(TOSSIM.Tossim))f = open("topo.txt", "r")lines = f.readlines()for line in lines: s = line.split() if (len(s) > 0): if (s[0] == "gain"): r.add(int(s[1]), int(s[2]), float(s[3])) elif (s[0] == "noise"): r.setNoise(int(s[1]), float(s[2]), float(s[3]))for i in range(0, 225): m = t.getNode(i); m.bootAtTime((t.ticksPerSecond() / 50) * i + 43); while (t.time() / t.ticksPerSecond() < 600): t.runNextEvent()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?