Commit 847d1adf authored by Georgios Dagkakis's avatar Georgios Dagkakis

first version of failure that depends only on working time

parent e0cebfb4
......@@ -59,7 +59,7 @@ class Failure(ObjectInterruption):
# 'onShift' counts only if the victim is onShift
# 'working' counts only working time
self.deteriorationType=deteriorationType
if(self.distType=="Availability"):
# --------------------------------------------------------------
......@@ -91,6 +91,11 @@ class Failure(ObjectInterruption):
# flag used to identify if the time between failures should be counted while the victim is off-shift
self.offshift=offshift
def initialize(self):
ObjectInterruption.initialize(self)
self.victimStartsProcess=self.env.event()
self.victimEndsProcess=self.env.event()
# =======================================================================
# The run method for the failure which has to served by a repairman
# =======================================================================
......@@ -104,7 +109,7 @@ class Failure(ObjectInterruption):
if self.deteriorationType=='constant':
yield self.env.timeout(remainingTimeToFailure)
else:
elif self.deteriorationType=='onShift':
while failureNotTriggered:
timeRestartedCounting=self.env.now
# TODO: can also wait for interruptionStart signal of the victim and check whether the interruption is caused by a shiftScheduler
......@@ -122,7 +127,24 @@ class Failure(ObjectInterruption):
# TODO: the signal interruptionStart is reset by the time it is received by the victim. not sure if will be still triggered when it is checked here
else:
failureNotTriggered=False
elif self.deteriorationType=='working':
yield self.victimStartsProcess
self.victimStartsProcess=self.env.event()
while failureNotTriggered:
timeRestartedCounting=self.env.now
receivedEvent=yield self.env.timeout(remainingTimeToFailure) | self.victimEndsProcess
if self.victimEndsProcess in receivedEvent:
#print self.env.now, 'victimEndsProcess'
self.victimEndsProcess=self.env.event()
remainingTimeToFailure=remainingTimeToFailure-(self.env.now-timeRestartedCounting)
self.victim.expectedDownTime=self.env.now+remainingTimeToFailure
yield self.victimStartsProcess
self.victimStartsProcess=self.env.event()
#print self.env.now, 'startsProcess'
else:
failureNotTriggered=False
# interrupt the victim only if it was not previously interrupted
if not self.victim.interruptionStart.triggered:
self.interruptVictim() # interrupt the victim
......
......@@ -451,6 +451,12 @@ class Machine(CoreObject):
# timers to follow up the failure time of the machine while on current Entity
self.downTimeInCurrentEntity=0 #holds the total time that the
#object was down while holding current entity
for oi in self.objectInterruptions:
if oi.type=='Failure':
if oi.deteriorationType=='working':
oi.victimStartsProcess.succeed(self.env.now)
# this loop is repeated until the processing time is expired with no failure
# check when the processingEndedFlag switched to false
while processingNotFinished:
......@@ -624,7 +630,12 @@ class Machine(CoreObject):
# reseting flags
self.shouldPreempt=False
self.isProcessingInitialWIP=False
for oi in self.objectInterruptions:
if oi.type=='Failure':
if oi.deteriorationType=='working':
oi.victimEndsProcess.succeed(self.env.now)
# in case Machine just performed the last work before the scheduled maintenance signal the corresponding object
if self.isWorkingOnTheLast:
# for the scheduled Object interruptions
......@@ -693,10 +704,7 @@ class Machine(CoreObject):
# checks if the machine is Up
# =======================================================================
def checkIfMachineIsUp(self):
# the second part is added for synchronisation.
# if Machine is to get failure at the current time but did not get it yet
# return also false
return self.Up and not self.expectedDownTime==self.env.now
return self.Up
# =======================================================================
# checks if the Machine can accept an entity
......
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