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