plugins clean up

parent 3ebfecc1
...@@ -103,6 +103,7 @@ class InsertQueues(plugin.InputPreparationPlugin): ...@@ -103,6 +103,7 @@ class InsertQueues(plugin.InputPreparationPlugin):
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:
successor_list = []
for successor in self.getNotMachineNodeSuccessorList(stationIdsList): for successor in self.getNotMachineNodeSuccessorList(stationIdsList):
successor_list.append(successor) successor_list.append(successor)
if successor_list: if successor_list:
......
...@@ -8,60 +8,19 @@ import copy ...@@ -8,60 +8,19 @@ 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: for order in orders:
orderComponents = order.get("componentsList", []) orderComponents = order.get("componentsList", [])
for index, component in enumerate(orderComponents): for index, component in enumerate(orderComponents):
...@@ -84,7 +43,7 @@ class SplitRoute(plugin.InputPreparationPlugin): ...@@ -84,7 +43,7 @@ class SplitRoute(plugin.InputPreparationPlugin):
"quantity": component.get("quantity", 1), "quantity": component.get("quantity", 1),
"route": design_step_list} "route": design_step_list}
orderComponents.append(design) orderComponents.append(design)
return data return self.data
if __name__ == '__main__': if __name__ == '__main__':
pass pass
\ No newline at end of file
...@@ -12,6 +12,24 @@ class UpdateStationList(plugin.InputPreparationPlugin): ...@@ -12,6 +12,24 @@ 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
...@@ -25,11 +43,13 @@ class UpdateStationList(plugin.InputPreparationPlugin): ...@@ -25,11 +43,13 @@ class UpdateStationList(plugin.InputPreparationPlugin):
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]
step["technology"] = technology
technologyStations = [] technologyStations = []
for station in stations: for station in stations:
if station.startswith(technology): assert self.getStationInitials(technology), 'there is no corresponding station initial for that technology'
if station.startswith(self.getStationInitials(technology)):
found = False # check that the id of the station provided by the db BOM exist in the nodes of the graph found = False # check that the id of the station provided by the db BOM exist in the nodes of the graph
for node in nodes: for node in nodes:
if node["id"] == station: if node["id"] == station:
......
...@@ -82,7 +82,11 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -82,7 +82,11 @@ class UpdateWIP(plugin.InputPreparationPlugin):
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