Commit 5190dff0 authored by Georgios Dagkakis's avatar Georgios Dagkakis

objects updated so that the env and also signals are set in initialize

parent 7d8291bf
......@@ -55,8 +55,7 @@ class Conveyer(CoreObject):
# when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time
# that the machine is being loaded
self.moveEnd=self.env.event()
#===========================================================================
# the initialize method
#===========================================================================
......@@ -85,6 +84,8 @@ class Conveyer(CoreObject):
self.successorIndex=0 #holds the index of the successor where the Queue Conveyer dispose an entity next
self.requestingEntities=[] # list of the entities requesting space on the conveyer
# signal that notifies the conveyer that its move is completed
self.moveEnd=self.env.event()
#===========================================================================
# conveyer generator
......@@ -521,8 +522,8 @@ class ConveyerMover(object):
yield self.env.timeout(self.timeToWait) #wait for the time that the conveyer calculated
# continue if interrupted
self.conveyer.moveEntities() #move the entities of the conveyer
self.conveyer.moveEnd.succeed(self.env.now)
self.conveyer.moveEntities() # move the entities of the conveyer
self.conveyer.moveEnd.succeed(self.env.now) # send a signal to the conveyer that the move has ended
......@@ -34,9 +34,6 @@ import simpy
class CoreObject(object):
def __init__(self, id, name, **kw):
from Globals import G
self.env=G.env
# Process.__init__(self)
self.id = id
self.objName = name
# lists that hold the previous and next objects in the flow
......@@ -56,23 +53,10 @@ class CoreObject(object):
self.resetOnPreemption=False
self.interruptCause=None
self.gatherWipStat=False
# signalizing an event that activates the generator
# self.isRequested=SimEvent('isRequested')
self.isRequested=self.env.event()
# self.canDispose=SimEvent('canDispose')
self.canDispose=self.env.event()
# self.interruptionEnd=SimEvent('interruptionEnd')
self.interruptionEnd=self.env.event()
# self.interruptionStart=SimEvent('interruptionStart')
self.interruptionStart=self.env.event()
# variable that holds the the type of interruption interrupting the station
self.interruptedBy=None
self.entityRemoved=self.env.event()
def initialize(self):
# XXX why call super.__init__ outside of __init__ ?
# Process.__init__(self)
from Globals import G
self.env=G.env
self.Up=True #Boolean that shows if the machine is in failure ("Down") or not ("up")
self.onShift=True
self.currentEntity=None
......@@ -143,16 +127,12 @@ class CoreObject(object):
# TODO, think what to do in multiple runs
# TODO, this should be also updated in Globals.setWIP (in case we have initial wip)
self.wipStatList=[[0,0]]
# signalizing an event that activates the generator
# self.isRequested=SimEvent('isRequested')
self.isRequested=self.env.event()
# self.canDispose=SimEvent('canDispose')
self.canDispose=self.env.event()
# self.interruptionEnd=SimEvent('interruptionEnd')
self.interruptionEnd=self.env.event()
# self.interruptionStart=SimEvent('interruptionStart')
self.interruptionStart=self.env.event()
self.interruptedBy=None
self.entityRemoved=self.env.event()
# =======================================================================
......
......@@ -150,15 +150,6 @@ class Machine(CoreObject):
# flags used for preemption purposes
self.isPreemptive=isPreemptive
self.resetOnPreemption=resetOnPreemption
# events used by the broker
self.brokerIsSet=self.env.event()
# this event is generated every time an operator is requested by machine for Load operation type.
# if the machine has not succeeded in getting an entity due to the resource absence
# and waits for the next event to get the entity,
# then it must be signalled that the operator is now available
self.loadOperatorAvailable=self.env.event()
# signal used for preemption
self.preemptQueue=self.env.event()
# flag notifying that there is operator assigned to the actievObject
self.assignedOperator=True
......
......@@ -55,6 +55,7 @@ class MachineManagedJob(MachineJobShop):
self.operatorPool.operators=[]
#create a Broker
self.broker = Broker(self)
self.broker.initialize()
self.env.process(self.broker.run())
# activate(self.broker,self.broker.run())
#create a Router
......@@ -62,6 +63,7 @@ class MachineManagedJob(MachineJobShop):
from Globals import G
if not G.Router:
self.router=Router()
self.router.initialize()
self.env.process(self.router.run())
# activate(self.router,self.router.run())
G.Router=self.router
......
......@@ -35,13 +35,13 @@ import simpy
class ObjectInterruption(object):
def __init__(self, victim=None):
from Globals import G
self.env=G.env
self.victim=victim
# variable used to hand in control to the objectInterruption
self.call=False
def initialize(self):
from Globals import G
self.env=G.env
self.call=False
#===========================================================================
......
......@@ -33,11 +33,11 @@ import simpy
class ObjectResource(object):
def __init__(self):
from Globals import G
self.env=G.env
self.initialized = False
def initialize(self):
from Globals import G
self.env=G.env
self.totalWorkingTime=0 #holds the total working time
self.totalWaitingTime=0 #holds the total waiting time
self.timeLastOperationStarted=0 #holds the time that the last repair was started
......
......@@ -48,9 +48,6 @@ class Broker(ObjectInterruption):
self.timeOperationStarted = 0
self.timeLastOperationEnded = 0
self.timeWaitForOperatorStarted=0
# Broker events
self.isCalled=self.env.event()#SimEvent('brokerIsCalled')
self.resourceAvailable=self.env.event()#SimEvent('resourceAvailable')
self.waitForOperator=False
#===========================================================================
......@@ -62,6 +59,10 @@ class Broker(ObjectInterruption):
self.timeOperationStarted=0
self.timeWaitForOperatorStarted=0
self.waitForOperator=False
# Broker events
self.isCalled=self.env.event()
self.resourceAvailable=self.env.event()
# =======================================================================
# the run method
......
......@@ -49,8 +49,6 @@ class Router(ObjectInterruption):
def __init__(self,sorting=False):
ObjectInterruption.__init__(self)
self.type = "Router"
# signal used to initiate the generator of the Router
self.isCalled=self.env.event()
self.isInitialized=False
self.candidateOperators=[]
self.multipleCriterionList=[]
......@@ -78,6 +76,8 @@ class Router(ObjectInterruption):
#===========================================================================
def initialize(self):
ObjectInterruption.initialize(self)
# signal used to initiate the generator of the Router
self.isCalled=self.env.event()
# list that holds all the objects that can receive
self.pendingObjects=[]
self.calledOperator=[]
......
......@@ -67,8 +67,6 @@ class Queue(CoreObject):
self.gatherWipStat=gatherWipStat
# Will be populated by an event generator
self.wip_stat_list = []
# event used by router
self.loadOperatorAvailable=self.env.event()
@staticmethod
def getSupportedSchedulingRules():
......
......@@ -102,14 +102,7 @@ class Source(CoreObject):
self.rng = RandomNumberGenerator(self, **interarrivalTime)
self.item=Globals.getClassFromName(entity) #the type of object that the Source will generate
self.entityGenerator=EntityGenerator(victim=self) # the EntityGenerator of the Source
# self.entityCreated=SimEvent('an entity is created')
self.entityCreated=self.env.event()
# event used by router
# self.loadOperatorAvailable=SimEvent('loadOperatorAvailable')
self.loadOperatorAvailable=self.env.event()
self.scheduledEntities=[] # list of creations that are scheduled
......@@ -124,7 +117,8 @@ class Source(CoreObject):
# self.Res=Resource(capacity=infinity)
self.Res=simpy.Resource(self.env, capacity=float('inf'))
self.Res.users=[]
# self.Res.waitQ=[]
self.entityGenerator=EntityGenerator(victim=self) # the EntityGenerator of the Source
self.numberOfArrivals = 0
# self.entityGenerator.initialize()
# activate(self.entityGenerator,self.entityGenerator.run())
......
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