minor corrections to JS plugins

parent 49b82fed
...@@ -63,7 +63,7 @@ class MergeSteps(plugin.InputPreparationPlugin): ...@@ -63,7 +63,7 @@ class MergeSteps(plugin.InputPreparationPlugin):
if stepToMerge["processingTime"]: if stepToMerge["processingTime"]:
step["setupTime"] = stepToMerge["processingTime"] step["setupTime"] = stepToMerge["processingTime"]
# setupType + operator for setup # setupType + operator for setup
if stepToMerge["operator"] == "Automatic" if stepToMerge["operator"] == "Automatic":
step["operationType"]["setup"] = "Automatic" step["operationType"]["setup"] = "Automatic"
else: else:
step["operationType"]["setup"] = "Manual" step["operationType"]["setup"] = "Manual"
......
...@@ -19,7 +19,7 @@ class SplitRoute(plugin.InputPreparationPlugin): ...@@ -19,7 +19,7 @@ class SplitRoute(plugin.InputPreparationPlugin):
""" splits the routes of mould parts (design + mould) """ splits the routes of mould parts (design + mould)
""" """
orders = data["input"]["BOM"]["orders"] orders = data["input"]["BOM"]["orders"]
stations = data["input"]["BOM"]["stations"] # stations = data["input"]["BOM"]["stations"]
for order in orders: for order in orders:
orderComponents = order.get("componentsList", []) orderComponents = order.get("componentsList", [])
componentsToAdd = [] componentsToAdd = []
...@@ -31,8 +31,8 @@ class SplitRoute(plugin.InputPreparationPlugin): ...@@ -31,8 +31,8 @@ class SplitRoute(plugin.InputPreparationPlugin):
i = 0 i = 0
for step in routeList: for step in routeList:
stepTechnology = step.get('technology',[]) stepTechnology = step.get('technology',[])
assert stepTechnology in ROUTE_STEPS_SET, 'the technology provided does not exist' assert stepTechnology in self.ROUTE_STEPS_SET, 'the technology provided does not exist'
if stepTechnology in DESIGN_ROUTE_STEPS_SET: if stepTechnology in self.DESIGN_ROUTE_STEPS_SET:
design_step_list.append(step) design_step_list.append(step)
route.pop(i) route.pop(i)
else: else:
......
...@@ -12,6 +12,7 @@ class UpdateStationList(plugin.InputPreparationPlugin): ...@@ -12,6 +12,7 @@ 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
""" """
@staticmethod
def getStationTechnologies(): def getStationTechnologies():
'''returns the technologies that can be processed on the stations''' '''returns the technologies that can be processed on the stations'''
return {"CAD": ["ENG", "CAD"], return {"CAD": ["ENG", "CAD"],
...@@ -31,11 +32,22 @@ class UpdateStationList(plugin.InputPreparationPlugin): ...@@ -31,11 +32,22 @@ class UpdateStationList(plugin.InputPreparationPlugin):
return initials return initials
return None return None
def getStationNames(self):
node = self.data["graph"]["node"]
stations = []
for nodeID in node.keys():
stations.append(nodeID)
return stations
def preprocess(self, data): def preprocess(self, data):
""" substitutes the technology information with stationIDs lists """ substitutes the technology information with stationIDs lists
""" """
self.data = data
orders = data["input"]["BOM"]['orders'] orders = data["input"]["BOM"]['orders']
stations = data["input"]["BOM"]['stations'] try:
stations = data["input"]["BOM"]['stations']
except:
stations = self.getStationNames()
nodes = data["graph"]["node"] nodes = data["graph"]["node"]
for order in orders: for order in orders:
...@@ -45,14 +57,14 @@ class UpdateStationList(plugin.InputPreparationPlugin): ...@@ -45,14 +57,14 @@ class UpdateStationList(plugin.InputPreparationPlugin):
for index, step in enumerate(route): for index, step in enumerate(route):
technology = step.get("technology", None) technology = step.get("technology", None)
technology = technology.split("-")[0] technology = technology.split("-")[0]
assert self.getStationInitials(technology), 'there is no corresponding station initial for that technology'
step["technology"] = technology step["technology"] = technology
technologyStations = [] technologyStations = []
for station in stations: for station in stations:
assert self.getStationInitials(technology), 'there is no corresponding station initial for that technology'
if station.startswith(self.getStationInitials(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.keys():
if node["id"] == station: if node == station:
found = True found = True
break break
assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model" assert found == True, "the station ids in the DB must be the same with the stations ids provided by the model"
......
...@@ -12,7 +12,7 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -12,7 +12,7 @@ class UpdateWIP(plugin.InputPreparationPlugin):
def getWIPIds(self): def getWIPIds(self):
"""returns the ids of the parts that are in the WIP dictionary""" """returns the ids of the parts that are in the WIP dictionary"""
wipIDs = [] wipIDs = []
for key in self.data["input"]["BOM"].get("WIP", {}).keys() for key in self.data["input"]["BOM"].get("WIP", {}).keys():
wipIDs.append(key) wipIDs.append(key)
return wipIDs return wipIDs
...@@ -91,7 +91,7 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -91,7 +91,7 @@ class UpdateWIP(plugin.InputPreparationPlugin):
# # if the design is not complete # # if the design is not complete
else: else:
# # if the component is design then put it at the start of its route # # if the component is design then put it at the start of its route
if any(station.startswith("OD") for station in route[0]["stationIdsList"]): if any(station.startswith("OD") for station in route[-1]["stationIdsList"]):
insertWIPitem = True insertWIPitem = True
# # if the completed components include all the components (exclude mould and design) # # if the completed components include all the components (exclude mould and design)
if len(completedComponents) == len(orderComponents)-2: if len(completedComponents) == len(orderComponents)-2:
...@@ -99,7 +99,7 @@ class UpdateWIP(plugin.InputPreparationPlugin): ...@@ -99,7 +99,7 @@ class UpdateWIP(plugin.InputPreparationPlugin):
if any(station.startswith("E") for station in route[-1]["stationIdsList"]): if any(station.startswith("E") for station in route[-1]["stationIdsList"]):
insertWIPitem = True insertWIPitem = True
if insertWIPitem: if insertWIPitem:
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"]
......
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