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 ...@@ -34,11 +34,12 @@ from SubBatch import SubBatch
class Batch(Entity): class Batch(Entity):
type="Batch" type="Batch"
def __init__(self, id, name, numberOfUnits=1): def __init__(self, id, name, numberOfUnits=1, remainingProcessingTime=0, unitsToProcess=0):
Entity.__init__(self, name=name, id=id) Entity.__init__(self, name=name, id=id, remainingProcessingTime=remainingProcessingTime)
self.numberOfUnits=numberOfUnits self.numberOfUnits=int(numberOfUnits)
self.numberOfSubBatches=1 #integer that shows in how many sub batches is the batch broken 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.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 # finds the schedule of each child and returns the combined route
......
...@@ -374,7 +374,8 @@ def createWIP(): ...@@ -374,7 +374,8 @@ def createWIP():
inputDict=dict(entity) inputDict=dict(entity)
inputDict.pop('_class') 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) entity=entityType(**inputDict)
G.EntityList.append(entity) G.EntityList.append(entity)
object=Globals.findObjectById(element['id']) object=Globals.findObjectById(element['id'])
...@@ -531,47 +532,7 @@ def createWIP(): ...@@ -531,47 +532,7 @@ def createWIP():
G.WipList.append(J) G.WipList.append(J)
G.EntityList.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': if entityClass=='Dream.Order':
id=entity.get('id', 'not found') id=entity.get('id', 'not found')
......
...@@ -35,8 +35,5 @@ class Part(Entity): ...@@ -35,8 +35,5 @@ class Part(Entity):
type="Part" type="Part"
def __init__(self, id=None, name=None, remainingProcessingTime=0): def __init__(self, id=None, name=None, remainingProcessingTime=0):
Entity.__init__(self, id, name, remainingProcessingTime=remainingProcessingTime) Entity.__init__(self, id, name, remainingProcessingTime=remainingProcessingTime)
from Globals import G
G.PartList.append(self)
...@@ -31,10 +31,27 @@ from Entity import Entity ...@@ -31,10 +31,27 @@ from Entity import Entity
class SubBatch(Entity): class SubBatch(Entity):
type="SubBatch" type="SubBatch"
def __init__(self, id, name, numberOfUnits=1, parentBatch=None): def __init__(self, id, name, numberOfUnits=1, parentBatch=None, parentBatchName=None, parentBatchId=None,
Entity.__init__(self, name=name, id=id) remainingProcessingTime=0, unitsToProcess=0):
self.numberOfUnits=numberOfUnits Entity.__init__(self, name=name, id=id, remainingProcessingTime=remainingProcessingTime)
self.numberOfUnits=int(numberOfUnits)
self.parentBatch=parentBatch 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