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):
activeEntity=giverObjectQueue[0]
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
self.outputTrace(activeEntity.name, "got into "+ self.objName)
elif(type=="Frame"):
......@@ -209,6 +209,7 @@ class Assembly(CoreObject):
self.outputTrace(activeEntity.name, "got into "+ self.objName)
self.nameLastEntityEntered=activeEntity.name
self.timeLastEntityEntered=now()
activeEntity.currentStation=self
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None):
......
......@@ -26,6 +26,7 @@ Batch is an Entity that contains a number of units
'''
from Entity import Entity
from SubBatch import SubBatch
#The batch object
class Batch(Entity):
......@@ -35,4 +36,31 @@ class Batch(Entity):
Entity.__init__(self, name)
self.id=id
self.numberOfUnits=numberOfUnits
\ No newline at end of file
self.numberOfSubBatches=1 #integer that shows in how many sub batches is the batch broken
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):
self.position.append(0) #the entity is placed in the start of the conveyer
giverObject.removeEntity() #remove the entity from the previous object
self.outputTrace(activeEntity.name, "got into "+ self.objName)
activeEntity.currentStation=self
#check if the conveyer became full to start counting blockage
if self.isFull():
self.timeBlockageStarted=now()
......
......@@ -88,6 +88,7 @@ class CoreObject(Process):
#and put it in front of the activeQ
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.currentStation=self
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None):
......
......@@ -173,9 +173,11 @@ class Dismantle(CoreObject):
activeObjectQueue.append(activeEntity) #get the frame from the predecessor
giverObject.removeEntity()
activeEntity.currentStation=self
#append also the parts in the res so that they can be popped
for part in activeEntity.getFrameQueue():
activeObjectQueue.append(part)
part.currentStation=self
activeEntity.getFrameQueue=[] #empty the frame
#move the frame to the end of the internal queue since we want the frame to be disposed first
activeObjectQueue.append(activeEntity)
......
......@@ -43,6 +43,7 @@ class Entity(object):
self.dueDate=dueDate
self.orderDate=orderDate
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
def outputResultsJSON(self):
......
......@@ -137,6 +137,7 @@ class Exit(CoreObject):
self.totalLifespan+=now()-activeEntity.startTime #Add the entity's lifespan to the total one.
self.outputTrace(name)
activeEntity.currentStation=self
#actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None):
......
......@@ -53,6 +53,7 @@ class ExitJobShop(Exit):
giverObject.removeEntity() #remove the entity from the previous object
self.outputTrace(name)
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.
def getGiverObject(self):
......
......@@ -38,7 +38,6 @@ class Job(Entity):
self.id=id
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.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
#outputs results to JSON File
......@@ -61,6 +60,6 @@ class Job(Entity):
#initializes all the Entity for a new simulation replication
def initialize(self):
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():
def setWIP():
#read the start station of the Entities and assign them to it
for entity in G.WipList:
objectId=entity.currentStop
objectId=entity.currentStation
object=None
for obj in G.ObjList:
if obj.id==objectId:
......@@ -395,6 +395,7 @@ def setWIP():
object.getActiveObjectQueue().append(entity)
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.currentStation=object
#the main script that is ran
......
......@@ -89,6 +89,7 @@ class Source(CoreObject):
self.numberOfArrivals+=1 #we have one new arrival
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.currentStation=self
self.outputTrace(self.item.type+str(self.numberOfArrivals)) #output the trace
activeObjectQueue.append(entity) #append the entity to the resource
yield hold,self,self.calculateInterarrivalTime() #wait until the next arrival
......
......@@ -22,10 +22,11 @@ Created on 22 Oct 2013
@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 Batch import Batch
#The batch object
class SubBatch(Entity):
......@@ -35,4 +36,6 @@ class SubBatch(Entity):
Entity.__init__(self, name)
self.id=id
self.numberOfUnits=numberOfUnits
self.batchId=batchId
\ No newline at end of file
self.batchId=batchId
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