Commit c15a0ee3 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

getObjecctById is moved to be a global method

parent 65102d52
......@@ -68,4 +68,10 @@ class G:
outputJSON={}
outputJSONFile=None
numberOfEntities = 0
\ No newline at end of file
numberOfEntities = 0
def findObjectById(id):
for obj in G.ObjList:
if obj.id==id:
return obj
return None
\ No newline at end of file
......@@ -574,17 +574,12 @@ def setWIP():
if obj.id==objectId:
object=obj # find the object in the 'G.ObjList
object.getActiveObjectQueue().append(entity) # append the entity to its Queue
object.receiver=findObjectById(entity.remainingRoute[1][0])
import Globals
object.receiver=Globals.findObjectById(entity.remainingRoute[1][0])
entity.remainingRoute.pop(0) # remove data from the remaining route.
entity.schedule.append([object,now()]) #append the time to schedule so that it can be read in the result
entity.currentStation=object # update the current station of the entity
def findObjectById(id):
from Globals import G
for obj in G.ObjList:
if obj.id==id:
return obj
# ===========================================================================
# the main script that is ran
# ===========================================================================
......
......@@ -42,7 +42,8 @@ class MachineJobShop(Machine):
def getEntity(self):
activeEntity=Machine.getEntity(self) #run the default code
self.procTime=activeEntity.remainingRoute[0][1] #read the processing time from the entity
self.receiver=self.findObjectById(activeEntity.remainingRoute[1][0]) #read the next station
import Globals
self.receiver=Globals.findObjectById(activeEntity.remainingRoute[1][0]) #read the next station
activeEntity.remainingRoute.pop(0) #remove data from the remaining route of the entity
return activeEntity
......@@ -117,13 +118,6 @@ class MachineJobShop(Machine):
#else if there is a giver return it
elif self.giver:
return self.giver
return None
def findObjectById(self, id):
from Globals import G
for obj in G.ObjList:
if obj.id==id:
return obj
return None
\ No newline at end of file
......@@ -90,7 +90,8 @@ class QueueJobShop(Queue):
#gets an entity from the predecessor that the predecessor index points to
def getEntity(self):
activeEntity=Queue.getEntity(self)
self.receiver=self.findObjectById(activeEntity.remainingRoute[1][0]) #read the next station
import Globals
self.receiver=Globals.findObjectById(activeEntity.remainingRoute[1][0]) #read the next station
activeEntity.remainingRoute.pop(0) #remove data from the remaining route of the entity
return activeEntity
......@@ -115,9 +116,5 @@ class QueueJobShop(Queue):
return self.giver
return None
def findObjectById(self, id):
from Globals import G
for obj in G.ObjList:
if obj.id==id:
return obj
\ 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