Commit c3943b8e authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

more CoreObjects use the expectedSignals dict

parent 6ddc0faa
......@@ -154,6 +154,9 @@ class Assembly(CoreObject):
while 1:
self.printTrace(self.id, waitEvent='')
# wait until the Queue can accept an entity and one predecessor requests it
self.expectedSignals['isRequested']=1
yield self.isRequested #[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if self.isRequested.value:
transmitter, eventTime=self.isRequested.value
......@@ -173,7 +176,9 @@ class Assembly(CoreObject):
self.isRequested=self.env.event()
# TODO: fix the getEntity 'Part' case
self.getEntity("Part")
self.expectedSignals['isRequested']=0
self.outputTrace(self.getActiveObjectQueue()[0].name, "is now full in "+ self.objName)
self.isProcessing=True
......@@ -199,6 +204,10 @@ class Assembly(CoreObject):
# 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
self.expectedSignals['canDispose']=1
self.expectedSignals['interruptionStart']=1
while 1:
# self.timeLastBlockageStarted=self.env.now # blockage is starting
# wait the event canDispose, this means that the station can deliver the item to successor
......@@ -214,7 +223,13 @@ class Assembly(CoreObject):
self.interruptionActions() # execute interruption actions
# loop until we reach at a state that there is no interruption
while 1:
self.expectedSignals['interruptionEnd']=1
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
self.expectedSignals['interruptionEnd']=0
transmitter, eventTime=self.interruptionEnd.value
assert eventTime==self.env.now, 'the victim of the failure is not the object that received it'
self.interruptionEnd=self.env.event()
......@@ -246,7 +261,13 @@ class Assembly(CoreObject):
# notify that the station waits the entity to be removed
self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)')
self.expectedSignals['entityRemoved']=1
yield self.entityRemoved
self.expectedSignals['entityRemoved']=0
transmitter, eventTime=self.entityRemoved.value
self.printTrace(self.id, entityRemoved=eventTime)
assert eventTime==self.env.now,'entityRemoved event activated earlier than received'
......@@ -255,7 +276,10 @@ class Assembly(CoreObject):
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
if not self.haveToDispose():
break
self.expectedSignals['canDispose']=0
self.expectedSignals['interruptionStart']=0
#===========================================================================
# checks if the Assembly can accept an entity
#===========================================================================
......
......@@ -107,6 +107,11 @@ class Conveyer(CoreObject):
self.conveyerMover.canMove.succeed(succeedTuple)
self.printTrace(self.id, waitEvent='')
self.expectedSignals['isRequested']=1
self.expectedSignals['canDispose']=1
self.expectedSignals['moveEnd']=1
receivedEvent=yield self.env.any_of([self.isRequested , self.canDispose , self.moveEnd]) # , self.loadOperatorAvailable]
# if the event that activated the thread is isRequested then getEntity
if self.isRequested in receivedEvent:
......@@ -137,6 +142,10 @@ class Conveyer(CoreObject):
self.printTrace(self.id, attemptSignalGiver='(removeEntity)')
self.signalGiver()
self.expectedSignals['isRequested']=0
self.expectedSignals['canDispose']=0
self.expectedSignals['moveEnd']=0
# if the event that activated the thread is canDispose then signalReceiver
if self.haveToDispose():
self.printTrace(self.id, attemptSignalReceiver='(generator)')
......@@ -531,8 +540,9 @@ 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
succeedTuple=(self,self.env.now)
self.conveyer.moveEnd.succeed(succeedTuple) # send a signal to the conveyer that the move has ended
if self.conveyer.expectedSignals['moveEnd']:
succeedTuple=(self,self.env.now)
self.conveyer.moveEnd.succeed(succeedTuple) # send a signal to the conveyer that the move has ended
......@@ -126,8 +126,13 @@ class Dismantle(CoreObject):
while 1:
# self.printTrace(self.id, waitEvent='(frame)')
# wait until the Queue can accept an entity and one predecessor requests it
self.expectedSignals['isRequested']=1
yield self.isRequested #[self.isRequested,self.canDispose, self.loadOperatorAvailable]
self.expectedSignals['isRequested']=0
if self.isRequested.value:
# self.printTrace(self.id, isRequested=self.isRequested.value.id)
# reset the isRequested signal parameter
......@@ -154,6 +159,9 @@ class Dismantle(CoreObject):
# while the object still holds the frame
flag=False
while not self.isEmpty():
self.expectedSignals['canDispose']=1
# try and signal the receiver
if not self.signalReceiver():
# if not possible, then wait till a receiver is available
......@@ -164,7 +172,13 @@ class Dismantle(CoreObject):
continue
# if the receiver was not responsive, release the control to let him remove the entity
self.waitEntityRemoval=True
self.expectedSignals['entityRemoved']=1
yield self.entityRemoved
self.expectedSignals['entityRemoved']=0
self.waitEntityRemoval=False
self.entityRemoved=self.env.event()
......@@ -175,6 +189,8 @@ class Dismantle(CoreObject):
if self.isEmpty():
self.waitToDisposeFrame=False #the Dismantle has no Frame to dispose now
break
self.expectedSignals['canDispose']=0
#===========================================================================
# checks if the Dismantle can accept an entity and there is a Frame
......
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