Commit 3daaafdc authored by Georgios Dagkakis's avatar Georgios Dagkakis

wip can be set in Machine. Processing time is not yet calculated correctly

parent f842a78c
......@@ -32,6 +32,7 @@ import simpy
# the core object
# ===========================================================================
class CoreObject(object):
class_name = 'Dream.CoreObject'
def __init__(self, id, name, **kw):
self.id = id
......@@ -128,6 +129,7 @@ class CoreObject(object):
self.setupTimeCurrentEntity=0
self.shouldPreempt=False #flag that shows that the machine should preempt or not
self.isProcessingInitialWIP=False #flag that is used only when a Machine has initial wip
self.lastGiver=None # variable that holds the last giver of the object, used by machine in case of preemption
# initialize the wipStatList -
......@@ -141,6 +143,7 @@ class CoreObject(object):
self.interruptionStart=self.env.event()
self.interruptedBy=None
self.entityRemoved=self.env.event()
self.initialWIP=self.env.event()
# flag used to signal that the station waits for removeEntity event
self.waitEntityRemoval=False
# attributes/indices used for printing the route, hold the cols corresponding to the machine (entities route and operators route)
......
......@@ -247,6 +247,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 G.env.now==0 and entity.currentStation:
if entity.currentStation.class_name:
if entity.currentStation.class_name == 'Dream.Machine':
entity.currentStation.currentEntity=entity
entity.currentStation.initialWIP.succeed(G.env)
from Exit import Exit
def countIntervalThroughput(argumentDict={}):
......
......@@ -301,7 +301,7 @@ class Machine(CoreObject):
# waitEvent isRequested /interruptionEnd/loadOperatorAvailable
while 1:
self.printTrace(self.id, waitEvent='')
receivedEvent = yield self.isRequested | self.interruptionEnd | self.loadOperatorAvailable
receivedEvent = yield self.isRequested | self.interruptionEnd | self.loadOperatorAvailable | self.initialWIP
self.printTrace(self.id, received='')
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if self.isRequested in receivedEvent:
......@@ -325,6 +325,12 @@ class Machine(CoreObject):
# try to signal the Giver, otherwise wait until it is requested
if self.signalGiver():
break
if 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
# TODO: maybe here have to assigneExit of the giver and add self to operator activeCallers list
# here or in the getEntity (apart from the loadTimeCurrentEntity)
......@@ -376,7 +382,8 @@ class Machine(CoreObject):
# 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()?)
self.currentEntity=self.getEntity()
if not self.isProcessingInitialWIP:
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
......@@ -613,8 +620,9 @@ class Machine(CoreObject):
self.timeLastEntityEnded=self.env.now # this holds the time that the last entity ended processing in Machine
self.nameLastEntityEnded=self.currentEntity.name # this holds the name of the last entity that ended processing in Machine
self.completedJobs+=1 # Machine completed one more Job
# reseting the shouldPreempt flag
# reseting flags
self.shouldPreempt=False
self.isProcessingInitialWIP=False
# in case Machine just performed the last work before the scheduled maintenance signal the corresponding object
if self.isWorkingOnTheLast:
......
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