Commit fdbde03c authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

LineGeneration update to read current sequence from wip while BOM productionOrders are provided

parent c3c88534
...@@ -54,7 +54,7 @@ class Job(Entity): # inherits from the Entity c ...@@ -54,7 +54,7 @@ class Job(Entity): # inherits from the Entity c
# used by printRoute # used by printRoute
self.alias='J'+str(len(G.JobList)) self.alias='J'+str(len(G.JobList))
# added for testing - flag that shows if the order and component routes are defined in the BOM # added for testing - flag that shows if the order and component routes are defined in the BOM
self.orderInBOM=False self.routeInBOM=False
# ======================================================================= # =======================================================================
# outputs results to JSON File # outputs results to JSON File
...@@ -108,8 +108,8 @@ class Job(Entity): # inherits from the Entity c ...@@ -108,8 +108,8 @@ class Job(Entity): # inherits from the Entity c
# ======================================================================= # =======================================================================
def initialize(self): def initialize(self):
currentStationWellDefined=False currentStationWellDefined=False
# XXX change WIP definition when BOM is provided (current sequence number should be provided)
if self.currentStation and self.orderInBOM: if self.currentStation and self.routeInBOM:
for step in self.route: for step in self.route:
stepObjectIds=step.get('stationIdsList',[]) stepObjectIds=step.get('stationIdsList',[])
if self.currentStation.id in stepObjectIds: if self.currentStation.id in stepObjectIds:
......
...@@ -384,18 +384,39 @@ def createWIP(): ...@@ -384,18 +384,39 @@ def createWIP():
from dream.simulation.OrderDesign import OrderDesign from dream.simulation.OrderDesign import OrderDesign
for entity in wip: for entity in wip:
entityOrder=None # variable to hold the parent order of the WIP entityOrder=None # variable to hold the parent order of the WIP
# if the dictionary contains no objects but ids (the orders are provided in BOM echelon) # if there is BOM defined
if not type(entity) is dict: if bom:
# try to find the parent order and the dict corresponding to the ID provided in the WIP # and production orders in it
if bom.get('productionOrders',[]):
# find which order has the entity in its componentsList
for order in G.OrderList: for order in G.OrderList:
if order.componentsList: if order.componentsList:
for componentDict in order.componentsList: for componentDict in order.componentsList:
tempID=componentDict.get('id','not found') # if the entity has no parent order the following control will not be performed
if entity==tempID: if entity['id']==componentDict['id']:
entity=componentDict entityOrder=order # the parent order of the entity
entityOrder=order entityCurrentSeq=int(entity['sequence'])# the current seq number of the entity's route
if type(entity) is dict: ind=0 # holder of the route index corresponding to the entityCurrentSeq
solution=False # flag to signal that the route step is found
# find the step that corresponds to the entityCurrentSeq
for i, step in enumerate(componentDict.get('route',[])):
stepSeq=step['sequence'] # the sequence of step i
if stepSeq=='':
stepSeq=0 # if the seq is ''>OrderDecomposition then 0
# if the entityCurrentSeq is found and the id of the holding Station is in the steps stationIdsList
if int(stepSeq)==int(entityCurrentSeq) and element['id'] in step['stationIdsList']:
ind=i # hold the index
solution=True # the solution isfound
break
# assert that there is solution
assert solution, 'something is wrong with the initial step of '+entity['id']
# the remaining route of the entity assuming that the given route doesn't start from the entityCurrentSeq
entityRoute=componentDict.get('route',[])[ind:]
entity=dict(componentDict) # copy the entity dict
entity.pop('route') # remove the old route
entity['route']=entityRoute # and hold the new one without the previous steps
break break
entityClass=entity.get('_class', None) entityClass=entity.get('_class', None)
entityType=Globals.getClassFromName(entityClass) entityType=Globals.getClassFromName(entityClass)
inputDict=dict(entity) inputDict=dict(entity)
...@@ -405,7 +426,7 @@ def createWIP(): ...@@ -405,7 +426,7 @@ def createWIP():
# if orders are provided separately (BOM) provide the parent order as argument # if orders are provided separately (BOM) provide the parent order as argument
if entityOrder: if entityOrder:
entity=entityType(order=order,**inputDict) entity=entityType(order=order,**inputDict)
entity.orderInBOM=True entity.routeInBOM=True
else: else:
entity=entityType(**inputDict) entity=entityType(**inputDict)
G.EntityList.append(entity) G.EntityList.append(entity)
......
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