Commit 9164973f authored by Georgios Dagkakis's avatar Georgios Dagkakis

many objects set to update the flags at correct place

parent df5712d6
......@@ -85,13 +85,11 @@ class BatchDecomposition(CoreObject):
# check if there is WIP and signal receiver
self.initialSignalReceiver()
while 1:
# wait for an event or an interruption
self.expectedSignals['isRequested']=1
self.expectedSignals['interruptionStart']=1
self.expectedSignals['initialWIP']=1
# wait for an event or an interruption
while 1:
self.expectedSignals['isRequested']=1
self.expectedSignals['interruptionStart']=1
self.expectedSignals['initialWIP']=1
receivedEvent=yield self.env.any_of([self.isRequested , self.interruptionStart , self.initialWIP])
# if an interruption has occurred
if self.interruptionStart in receivedEvent:
......@@ -144,9 +142,7 @@ class BatchDecomposition(CoreObject):
# reset the variable
self.isProcessingInitialWIP=False
self.expectedSignals['canDispose']=1
# TODO: add failure control
# as long as there are sub-Batches in the internal Resource
numberOfSubBatches=int(len(self.getActiveObjectQueue()))
......@@ -161,6 +157,7 @@ class BatchDecomposition(CoreObject):
if not signaling:
# if there was no success wait till the receiver is available
while 1:
self.expectedSignals['canDispose']=1
yield self.canDispose
transmitter, eventTime=self.canDispose.value
self.canDispose=self.env.event()
......@@ -182,6 +179,7 @@ class BatchDecomposition(CoreObject):
# we know that the receiver is occupied with the previous sub-batch
else:
while 1:
self.expectedSignals['canDispose']=1
yield self.canDispose
transmitter, eventTime=self.canDispose.value
self.canDispose=self.env.event()
......
......@@ -81,13 +81,11 @@ class BatchReassembly(CoreObject):
activeObjectQueue=self.getActiveObjectQueue()
# check if there is WIP and signal receiver
self.initialSignalReceiver()
while 1:
self.expectedSignals['isRequested']=1
self.expectedSignals['interruptionStart']=1
self.expectedSignals['initialWIP']=1
while 1:
while 1:
self.expectedSignals['isRequested']=1
self.expectedSignals['interruptionStart']=1
self.expectedSignals['initialWIP']=1
receivedEvent=yield self.env.any_of([self.isRequested , self.interruptionStart , self.initialWIP])
if self.interruptionStart in receivedEvent:
transmitter, eventTime=self.interruptionStart.value
......@@ -140,16 +138,15 @@ class BatchReassembly(CoreObject):
self.reassemble()
self.isProcessingInitialWIP=False
# signal the receiver that the activeObject has something to dispose of
self.expectedSignals['interruptionStart']=1
self.expectedSignals['canDispose']=1
if not self.signalReceiver():
# if there was no available receiver, get into blocking control
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
self.printTrace(self.id, waitEvent='(canDispose or interruption start)')
self.expectedSignals['interruptionStart']=1
self.expectedSignals['canDispose']=1
receivedEvent=yield self.env.any_of([self.canDispose , self.interruptionStart])
# if there was interruption
# TODO not good implementation
......
......@@ -65,6 +65,7 @@ class CapacityStationController(EventGenerator):
if exit.expectedSignals['isRequested']:
succeedTuple=(station,self.env.now)
exit.isRequested.succeed(succeedTuple) # send is requested to station
exit.expectedSignals['isRequested']=0
# wait until the entity is removed
station.waitEntityRemoval=True
......@@ -125,6 +126,7 @@ class CapacityStationController(EventGenerator):
if station.expectedSignals['isRequested']:
succeedTuple=(buffer,self.env.now)
station.isRequested.succeed(succeedTuple) # send is requested to station
station.expectedSignals['isRequested']=0
# wait until the entity is removed
buffer.waitEntityRemoval=True
......
......@@ -543,6 +543,6 @@ class ConveyerMover(object):
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
self.conveyer.expectedSignals['moveEnd']=0
......@@ -298,11 +298,13 @@ class CoreObject(ManPyObject):
self.printTrace(self.id, signal='(removedEntity)')
succeedTuple=(self,self.env.now)
self.entityRemoved.succeed(succeedTuple)
self.expectedSignals['entityRemoved']=0
elif self.waitEntityRemoval and self.expectedSignals['entityRemoved']:
# print self.id,'not triggered and waiting'
self.printTrace(self.id, signal='(removedEntity)')
succeedTuple=(self,self.env.now)
self.entityRemoved.succeed(succeedTuple)
self.expectedSignals['entityRemoved']=0
elif not self.waitEntityRemoval and not self.expectedSignals['entityRemoved']:
# print self.id,'not triggered but not waiting'
pass
......@@ -566,6 +568,7 @@ class CoreObject(ManPyObject):
self.printTrace(self.id, signalGiver=self.giver.id)
succeedTuple=(self,self.env.now)
self.giver.canDispose.succeed(succeedTuple)
self.giver.expectedSignals['canDispose']=0
return True
return False
......
......@@ -70,6 +70,7 @@ class Exit(CoreObject):
def run(self):
while 1:
# wait until the Queue can accept an entity and one predecessor requests it
self.expectedSignals['isRequested']=1
yield self.isRequested
self.isRequested=self.env.event()
# TODO: insert extra controls to check whether the self.giver attribute is correctly updated
......
......@@ -732,11 +732,10 @@ class Machine(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['interruptionStart']=1
self.expectedSignals['canDispose']=1
while 1:
self.expectedSignals['interruptionStart']=1
self.expectedSignals['canDispose']=1
self.timeLastBlockageStarted=self.env.now # blockage is starting
# wait the event canDispose, this means that the station can deliver the item to successor
self.printTrace(self.id, waitEvent='(canDispose or interruption start)')
......
......@@ -102,6 +102,9 @@ class Queue(CoreObject):
while 1:
self.printTrace(self.id, waitEvent='')
# wait until the Queue can accept an entity and one predecessor requests it
self.expectedSignals['canDispose']=1
self.expectedSignals['isRequested']=1
self.expectedSignals['loadOperatorAvailable']=1
receivedEvent=yield self.isRequested | self.canDispose | self.loadOperatorAvailable
self.printTrace(self.id, received='')
# if the event that activated the thread is isRequested then getEntity
......
......@@ -140,6 +140,9 @@ class Source(CoreObject):
activeObjectQueue=self.getActiveObjectQueue()
while 1:
# wait for any event (entity creation or request for disposal of entity)
self.expectedSignals['canDispose']=1
self.expectedSignals['entityCreated']=1
self.expectedSignals['loadOperatorAvailable']=1
receivedEvent=yield self.entityCreated | self.canDispose | self.loadOperatorAvailable
self.printTrace(self.id, received='')
# if an entity is created try to signal the receiver and continue
......
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