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