我正在使用SimPy,並嘗試模擬網絡。如何在不同模塊中啓用對象之間的交互
這是我的主要模塊:
from SimPy.Simulation import *
import node0
import message0
import network0
reload (message0)
reload (node0)
reload(network0)
initialize()
topology=network0.Network()
activate(topology, topology.operate())
node1=node0.Node(1)
node1.interface.send(destination='node1')
simulate(until=25)
我想類消息,它是由類節點的目的活化的目的,對interrrupt
class Message(Process):
def arrive(self, destination, myEvent=delay):
self.destination=destination
self.interrupt(topology)
Network (topology)
類的對象。
但我發現了一個錯誤:
NameError: global name 'topology' is not defined
我不知道如何使一個對象全局。如果我在python shell中輸入拓撲結構,那麼它會顯示對象拓撲結構,爲什麼不能在消息中看到它?