new printTrace method

parent f82e0286
......@@ -123,22 +123,26 @@ class Assembly(CoreObject):
# check if there is WIP and signal receiver
self.initialSignalReceiver()
while 1:
self.printTrace(self.id, 'will wait for frame event')
# self.printTrace(self.id, 'will wait for frame event')
self.printTrace1(self.id, waitEvent='')
# wait until the Queue can accept an entity and one predecessor requests it
yield waitevent, self, self.isRequested #[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if self.isRequested.signalparam:
self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
# self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
self.printTrace1(self.id, isRequested=self.isRequested.signalparam.id)
# reset the isRequested signal parameter
self.isRequested.signalparam=None
self.getEntity("Frame") #get the Frame
for i in range(self.getActiveObjectQueue()[0].capacity): #this loop will be carried until the Frame is full with the parts
self.printTrace(self.id, 'will wait for part event')
self.printTrace1(self.id, waitEvent='(to load parts)')
# self.printTrace(self.id, 'will wait for part event')
yield waitevent, self, self.isRequested
if self.isRequested.signalparam:
self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
# self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
self.printTrace1(self.id, isRequested=self.isRequested.signalparam.id)
# reset the isRequested signal parameter
self.isRequested.signalparam=None
# TODO: fix the getEntity 'Part' case
......@@ -162,7 +166,8 @@ class Assembly(CoreObject):
self.completedJobs+=1 #Assembly completed a job
self.waitToDispose=True #since all the frame is full
self.printTrace(self.id, 'will try to signal a receiver from generator')
# self.printTrace(self.id, 'will try to signal a receiver from generator')
self.printTrace1(self.id, attemptSignalReceiver='(generator')
# signal the receiver that the activeObject has something to dispose of
if not self.signalReceiver():
# if there was no available receiver, get into blocking control
......@@ -245,7 +250,8 @@ class Assembly(CoreObject):
activeEntity=CoreObject.removeEntity(self, entity) #run the default method
self.waitToDispose=False
if self.canAccept():
self.printTrace(self.id, 'will try signalling a giver from removeEntity')
# self.printTrace(self.id, 'will try signalling a giver from removeEntity')
self.printTrace1(self.id, attemptSignalGiver='(removeEntity)')
self.signalGiver()
return activeEntity
......@@ -270,7 +276,8 @@ class Assembly(CoreObject):
assert activeEntity.type==type, 'the type of the entity to get must be of type '+type+' while it is '+activeEntity.type
#remove the entity from the previews object
giverObject.removeEntity(activeEntity)
self.printTrace(activeEntity.name, "got into "+self.id)
# self.printTrace(activeEntity.name, "got into "+self.id)
self.printTrace1(activeEntity.name, enter=self.id)
self.outputTrace(activeEntity.name, "got into "+ self.objName)
# if the type is Frame
if(activeEntity.type=="Frame"):
......@@ -280,7 +287,8 @@ class Assembly(CoreObject):
# if the frame is not fully loaded then signal a giver
if len(activeObjectQueue[0].getFrameQueue())<activeObjectQueue[0].capacity:
self.printTrace(self.id, 'will try signalling a giver from getEntity')
# self.printTrace(self.id, 'will try signalling a giver from getEntity')
self.printTrace1(self.id, attemptSignalGiver='(getEntity)')
self.signalGiver()
return activeEntity
......
......@@ -100,11 +100,13 @@ class Conveyer(CoreObject):
# print self.id, 'time to move', self.conveyerMover.timeToWait
self.conveyerMover.canMove.signal(now())
self.printTrace(self.id, 'will wait for event')
# self.printTrace(self.id, 'will wait for event')
self.printTrace1(self.id, waitEvent='')
yield waitevent, self, [self.isRequested,self.canDispose, self.moveEnd] # , self.loadOperatorAvailable]
# if the event that activated the thread is isRequested then getEntity
if self.isRequested.signalparam:
self.printTrace(self.id, 'received an is requested event')
# self.printTrace(self.id, 'received an is requested event')
self.printTrace1(self.id, isRequested='')
# reset the isRequested signal parameter
self.isRequested.signalparam=None
# get the entity
......@@ -117,26 +119,32 @@ class Conveyer(CoreObject):
# self.loadOperatorAvailable.signalparam=None
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if self.canDispose.signalparam:
self.printTrace(self.id, 'received a canDispose event')
# self.printTrace(self.id, 'received a canDispose event')
self.printTrace1(self.id, canDispose='')
self.canDispose.signalparam=None
# if the object received a moveEnd signal from the ConveyerMover
if self.moveEnd.signalparam:
self.printTrace(self.id, 'received a moveEnd event')
# self.printTrace(self.id, 'received a moveEnd event')
self.printTrace1(self.id, moveEnd='')
self.moveEnd.signalparam=None
# check if there is a possibility to accept and signal a giver
if self.canAccept():
self.printTrace(self.id, 'will try to signal Giver from removeEntity')
# self.printTrace(self.id, 'will try to signal Giver from removeEntity')
self.printTrace(self.id, attemptSignalGiver='(removeEntity)')
self.signalGiver()
# if the event that activated the thread is canDispose then signalReceiver
if self.haveToDispose():
# self.printTrace(self.id, 'will try to signal a receiver from generator')
self.printTrace1(self.id, attemptSignalReceiver='(generator)')
if self.receiver:
if not self.receiver.entryIsAssignedTo():
self.printTrace(self.id, 'will try to signal receiver from generator1')
# self.printTrace(self.id, 'will try to signal receiver from generator1')
self.printTrace1(self.id, attemptSignalReceiver='(generator1)')
self.signalReceiver()
continue
self.printTrace(self.id, 'will try to signal receiver from generator2')
# self.printTrace(self.id, 'will try to signal receiver from generator2')
self.printTrace1(self.id, attemptSignalReceiver='(generator2)')
self.signalReceiver()
#===========================================================================
......@@ -195,7 +203,8 @@ class Conveyer(CoreObject):
if(self.length-self.position[0]<0.000001) and (not self.entityLastReachedEnd==self.getActiveObjectQueue()[0]):
self.waitToDispose=True
self.entityLastReachedEnd=self.getActiveObjectQueue()[0]
self.printTrace(self.getActiveObjectQueue()[0].name, 'has reached the end'+' !! . !! .'*7)
# self.printTrace(self.getActiveObjectQueue()[0].name, 'has reached the end'+' !! . !! .'*7)
self.printTrace1(self.getActiveObjectQueue()[0].name, conveyerEnd='')
return True
return False
......@@ -334,7 +343,8 @@ class Conveyer(CoreObject):
if self.isFull():
self.timeBlockageStarted=now()
self.wasFull=True
self.printTrace(self.id, 'is now Full '+str(len(self.getActiveObjectQueue()))+' (*) '*20)
# self.printTrace(self.id, 'is now Full '+str(len(self.getActiveObjectQueue()))+' (*) '*20)
self.printTrace1(self.id, conveyerFull=str(len(self.getActiveObjectQueue())))
return activeEntity
#===========================================================================
......@@ -357,7 +367,8 @@ class Conveyer(CoreObject):
self.conveyerMover.canMove.signal(now())
# if there is anything to dispose of then signal a receiver
if self.haveToDispose():
self.printTrace(self.id, 'will try to signal a receiver from removeEntity')
# self.printTrace(self.id, 'will try to signal a receiver from removeEntity')
self.printTrace1(self.id, attemptSingalReceiver='(removeEntity)')
self.signalReceiver()
return activeEntity
......@@ -510,9 +521,11 @@ class ConveyerMover(Process):
#===========================================================================
def run(self):
while 1:
self.conveyer.printTrace(self.conveyer.id, 'mover will wait for canMove event')
# self.conveyer.printTrace(self.conveyer.id, 'mover will wait for canMove event')
self.conveyer.printTrace1(self.conveyer.id, waitEvent='(canMove)')
yield waitevent,self,self.canMove #wait until the conveyer triggers the mover
self.conveyer.printTrace(self.conveyer.id, 'mover received canMove event')
# self.conveyer.printTrace(self.conveyer.id, 'mover received canMove event')
self.conveyer.printTrace1(self.conveyer.id, received='(canMove)')
yield hold,self,self.timeToWait #wait for the time that the conveyer calculated
# print '. .'*40
......
......@@ -248,7 +248,8 @@ class CoreObject(Process):
# update the next list of the object
activeObject.updateNext(activeEntity)
self.outputTrace(activeEntity.name, "got into "+self.objName)
self.printTrace(activeEntity.name, "got into "+self.id)
# self.printTrace(activeEntity.name, "got into "+self.id)
self.printTrace1(activeEntity.name, enter=self.id)
return activeEntity
#===========================================================================
......@@ -299,7 +300,8 @@ class CoreObject(Process):
#if the receiver does not hold an Entity that is also critical
if not receiver.getActiveObjectQueue()[0].isCritical:
receiver.shouldPreempt=True
activeObject.printTrace(self.id, 'preempting receiver '+receiver.id+'.. '*6)
# activeObject.printTrace(self.id, 'preempting receiver '+receiver.id+'.. '*6)
self.printTrace1(self.id, preempt=receiver.id)
receiver.preempt()
receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
# sort so that the critical entity is placed in front
......@@ -351,7 +353,8 @@ class CoreObject(Process):
activeObject.receiver=receiver
activeObject.receiver.giver=activeObject
self.printTrace(self.id, ' '*50+'signalling receiver '+self.receiver.id)
# self.printTrace(self.id, ' '*50+'signalling receiver '+self.receiver.id)
self.printTrace1(self.id, signalReceiver=self.receiver.id)
# assign the entry of the receiver
activeObject.receiver.assignEntryTo()
activeObject.receiver.isRequested.signal(activeObject)
......@@ -387,7 +390,8 @@ class CoreObject(Process):
if receiver.isLoadRequested():
from Globals import G
if not G.Router.invoked:
self.printTrace(self.id, ' '*50+'signalling router')
# self.printTrace(self.id, ' '*50+'signalling router')
self.printTrace1(self.id, signal='router')
G.Router.invoked=True
G.Router.isCalled.signal(now())
return True
......@@ -432,7 +436,8 @@ class CoreObject(Process):
giversReceiver=activeObject
activeObject.giver=giver
activeObject.giver.receiver=activeObject
self.printTrace(self.id, ' '*50+'signalling giver '+self.giver.id)
# self.printTrace(self.id, ' '*50+'signalling giver '+self.giver.id)
self.printTrace1(self.id, signalGiver=self.giver.id)
activeObject.giver.canDispose.signal(activeObject)
return True
return False
......@@ -496,6 +501,67 @@ class CoreObject(Process):
from Globals import G
if(G.console=="Yes"): #output only if the user has selected to
print now(), entityName, message
def printTrace1(self,entity='', **kw):
assert len(kw)==1, 'only one phrase per printTrace supported for the moment'
from Globals import G
time=now()
charLimit=60
remainingChar=charLimit-len(entity)-len(str(time))
if(G.console=='Yes'):
print time,entity,
for key in kw:
if key not in self.getSupportedPrintKwrds():
raise ValueError("Unsupported phrase %s for %s" % (key, self.id))
element=self.getPhrase()[key]
phrase=element['phrase']
prefix=element.get('prefix',None)
suffix=element.get('suffix',None)
arg=kw[key]
if prefix:
print prefix*remainingChar,phrase,arg
elif suffix:
remainingChar-=len(phrase)+len(arg)
suffix*=remainingChar
if key=='enter':
suffix=suffix+'>'
print phrase,arg,suffix
else:
print phrase,arg
@staticmethod
def getSupportedPrintKwrds():
return ("signal", "signalReceiver", "signalGiver","attemptSignal",
"attemptSignalGiver", "attemptSignalReceiver",
"preempt", "preempted","startWork", "finishWork", "processEnd", "interrupted",
"enter", "waitEvent", "received",
"isRequested","canDispose","interruptionEnd", "loadOperatorAvailable", 'resourceAvailable',
'conveyerEnd', 'conveyerFull','moveEnd')
@staticmethod
def getPhrase():
printKwrds={'signal':{'phrase':'signalling'},
'signalGiver':{'phrase':'signalling giver', 'prefix':'_'},
'signalReceiver':{'phrase':'signalling receiver','prefix':'_'},
'attemptSignal':{'phrase':'will try to signal'},
'attemptSignalGiver':{'phrase':'will try to signal a giver'},
'attemptSignalReceiver':{'phrase':'will try to signal a receiver'},
'preempt': {'phrase':'preempts','suffix':' .'},
'preempted': {'phrase':'is being preempted','suffix':'. '},
'startWork':{'phrase':'started working in'},
'finishWork':{'phrase':'finished working in'},
'processEnd':{'phrase':'ended processing in'},
'interrupted':{'phrase':'interrupted at','suffix':' .'},
'enter':{'phrase':'got into','suffix':'='},
'waitEvent':{'phrase':'will wait for event'},
'received':{'phrase':'received event'},
'isRequested':{'phrase':'received an isRequested event from'},
'canDispose':{'phrase':'received an canDispose event'},
'interruptionEnd':{'phrase':'received an interruptionEnd event at'},
"loadOperatorAvailable":{'phrase':'received a loadOperatorAvailable event at'},
"resourceAvailable":{'phrase':'received a resourceAvailable event'},
'moveEnd':{'phrase':'received a moveEnd event'},
"conveyerEnd":{'phrase':'has reached conveyer End', 'suffix':'.!'},
'conveyerFull':{'phrase':'is now Full, No of units:', 'suffix':'(*)'}}
return printKwrds
# =======================================================================
# outputs data to "output.xls"
......
......@@ -117,12 +117,14 @@ class Dismantle(CoreObject):
# check if there is WIP and signal receiver
self.initialSignalReceiver()
while 1:
self.printTrace(self.id, 'will wait for frame event')
# self.printTrace(self.id, 'will wait for frame event')
self.printTrace1(self.id, waitEvent='(frame)')
# wait until the Queue can accept an entity and one predecessor requests it
yield waitevent, self, self.isRequested #[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if self.isRequested.signalparam:
self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
# self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
self.printTrace1(self.id, isRequested=self.isRequested.signalparam.id)
# reset the isRequested signal parameter
self.isRequested.signalparam=None
......@@ -275,7 +277,8 @@ class Dismantle(CoreObject):
activeObject.waitToDisposePart=False
# if the internal queue is empty then try to signal the giver that the object can now receive
if activeObject.canAccept():
activeObject.printTrace(self.id, 'will try signalling a giver from removeEntity')
# activeObject.printTrace(self.id, 'will try signalling a giver from removeEntity')
activeObject.printTrace1(self.id, attemptSingalGiver='(removeEntity)')
activeObject.signalGiver()
return activeEntity
......
......@@ -221,12 +221,15 @@ class Machine(CoreObject):
while 1:
# waitEvent isRequested /interruptionEnd/loadOperatorAvailable
while 1:
self.printTrace(self.id, 'will wait for event')
# self.printTrace(self.id, 'will wait for event')
self.printTrace1(self.id, waitEvent='')
yield waitevent, self, [self.isRequested, self.interruptionEnd, self.loadOperatorAvailable]
self.printTrace(self.id, 'received an event')
# self.printTrace(self.id, 'received an event')
self.printTrace1(self.id, received='')
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if self.isRequested.signalparam:
self.printTrace(self.id, 'received an isRequested event from'+self.isRequested.signalparam.id)
# self.printTrace(self.id, 'received an isRequested event from'+self.isRequested.signalparam.id)
self.printTrace1(self.id, isRequested=self.isRequested.signalparam.id)
assert self.isRequested.signalparam==self.giver, 'the giver is not the requestingObject'
assert self.giver.receiver==self, 'the receiver of the signalling object in not the station'
# reset the signalparam of the isRequested event
......@@ -236,9 +239,11 @@ class Machine(CoreObject):
# if an operator was rendered available while it was needed by the machine to proceed with getEntity
if self.interruptionEnd.signalparam==now() or self.loadOperatorAvailable.signalparam==now():
if self.interruptionEnd.signalparam==now():
self.printTrace(self.id, 'received an interruptionEnd event sent at '+str(self.interruptionEnd.signalparam))
# self.printTrace(self.id, 'received an interruptionEnd event sent at '+str(self.interruptionEnd.signalparam))
self.printTrace1(self.id, interruptionEnd=str(self.interruptionEnd.signalparam))
elif self.loadOperatorAvailable.signalparam==now():
self.printTrace(self.id, 'received an loadOperatorAvailable event sent at '+str(self.loadOperatorAvailable.signalparam))
# self.printTrace(self.id, 'received an loadOperatorAvailable event sent at '+str(self.loadOperatorAvailable.signalparam))
self.printTrace1(self.id,loadOperatorAvailable=str(self.loadOperatorAvailable.signalparam))
# try to signal the Giver, otherwise wait until it is requested
if self.signalGiver():
break
......@@ -463,7 +468,8 @@ class Machine(CoreObject):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
activeEntity=activeObjectQueue[0]
self.printTrace(activeObject.getActiveObjectQueue()[0].name,"ended processing in "+activeObject.objName)
# self.printTrace(activeObject.getActiveObjectQueue()[0].name,"ended processing in "+activeObject.objName)
self.printTrace1(activeObject.getActiveObjectQueue()[0].name, processEnd=activeObject.objName)
# reset the variables used to handle the interruptions timing
self.timeRestartingProcessing=0
self.breakTime=0
......@@ -513,7 +519,8 @@ class Machine(CoreObject):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
activeEntity=activeObjectQueue[0]
self.printTrace(self.getActiveObjectQueue()[0].name, "Interrupted at "+self.objName+'. '*5)
# self.printTrace(self.getActiveObjectQueue()[0].name, "Interrupted at "+self.objName+'. '*5)
self.printTrace1(self.getActiveObjectQueue()[0].name, interrupted=self.objName)
# if the interrupt occured while processing an entity
if not activeObject.waitToDispose:
# output to trace that the Machine (self.objName) got interrupted
......@@ -698,7 +705,8 @@ class Machine(CoreObject):
activeObject.waitToDispose=False # update the waitToDispose flag
# if the Machine canAccept then signal a giver
if activeObject.canAccept():
self.printTrace(self.id, 'will try signalling a giver from removeEntity')
# self.printTrace(self.id, 'will try signalling a giver from removeEntity')
self.printTrace1(self.id, attemptSignalGiver='(removeEntity)')
activeObject.signalGiver()
return activeEntity
......
......@@ -49,7 +49,8 @@ class MachineJobShop(Machine):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
activeEntity=activeObjectQueue[0]
self.printTrace(activeObject.getActiveObjectQueue()[0].name,"ended processing in "+activeObject.objName)
# self.printTrace(activeObject.getActiveObjectQueue()[0].name,"ended processing in "+activeObject.objName)
self.printTrace1(activeObject.getActiveObjectQueue()[0].name,processEnd=activeObject.objName)
# reset the variables used to handle the interruptions timing
self.timeRestartingProcessing=0
self.breakTime=0
......@@ -230,7 +231,8 @@ class MachineJobShop(Machine):
# method to execute preemption
# =======================================================================
def preempt(self):
self.printTrace(self.id,'preempting'+' .'*7)
# self.printTrace(self.id,'preempting'+' .'*7)
self.printTrace1(self.id,preempted='')
activeObject=self.getActiveObject()
activeEntity=self.getActiveObjectQueue()[0] #get the active Entity
#calculate the remaining processing time
......
......@@ -105,7 +105,6 @@ class MachineManagedJob(MachineJobShop):
# also updates the giver to the one that is to be taken
# =======================================================================
def canAcceptAndIsRequested(self,callerObject=None):
# print self.id, 'CAAIR'
# get active and giver objects
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
......@@ -191,15 +190,3 @@ class MachineManagedJob(MachineJobShop):
return self.entityToGet
# # =======================================================================
# # prepare the machine to be released
# # =======================================================================
# def releaseOperator(self):
# self.outputTrace(self.currentOperator.objName, "released from "+ self.objName)
# # # TESTING
# # print now(), self.id, 'will release operator', self.operatorPool.operators[0].objName
# # set the flag operatorAssignedTo to None
# self.currentOperator.operatorAssignedTo=None
# self.broker.invokeBroker()
# self.toBeOperated = False
......@@ -71,11 +71,11 @@ class Broker(ObjectInterruption):
# TODO: add new broker event - brokerIsCalled
yield waitevent, self, self.isCalled
assert self.isCalled.signalparam==now(), 'the broker should be granted control instantly'
self.victim.printTrace1(self.victim.id, received='(broker)')
# ======= request a resource
if self.victim.isOperated()\
and any(type=='Load' or type=='Setup' or type=='Processing'\
for type in self.victim.multOperationTypeList):
# self.printTrace(self.victim.id, 'broker is invoked')
# update the time that the station is waiting for the operator
self.timeWaitForOperatorStarted=now()
#===============================================================
......@@ -87,24 +87,28 @@ class Broker(ObjectInterruption):
if not self.victim.currentEntity in G.pendingEntities:
G.pendingEntities.append(self.victim.currentEntity)
if not G.Router.invoked:
self.printTrace(self.victim.id, 'broker'+' '*50+'signalling router')
# self.printTrace(self.victim.id, 'broker'+' '*50+'signalling router')
self.victim.printTrace1(self.victim.id, signal='router (broker)')
G.Router.invoked=True
G.Router.isCalled.signal(now())
self.waitForOperator=True
# self.printTrace(self.victim.id, 'broker waits till resource is available1')
self.victim.printTrace1(self.victim.id, waitEvent='(resourceIsAvailable broker)')
yield waitevent, self, self.resourceAvailable
# remove the currentEntity from the pendingEntities
if self.victim.currentEntity in G.pendingEntities:
G.pendingEntities.remove(self.victim.currentEntity)
self.waitForOperator=False
# self.printTrace(self.victim.id, 'received resourceAvailable event')
self.victim.printTrace1(self.victim.id, resourceAvailable='(broker)')
#===============================================================
assert self.victim.operatorPool.checkIfResourceIsAvailable(), 'there is no available operator to request'
# set the available resource as the currentOperator
self.victim.currentOperator=self.victim.operatorPool.findAvailableOperator()
yield request, self, self.victim.operatorPool.getResource(self.victim.currentOperator)
self.printTrace(self.victim.currentOperator.objName, 'started work in '+self.victim.id)
# self.printTrace(self.victim.currentOperator.objName, 'started work in '+self.victim.id)
self.victim.printTrace1(self.victim.currentOperator.objName, startWork=self.victim.id)
# clear the timeWaitForOperatorStarted variable
self.timeWaitForOperatorStarted = 0
# update the time that the operation started
......@@ -121,7 +125,8 @@ class Broker(ObjectInterruption):
# TODO: signalling the router must be done more elegantly, router must be set as global variable
# if the router is already invoked then do not signal it again
if not self.victim.router.invoked:
self.printTrace(self.victim.id, 'broker'+' '*50+'signalling ROUTER')
# self.printTrace(self.victim.id, 'broker'+' '*50+'signalling ROUTER')
self.victim.printTrace1(self.victim.id, signal='router (broker)')
self.victim.router.invoked=True
self.victim.router.isCalled.signal(now())
# TODO: signalling the router will give the chance to it to take the control, but when will it eventually receive it.
......@@ -129,6 +134,7 @@ class Broker(ObjectInterruption):
# TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers.
self.printTrace(self.victim.currentOperator.objName, 'released '+self.victim.id)
self.victim.printTrace1(self.victim.currentOperator.objName, finishWork=self.victim.id)
# the victim current operator must be cleared after the operator is released
self.timeLastOperationEnded = now()
self.victim.currentOperator = None
......
......@@ -93,13 +93,16 @@ class Queue(CoreObject):
# check if there is WIP and signal receiver
self.initialSignalReceiver()
while 1:
self.printTrace(self.id, 'will wait for event')
# self.printTrace(self.id, 'will wait for event')
self.printTrace1(self.id, waitEvent='')
# wait until the Queue can accept an entity and one predecessor requests it
yield waitevent, self, [self.isRequested,self.canDispose, self.loadOperatorAvailable]
self.printTrace(self.id, 'just received an event')
# self.printTrace(self.id, 'just received an event')
self.printTrace1(self.id, received='')
# if the event that activated the thread is isRequested then getEntity
if self.isRequested.signalparam:
self.printTrace(self.id, 'received a isRequested event from'+self.isRequested.signalparam.id)
# self.printTrace(self.id, 'received a isRequested event from'+self.isRequested.signalparam.id)
self.printTrace1(self.id, isRequested=self.isRequested.signalparam.id)
# reset the isRequested signal parameter
self.isRequested.signalparam=None
self.getEntity()
......@@ -109,14 +112,17 @@ class Queue(CoreObject):
# if the queue received an loadOperatorIsAvailable (from Router) with signalparam time
if self.loadOperatorAvailable.signalparam:
# self.printTrace(self.id, 'received a loadOperatorAvailable event')
# self.printTrace1(self.id, loadOperatorAvailable=str(self.loadOperatorAvailable.signalparam))
self.loadOperatorAvailable.signalparam=None
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if self.canDispose.signalparam:
self.printTrace(self.id, 'received a canDispose event')
# self.printTrace(self.id, 'received a canDispose event')
self.printTrace1(self.id, canDispose='')
self.canDispose.signalparam=None
# if the event that activated the thread is canDispose then signalReceiver
if self.haveToDispose():
self.printTrace(self.id, 'will try to signal a receiver from generator')
# self.printTrace(self.id, 'will try to signal a receiver from generator')
self.printTrace1(self.id, attemptSignalReceiver='(generator)')
if self.receiver:
if not self.receiver.entryIsAssignedTo():
self.signalReceiver()
......@@ -170,6 +176,7 @@ class Queue(CoreObject):
if not self.__class__.__name__=='MouldAssemblyBuffer':
if self.haveToDispose():
self.printTrace(self.id, 'will try to signal a receiver from removeEntity')
self.printTrace1(self.id, attemptSignalReceiver='(removeEntity)')
self.signalReceiver()
return activeEntity
......
......@@ -113,7 +113,8 @@ class QueueManagedJob(QueueJobShop):
if receiver.identifyEntityToGet().manager.isAssignedTo()!=receiver:
from Globals import G
if not G.Router.invoked:
self.printTrace(self.id,' '*50+'signalling router')
# self.printTrace(self.id,' '*50+'signalling router')
self.printTrace1(self.id, signal='router')
G.Router.invoked=True
G.Router.isCalled.signal(now())
return True
......
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