plugins clean up

parent 3ebfecc1
......@@ -81,14 +81,14 @@ class InsertQueues(plugin.InputPreparationPlugin):
pre_predecessor_list.append(pre_predecessor)
if pre_predecessor_list:
route.insert(index, {"stationIdsList" : pre_predecessor_list,
"sequence": "",
"task_id": "",})
"sequence": "",
"task_id": "",})
index+=1
predecessor_list.append(predecessor)
if predecessor_list:
route.insert(index, {"stationIdsList": predecessor_list,
"sequence": sequence,
"task_id": task_id})
"sequence": sequence,
"task_id": task_id})
index+=1
''' add successors wherever needed (buffers, OrderDecomposition, exit, AssemblyBuffer, Assembly stations) '''
# # design case - add OrderDecomposition at the end of a design route
......@@ -98,17 +98,18 @@ class InsertQueues(plugin.InputPreparationPlugin):
successor_list.append(successor)
if successor_list:
route.insert(index, {"stationIdsList": successor_list,
"sequence": "",
"task_id": ""})
"sequence": "",
"task_id": ""})
index+=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):
successor_list = []
for successor in self.getNotMachineNodeSuccessorList(stationIdsList):
successor_list.append(successor)
if successor_list:
route.insert(index, {"stationIdsList": successor_list,
"sequence": sequence,
"task_id": task_id})
"sequence": sequence,
"task_id": task_id})
index+=1
# # normal components - add ASSM buffer and ASSM at the end of their route
elif tempIndex == len(tempRoute)-1:
......@@ -128,8 +129,8 @@ class InsertQueues(plugin.InputPreparationPlugin):
assemblyBufferIDlist.append(str(nodeID))
if assemblyBufferIDlist:
route.insert(index,{"stationIdsList": assemblyBufferIDlist,
"sequence": assembly_sequence,
"task_id": assembly_task_id})
"sequence": assembly_sequence,
"task_id": assembly_task_id})
index+=1
# # add assemblers to the route
assemblyIDlist = []
......@@ -138,8 +139,8 @@ class InsertQueues(plugin.InputPreparationPlugin):
assemblyIDlist.append(str(nodeID))
if assemblyIDlist:
route.insert(index,{"stationIdsList": assemblyIDlist,
"sequence": assembly_sequence,
"task_id": assembly_task_id})
"sequence": assembly_sequence,
"task_id": assembly_task_id})
index+=1
index+=1
......
......@@ -8,83 +8,42 @@ import copy
from dream.plugins import plugin
# XXX HARDCODED
MACHINE_TYPE_SET = set(["Dream.MachineJobShop", "Dream.MouldAssembly"])
class SplitRoute(plugin.InputPreparationPlugin):
""" Input preparation
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"])
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):
""" splits the routes of mould parts (design + mould)
"""
self.data = copy(data)
self.data = copy(data)
orders = self.data["input"]["BOM"]["orders"]
stations = self.data["input"]["BOM"]["stations"]
for order in orders:
orderComponents = order.get("componentsList", [])
for index, component in enumerate(orderComponents):
route = component.get("route", [])
design_step_list = []
# 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
routeList = deepcopy(route)
i = 0
for step in routeList:
stepTechnology = step.get('technology',[])
assert stepTechnology in ROUTE_STEPS_SET, 'the technology provided does not exist'
if stepTechnology in DESIGN_ROUTE_STEPS_SET:
design_step_list.append(step)
route.pop(i)
else:
i+=1
if design_step_list:
design = {"componentName": component.get("componentName","")+"Design",
"componentID": component.get("componentID","")+"D",
"quantity": component.get("quantity", 1),
"route": design_step_list}
orderComponents.append(design)
return data
stations = self.data["input"]["BOM"]["stations"]
for order in orders:
orderComponents = order.get("componentsList", [])
for index, component in enumerate(orderComponents):
route = component.get("route", [])
design_step_list = []
# 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
routeList = deepcopy(route)
i = 0
for step in routeList:
stepTechnology = step.get('technology',[])
assert stepTechnology in ROUTE_STEPS_SET, 'the technology provided does not exist'
if stepTechnology in DESIGN_ROUTE_STEPS_SET:
design_step_list.append(step)
route.pop(i)
else:
i+=1
if design_step_list:
design = {"componentName": component.get("componentName","")+"Design",
"componentID": component.get("componentID","")+"D",
"quantity": component.get("quantity", 1),
"route": design_step_list}
orderComponents.append(design)
return self.data
if __name__ == '__main__':
pass
\ No newline at end of file
......@@ -12,33 +12,53 @@ class UpdateStationList(plugin.InputPreparationPlugin):
""" Input preparation
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):
""" substitutes the technology information with stationIDs lists
"""
orders = data["input"]["BOM"]['orders']
stations = data["input"]["BOM"]['stations']
nodes = data["graph"]["node"]
for order in orders:
orderComponents = order.get("componentsList", [])
for component in orderComponents:
route = component.get("route", [])
for index, step in enumerate(route):
technology = step.pop("technology", None)
technology = technology.split("-")[0]
technologyStations = []
for station in stations:
if station.startswith(technology):
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:
if node["id"] == station:
found = True
break
assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model"
technologyStations.append(station)
assert len(technologyStations)>0, "the stations corresponding to the defined technology must be more than 0"
step["stationIdsList"] = technologyStations
stations = data["input"]["BOM"]['stations']
nodes = data["graph"]["node"]
for order in orders:
orderComponents = order.get("componentsList", [])
for component in orderComponents:
route = component.get("route", [])
for index, step in enumerate(route):
technology = step.get("technology", None)
technology = technology.split("-")[0]
step["technology"] = technology
technologyStations = []
for station in stations:
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
for node in nodes:
if node["id"] == station:
found = True
break
assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model"
technologyStations.append(station)
assert len(technologyStations)>0, "the stations corresponding to the defined technology must be more than 0"
step["stationIdsList"] = technologyStations
return data
if __name__ == '__main__':
......
......@@ -81,8 +81,12 @@ class UpdateWIP(plugin.InputPreparationPlugin):
wip["componentID"]["task_id"] = current_step["task_id"]
if not exitTime:
wip["componentID"]["remainingProcessingTime"] = {"Fixed": {"mean": remainingProcessingTime}}
# if the entity is not recognized within the current WIP then check if it should be created
else:
# if the entity is not recognized within the current WIP then check if it should be created
# 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
# # if the design is complete
if designComplete:
......@@ -104,10 +108,6 @@ class UpdateWIP(plugin.InputPreparationPlugin):
wip["componentID"]["station"] = route[0]["stationIdsList"][0]
wip["componentID"]["sequence"] = route[0]["sequence"]
wip["componentID"]["task_id"] = route[0]["task_id"]
# remove the idle entities
for entityID in wipToBeRemoved:
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