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