Stefan Scherfke | 7 Jan 10:17
Picon

Notifiy a PEM that a simulation is over

Moin moin,

is there an easy way to notify a PEM that the simulation finished while the PEM was in a "yield hold"?

Example for a battery controller:

    …

    charge_start = self.sim.now()
    duration = self.get_charge_duration()
    yield hold, self, duration

    # This will be called if the battery is full or if someone
    # pulled the plug (and thus interruped the charging) 
    duration = self.sim.now() - charge_start
    self.battery.charge(self.kw, duration)

    …

If the simulation ends while the PEM has yielded "yield hold, self, duration", "self.battery.charge()"
wont get called.

I’ve tryied to wrap the yield in a try: yield except GeneratorExit, but this works neither. It seems like
the generator is not deleted correctly, when the simulation finishes and so no GeneratorExit is raised.

My current work-around for this is to call charge() manually for each process, when the simulation has
finished, but this is not really satisfying … ;-)

Ontje and I are currently fiddling around with it and try to find out, where references to the PEM could be
still alive after the sim. The eventlist is set to None and process._nextpoint is also None …

Any ideas?

Best regards,
Stefan
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 

Gmane