from simx.probe import Loader

from TOSSIM import Tossim
import SimxProbe

_tossim = Tossim([])
loader = Loader('app.xml', SimxProbe)

print "--1--"
v1 = loader.lookup("OctopusC$alpha")
print "have def: %s" % v1
p1 = v1.bind(1)

print "have probe: %s" % p1.get()

print "--2--"
v2 = loader.lookup("OctopusC$ttt")
print "have def: %s" % v2
p2 = v2.bind(2)
print "have probe: %s" % p2.print_buf()

print "--3--"
v3 = loader.lookup("OctopusC$ttt_optimized_out")
print "have def: %s" % 32
try:
    p3 = v3.bind(3)
    print "have probe: %s" % p3
except Exception, e:
    print "it is expected this raises an exception: %s" % e.message
示例#2
0
#tossim.addChannel("PlatformC", sys.stdout)
#tossim.addChannel("Serial", sys.stdout)
#tossim.addChannel("CpmModelC,SNRLoss", sys.stdout)
#tossim.addChannel("Gain,SNRLoss", sys.stdout)
#tossim.addChannel("Binary", sys.stdout)


# init
nodes = []
probes = []
COUNT = 10
for n in xrange(0, COUNT):
    node = tossim.getNode(n)
    # boot evenly across one second
    node.bootAtTime(0 + (float(n) / (COUNT + 1)) * tossim.ticksPerSecond())
    probe = loader.lookup("ProbeTestC$nx_struct_data",
                          ["", "nx_varied_struct_t"]).bind(n)
    probe.memo().event_count = 0

    nodes.append(node)
    probes.append(probe)


def check_update(probe):
    # keep in-sync with updates..
    memo = probe.memo()
    memo.event_count += 1
    # only odd probes update!
    assert probe.node % 2, "odd node (but was %s)" % probe.node
    # and check update value
    assert probe["uint16"] == memo.event_count * probe.node
#tossim.addChannel("CpmModelC", sys.stdout)
#tossim.addChannel("PlatformC", sys.stdout)
#tossim.addChannel("Serial", sys.stdout)
#tossim.addChannel("CpmModelC,SNRLoss", sys.stdout)
#tossim.addChannel("Gain,SNRLoss", sys.stdout)
#tossim.addChannel("Binary", sys.stdout)

# init
nodes = []
probes = []
COUNT = 10
for n in xrange(0, COUNT):
    node = tossim.getNode(n)
    # boot evenly across one second
    node.bootAtTime(0 + (float(n) / (COUNT + 1)) * tossim.ticksPerSecond())
    probe = loader.lookup("ProbeTestC$nx_struct_data",
                          ["", "nx_varied_struct_t"]).bind(n)
    probe.memo().event_count = 0

    nodes.append(node)
    probes.append(probe)


def check_update(probe):
    # keep in-sync with updates..
    memo = probe.memo()
    memo.event_count += 1
    # only odd probes update!
    assert probe.node % 2, "odd node (but was %s)" % probe.node
    # and check update value
    assert probe["uint16"] == memo.event_count * probe.node