Commit 59cea657 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

documentation updated. Examples to be added. Also, sseveral refinements on the...

documentation updated. Examples to be added. Also, sseveral refinements on the clearence of the code
parent 360ef07a
No preview for this file type
...@@ -75,7 +75,7 @@ class Failure(ObjectInterruption): ...@@ -75,7 +75,7 @@ class Failure(ObjectInterruption):
while 1: while 1:
yield hold,self,self.rngTTF.generateNumber() #wait until a failure happens yield hold,self,self.rngTTF.generateNumber() #wait until a failure happens
try: try:
if(len(self.victim.Res.activeQ)>0): if(len(self.getVictimQueue())>0):
self.interrupt(self.victim) #when a Machine gets failure while in process it is interrupted self.interrupt(self.victim) #when a Machine gets failure while in process it is interrupted
self.victim.Up=False self.victim.Up=False
self.victim.timeLastFailure=now() self.victim.timeLastFailure=now()
...@@ -88,7 +88,7 @@ class Failure(ObjectInterruption): ...@@ -88,7 +88,7 @@ class Failure(ObjectInterruption):
failTime=now() failTime=now()
if(self.repairman!="None"): #if the failure needs a resource to be fixed, the machine waits until the if(self.repairman!="None"): #if the failure needs a resource to be fixed, the machine waits until the
#resource is available #resource is available
yield request,self,self.repairman.Res yield request,self,self.repairman.getResource()
timeRepairStarted=now() timeRepairStarted=now()
self.repairman.timeLastRepairStarted=now() self.repairman.timeLastRepairStarted=now()
...@@ -96,12 +96,12 @@ class Failure(ObjectInterruption): ...@@ -96,12 +96,12 @@ class Failure(ObjectInterruption):
self.victim.totalFailureTime+=now()-failTime self.victim.totalFailureTime+=now()-failTime
try: try:
if(len(self.victim.Res.activeQ)>0): if(len(self.getVictimQueue())>0):
reactivate(self.victim) #since repairing is over, the Machine is reactivated reactivate(self.victim) #since repairing is over, the Machine is reactivated
self.victim.Up=True self.victim.Up=True
self.outputTrace("is up") self.outputTrace("is up")
if(self.repairman!="None"): #if a resource was used, it is now released if(self.repairman!="None"): #if a resource was used, it is now released
yield release,self,self.repairman.Res yield release,self,self.repairman.getResource()
self.repairman.totalWorkingTime+=now()-timeRepairStarted self.repairman.totalWorkingTime+=now()-timeRepairStarted
except AttributeError: except AttributeError:
print "AttributeError2" print "AttributeError2"
......
...@@ -434,10 +434,6 @@ def main(argv=[], input_data=None): ...@@ -434,10 +434,6 @@ def main(argv=[], input_data=None):
initialize() #initialize the simulation initialize() #initialize the simulation
initializeObjects() initializeObjects()
setWIP() setWIP()
for Q in G.QueueJobShopList:
pass
activateObjects() activateObjects()
#if the simulation is ran until no more events are scheduled, then we have to find the end time as the time the last entity ended. #if the simulation is ran until no more events are scheduled, then we have to find the end time as the time the last entity ended.
......
...@@ -30,11 +30,21 @@ from SimPy.Simulation import Process, Resource ...@@ -30,11 +30,21 @@ from SimPy.Simulation import Process, Resource
class ObjectInterruption(Process): class ObjectInterruption(Process):
def __init__(self, victim):
self.victim=victim
#the main process of the core object #the main process of the core object
#this is dummy, every object must have its own implementation #this is dummy, every object must have its own implementation
def run(self): def run(self):
raise NotImplementedError("Subclass must define 'run' method") raise NotImplementedError("Subclass must define 'run' method")
#outputs data to "output.xls" #outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime): def outputTrace(self, message):
pass pass
#returns the internal queue of the victim
def getVictimQueue(self):
return self.victim.getActiveObjectQueue()
\ No newline at end of file
...@@ -37,7 +37,7 @@ class ObjectResource(object): ...@@ -37,7 +37,7 @@ class ObjectResource(object):
#checks if the worker is available #checks if the worker is available
def checkIfResourceIsAvailable(self): def checkIfResourceIsAvailable(self):
return len(self.W.activeQ)<self.capacity return len(self.Res.activeQ)<self.capacity
#actions to be taken after the simulation ends #actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime): def postProcessing(self, MaxSimtime):
...@@ -64,3 +64,10 @@ class ObjectResource(object): ...@@ -64,3 +64,10 @@ class ObjectResource(object):
difValuesFlag=True difValuesFlag=True
return difValuesFlag return difValuesFlag
#returns the resource
def getResource(self):
return self.Res
#returns the active queue of the resource
def getResourceQueue(self):
return self.Res.activeQ
\ No newline at end of file
...@@ -33,7 +33,7 @@ from CoreObject import CoreObject ...@@ -33,7 +33,7 @@ from CoreObject import CoreObject
#the Queue object #the Queue object
class Queue(CoreObject): class Queue(CoreObject):
def __init__(self, id, name, capacity, dummy, schedulingRule="FIFO"): def __init__(self, id, name, capacity, dummy=False, schedulingRule="FIFO"):
Process.__init__(self) Process.__init__(self)
self.predecessorIndex=0 #holds the index of the predecessor from which the Queue will take an entity next self.predecessorIndex=0 #holds the index of the predecessor from which the Queue will take an entity next
self.successorIndex=0 #holds the index of the successor where the Queue will dispose an entity next self.successorIndex=0 #holds the index of the successor where the Queue will dispose an entity next
......
...@@ -39,6 +39,7 @@ class Repairman(ObjectResource): ...@@ -39,6 +39,7 @@ class Repairman(ObjectResource):
self.objName=name self.objName=name
self.capacity=capacity #repairman is an instance of resource self.capacity=capacity #repairman is an instance of resource
self.type="Repairman" self.type="Repairman"
self.Res=Resource(self.capacity)
#lists to hold statistics of multiple runs #lists to hold statistics of multiple runs
self.Waiting=[] self.Waiting=[]
...@@ -50,7 +51,7 @@ class Repairman(ObjectResource): ...@@ -50,7 +51,7 @@ class Repairman(ObjectResource):
#actions to be taken after the simulation ends #actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime): def postProcessing(self, MaxSimtime):
#if the repairman is currently working we have to count the time of this work #if the repairman is currently working we have to count the time of this work
if len(self.Res.activeQ)>0: if len(self.getResourceQueue())>0:
self.totalWorkingTime+=now()-self.timeLastRepairStarted self.totalWorkingTime+=now()-self.timeLastRepairStarted
#Repairman was idle when he was not in any other state #Repairman was idle when he was not in any other state
......
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