Commit 37a13947 authored by Georgios Dagkakis's avatar Georgios Dagkakis

define Batch and SubBatch in new way

parent 83b3c602
......@@ -34,11 +34,12 @@ from SubBatch import SubBatch
class Batch(Entity):
type="Batch"
def __init__(self, id, name, numberOfUnits=1):
Entity.__init__(self, name=name, id=id)
self.numberOfUnits=numberOfUnits
def __init__(self, id, name, numberOfUnits=1, remainingProcessingTime=0, unitsToProcess=0):
Entity.__init__(self, name=name, id=id, remainingProcessingTime=remainingProcessingTime)
self.numberOfUnits=int(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.unitsToProcess=int(unitsToProcess)
#===========================================================================
# finds the schedule of each child and returns the combined route
......
......@@ -374,11 +374,12 @@ def createWIP():
inputDict=dict(entity)
inputDict.pop('_class')
if entityClass in ['Dream.CapacityEntity', 'Dream.CapacityProject', 'Dream.Part']:
if entityClass in ['Dream.CapacityEntity', 'Dream.CapacityProject', 'Dream.Part',
'Dream.Batch', 'Dream.SubBatch']:
entity=entityType(**inputDict)
G.EntityList.append(entity)
object=Globals.findObjectById(element['id'])
entity.currentStation=object
entity.currentStation=object
elif entityClass=='Dream.OrderComponent':
id=entity.get('id', 'not found')
......@@ -530,48 +531,8 @@ def createWIP():
G.JobList.append(J)
G.WipList.append(J)
G.EntityList.append(J)
elif entityClass=='Dream.Batch':
id=entity.get('id', 'not found')
name=entity.get('name', 'not found')
numberOfUnits=int(entity.get('numberOfUnits', '4'))
B=Batch(id,name, numberOfUnits)
G.BatchList.append(B)
G.WipList.append(B)
G.EntityList.append(B)
object=Globals.findObjectById(element['id'])
B.unitsToProcess=int(entity.get('unitsToProcess', numberOfUnits))
B.remainingProcessingTime=entity.get('remainingProcessingTime', {})
B.currentStation=object
elif entityClass=='Dream.SubBatch':
id=entity.get('id', 'not found')
name=entity.get('name', 'not found')
numberOfUnits=int(entity.get('numberOfUnits', '4'))
parentBatchId=entity.get('parentBatchId', 'not found')
parentBatchName=entity.get('parentBatchName', 'not found')
# check if the parent batch is already created. If not, then create it
batch=None
for b in G.BatchList:
if b.id==parentBatchId:
batch=b
if batch: #if the parent batch was found add the number of units of current sub-batch
batch.numberOfUnits+=numberOfUnits
else: #if the parent batch was not found create it
batch=Batch(parentBatchId,parentBatchName, numberOfUnits)
G.BatchList.append(batch)
G.WipList.append(batch)
G.EntityList.append(batch)
SB=SubBatch(id,name, numberOfUnits=numberOfUnits, parentBatch=batch)
G.SubBatchList.append(SB)
G.WipList.append(SB)
G.EntityList.append(SB)
object=Globals.findObjectById(element['id'])
SB.unitsToProcess=int(entity.get('unitsToProcess', numberOfUnits))
SB.remainingProcessingTime=entity.get('remainingProcessingTime', {})
SB.currentStation=object
if entityClass=='Dream.Order':
id=entity.get('id', 'not found')
......
......@@ -34,9 +34,6 @@ from Entity import Entity
class Part(Entity):
type="Part"
def __init__(self, id=None, name=None, remainingProcessingTime=0):
Entity.__init__(self, id, name, remainingProcessingTime=remainingProcessingTime)
from Globals import G
G.PartList.append(self)
Entity.__init__(self, id, name, remainingProcessingTime=remainingProcessingTime)
......@@ -31,10 +31,27 @@ from Entity import Entity
class SubBatch(Entity):
type="SubBatch"
def __init__(self, id, name, numberOfUnits=1, parentBatch=None):
Entity.__init__(self, name=name, id=id)
self.numberOfUnits=numberOfUnits
def __init__(self, id, name, numberOfUnits=1, parentBatch=None, parentBatchName=None, parentBatchId=None,
remainingProcessingTime=0, unitsToProcess=0):
Entity.__init__(self, name=name, id=id, remainingProcessingTime=remainingProcessingTime)
self.numberOfUnits=int(numberOfUnits)
self.parentBatch=parentBatch
self.batchId=parentBatch.id
self.unitsToProcess=int(unitsToProcess)
# if the parent batch was not given find it or create it
if not self.parentBatch:
# check if the parent batch is already created. If not, then create it
batch=None
from Batch import Batch
from Globals import G
for b in G.EntityList:
if b.id==parentBatchId:
batch=b
if batch: #if the parent batch was found add the number of units of current sub-batch
batch.numberOfUnits+=self.numberOfUnits
else: #if the parent batch was not found create it
batch=Batch(parentBatchId,parentBatchName,numberOfUnits)
G.EntityList.append(batch)
self.parentBatch=batch
self.batchId=self.parentBatch.id
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