Commit e672fff7 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

getEntity in objects enhanced so that the currentStation attribute of the...

getEntity in objects enhanced so that the currentStation attribute of the Entity is updated. Now currentStation for each Entity should contain the station where the Entity is in
parent 605285e8
...@@ -200,7 +200,7 @@ class Assembly(CoreObject): ...@@ -200,7 +200,7 @@ class Assembly(CoreObject):
activeEntity=giverObjectQueue[0] activeEntity=giverObjectQueue[0]
if(type=="Part"): if(type=="Part"):
activeObjectQueue[0].getFrameQueue().append(giverObjectQueue[0]) #get the part from the predecessor and append it to the frame! activeObjectQueue[0].getFrameQueue().append(activeEntity) #get the part from the predecessor and append it to the frame!
giverObject.removeEntity() #remove the part from the previews object giverObject.removeEntity() #remove the part from the previews object
self.outputTrace(activeEntity.name, "got into "+ self.objName) self.outputTrace(activeEntity.name, "got into "+ self.objName)
elif(type=="Frame"): elif(type=="Frame"):
...@@ -209,6 +209,7 @@ class Assembly(CoreObject): ...@@ -209,6 +209,7 @@ class Assembly(CoreObject):
self.outputTrace(activeEntity.name, "got into "+ self.objName) self.outputTrace(activeEntity.name, "got into "+ self.objName)
self.nameLastEntityEntered=activeEntity.name self.nameLastEntityEntered=activeEntity.name
self.timeLastEntityEntered=now() self.timeLastEntityEntered=now()
activeEntity.currentStation=self
#actions to be taken after the simulation ends #actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None): def postProcessing(self, MaxSimtime=None):
......
...@@ -26,6 +26,7 @@ Batch is an Entity that contains a number of units ...@@ -26,6 +26,7 @@ Batch is an Entity that contains a number of units
''' '''
from Entity import Entity from Entity import Entity
from SubBatch import SubBatch
#The batch object #The batch object
class Batch(Entity): class Batch(Entity):
...@@ -35,4 +36,31 @@ class Batch(Entity): ...@@ -35,4 +36,31 @@ class Batch(Entity):
Entity.__init__(self, name) Entity.__init__(self, name)
self.id=id self.id=id
self.numberOfUnits=numberOfUnits self.numberOfUnits=numberOfUnits
self.numberOfSubBatches=1 #integer that shows in how many sub batches is the batch broken
\ No newline at end of file self.subBatchList=[] #list that contains the sub-batches that this batch has been broken into
#breaks the Batch to a number of SubBatches
def breakToSubBatches(self, numberOfSubBatches=2):
numberOfSubBatchUnits=self.numberOfUnits/numberOfSubBatches #for now it considers that the division gives an integer
#(E.g. 100 units to be divided to 4 sub-batches)
activeObjectQueue=self.currentStation.getActiveObjectQueue() #get the internal queue of the active core object
activeObjectQueue.remove(self) #the Batch is non-existent in this active Queue now (since it is broken)
for i in range(numberOfSubBatches):
subBatch=SubBatch(str(self.id)+'_'+str(i), self.name+"_SB_"
+str(i), self.id, numberOfUnits=numberOfSubBatchUnits) #create the sub-batch
activeObjectQueue.append(subBatch) #append the sub-batch to the active object Queue
self.subBatchList.append(subBatch)
self.numberOfSubBatches=numberOfSubBatches
#re-assembles a batch that was broken into sub-batches
def reAssembleBatch(self):
self.numberOfUnits=0
activeObjectQueue=self.subBatchList[0].currentStation.getActiveObjectQueue() #get the internal queue of the active core object
#it should be the same for all the sub-batches
for subBatch in self.subBatchList:
self.numberOfUnits+=subBatch.numberOfUnits #maybe there are units lost (scrapped), so it has to be re-calculated
activeObjectQueue.remove
\ No newline at end of file
...@@ -215,6 +215,7 @@ class Conveyer(CoreObject): ...@@ -215,6 +215,7 @@ class Conveyer(CoreObject):
self.position.append(0) #the entity is placed in the start of the conveyer self.position.append(0) #the entity is placed in the start of the conveyer
giverObject.removeEntity() #remove the entity from the previous object giverObject.removeEntity() #remove the entity from the previous object
self.outputTrace(activeEntity.name, "got into "+ self.objName) self.outputTrace(activeEntity.name, "got into "+ self.objName)
activeEntity.currentStation=self
#check if the conveyer became full to start counting blockage #check if the conveyer became full to start counting blockage
if self.isFull(): if self.isFull():
self.timeBlockageStarted=now() self.timeBlockageStarted=now()
......
...@@ -88,6 +88,7 @@ class CoreObject(Process): ...@@ -88,6 +88,7 @@ class CoreObject(Process):
#and put it in front of the activeQ #and put it in front of the activeQ
giverObject.removeEntity() #remove the entity from the previous object giverObject.removeEntity() #remove the entity from the previous object
activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result
activeEntity.currentStation=self
#actions to be taken after the simulation ends #actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None): def postProcessing(self, MaxSimtime=None):
......
...@@ -173,9 +173,11 @@ class Dismantle(CoreObject): ...@@ -173,9 +173,11 @@ class Dismantle(CoreObject):
activeObjectQueue.append(activeEntity) #get the frame from the predecessor activeObjectQueue.append(activeEntity) #get the frame from the predecessor
giverObject.removeEntity() giverObject.removeEntity()
activeEntity.currentStation=self
#append also the parts in the res so that they can be popped #append also the parts in the res so that they can be popped
for part in activeEntity.getFrameQueue(): for part in activeEntity.getFrameQueue():
activeObjectQueue.append(part) activeObjectQueue.append(part)
part.currentStation=self
activeEntity.getFrameQueue=[] #empty the frame activeEntity.getFrameQueue=[] #empty the frame
#move the frame to the end of the internal queue since we want the frame to be disposed first #move the frame to the end of the internal queue since we want the frame to be disposed first
activeObjectQueue.append(activeEntity) activeObjectQueue.append(activeEntity)
......
...@@ -43,6 +43,7 @@ class Entity(object): ...@@ -43,6 +43,7 @@ class Entity(object):
self.dueDate=dueDate self.dueDate=dueDate
self.orderDate=orderDate self.orderDate=orderDate
self.schedule=[] #a list that holds information about the schedule of the entity (when it enters and exits every station) self.schedule=[] #a list that holds information about the schedule of the entity (when it enters and exits every station)
self.currentStation=None
#outputs results to JSON File #outputs results to JSON File
def outputResultsJSON(self): def outputResultsJSON(self):
......
...@@ -137,6 +137,7 @@ class Exit(CoreObject): ...@@ -137,6 +137,7 @@ class Exit(CoreObject):
self.totalLifespan+=now()-activeEntity.startTime #Add the entity's lifespan to the total one. self.totalLifespan+=now()-activeEntity.startTime #Add the entity's lifespan to the total one.
self.outputTrace(name) self.outputTrace(name)
activeEntity.currentStation=self
#actions to be taken after the simulation ends #actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None): def postProcessing(self, MaxSimtime=None):
......
...@@ -53,6 +53,7 @@ class ExitJobShop(Exit): ...@@ -53,6 +53,7 @@ class ExitJobShop(Exit):
giverObject.removeEntity() #remove the entity from the previous object giverObject.removeEntity() #remove the entity from the previous object
self.outputTrace(name) self.outputTrace(name)
activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result
activeEntity.currentStation=self
#get the giver object in a getEntity transaction. #get the giver object in a getEntity transaction.
def getGiverObject(self): def getGiverObject(self):
......
...@@ -38,7 +38,6 @@ class Job(Entity): ...@@ -38,7 +38,6 @@ class Job(Entity):
self.id=id self.id=id
self.route=route #the route that the job follows, also contains the processing times in each station self.route=route #the route that the job follows, also contains the processing times in each station
self.remainingRoute=route #the remaining route. in the beginning this should be the same as the full route self.remainingRoute=route #the remaining route. in the beginning this should be the same as the full route
self.currentStop=route[0][0] #the starting stop should be the first in the route
self.schedule=[] #keeps the result of the simulation. A list with the stations and time of entrance self.schedule=[] #keeps the result of the simulation. A list with the stations and time of entrance
#outputs results to JSON File #outputs results to JSON File
...@@ -61,6 +60,6 @@ class Job(Entity): ...@@ -61,6 +60,6 @@ class Job(Entity):
#initializes all the Entity for a new simulation replication #initializes all the Entity for a new simulation replication
def initialize(self): def initialize(self):
self.remainingRoute=self.route self.remainingRoute=self.route
self.currentStop=self.route[0][0] self.currentStation=self.route[0][0]
\ No newline at end of file
...@@ -387,7 +387,7 @@ def activateObjects(): ...@@ -387,7 +387,7 @@ def activateObjects():
def setWIP(): def setWIP():
#read the start station of the Entities and assign them to it #read the start station of the Entities and assign them to it
for entity in G.WipList: for entity in G.WipList:
objectId=entity.currentStop objectId=entity.currentStation
object=None object=None
for obj in G.ObjList: for obj in G.ObjList:
if obj.id==objectId: if obj.id==objectId:
...@@ -395,6 +395,7 @@ def setWIP(): ...@@ -395,6 +395,7 @@ def setWIP():
object.getActiveObjectQueue().append(entity) object.getActiveObjectQueue().append(entity)
entity.remainingRoute[0][0]="" #remove data from the remaining route. entity.remainingRoute[0][0]="" #remove data from the remaining route.
entity.schedule.append([object.id,now()]) #append the time to schedule so that it can be read in the result entity.schedule.append([object.id,now()]) #append the time to schedule so that it can be read in the result
entity.currentStation=object
#the main script that is ran #the main script that is ran
......
...@@ -89,6 +89,7 @@ class Source(CoreObject): ...@@ -89,6 +89,7 @@ class Source(CoreObject):
self.numberOfArrivals+=1 #we have one new arrival self.numberOfArrivals+=1 #we have one new arrival
entity.creationTime=now() #assign the current simulation time as the Entity's creation time entity.creationTime=now() #assign the current simulation time as the Entity's creation time
entity.startTime=now() #assign the current simulation time as the Entity's start time entity.startTime=now() #assign the current simulation time as the Entity's start time
entity.currentStation=self
self.outputTrace(self.item.type+str(self.numberOfArrivals)) #output the trace self.outputTrace(self.item.type+str(self.numberOfArrivals)) #output the trace
activeObjectQueue.append(entity) #append the entity to the resource activeObjectQueue.append(entity) #append the entity to the resource
yield hold,self,self.calculateInterarrivalTime() #wait until the next arrival yield hold,self,self.calculateInterarrivalTime() #wait until the next arrival
......
...@@ -22,10 +22,11 @@ Created on 22 Oct 2013 ...@@ -22,10 +22,11 @@ Created on 22 Oct 2013
@author: George @author: George
''' '''
''' '''
Batch is an Entity that contains a number of units SubBatch is an Entity that contains a number of units and is derived from a parent Batch
''' '''
from Entity import Entity from Entity import Entity
from Batch import Batch
#The batch object #The batch object
class SubBatch(Entity): class SubBatch(Entity):
...@@ -35,4 +36,6 @@ class SubBatch(Entity): ...@@ -35,4 +36,6 @@ class SubBatch(Entity):
Entity.__init__(self, name) Entity.__init__(self, name)
self.id=id self.id=id
self.numberOfUnits=numberOfUnits self.numberOfUnits=numberOfUnits
self.batchId=batchId self.batchId=batchId
\ 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