Commit fb3c7870 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Sebastien Robin

Batch.py and SubBatch.py updated

parent 0d1b0971
......@@ -33,35 +33,35 @@ class Batch(Entity):
type="Batch"
def __init__(self, id, name, numberOfUnits=1):
Entity.__init__(self, name)
Entity.__init__(self, name=name)
self.id=id
self.numberOfUnits=numberOfUnits
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
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
#the sub-batch no longer exists
activeObjectQueue.remove(subBatch)
del subBatch
# #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
# #the sub-batch no longer exists
# activeObjectQueue.remove(subBatch)
# del subBatch
......@@ -32,7 +32,7 @@ class SubBatch(Entity):
type="SubBatch"
def __init__(self, id, name, batchId, numberOfUnits=1):
Entity.__init__(self, name)
Entity.__init__(self, name=name)
self.id=id
self.numberOfUnits=numberOfUnits
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