- sim.ComponentGenerator can now also be used with a number of moments:
sim.ComponentGenerator(Ship, moments=(10, 20, 50))
This will generate Ships at t=10, t=20 and t=50. The times should be specified in the current time unit.
The moments do not have to be sorted.
Note that moment cannot be used together with at, delay, till,duration, number, iat,force_at, force_till, disturbance or equidistant
- This version introduces a new class: Event. This is a specialized Component, that is most useful as a timer, which performs
some action after a certain time. E.g.:
class Client(sim.Component):
def process(self):
timer = sim.Event(action= lambda: self.activate(), name='timer', delay=10)
self.hold(sim.Uniform(0,20))
timer.cancel() this can be done even is the action was taken and timer is a data component
if timer.action_taken():
print("balked, because I had to wait for 10 minutes")
return
print("do stuff ...")
For more information, see the section on events and the reference in the latest documentation.
- Canceling a data component does not result in an exception anymore. This can be useful to cancel a wake up event even if it
it already ended.
- When reading a font file, the fontfile was not closed, thus causing a warning message if run under Viktor.ai. Fixed.
(Inspired by a comment by Michiel Luyken)