minor improvements to Machine, assertion added

parent a825d615
...@@ -222,22 +222,20 @@ class Machine(CoreObject): ...@@ -222,22 +222,20 @@ class Machine(CoreObject):
self.initialSignalReceiver() self.initialSignalReceiver()
# execute all through simulation time # execute all through simulation time
while 1: while 1:
# waitEvent isRequested or an interruptionEnd # waitEvent isRequested /interruptionEnd/loadOperatorAvailable
while 1: while 1:
yield waitevent, self, [self.isRequested, self.interruptionEnd, self.loadOperatorAvailable] yield waitevent, self, [self.isRequested, self.interruptionEnd, self.loadOperatorAvailable]
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity # if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if self.isRequested.signalparam: if self.isRequested.signalparam:
assert self.isRequested.signalparam==self.giver, 'the giver is not the requestingObject' 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
self.isRequested.signalparam=None self.isRequested.signalparam=None
break break
# if an interruption caused the control to be taken by the machine # if an interruption caused the control to be taken by the machine or
if self.interruptionEnd.signalparam==now(): # if an operator was rendered available while it was needed by the machine to proceed with getEntity
# and signal the Giver, otherwise wait until it is requested if self.interruptionEnd.signalparam==now() or self.loadOperatorAvailable.signalparam==now():
if self.signalGiver(): # try to signal the Giver, otherwise wait until it is requested
break
# if an operator was rendered available while it was needed by the machine to proceed with getting
elif self.loadOperatorAvailable.signalparam==now():
# try to signal the giver, otherwise wait until it is requested
if self.signalGiver(): if self.signalGiver():
break break
# TODO: maybe here have to assigneExit of the giver and add self to operator activeCallers list # TODO: maybe here have to assigneExit of the giver and add self to operator activeCallers list
...@@ -722,6 +720,7 @@ class Machine(CoreObject): ...@@ -722,6 +720,7 @@ class Machine(CoreObject):
activeObject.waitToDispose=False # update the waitToDispose flag activeObject.waitToDispose=False # update the waitToDispose flag
# if the Machine canAccept then signal a giver # if the Machine canAccept then signal a giver
if activeObject.canAccept(): if activeObject.canAccept():
# print now(), self.id, 'will singal giver'
activeObject.signalGiver() activeObject.signalGiver()
# if the Machine is operated then signal Broker that the internal queue is now empty # if the Machine is operated then signal Broker that the internal queue is now empty
if activeObject.currentOperator: if activeObject.currentOperator:
......
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