Commit 7f1e82b8 authored by Georgios Dagkakis's avatar Georgios Dagkakis

more robust tests on Machine now that it can deliver on interruption

parent 9380a23a
...@@ -753,6 +753,8 @@ class Machine(CoreObject): ...@@ -753,6 +753,8 @@ class Machine(CoreObject):
# if there was no available receiver, get into blocking control # if there was no available receiver, get into blocking control
while 1: while 1:
if not len(self.getActiveObjectQueue()):
break
self.expectedSignals['interruptionStart']=1 self.expectedSignals['interruptionStart']=1
self.expectedSignals['canDispose']=1 self.expectedSignals['canDispose']=1
self.timeLastBlockageStarted=self.env.now # blockage is starting self.timeLastBlockageStarted=self.env.now # blockage is starting
...@@ -818,14 +820,13 @@ class Machine(CoreObject): ...@@ -818,14 +820,13 @@ class Machine(CoreObject):
# the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station # the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station
# and then cannot exit an infinite loop. # and then cannot exit an infinite loop.
# notify that the station waits the entity to be removed # notify that the station waits the entity to be removed
activeObjectQueue=self.getActiveObjectQueue()
if len(activeObjectQueue):
self.waitEntityRemoval=True self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)') self.printTrace(self.id, waitEvent='(entityRemoved)')
self.expectedSignals['entityRemoved']=1 self.expectedSignals['entityRemoved']=1
yield self.entityRemoved yield self.entityRemoved
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'
...@@ -923,16 +924,12 @@ class Machine(CoreObject): ...@@ -923,16 +924,12 @@ class Machine(CoreObject):
# the machine is currently performing nothing # the machine is currently performing nothing
self.currentlyPerforming=None self.currentlyPerforming=None
activeObjectQueue=self.Res.users activeObjectQueue=self.Res.users
if len(activeObjectQueue):
activeEntity=activeObjectQueue[0] activeEntity=activeObjectQueue[0]
self.printTrace(activeEntity.name, interrupted=self.objName) self.printTrace(activeEntity.name, interrupted=self.objName)
# if the interrupt occurred while processing an entity
if not self.waitToDispose:
# output to trace that the Machine (self.objName) got interrupted
try:
self.outputTrace(activeObjectQueue[0].name, "Interrupted at "+self.objName) self.outputTrace(activeObjectQueue[0].name, "Interrupted at "+self.objName)
except IndexError:
pass
# recalculate the processing time left tinM # recalculate the processing time left tinM
if self.timeLastOperationStarted:
self.tinM=self.tinM-(self.env.now-self.timeLastOperationStarted) self.tinM=self.tinM-(self.env.now-self.timeLastOperationStarted)
if(self.tinM==0): # sometimes the failure may happen exactly at the time that the processing would finish if(self.tinM==0): # sometimes the failure may happen exactly at the time that the processing would finish
# this may produce disagreement with the simul8 because in both SimPy and Simul8 # this may produce disagreement with the simul8 because in both SimPy and Simul8
...@@ -957,12 +954,14 @@ class Machine(CoreObject): ...@@ -957,12 +954,14 @@ class Machine(CoreObject):
# ======================================================================= # =======================================================================
def postInterruptionActions(self): def postInterruptionActions(self):
activeObjectQueue=self.Res.users activeObjectQueue=self.Res.users
if len(activeObjectQueue):
activeEntity=activeObjectQueue[0] activeEntity=activeObjectQueue[0]
# if the machine returns from an failure while processing an entity # if the machine returns from an failure while processing an entity
if not self.waitToDispose: if not self.waitToDispose:
# use the timers to count the time that Machine is down and related # use the timers to count the time that Machine is down and related
self.timeLastFailureEnded=self.env.now # set the timeLastFailureEnded self.timeLastFailureEnded=self.env.now # set the timeLastFailureEnded
# output to trace that the Machine self.objName was passivated for the current failure time # output to trace that the Machine self.objName was passivated for the current failure time
if len(activeObjectQueue):
self.outputTrace(activeObjectQueue[0].name, "passivated in "+self.objName+" for "+str(self.env.now-self.breakTime)) self.outputTrace(activeObjectQueue[0].name, "passivated in "+self.objName+" for "+str(self.env.now-self.breakTime))
# when a machine returns from failure while trying to deliver an entity # when a machine returns from failure while trying to deliver an entity
else: else:
......
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