def test_live_single(): end_time = tossim.time() + 5 * tossim.ticksPerSecond() while tossim.time() < end_time: tossim.runNextEvent() # this approach will only ever yield a list of zero or one # items because only a single event runs at a time under the # TOSSIM model dirty = Probe.synchronize_all(probes) assert len(dirty) <= 1 for probe in dirty: check_update(probe)
def test_live_batch(): end_time = tossim.time() + 5 * tossim.ticksPerSecond() while tossim.time() < end_time: # ensure simulation is run in some form of batches so that # sync_shadows can queue multiple buffers, as long as the # batches are less than a second it won't skip writes in the # ProbeTest code. target = tossim.time() + (0.8 * tossim.ticksPerSecond()) while tossim.time() < target: tossim.runNextEvent() dirty = Probe.synchronize_all(probes) # assert len(dirty) > 1, "len(dirty) > 1, was %d" % len(dirty) for probe in dirty: check_update(probe)
def handler(self): # for k, v in self.bindings: # (resolved, bindings) = v # print "Binding %i has %i binding" % (k, len(bindings)) # PST-- execute shadows, transmit results dirty= Probe.synchronize_all(self.probes) #if(tmp is not None and tmp != []): print tmp[0] #print "handler",dirty for probe in dirty: #print "probe.node",probe.node self.check_update(probe) #print self.binding # for a in self.binding: # print "a",a,"b",b pass