Commit 007e5b7c authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

nomeclature change (repair->operation) to incorporate the use of operators

parent 1d85fc71
...@@ -98,8 +98,8 @@ class Failure(ObjectInterruption): ...@@ -98,8 +98,8 @@ class Failure(ObjectInterruption):
#resource is available #resource is available
yield request,self,self.repairman.getResource() yield request,self,self.repairman.getResource()
# update the time that the repair started # update the time that the repair started
timeRepairStarted=now() timeOperationStarted=now()
self.repairman.timeLastRepairStarted=now() self.repairman.timeLastOperationStarted=now()
yield hold,self,self.rngTTR.generateNumber() # wait until the repairing process is over yield hold,self,self.rngTTR.generateNumber() # wait until the repairing process is over
self.victim.totalFailureTime+=now()-failTime self.victim.totalFailureTime+=now()-failTime
...@@ -111,7 +111,7 @@ class Failure(ObjectInterruption): ...@@ -111,7 +111,7 @@ class Failure(ObjectInterruption):
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.getResource() yield release,self,self.repairman.getResource()
self.repairman.totalWorkingTime+=now()-timeRepairStarted self.repairman.totalWorkingTime+=now()-timeOperationStarted
except AttributeError: except AttributeError:
print "AttributeError2" print "AttributeError2"
......
...@@ -279,7 +279,6 @@ class Machine(CoreObject): ...@@ -279,7 +279,6 @@ class Machine(CoreObject):
# ======================================================================= # =======================================================================
# checks if the machine down or it can dispose the object # checks if the machine down or it can dispose the object
# ======================================================================= # =======================================================================
#checks if the machine down or it can dispose the object
def ifCanDisposeOrHaveFailure(self): def ifCanDisposeOrHaveFailure(self):
return self.Up==False or self.getReceiverObject().canAccept(self) or len(self.getActiveObjectQueue())==0 return self.Up==False or self.getReceiverObject().canAccept(self) or len(self.getActiveObjectQueue())==0
......
...@@ -34,7 +34,7 @@ class ObjectResource(object): ...@@ -34,7 +34,7 @@ class ObjectResource(object):
def initialize(self): def initialize(self):
self.totalWorkingTime=0 #holds the total working time self.totalWorkingTime=0 #holds the total working time
self.totalWaitingTime=0 #holds the total waiting time self.totalWaitingTime=0 #holds the total waiting time
self.timeLastRepairStarted=0 #holds the time that the last repair was started self.timeLastOperationStarted=0 #holds the time that the last repair was started
self.Res=Resource(self.capacity) self.Res=Resource(self.capacity)
# ======================================================================= # =======================================================================
...@@ -89,4 +89,11 @@ class ObjectResource(object): ...@@ -89,4 +89,11 @@ class ObjectResource(object):
# returns the active queue of the resource # returns the active queue of the resource
# ======================================================================= # =======================================================================
def getResourceQueue(self): def getResourceQueue(self):
return self.Res.activeQ return self.Res.activeQ
\ No newline at end of file
# =======================================================================
# check availability of the resource
# =======================================================================
def isResourceFree(self):
if len(self.getResourceQueue())==0:
return True
\ No newline at end of file
...@@ -41,7 +41,7 @@ class Repairman(ObjectResource): ...@@ -41,7 +41,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) self.Res=Resource(self.capacity)
# lists to hold statistics of multiple runs # lists to hold statistics of multiple runs
self.Waiting=[] # holds the percentage of waiting time self.Waiting=[] # holds the percentage of waiting time
self.Working=[] # holds the percentage of working time self.Working=[] # holds the percentage of working time
...@@ -56,8 +56,9 @@ class Repairman(ObjectResource): ...@@ -56,8 +56,9 @@ class Repairman(ObjectResource):
from Globals import G from Globals import G
MaxSimtime=G.maxSimTime MaxSimtime=G.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.getResourceQueue())>0: # if len(self.getResourceQueue())>0:
self.totalWorkingTime+=now()-self.timeLastRepairStarted if not self.isResourceFree():
self.totalWorkingTime+=now()-self.timeLastOperationStarted
# Repairman was idle when he was not in any other state # Repairman was idle when he was not in any other state
self.totalWaitingTime=MaxSimtime-self.totalWorkingTime self.totalWaitingTime=MaxSimtime-self.totalWorkingTime
......
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