Commit 7471841a authored by Georgios Dagkakis's avatar Georgios Dagkakis

comments and cleanup

parent 3a1323c0
......@@ -1118,7 +1118,7 @@ class Machine(CoreObject):
# find an available operator
candidateOperator=self.operatorPool.findAvailableOperator()
# append the station into its candidateStations
if candidateOperator:
if candidateOperator: # if there was an operator found append the Machine on his candidateStations
candidateOperator.candidateStations.append(self)
return candidateOperator
......
......@@ -58,12 +58,14 @@ class ObjectResource(ManPyObject):
self.coreObjectIds=[]
# list with the coreObjects that the resource services
self.coreObjects=[]
# flag that shows if the resourse is on shift
self.onShift=True
# =======================================================================
# checks if the worker is available
# =======================================================================
def checkIfResourceIsAvailable(self,callerObject=None):
# return true if the operator is idle and on shift
return len(self.Res.users)<self.capacity and self.onShift
......
......@@ -99,7 +99,6 @@ class OperatorPool(ObjectResource):
# =======================================================================
def findAvailableOperator(self): # may need to implement different sorting of the operators
# find the free operator if any
# freeOperator = next(x for x in self.operators if x.checkIfResourceIsAvailable())
freeOperator = None
for operator in self.operators:
if operator.checkIfResourceIsAvailable():
......
......@@ -321,6 +321,7 @@ class Router(ObjectInterruption):
for object in self.pendingMachines:
# find candidateOperators for each object operator
candidateOperator=object.findCandidateOperator()
# if there is candidateOperator that is not already in self.candidateOperators add him
# TODO: this way no sorting is performed
if candidateOperator and (not candidateOperator in self.candidateOperators):
self.candidateOperators.append(candidateOperator)
......@@ -357,6 +358,7 @@ class Router(ObjectInterruption):
# update the schedulingRule/multipleCriterionList of the Router
if self.sorting:
self.updateSchedulingRule()
# if there are candidate operators
if self.candidateOperators:
self.printTrace('router found candidate operators'+' '*3,
[(operator.id, [station.id for station in operator.candidateStations]) for operator in self.candidateOperators])
......
......@@ -67,7 +67,10 @@ class ShiftScheduler(ObjectInterruption):
# if in the beginning the victim is offShift set it as such
if float(self.remainingShiftPattern[0][0])!=self.env.now:
self.victim.onShift=False
# if the victim is CoreObject interrupt it. Else ask the router for allocation of operators
# TODO more generic implementation
if issubclass(self.victim.__class__, CoreObject):
# interrupt the victim only if it was not previously interrupted
if not self.victim.interruptionStart.triggered:
self.interruptVictim() # interrupt the victim
else:
......@@ -79,6 +82,8 @@ class ShiftScheduler(ObjectInterruption):
while 1:
if not self.victim.onShift:
yield self.env.timeout(float(self.remainingShiftPattern[0][0]-self.env.now)) # wait for the onShift
# if the victim is CoreObject reactivate it. Else ask the router for allocation of operators
# TODO more generic implementation
if issubclass(self.victim.__class__, CoreObject):
self.reactivateVictim() # re-activate the victim in case it was interrupted
else:
......@@ -124,8 +129,10 @@ class ShiftScheduler(ObjectInterruption):
succeedTuple=(self, self.env.now)
oi.victimOffShift.succeed(succeedTuple)
# interrupt the victim only if it was not previously interrupted
# if the victim is CoreObject interrupt it. Else ask the router for allocation of operators
# TODO more generic implementation
if issubclass(self.victim.__class__, CoreObject):
# interrupt the victim only if it was not previously interrupted
if not self.victim.interruptionStart.triggered:
self.interruptVictim() # interrupt the victim
else:
......
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