Commit e39066a0 authored by Georgios Dagkakis's avatar Georgios Dagkakis

correction on how BatchReassemblyBlocking calculates the blocking time

parent 2259bd6a
......@@ -133,7 +133,8 @@ class BatchReassembly(CoreObject):
self.reassemble()
self.isProcessingInitialWIP=False
# signal the receiver that the activeObject has something to dispose of
self.timeLastBlockageStarted=self.env.now
self.timeLastBlockageStarted=self.env.now
self.isBlocked=True
if not self.signalReceiver():
# if there was no available receiver, get into blocking control
while 1:
......
......@@ -57,28 +57,26 @@ class BatchReassemblyBlocking(BatchReassembly):
# find the previous station
station=self.previous[0]
from Globals import G
from ShiftScheduler import ShiftScheduler
shift=[]
# find the shiftPattern of the previous station
for oi in G.ObjectInterruptionList:
if issubclass(oi.__class__,ShiftScheduler):
if oi.victim is station:
shift=oi.shiftPattern
break
from ShiftScheduler import ShiftScheduler
if self.timeLastBlockageStarted:
# calculate how much time the previous station was offShift
offShift=0
for i, record in enumerate(shift):
start=record[0]
end=record[1]
if start>self.env.now:
break
if end<self.timeLastBlockageStarted:
continue
# if the there is offShift time in the blockage
if end<self.env.now:
try:
offShift+=shift[i+1][0]-end
except IndexError:
pass
for endShiftTime in station.endShiftTimes:
# if there was end of shift while the station was blocked
if endShiftTime>=self.timeLastBlockageStarted:
end=endShiftTime
lastShift=True
# find the start of the next shift
for startShiftTime in station.startShiftTimes:
if startShiftTime>end:
lastShift=False
nextStart=startShiftTime
break
# if there is not start of next shift, then it was the last shift, so
# the station is currently off. Subtract this off-shift time
if lastShift:
offShift+=self.env.now-end
# else, subtract the whole off-shift time of that shift
else:
offShift+=nextStart-end
self.totalBlockageTime+=self.env.now-self.timeLastBlockageStarted-offShift
......@@ -223,6 +223,9 @@ class CoreObject(ManPyObject):
"entityCreated":0,
"moveEnd":0
}
# lists that keep the start/endShiftTimes of the victim
self.endShiftTimes=[]
self.startShiftTimes=[]
# =======================================================================
# the main process of the core object
......
......@@ -58,7 +58,10 @@ class ObjectResource(ManPyObject):
self.coreObjects=[]
# flag that locks the resource so that it cannot get new jobs
self.isLocked=False
# lists that keep the start/endShiftTimes of the victim
self.endShiftTimes=[]
self.startShiftTimes=[]
# =======================================================================
# checks if the worker is available
# =======================================================================
......
......@@ -58,7 +58,7 @@ class ShiftScheduler(ObjectInterruption):
self.remainingShiftPattern=list(self.shiftPattern)
# self.victimEndedLastProcessing=self.env.event()
self.waitingSignal=False
# =======================================================================
# The run method for the failure which has to served by a repairman
# =======================================================================
......@@ -81,6 +81,7 @@ class ShiftScheduler(ObjectInterruption):
self.requestAllocation()
self.victim.timeLastShiftEnded=self.env.now
self.victim.endShiftTimes.append(self.env.now)
self.outputTrace(self.victim.name,"is off shift")
while 1:
......@@ -91,6 +92,7 @@ class ShiftScheduler(ObjectInterruption):
self.victim.onShift=True
self.victim.totalOffShiftTime+=self.env.now-self.victim.timeLastShiftEnded
self.victim.timeLastShiftStarted=self.env.now
self.victim.startShiftTimes.append(self.env.now)
self.outputTrace(self.victim.name,"is on shift")
startShift=self.env.now
if issubclass(self.victim.__class__, CoreObject):
......@@ -143,6 +145,7 @@ class ShiftScheduler(ObjectInterruption):
self.victim.onShift=False # get the victim off-shift
self.victim.timeLastShiftEnded=self.env.now
self.victim.endShiftTimes.append(self.env.now)
self.outputTrace(self.victim.name,"is off shift")
self.remainingShiftPattern.pop(0)
......
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