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):
while 1:
yield hold,self,self.rngTTF.generateNumber() #wait until a failure happens
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.victim.Up=False
self.victim.timeLastFailure=now()
......@@ -88,7 +88,7 @@ class Failure(ObjectInterruption):
failTime=now()
if(self.repairman!="None"): #if the failure needs a resource to be fixed, the machine waits until the
#resource is available
yield request,self,self.repairman.Res
yield request,self,self.repairman.getResource()
timeRepairStarted=now()
self.repairman.timeLastRepairStarted=now()
......@@ -96,12 +96,12 @@ class Failure(ObjectInterruption):
self.victim.totalFailureTime+=now()-failTime
try:
if(len(self.victim.Res.activeQ)>0):
if(len(self.getVictimQueue())>0):
reactivate(self.victim) #since repairing is over, the Machine is reactivated
self.victim.Up=True
self.outputTrace("is up")
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
except AttributeError:
print "AttributeError2"
......
......@@ -433,11 +433,7 @@ def main(argv=[], input_data=None):
initialize() #initialize the simulation
initializeObjects()
setWIP()
for Q in G.QueueJobShopList:
pass
setWIP()
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.
......
......@@ -30,11 +30,21 @@ from SimPy.Simulation import Process, Resource
class ObjectInterruption(Process):
def __init__(self, victim):
self.victim=victim
#the main process of the core object
#this is dummy, every object must have its own implementation
def run(self):
raise NotImplementedError("Subclass must define 'run' method")
#outputs data to "output.xls"
def outputResultsXL(self, MaxSimtime):
pass
\ No newline at end of file
def outputTrace(self, message):
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):
#checks if the worker is available
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
def postProcessing(self, MaxSimtime):
......@@ -63,4 +63,11 @@ class ObjectResource(object):
if(array[i]!=array[1]):
difValuesFlag=True
return difValuesFlag
\ No newline at end of file
#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
#the Queue object
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)
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
......
......@@ -39,6 +39,7 @@ class Repairman(ObjectResource):
self.objName=name
self.capacity=capacity #repairman is an instance of resource
self.type="Repairman"
self.Res=Resource(self.capacity)
#lists to hold statistics of multiple runs
self.Waiting=[]
......@@ -50,7 +51,7 @@ class Repairman(ObjectResource):
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime):
#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
#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