InsertQueues plugin tested and corrected

parent 7e37f6d0
...@@ -8,7 +8,8 @@ from datetime import datetime ...@@ -8,7 +8,8 @@ from datetime import datetime
from dream.plugins import plugin 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
...@@ -21,14 +22,14 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -21,14 +22,14 @@ class InsertQueues(plugin.InputPreparationPlugin):
""" """
predecessor_list = [] predecessor_list = []
for edge in self.data["graph"]["edge"].values(): for edge in self.data["graph"]["edge"].values():
if edge["destination"] in stationIDs_list: if edge["destination"] in stationIDs_list:
predecessor_step = edge["source"] predecessor_step = edge["source"]
if predecessor_step in predecessor_list: if predecessor_step in predecessor_list:
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
def getNotMachineNodeSuccessorList(self, stationIDs_list): def getNotMachineNodeSuccessorList(self, stationIDs_list):
...@@ -39,112 +40,111 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -39,112 +40,111 @@ class InsertQueues(plugin.InputPreparationPlugin):
""" """
successor_list = [] successor_list = []
for edge in self.data["graph"]["edge"].values(): for edge in self.data["graph"]["edge"].values():
if edge["source"] in stationIDs_list: if edge["source"] in stationIDs_list:
successor_step = edge["destination"] successor_step = edge["destination"]
if successor_step in successor_list: if successor_step in successor_list:
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
""" """
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: route = component.get("route", [])
updatedRoute = [] componentType = None
route = component.get("route", []) index = 0
index = 0 tempRoute = copy(route)
tempRoute = copy.deepcopy(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 the predecessor is OrderDecomposition then task_id and sequence are ""
# # if there is a QCAM there must an OrderDecomposition inserted before that if predecessor.startswith("OD"):
if predecessor.startswith("QCAM"): temp_sequence = temp_task_id = ""
pre_predecessor_list = [] else:
for pre_predecessor in self.getNotMachineNodePredecessorList([predecessor]): temp_sequence = sequence
pre_predecessor_list.append(pre_predecessor) temp_task_id = task_id
if pre_predecessor_list: route.insert(index, {"stationIdsList": [predecessor],
route.insert(index, {"stationIdsList" : pre_predecessor_list, "sequence": temp_sequence,
"sequence": "", "task_id": temp_task_id})
"task_id": "",}) index+=1
index+=1 '''find out if the part's route starts with ASSM'''
predecessor_list.append(predecessor) if technology.startswith("ASS") and tempIndex == 0:
if predecessor_list: componentType = "Mold"
route.insert(index, {"stationIdsList": predecessor_list,
"sequence": sequence, ''' add successors wherever needed (buffers, OrderDecomposition, exit, AssemblyBuffer, Assembly stations) '''
"task_id": task_id}) # # design case - add OrderDecomposition at the end of a design route
index+=1 if any(station.startswith("CAD") for station in stationIdsList) and tempIndex==len(tempRoute)-1:
''' add successors wherever needed (buffers, OrderDecomposition, exit, AssemblyBuffer, Assembly stations) ''' for successor in self.getNotMachineNodeSuccessorList(stationIdsList):
# # design case - add OrderDecomposition at the end of a design route # if the successor is a CAM buffer then do not add it to the route of the design
if any(station.startswith("CAD") for station in stationIdsList) and tempIndex==len(tempRoute)-1: if successor.startswith("QCAM"):
successor_list = [] continue
for successor in self.getNotMachineNodeSuccessorList(stationIdsList): route.append({"stationIdsList": [successor],
successor_list.append(successor) "sequence": "",
if successor_list: "task_id": ""})
route.insert(index, {"stationIdsList": successor_list, # # mould case - add exit at the a mould route
"sequence": "", elif componentType=="Mold" and tempIndex == len(tempRoute)-1:
"task_id": ""}) route.append({"stationIdsList": self.getExitStations(),
index+=1 "sequence": sequence,
# # mould case - add exit at the a mould route "task_id": task_id})
elif any(station.startswith("INJM") for station in stationIdsList) and tempIndex == len(tempRoute)-1:
successor_list = [] # # normal components - add ASSM buffer and ASSM at the end of their route
for successor in self.getNotMachineNodeSuccessorList(stationIdsList): elif tempIndex == len(tempRoute)-1 and not componentType == "Mold":
successor_list.append(successor) # exitAssigned=any(station.startswith("ASS") for station in stationIdsList)
if successor_list: exitAssigned=technology.startswith("ASS")
route.insert(index, {"stationIdsList": successor_list, if not exitAssigned:
"sequence": sequence, """find the sequence and task_id that has the assembly for the mould component"""
"task_id": task_id}) for sibling in orderComponents:
index+=1 for siblingStep in sibling["route"]:
# # normal components - add ASSM buffer and ASSM at the end of their route # if any(proc.startswith("ASS") for proc in siblingStep["stationIdsList"]):
elif tempIndex == len(tempRoute)-1: if siblingStep.get("technology", " ").startswith("ASS"):
exitAssigned=any(station.startswith("ASS") for station in stationIdsList) if siblingStep["task_id"]:
if not exitAssigned: assembly_sequence = siblingStep["sequence"]
"""find the sequence and tas_id that has the assembly for the mould component""" assembly_task_id = siblingStep["task_id"]
for sibling in orderComponents: # # add assemble buffers to the route
for siblingStep in sibling["route"]: assemblyBufferIDlist = []
if any(proc.startswith("ASS") for proc in siblingStep["stationIdsList"]): for nodeID, node in nodes.items():
if siblingStep["task_id"]: if node["_class"] == "Dream.MouldAssemblyBuffer":
assembly_sequence = siblingStep["sequence"] assemblyBufferIDlist.append(str(nodeID))
assembly_task_id = siblingStep["task_id"] if assemblyBufferIDlist:
# # add assemble buffers to the route route.append({"stationIdsList": assemblyBufferIDlist,
assemblyBufferIDlist = [] "sequence": assembly_sequence,
for nodeID, node in nodes.items(): "task_id": assembly_task_id})
if node["_class"] = "Dream.MouldAssemblyBuffer": # # add assemblers to the route
assemblyBufferIDlist.append(str(nodeID)) assemblyIDlist = []
if assemblyBufferIDlist: for nodeID, node in nodes.items():
route.insert(index,{"stationIdsList": assemblyBufferIDlist, if node["_class"] == "Dream.MouldAssembly":
"sequence": assembly_sequence, assemblyIDlist.append(str(nodeID))
"task_id": assembly_task_id}) if assemblyIDlist:
index+=1 route.append({"stationIdsList": assemblyIDlist,
# # add assemblers to the route "sequence": assembly_sequence,
assemblyIDlist = [] "task_id": assembly_task_id})
for nodeID, node in nodes.items():
if node["_class"] = "Dream.MouldAssembly":
assemblyIDlist.append(str(nodeID))
if assemblyIDlist:
route.insert(index,{"stationIdsList": assemblyIDlist,
"sequence": assembly_sequence,
"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