Commit 0da9016c authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

QueuePreemptive code collapsed to CoreObject

parent 19784fcb
......@@ -171,7 +171,20 @@ class CoreObject(Process):
self.timeLastEntityEntered=now()
self.nameLastEntityEntered=activeEntity.name # this holds the name of the last entity that got into Machine
self.downTimeProcessingCurrentEntity=0
# perform preemption when required
# if the object is not Exit
if activeObject.receiver:
# if the obtained Entity is critical
if activeEntity.isCritical:
#if the receiver is not empty
if len(self.receiver.getActiveObjectQueue())>0:
#if the receiver does not hold an Entity that is also critical
if not self.receiver.getActiveObjectQueue()[0].isCritical:
self.receiver.shouldPreempt=True
self.receiver.preempt()
self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
self.outputTrace(activeEntity.name, "got into "+self.objName)
return activeEntity
......@@ -348,6 +361,12 @@ class CoreObject(Process):
def unAssignExit(self):
self.exitAssignedToReceiver = False
# =======================================================================
# actions to be carried whenever the object is preemptied
# =======================================================================
def preempt(self):
pass
# =======================================================================
# actions to be carried whenever the object is interrupted
# (failure, break, preemption, etc)
......
......@@ -54,6 +54,7 @@ class MachinePreemptive(MachineJobShop):
# method to execute the preemption
# =======================================================================
def preempt(self):
activeObject=self.getActiveObject()
activeEntity=self.getActiveObjectQueue()[0] #get the active Entity
#calculate the remaining processing time
#if it is reset then set it as the original processing time
......@@ -77,7 +78,8 @@ class MachinePreemptive(MachineJobShop):
#set the receiver as the object where the active entity was preempted from
self.receiver=self.lastGiver
self.next=[self.receiver]
self.waitToDispose=True #set that I have to dispose
self.waitToDispose=True #set that I have to dispose
self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
reactivate(self)
......
......@@ -32,21 +32,21 @@ from SimPy.Simulation import now
# the QueuePreemptive object
# ===========================================================================
class QueuePreemptive(QueueJobShop):
# =======================================================================
# extend he default so that it can interrupt the receiver if need be
# =======================================================================
def getEntity(self):
activeEntity=QueueJobShop.getEntity(self) #execute default behaviour
#if the obtained Entity is critical
if activeEntity.isCritical:
#if the receiver is not empty
if len(self.receiver.getActiveObjectQueue())>0:
#if the receiver does not hold an Entity that is also critical
if not self.receiver.getActiveObjectQueue()[0].isCritical:
self.receiver.shouldPreempt=True
self.receiver.preempt()
self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
return activeEntity
# # =======================================================================
# # extend he default so that it can interrupt the receiver if need be
# # =======================================================================
# def getEntity(self):
# activeEntity=QueueJobShop.getEntity(self) #execute default behaviour
# #if the obtained Entity is critical
# if activeEntity.isCritical:
# #if the receiver is not empty
# if len(self.receiver.getActiveObjectQueue())>0:
# #if the receiver does not hold an Entity that is also critical
# if not self.receiver.getActiveObjectQueue()[0].isCritical:
# self.receiver.shouldPreempt=True
# self.receiver.preempt()
# self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
# return activeEntity
# =======================================================================
# for future use
......
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