Commit 3938d177 authored by Georgios Dagkakis's avatar Georgios Dagkakis

BatchDecomposition can receive wip

parent bb096f30
......@@ -81,7 +81,7 @@ class BatchDecomposition(CoreObject):
while 1:
# wait for an event or an interruption
while 1:
receivedEvent=yield self.isRequested | self.interruptionStart
receivedEvent=yield self.isRequested | self.interruptionStart | self.initialWIP
# if an interruption has occurred
if self.interruptionStart in receivedEvent:
assert self.interruptionStart.value==self.env.now, 'the interruption received by batchDecomposition was created earlier'
......@@ -92,26 +92,39 @@ class BatchDecomposition(CoreObject):
self.interruptionEnd=self.env.event()
if self.signalGiver():
break
# if we have initial wip
elif self.initialWIP in receivedEvent:
assert self.initialWIP.value==self.env, 'initial wip was not sent by the Environment'
self.initialWIP=self.env.event()
self.isProcessingInitialWIP=True
break
# otherwise proceed with getEntity
else:
else:
requestingObject=self.isRequested.value
assert requestingObject==self.giver, 'the giver is not the requestingObject'
self.isRequested=self.env.event()
break
requestingObject=self.isRequested.value
assert requestingObject==self.giver, 'the giver is not the requestingObject'
self.isRequested=self.env.event()
self.currentEntity=self.getEntity()
if not self.isProcessingInitialWIP: # if we are in the state of having initial wip no need to take an Entity
self.currentEntity=self.getEntity()
# set the currentEntity as the Entity just received and initialize the timer timeLastEntityEntered
self.nameLastEntityEntered=self.currentEntity.name # this holds the name of the last entity that got into Machine
self.timeLastEntityEntered=self.env.now #this holds the last time that an entity got into Machine
self.timeLastEntityEntered=self.env.now #this holds the last time that an entity got into Machine
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime()
# if we have batch in the decomposition (initial wip may be in sub-batch)
if self.getActiveObjectQueue()[0].__class__.__name__=='Batch':
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime()
yield self.env.timeout(self.totalProcessingTimeInCurrentEntity)
self.decompose()
yield self.env.timeout(self.totalProcessingTimeInCurrentEntity)
self.decompose()
# reset the variable
self.isProcessingInitialWIP=False
# TODO: add failure control
# as long as there are sub-Batches in the internal Resource
for i in range(self.numberOfSubBatches):
numberOfSubBatches=int(len(self.getActiveObjectQueue()))
for i in range(numberOfSubBatches):
# added here temporarily, it is supposed to break when i==numberOfSubBatches
if not self.getActiveObjectQueue():
break
......@@ -242,3 +255,4 @@ class BatchDecomposition(CoreObject):
giverObject=callerObject
assert giverObject, 'there must be a caller for canAcceptAndIsRequested'
return activeObject.Up and len(activeObjectQueue)==0 and giverObject.haveToDispose(activeObject)
......@@ -250,10 +250,12 @@ def setWIP(entityList):
entity.hot = True
# add the entity to the pendingEntities list
G.pendingEntities.append(entity)
# if we are in the start of the simulation the object is of Machine type then we should send initialWIP signal
# if we are in the start of the simulation the object is of server type then we should send initialWIP signal
# TODO, maybe use 'class_family attribute here'
if G.env.now==0 and entity.currentStation:
if entity.currentStation.class_name:
if entity.currentStation.class_name == 'Dream.Machine':
stationClass=entity.currentStation.__class__.__name__
if stationClass in ['Machine', 'BatchScrapMachine', 'MachineJobShop','BatchDecomposition']:
entity.currentStation.currentEntity=entity
entity.currentStation.initialWIP.succeed(G.env)
......
......@@ -1168,6 +1168,7 @@ def createWIP():
G.EntityList.append(B)
object=Globals.findObjectById(element['id'])
B.unitsToProcess=int(entity.get('unitsToProcess', numberOfUnits))
B.remainingProcessingTime=float(entity.get('remainingProcessingTime', 0))
B.currentStation=object
elif entityClass=='Dream.SubBatch':
......@@ -1196,6 +1197,7 @@ def createWIP():
G.EntityList.append(SB)
object=Globals.findObjectById(element['id'])
SB.unitsToProcess=int(entity.get('unitsToProcess', numberOfUnits))
SB.remainingProcessingTime=float(entity.get('remainingProcessingTime', 0))
SB.currentStation=object
if entityClass=='Dream.Order':
......
......@@ -378,11 +378,11 @@ class Machine(CoreObject):
# TODO: reset the requestinEntity before receiving the currentEntity
self.requestingEntity=None
# get the entity
# get the entity
# TODO: if there was loading time then we must solve the problem of getting an entity
# from an unidentified giver or not getting an entity at all as the giver
# may fall in failure mode (assignExit()?)
if not self.isProcessingInitialWIP:
if not self.isProcessingInitialWIP: # if we are in the state of having initial wip no need to take an Entity
self.currentEntity=self.getEntity()
# TODO: the Machine receive the entity after the operator is available
# the canAcceptAndIsRequested method checks only in case of Load type of operation
......
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