InsertQueues plugin tested and corrected

parent 5a91b859
...@@ -9,6 +9,7 @@ from dream.plugins import plugin ...@@ -9,6 +9,7 @@ from dream.plugins import plugin
# XXX HARDCODED # XXX HARDCODED
MACHINE_TYPE_SET = set(["Dream.MachineJobShop", "Dream.MouldAssembly"]) MACHINE_TYPE_SET = set(["Dream.MachineJobShop", "Dream.MouldAssembly"])
EXIT_TYPE_SET = set(["Dream.ExitJobShop"])
class InsertQueues(plugin.InputPreparationPlugin): class InsertQueues(plugin.InputPreparationPlugin):
""" Input preparation """ Input preparation
reads the data from external data base and inserts buffers before the corresponding stations reads the data from external data base and inserts buffers before the corresponding stations
...@@ -27,7 +28,7 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -27,7 +28,7 @@ class InsertQueues(plugin.InputPreparationPlugin):
continue continue
if not self.data["graph"]["node"][predecessor_step]["_class"] in MACHINE_TYPE_SET: if not self.data["graph"]["node"][predecessor_step]["_class"] in MACHINE_TYPE_SET:
predecessor_list = [predecessor_step] + predecessor_list predecessor_list = [predecessor_step] + predecessor_list
predecessor_list = [x for x in getNotMachineNodePredecessorList([predecessor_step]) \ predecessor_list = [x for x in self.getNotMachineNodePredecessorList([predecessor_step]) \
if x not in predecessor_list] + predecessor_list if x not in predecessor_list] + predecessor_list
return predecessor_list return predecessor_list
...@@ -45,10 +46,18 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -45,10 +46,18 @@ class InsertQueues(plugin.InputPreparationPlugin):
continue continue
if not self.data["graph"]["node"][successor_step]["_class"] in MACHINE_TYPE_SET: if not self.data["graph"]["node"][successor_step]["_class"] in MACHINE_TYPE_SET:
successor_list = [successor_step] + successor_list successor_list = [successor_step] + successor_list
successor_list = [x for x in getNotMachineNodeSuccessorList([successor_step]) \ successor_list = [x for x in self.getNotMachineNodeSuccessorList([successor_step]) \
if x not in successor_list] + successor_list if x not in successor_list] + successor_list
return successor_list return successor_list
def getExitStations(self):
"""returns the exits of the system"""
nodes = self.data["graph"]["node"]
exitList = []
for nodeID, node in nodes.iteritems():
if node["_class"] in EXIT_TYPE_SET:
exitList.append(nodeID)
return exitList
def preprocess(self, data): def preprocess(self, data):
""" inserts buffers before the corresponding stations """ inserts buffers before the corresponding stations
...@@ -56,95 +65,86 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -56,95 +65,86 @@ class InsertQueues(plugin.InputPreparationPlugin):
self.data = copy(data) self.data = copy(data)
orders = self.data["input"]["BOM"]["orders"] orders = self.data["input"]["BOM"]["orders"]
nodes = self.data["graph"]["node"] nodes = self.data["graph"]["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 = []
route = component.get("route", []) route = component.get("route", [])
componentType = None
index = 0 index = 0
tempRoute = copy.deepcopy(route) tempRoute = copy(route)
for tempIndex, step in enumerate(tempRoute): for tempIndex, step in enumerate(tempRoute):
stationIdsList = step.get("stationIdsList", []) stationIdsList = step.get("stationIdsList", [])
technology = step["technology"]
sequence = step["sequence"] sequence = step["sequence"]
task_id = step["task_id"] task_id = step["task_id"]
''' add predecessors wherever needed (buffers, OrderDecomposition) ''' ''' add predecessors wherever needed (buffers, OrderDecomposition) '''
predecessor_list = []
for predecessor in self.getNotMachineNodePredecessorList(stationIdsList): for predecessor in self.getNotMachineNodePredecessorList(stationIdsList):
# # 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
# # if there is a QCAM there must an OrderDecomposition inserted before that # if the predecessor is OrderDecomposition then task_id and sequence are ""
if predecessor.startswith("QCAM"): if predecessor.startswith("OD"):
pre_predecessor_list = [] temp_sequence = temp_task_id = ""
for pre_predecessor in self.getNotMachineNodePredecessorList([predecessor]): else:
pre_predecessor_list.append(pre_predecessor) temp_sequence = sequence
if pre_predecessor_list: temp_task_id = task_id
route.insert(index, {"stationIdsList" : pre_predecessor_list, route.insert(index, {"stationIdsList": [predecessor],
"sequence": "", "sequence": temp_sequence,
"task_id": "",}) "task_id": temp_task_id})
index+=1
predecessor_list.append(predecessor)
if predecessor_list:
route.insert(index, {"stationIdsList": predecessor_list,
"sequence": sequence,
"task_id": task_id})
index+=1 index+=1
'''find out if the part's route starts with ASSM'''
if technology.startswith("ASS") and tempIndex == 0:
componentType = "Mold"
''' add successors wherever needed (buffers, OrderDecomposition, exit, AssemblyBuffer, Assembly stations) ''' ''' add successors wherever needed (buffers, OrderDecomposition, exit, AssemblyBuffer, Assembly stations) '''
# # design case - add OrderDecomposition at the end of a design route # # 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: 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):
successor_list.append(successor) # if the successor is a CAM buffer then do not add it to the route of the design
if successor_list: if successor.startswith("QCAM"):
route.insert(index, {"stationIdsList": successor_list, continue
route.append({"stationIdsList": [successor],
"sequence": "", "sequence": "",
"task_id": ""}) "task_id": ""})
index+=1
# # mould case - add exit at the a mould route # # mould case - add exit at the a mould route
elif any(station.startswith("INJM") for station in stationIdsList) and tempIndex == len(tempRoute)-1: elif componentType=="Mold" and tempIndex == len(tempRoute)-1:
successor_list = [] route.append({"stationIdsList": self.getExitStations(),
for successor in self.getNotMachineNodeSuccessorList(stationIdsList):
successor_list.append(successor)
if successor_list:
route.insert(index, {"stationIdsList": successor_list,
"sequence": sequence, "sequence": sequence,
"task_id": task_id}) "task_id": task_id})
index+=1
# # normal components - add ASSM buffer and ASSM at the end of their route # # normal components - add ASSM buffer and ASSM at the end of their route
elif tempIndex == len(tempRoute)-1: elif tempIndex == len(tempRoute)-1 and not componentType == "Mold":
exitAssigned=any(station.startswith("ASS") for station in stationIdsList) # exitAssigned=any(station.startswith("ASS") for station in stationIdsList)
exitAssigned=technology.startswith("ASS")
if not exitAssigned: if not exitAssigned:
"""find the sequence and tas_id that has the assembly for the mould component""" """find the sequence and task_id that has the assembly for the mould component"""
for sibling in orderComponents: for sibling in orderComponents:
for siblingStep in sibling["route"]: for siblingStep in sibling["route"]:
if any(proc.startswith("ASS") for proc in siblingStep["stationIdsList"]): # if any(proc.startswith("ASS") for proc in siblingStep["stationIdsList"]):
if siblingStep.get("technology", " ").startswith("ASS"):
if siblingStep["task_id"]: if siblingStep["task_id"]:
assembly_sequence = siblingStep["sequence"] assembly_sequence = siblingStep["sequence"]
assembly_task_id = siblingStep["task_id"] assembly_task_id = siblingStep["task_id"]
# # add assemble buffers to the route # # add assemble buffers to the route
assemblyBufferIDlist = [] assemblyBufferIDlist = []
for nodeID, node in nodes.items(): for nodeID, node in nodes.items():
if node["_class"] = "Dream.MouldAssemblyBuffer": if node["_class"] == "Dream.MouldAssemblyBuffer":
assemblyBufferIDlist.append(str(nodeID)) assemblyBufferIDlist.append(str(nodeID))
if assemblyBufferIDlist: if assemblyBufferIDlist:
route.insert(index,{"stationIdsList": assemblyBufferIDlist, route.append({"stationIdsList": assemblyBufferIDlist,
"sequence": assembly_sequence, "sequence": assembly_sequence,
"task_id": assembly_task_id}) "task_id": assembly_task_id})
index+=1
# # add assemblers to the route # # add assemblers to the route
assemblyIDlist = [] assemblyIDlist = []
for nodeID, node in nodes.items(): for nodeID, node in nodes.items():
if node["_class"] = "Dream.MouldAssembly": if node["_class"] == "Dream.MouldAssembly":
assemblyIDlist.append(str(nodeID)) assemblyIDlist.append(str(nodeID))
if assemblyIDlist: if assemblyIDlist:
route.insert(index,{"stationIdsList": assemblyIDlist, route.append({"stationIdsList": assemblyIDlist,
"sequence": assembly_sequence, "sequence": assembly_sequence,
"task_id": assembly_task_id}) "task_id": assembly_task_id})
index+=1
index+=1 index+=1
return data return data
if __name__ == '__main__': if __name__ == '__main__':
......
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