plugins clean up

parent 3ebfecc1
...@@ -81,14 +81,14 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -81,14 +81,14 @@ class InsertQueues(plugin.InputPreparationPlugin):
pre_predecessor_list.append(pre_predecessor) pre_predecessor_list.append(pre_predecessor)
if pre_predecessor_list: if pre_predecessor_list:
route.insert(index, {"stationIdsList" : pre_predecessor_list, route.insert(index, {"stationIdsList" : pre_predecessor_list,
"sequence": "", "sequence": "",
"task_id": "",}) "task_id": "",})
index+=1 index+=1
predecessor_list.append(predecessor) predecessor_list.append(predecessor)
if predecessor_list: if predecessor_list:
route.insert(index, {"stationIdsList": predecessor_list, route.insert(index, {"stationIdsList": predecessor_list,
"sequence": sequence, "sequence": sequence,
"task_id": task_id}) "task_id": task_id})
index+=1 index+=1
''' 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
...@@ -98,17 +98,18 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -98,17 +98,18 @@ class InsertQueues(plugin.InputPreparationPlugin):
successor_list.append(successor) successor_list.append(successor)
if successor_list: if successor_list:
route.insert(index, {"stationIdsList": successor_list, route.insert(index, {"stationIdsList": successor_list,
"sequence": "", "sequence": "",
"task_id": ""}) "task_id": ""})
index+=1 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 any(station.startswith("INJM") for station in stationIdsList) and tempIndex == len(tempRoute)-1:
for successor in self.getNotMachineNodeSuccessorList(stationIdsList): successor_list = []
for successor in self.getNotMachineNodeSuccessorList(stationIdsList):
successor_list.append(successor) successor_list.append(successor)
if successor_list: if successor_list:
route.insert(index, {"stationIdsList": successor_list, route.insert(index, {"stationIdsList": successor_list,
"sequence": sequence, "sequence": sequence,
"task_id": task_id}) "task_id": task_id})
index+=1 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:
...@@ -128,8 +129,8 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -128,8 +129,8 @@ class InsertQueues(plugin.InputPreparationPlugin):
assemblyBufferIDlist.append(str(nodeID)) assemblyBufferIDlist.append(str(nodeID))
if assemblyBufferIDlist: if assemblyBufferIDlist:
route.insert(index,{"stationIdsList": assemblyBufferIDlist, route.insert(index,{"stationIdsList": assemblyBufferIDlist,
"sequence": assembly_sequence, "sequence": assembly_sequence,
"task_id": assembly_task_id}) "task_id": assembly_task_id})
index+=1 index+=1
# # add assemblers to the route # # add assemblers to the route
assemblyIDlist = [] assemblyIDlist = []
...@@ -138,8 +139,8 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -138,8 +139,8 @@ class InsertQueues(plugin.InputPreparationPlugin):
assemblyIDlist.append(str(nodeID)) assemblyIDlist.append(str(nodeID))
if assemblyIDlist: if assemblyIDlist:
route.insert(index,{"stationIdsList": assemblyIDlist, route.insert(index,{"stationIdsList": assemblyIDlist,
"sequence": assembly_sequence, "sequence": assembly_sequence,
"task_id": assembly_task_id}) "task_id": assembly_task_id})
index+=1 index+=1
index+=1 index+=1
......
...@@ -8,83 +8,42 @@ import copy ...@@ -8,83 +8,42 @@ import copy
from dream.plugins import plugin from dream.plugins import plugin
# XXX HARDCODED
MACHINE_TYPE_SET = set(["Dream.MachineJobShop", "Dream.MouldAssembly"])
class SplitRoute(plugin.InputPreparationPlugin): class SplitRoute(plugin.InputPreparationPlugin):
""" Input preparation """ Input preparation
reads the data from external data base and splits the routes if the parts described are design and mould reads the data from external data base and splits the routes if the parts described are design and mould
""" """
def getNotMachineNodePredecessorList(self, stationIDs_list):
"""
Give the list of all predecessors that are not of type machine
For example, for stations with ids that starts with "CAM", it may return "QCAM"
"""
predecessor_list = []
for edge in self.data["graph"]["edge"].values():
if edge["destination"] in stationIDs_list:
predecessor_step = edge["source"]
if predecessor_step in predecessor_list:
continue
if not self.data["graph"]["node"][predecessor_step]["_class"] in MACHINE_TYPE_SET:
predecessor_list = [predecessor_step] + predecessor_list
predecessor_list = [x for x in getNotMachineNodePredecessorList([predecessor_step]) \
if x not in predecessor_list] + predecessor_list
return predecessor_list
def getNotMachineNodeSuccessorList(self, stationIDs_list):
"""
Give the list of all successors that are not of type machine
For example, for stations of technology "CAM", it may return "Decomposition"
for stations of technology "INJM-MAN" or "INJM" it may return "Exit"
"""
successor_list = []
for edge in self.data["graph"]["edge"].values():
if edge["source"] in stationIDs_list:
successor_step = edge["destination"]
if successor_step in successor_list:
continue
if not self.data["graph"]["node"][successor_step]["_class"] in MACHINE_TYPE_SET:
successor_list = [successor_step] + successor_list
successor_list = [x for x in getNotMachineNodeSuccessorList([successor_step]) \
if x not in successor_list] + successor_list
return successor_list
ROUTE_STEPS_SET=set(["ENG", "CAD","CAM","MILL", "MILL-SET","TURN", "DRILL", "QUAL","EDM", "EDM-SET","ASSM", "MAN","INJM", "INJM-MAN", "INJM-SET"]) ROUTE_STEPS_SET=set(["ENG", "CAD","CAM","MILL", "MILL-SET","TURN", "DRILL", "QUAL","EDM", "EDM-SET","ASSM", "MAN","INJM", "INJM-MAN", "INJM-SET"])
DESIGN_ROUTE_STEPS_SET=set(["ENG", "CAD"]) DESIGN_ROUTE_STEPS_SET=set(["ENG", "CAD"])
ASSEMBLY_ROUTE_STEPS_SET=set(["QASSM"])
MOULD_ROUTE_STEPS_SET=set(["ASSM","INJM","INJM-MAN","INJM-SET"])
def preprocess(self, data): def preprocess(self, data):
""" splits the routes of mould parts (design + mould) """ splits the routes of mould parts (design + mould)
""" """
self.data = copy(data) self.data = copy(data)
orders = self.data["input"]["BOM"]["orders"] orders = self.data["input"]["BOM"]["orders"]
stations = self.data["input"]["BOM"]["stations"] stations = self.data["input"]["BOM"]["stations"]
for order in orders:
orderComponents = order.get("componentsList", [])
for order in orders: for index, component in enumerate(orderComponents):
orderComponents = order.get("componentsList", []) route = component.get("route", [])
for index, component in enumerate(orderComponents): design_step_list = []
route = component.get("route", []) # for each step of the components route find out if it is of a design route (ENG - CAD) or of mould route (ASSM-INJM). If the route contains none of these technology-types steps then the component is normal
design_step_list = [] routeList = deepcopy(route)
# for each step of the components route find out if it is of a design route (ENG - CAD) or of mould route (ASSM-INJM). If the route contains none of these technology-types steps then the component is normal i = 0
routeList = deepcopy(route) for step in routeList:
i = 0 stepTechnology = step.get('technology',[])
for step in routeList: assert stepTechnology in ROUTE_STEPS_SET, 'the technology provided does not exist'
stepTechnology = step.get('technology',[]) if stepTechnology in DESIGN_ROUTE_STEPS_SET:
assert stepTechnology in ROUTE_STEPS_SET, 'the technology provided does not exist' design_step_list.append(step)
if stepTechnology in DESIGN_ROUTE_STEPS_SET: route.pop(i)
design_step_list.append(step) else:
route.pop(i) i+=1
else: if design_step_list:
i+=1 design = {"componentName": component.get("componentName","")+"Design",
if design_step_list: "componentID": component.get("componentID","")+"D",
design = {"componentName": component.get("componentName","")+"Design", "quantity": component.get("quantity", 1),
"componentID": component.get("componentID","")+"D", "route": design_step_list}
"quantity": component.get("quantity", 1), orderComponents.append(design)
"route": design_step_list} return self.data
orderComponents.append(design)
return data
if __name__ == '__main__': if __name__ == '__main__':
pass pass
\ No newline at end of file
...@@ -12,33 +12,53 @@ class UpdateStationList(plugin.InputPreparationPlugin): ...@@ -12,33 +12,53 @@ class UpdateStationList(plugin.InputPreparationPlugin):
""" Input preparation """ Input preparation
reads the data from external data base and substitutes the technology information with stationIDs lists reads the data from external data base and substitutes the technology information with stationIDs lists
""" """
def getStationTechnologies():
'''returns the technologies that can be processed on the stations'''
return {"CAD": ["ENG", "CAD"],
"CAM": ["CAM"],
"MILL": ["MILL"],
"TURN": ["TURN"],
"DRILL": ["DRILL"],
"EDM": ["EDM"],
"WORK": ["QUAL", "ASSM", "MAN"],
"INJM": ["INJM"]}
def getStationInitials(self,technology):
'''get the stations that correspond to that technology'''
for initials, corresponding_tech_list in self.getStationTechnologies().iteritems():
for tech in corresponding_tech_list:
if tech == technology:
return initials
return None
def preprocess(self, data): def preprocess(self, data):
""" substitutes the technology information with stationIDs lists """ substitutes the technology information with stationIDs lists
""" """
orders = data["input"]["BOM"]['orders'] orders = data["input"]["BOM"]['orders']
stations = data["input"]["BOM"]['stations'] stations = data["input"]["BOM"]['stations']
nodes = data["graph"]["node"] nodes = 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", []) route = component.get("route", [])
for index, step in enumerate(route): for index, step in enumerate(route):
technology = step.pop("technology", None) technology = step.get("technology", None)
technology = technology.split("-")[0] technology = technology.split("-")[0]
technologyStations = [] step["technology"] = technology
for station in stations: technologyStations = []
if station.startswith(technology): for station in stations:
found = False # check that the id of the station provided by the db BOM exist in the nodes of the graph assert self.getStationInitials(technology), 'there is no corresponding station initial for that technology'
for node in nodes: if station.startswith(self.getStationInitials(technology)):
if node["id"] == station: found = False # check that the id of the station provided by the db BOM exist in the nodes of the graph
found = True for node in nodes:
break if node["id"] == station:
assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model" found = True
technologyStations.append(station) break
assert len(technologyStations)>0, "the stations corresponding to the defined technology must be more than 0" assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model"
step["stationIdsList"] = technologyStations technologyStations.append(station)
assert len(technologyStations)>0, "the stations corresponding to the defined technology must be more than 0"
step["stationIdsList"] = technologyStations
return data return data
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -81,8 +81,12 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -81,8 +81,12 @@ class UpdateWIP(plugin.InputPreparationPlugin):
wip["componentID"]["task_id"] = current_step["task_id"] wip["componentID"]["task_id"] = current_step["task_id"]
if not exitTime: if not exitTime:
wip["componentID"]["remainingProcessingTime"] = {"Fixed": {"mean": remainingProcessingTime}} wip["componentID"]["remainingProcessingTime"] = {"Fixed": {"mean": remainingProcessingTime}}
# if the entity is not recognized within the current WIP then check if it should be created # if the entity is not recognized within the current WIP then check if it should be created
else: # first the flag designComplete and the completedComponents list must be updated
for component in orderComponents:
componentID = component["componentID"]
route = component["route"]
if not componentID in self.getWIPIds():
insertWIPitem = False insertWIPitem = False
# # if the design is complete # # if the design is complete
if designComplete: if designComplete:
...@@ -104,10 +108,6 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -104,10 +108,6 @@ class UpdateWIP(plugin.InputPreparationPlugin):
wip["componentID"]["station"] = route[0]["stationIdsList"][0] wip["componentID"]["station"] = route[0]["stationIdsList"][0]
wip["componentID"]["sequence"] = route[0]["sequence"] wip["componentID"]["sequence"] = route[0]["sequence"]
wip["componentID"]["task_id"] = route[0]["task_id"] wip["componentID"]["task_id"] = route[0]["task_id"]
# remove the idle entities # remove the idle entities
for entityID in wipToBeRemoved: for entityID in wipToBeRemoved:
assert wip.pop(entityID, None), "while trying to remove WIP that has concluded it's route, nothing is removed" assert wip.pop(entityID, None), "while trying to remove WIP that has concluded it's route, nothing is removed"
......
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