Commit 20bed7cb authored by Georgios Dagkakis's avatar Georgios Dagkakis

SkilledRouter to check conditions correctly

parent bcac9132
...@@ -83,7 +83,7 @@ class SkilledRouter(Router): ...@@ -83,7 +83,7 @@ class SkilledRouter(Router):
self.expectedSignals['isCalled']=1 self.expectedSignals['isCalled']=1
yield self.isCalled yield self.isCalled
transmitter, eventTime=self.isCalled.value transmitter, eventTime=self.isCalled.value
self.isCalled=self.env.event() self.isCalled=self.env.event()
self.printTrace('','=-'*15) self.printTrace('','=-'*15)
...@@ -324,19 +324,22 @@ class SkilledRouter(Router): ...@@ -324,19 +324,22 @@ class SkilledRouter(Router):
def checkIfAllocationShouldBeCalled(self): def checkIfAllocationShouldBeCalled(self):
from Globals import G from Globals import G
# loop through the operators. If for one the shift ended or started right now allocation is needed # loop through the operators and the machines.
for operator in G.OperatorsList: # If for one the shift ended or started right now allocation is needed
if operator.timeLastShiftEnded==self.env.now or operator.timeLastShiftStarted==self.env.now: for obj in G.OperatorsList+G.MachineList:
# pass
if (obj.timeLastShiftEnded==self.env.now) or (obj.timeLastShiftStarted==self.env.now):
return True return True
# loop through the machines # loop through the machines
for machine in G.MachineList: for machine in G.MachineList:
# if one machine is starved more than 30 then allocation is needed # if one machine is starved more than 30 then allocation is needed
if (self.env.now-machine.timeLastEntityEnded>=30) and (not machine.isProcessing): if (self.env.now-machine.timeLastEntityLeft>=30) and (not machine.getActiveObjectQueue()):
# pass
return True return True
previousList=self.getPreviousList(machine) # check for the previous buffer. If it is more than 80% full allocation is needed
parallelMachinesList=self.getParallelMachinesList(machine) previousQueue=self.getPreviousQueue(machine)
if previousQueue:
if float(len(previousQueue.getActiveObjectQueue()))/float(previousQueue.capacity)>=0.8:
return True
return False return False
def postProcessing(self): def postProcessing(self):
...@@ -366,6 +369,17 @@ class SkilledRouter(Router): ...@@ -366,6 +369,17 @@ class SkilledRouter(Router):
predecessor=predecessor.previous[0] predecessor=predecessor.previous[0]
return previousList return previousList
# for a machine gets the previous queue (if any)
def getPreviousQueue(self, machine):
predecessor=machine.previous[0]
while 1:
if "Source" in str(predecessor.__class__):
return None
if "Queue" in str(predecessor.__class__) or "Clearance" in str(predecessor.__class__):
return predecessor
predecessor=predecessor.previous[0]
# for a machine gets a list with the parallel machines # for a machine gets a list with the parallel machines
def getParallelMachinesList(self, machine): def getParallelMachinesList(self, machine):
alreadyConsidered=[machine] alreadyConsidered=[machine]
......
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