batch related objects updated to comply with the new singlling norm

parent 028b3187
...@@ -86,23 +86,26 @@ class BatchDecomposition(CoreObject): ...@@ -86,23 +86,26 @@ class BatchDecomposition(CoreObject):
receivedEvent=yield self.env.any_of([self.isRequested , self.interruptionStart , self.initialWIP]) receivedEvent=yield self.env.any_of([self.isRequested , self.interruptionStart , self.initialWIP])
# if an interruption has occurred # if an interruption has occurred
if self.interruptionStart in receivedEvent: if self.interruptionStart in receivedEvent:
assert self.interruptionStart.value==self.env.now, 'the interruption received by batchDecomposition was created earlier' transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruption received by batchDecomposition was created earlier'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
# wait till it is over # wait till it is over
yield self.interruptionEnd yield self.interruptionEnd
assert self==self.interruptionEnd.value, 'the victim of the failure is not the object that received the interruptionEnd event' transmitter, eventTime=self.interruptionEnd.value
assert self==transmitter, 'the victim of the failure is not the object that received the interruptionEnd event'
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
if self.signalGiver(): if self.signalGiver():
break break
# if we have initial wip # if we have initial wip
elif self.initialWIP in receivedEvent: elif self.initialWIP in receivedEvent:
assert self.initialWIP.value==self.env, 'initial wip was not sent by the Environment' transmitter, eventTime=self.initialWIP.value
assert transmitter==self.env, 'initial wip was not sent by the Environment'
self.initialWIP=self.env.event() self.initialWIP=self.env.event()
self.isProcessingInitialWIP=True self.isProcessingInitialWIP=True
break break
# otherwise proceed with getEntity # otherwise proceed with getEntity
else: else:
requestingObject=self.isRequested.value requestingObject, eventTime=self.isRequested.value
assert requestingObject==self.giver, 'the giver is not the requestingObject' assert requestingObject==self.giver, 'the giver is not the requestingObject'
self.isRequested=self.env.event() self.isRequested=self.env.event()
break break
...@@ -138,11 +141,13 @@ class BatchDecomposition(CoreObject): ...@@ -138,11 +141,13 @@ class BatchDecomposition(CoreObject):
# if there was no success wait till the receiver is available # if there was no success wait till the receiver is available
while 1: while 1:
yield self.canDispose yield self.canDispose
transmitter, eventTime=self.canDispose.value
self.canDispose=self.env.event() self.canDispose=self.env.event()
# signal the receiver again and break # signal the receiver again and break
if self.signalReceiver(): if self.signalReceiver():
self.waitEntityRemoval=True self.waitEntityRemoval=True
yield self.entityRemoved yield self.entityRemoved
transmitter, eventTime=self.entityRemoved.value
self.waitEntityRemoval=False self.waitEntityRemoval=False
break break
...@@ -151,11 +156,13 @@ class BatchDecomposition(CoreObject): ...@@ -151,11 +156,13 @@ class BatchDecomposition(CoreObject):
else: else:
while 1: while 1:
yield self.canDispose yield self.canDispose
transmitter, eventTime=self.canDispose.value
self.canDispose=self.env.event() self.canDispose=self.env.event()
signaling=self.signalReceiver() signaling=self.signalReceiver()
if signaling: if signaling:
self.waitEntityRemoval=True self.waitEntityRemoval=True
yield self.entityRemoved yield self.entityRemoved
transmitter, eventTime=self.entityRemoved.value
self.waitEntityRemoval=False self.waitEntityRemoval=False
break break
......
...@@ -81,22 +81,25 @@ class BatchReassembly(CoreObject): ...@@ -81,22 +81,25 @@ class BatchReassembly(CoreObject):
while 1: while 1:
receivedEvent=yield self.env.any_of([self.isRequested , self.interruptionStart , self.initialWIP]) receivedEvent=yield self.env.any_of([self.isRequested , self.interruptionStart , self.initialWIP])
if self.interruptionStart in receivedEvent: if self.interruptionStart in receivedEvent:
assert self.interruptionStart.value==self.env.now, 'the interruptionStart received by BatchReassembly later than created' transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruptionStart received by BatchReassembly later than created'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
yield self.interruptionEnd yield self.interruptionEnd
assert self==self.interruptionEnd.value, 'the victim of the failure is not the object that received the interruptionEnd event' transmitter, eventTime=self.interruptionEnd.value
assert self==transmitter, 'the victim of the failure is not the object that received the interruptionEnd event'
self.interruptionEnd=self.env.event() self.interruptionEnd=self.env.event()
if self.signalGiver(): if self.signalGiver():
break break
# if we have initial wip # if we have initial wip
elif self.initialWIP in receivedEvent: elif self.initialWIP in receivedEvent:
assert self.initialWIP.value==self.env, 'initial wip was not sent by the Environment' transmitter, eventTime=self.initialWIP.value
assert transmitter==self.env, 'initial wip was not sent by the Environment'
self.initialWIP=self.env.event() self.initialWIP=self.env.event()
self.isProcessingInitialWIP=True self.isProcessingInitialWIP=True
break break
# otherwise proceed with getEntity # otherwise proceed with getEntity
else: else:
requestingObject=self.isRequested.value requestingObject, eventTime=self.isRequested.value
assert requestingObject==self.giver, 'the giver is not the requestingObject' assert requestingObject==self.giver, 'the giver is not the requestingObject'
self.isRequested=self.env.event() self.isRequested=self.env.event()
self.isProcessingInitialWIP=False self.isProcessingInitialWIP=False
...@@ -128,14 +131,16 @@ class BatchReassembly(CoreObject): ...@@ -128,14 +131,16 @@ class BatchReassembly(CoreObject):
# if there was interruption # if there was interruption
# TODO not good implementation # TODO not good implementation
if self.interruptionStart in receivedEvent: if self.interruptionStart in receivedEvent:
assert self.interruptionStart.value==self.env.now, 'the interruption has not been processed on the time of activation' transmitter, eventTime=self.interruptionStart.value
assert eventTime==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
# wait for the end of the interruption # wait for the end of the interruption
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:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it' 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() self.interruptionEnd=self.env.event()
if self.Up and self.onShift: if self.Up and self.onShift:
break break
...@@ -146,10 +151,11 @@ class BatchReassembly(CoreObject): ...@@ -146,10 +151,11 @@ class BatchReassembly(CoreObject):
else: else:
continue continue
if self.canDispose in receivedEvent: if self.canDispose in receivedEvent:
if self.canDispose.value!=self.env.now: transmitter, eventTime=self.canDispose.value
if eventTime!=self.env.now:
self.canDispose=self.env.event() self.canDispose=self.env.event()
continue continue
assert self.canDispose.value==self.env.now,'canDispose signal is late' assert eventTime==self.env.now,'canDispose signal is late'
self.canDispose=self.env.event() self.canDispose=self.env.event()
# try to signal a receiver, if successful then proceed to get an other entity # try to signal a receiver, if successful then proceed to get an other entity
if self.signalReceiver(): if self.signalReceiver():
...@@ -165,8 +171,9 @@ class BatchReassembly(CoreObject): ...@@ -165,8 +171,9 @@ class BatchReassembly(CoreObject):
self.waitEntityRemoval=True self.waitEntityRemoval=True
self.printTrace(self.id, waitEvent='(entityRemoved)') self.printTrace(self.id, waitEvent='(entityRemoved)')
yield self.entityRemoved yield self.entityRemoved
self.printTrace(self.id, entityRemoved=self.entityRemoved.value) transmitter, eventTime=self.entityRemoved.value
assert self.entityRemoved.value==self.env.now,'entityRemoved event activated earlier than received' self.printTrace(self.id, entityRemoved=eventTime)
assert eventTime==self.env.now,'entityRemoved event activated earlier than received'
self.waitEntityRemoval=False self.waitEntityRemoval=False
self.entityRemoved=self.env.event() self.entityRemoved=self.env.event()
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed # if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
......
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