Commit 5c913741 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

comments added in the previous commit

parent d3d76d75
......@@ -39,10 +39,11 @@ class MachineJobShop(Machine):
def getEntity(self):
Machine.getEntity(self) #run the default code
avtiveEntity=self.Res.activeQ[0]
self.procTime=avtiveEntity.remainingRoute[0][1]
self.nextStationId=avtiveEntity.remainingRoute[1][0]
avtiveEntity.remainingRoute.pop(0)
self.procTime=avtiveEntity.remainingRoute[0][1] #read the processing time from the entity
self.nextStationId=avtiveEntity.remainingRoute[1][0] #read the next station id
avtiveEntity.remainingRoute.pop(0) #remove data from the remaining route of the entity
from Globals import G
#loop through the objects to to assign the next station to the one that has the id
for obj in G.ObjList:
if obj.id==self.nextStationId:
self.nextStation=obj
......@@ -50,8 +51,6 @@ class MachineJobShop(Machine):
#checks if the machine down or it can dispose the object
def ifCanDisposeOrHaveFailure(self):
return self.Up==False or self.nextStation.canAccept(self) or len(self.Res.activeQ)==0
#the last part is added so that it is not removed and stack
#gotta think of it again
#calculates the processing time
def calculateProcessingTime(self):
......@@ -59,9 +58,10 @@ class MachineJobShop(Machine):
#checks if the Machine can dispose an entity. Returns True only to the potential receiver
def haveToDispose(self, callerObject=None):
if callerObject!=None:
if callerObject!=None:
#check it the object that called the method holds an Entity that requests for current object
if self.Res.activeQ[0].remainingRoute[0][0]==callerObject.id:
return len(self.Res.activeQ)>0 and self.waitToDispose and self.Up
return len(self.Res.activeQ)>0 and self.waitToDispose and self.Up #return according to the state of the machine
return False
......
......@@ -39,16 +39,18 @@ class QueueJobShop(Queue):
#it checks also who called it and returns TRUE only to the object that will give the entity.
def canAccept(self, callerObject=None):
if callerObject!=None:
#check it the caller object holds an Entity that requests for current object
if len(callerObject.Res.activeQ)>0:
activeEntity=callerObject.Res.activeQ[0]
if activeEntity.remainingRoute[0][0]==self.id:
return len(self.Res.activeQ)<self.capacity
return len(self.Res.activeQ)<self.capacity #return according to the state of the Queue
return False
#checks if the Queue can accept an entity and there is an entity in some predecessor waiting for it
#also updates the predecessorIndex to the one that is to be taken
def canAcceptAndIsRequested(self):
from Globals import G
#loop through the objects to see if there is one that holds an Entity requesting for current object
for obj in G.ObjList:
if len(obj.Res.activeQ)>0 and now()!=0:
activeEntity=obj.Res.activeQ[0]
......@@ -60,8 +62,9 @@ class QueueJobShop(Queue):
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
self.Res.activeQ.append(self.previousStation.Res.activeQ[0]) #get the entity from the previous object
#and put it in front of the activeQ
self.previousStation.removeEntity() #remove the entity from the previous object
self.Res.activeQ[0].remainingRoute[0][0]=""
#and put it in front of the activeQ
self.previousStation.removeEntity() #remove the entity from the previous object
self.Res.activeQ[0].remainingRoute[0][0]="" #remove data from the remaining route.
#This is needed so that the Queue will not request again for the Entity
\ No newline at end of file
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