InsertQueues plugin updated, not tested yet

parent f28d6247
...@@ -4,7 +4,6 @@ import time ...@@ -4,7 +4,6 @@ import time
import random import random
import operator import operator
from datetime import datetime from datetime import datetime
import copy
from dream.plugins import plugin from dream.plugins import plugin
...@@ -55,65 +54,74 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -55,65 +54,74 @@ class InsertQueues(plugin.InputPreparationPlugin):
""" inserts buffers before the corresponding stations """ inserts buffers before the corresponding stations
""" """
self.data = copy(data) self.data = copy(data)
orders = self.data["BOM"]["orders"] orders = self.data["input"]["BOM"]["orders"]
stations = self.data["BOM"]["stations"] nodes = self.data["graph"]["node"]
graph_data = self.data["graph"]
nodes = graph_data["node"]
for order in orders: for order in orders:
orderComponents = order.get("componentsList", []) orderComponents = order.get("componentsList", [])
for component in orderComponents: for component in orderComponents:
updatedRoute = [] updatedRoute = []
route = component.get("route", []) route = component.get("route", [])
# XXX separate mould from design index = 0
for step in route: tempRoute = copy.deepcopy(route)
stationIdsList = step.get("stationIdsList", []) for tempIndex, step in enumerate(tempRoute):
for index, step in enumerate(route):
stationIdsList = step.get("stationIdsList", []) stationIdsList = step.get("stationIdsList", [])
''' add predecessors wherever needed (buffers, OrderDecomposition) '''
predecessor_list = []
for predecessor in self.getNotMachineNodePredecessorList(stationIdsList): for predecessor in self.getNotMachineNodePredecessorList(stationIdsList):
# XXX if the component is a mould then before the assembly do not add AssemblyBuffer # # if the component is a mould then before the assembly do not add AssemblyBuffer
if predecessor.startswith("ASSM"): if predecessor.startswith("ASSM"):
break break
# XXX if there is a QCAM there must an OrderDecomposition come # # if there is a QCAM there must an OrderDecomposition inserted before that
if predecessor.startswith("QCAM"): if predecessor.startswith("QCAM"):
pre_predecessor_list = []
for pre_predecessor in self.getNotMachineNodePredecessorList([predecessor]): for pre_predecessor in self.getNotMachineNodePredecessorList([predecessor]):
"""insert this step (pre_predecessor) to the route pre_predecessor_list.append(pre_predecessor)
{"stationIdsList": [pre_predecessor],} if pre_predecessor_list:
""" route.insert(index, {"stationIdsList" : pre_predecessor_list,})
"""insert this step (predecessor) to the route index+=1
{"stationIdsList": [predecessor],} predecessor_list.append(predecessor)
""" if predecessor_list:
# XXX design case - add OrderDecomposition route.insert(index, {"stationIdsList": predecessor_list,})
if any(station.startswith("CAD") for station in stationIdsList) and index==len(route)-1: index+=1
''' add successors wherever needed (buffers, OrderDecomposition, exit, AssemblyBuffer, Assembly stations) '''
# # design case - add OrderDecomposition at the end of a design route
if any(station.startswith("CAD") for station in stationIdsList) and tempIndex==len(tempRoute)-1:
successor_list = []
for successor in self.getNotMachineNodeSuccessorList(stationIdsList): for successor in self.getNotMachineNodeSuccessorList(stationIdsList):
"""insert this step (successor) to the route successor_list.append(successor)
{"stationIdsList": [succecssor],} if successor_list:
""" route.insert(index, {"stationIdsList": successor_list,})
# XXX mould case - add exit index+=1
elif any(station.startswith("INJ") for station in stationIdsList) and index == len(route)-1: # # mould case - add exit at the a mould route
elif any(station.startswith("INJM") for station in stationIdsList) and tempIndex == len(tempRoute)-1:
for successor in self.getNotMachineNodeSuccessorList(stationIdsList): for successor in self.getNotMachineNodeSuccessorList(stationIdsList):
"""insert this step (successor) to the route successor_list.append(successor)
{"stationIdsList": [succecssor],} if successor_list:
""" route.insert(index, {"stationIdsList": successor_list,})
# XXX normal components - add ASSM buffer and ASSM after manual operations? index+=1
elif index == len(route)-1: # # normal components - add ASSM buffer and ASSM at the end of their route
exitAssigned=(station.startswith("ASS") for station in stationIdsList) elif tempIndex == len(tempRoute)-1:
exitAssigned=any(station.startswith("ASS") for station in stationIdsList)
if not exitAssigned: if not exitAssigned:
"""insert ASSM buffer to the route # # add assemble buffers to the route
{"stationIdsList": [AssemblyBufferIdsList],} assemblyBufferIDlist = []
""" for nodeID, node in nodes.items():
"""insert ASSM to the route if node["_class"] = "Dream.MouldAssemblyBuffer":
{"stationIdsList": [AssemblyIdsList],} assemblyBufferIDlist.append(str(nodeID))
""" if assemblyBufferIDlist:
route.insert(index,{"stationIdsList": assemblyBufferIDlist, })
index+=1
# XXX route.insert(indexToInsert, additionalStep) # # add assemblers to the route
assemblyIDlist = []
for nodeID, node in nodes.items():
if node["_class"] = "Dream.MouldAssembly":
assemblyIDlist.append(str(nodeID))
if assemblyIDlist:
route.insert(index,{"stationIdsList": assemblyIDlist, })
index+=1
index+=1
return data return data
......
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