BatchScrapMachine and EventGenerator updated

parent b1478fcf
......@@ -26,8 +26,9 @@ Models a machine that processes a (Sub)Batch and can scrap a number of units in
depends on the number of units of the (Sub)Batch
'''
from SimPy.Simulation import Process, Resource
from SimPy.Simulation import activate, passivate, waituntil, now, hold
# from SimPy.Simulation import Process, Resource
# from SimPy.Simulation import activate, passivate, waituntil, now, hold
import simpy
from RandomNumberGenerator import RandomNumberGenerator
from Machine import Machine
......
......@@ -26,7 +26,8 @@ Created on 4 Dec 2013
models a generator that runs a method at specified intervals
'''
from SimPy.Simulation import now, hold, Process
# from SimPy.Simulation import now, hold, Process
import simpy
from ObjectInterruption import ObjectInterruption
class EventGenerator(ObjectInterruption):
......@@ -43,15 +44,15 @@ class EventGenerator(ObjectInterruption):
self.argumentDict=argumentDict #the arguments of the method given in a dict
def run(self):
yield hold,self,self.start #wait until the start time
yield self.env.timeout(self.start) #wait until the start time
#loop until the end of the simulation
while 1:
#if the stop time is exceeded then break the loop
if self.stop:
if now()>self.stop:
if self.env.now>self.stop:
break
self.method(self.argumentDict) #call the method
yield hold,self,self.interval #wait for the predetermined interval
yield self.env.timeout(self.interval) #wait for the predetermined interval
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment