""" updates the Work in Process according to what is provided by the BOM, i.e. if a design just exited the last step of it's sequence
"""
currentTime=datetime.datetime.now().time()
self.data=copy(data)
orders=self.data["input"]["BOM"]["orders"]
nodes=self.data["graph"]["node"]
wip=self.data["input"]["BOM"].get("WIP",{})
""" get the tasks that are in the WIP, and place those that are not in the WIP in the corresponding stations. Consider the parts that have concluded their routes, or the components that are not created yet.
All the components defined by the corresponding orders should be examined
"""
wipToBeRemoved=[]
# # check all the orders
fororderinorders:
orderComponents=order.get("componentsList",[])
designComplete=False# flag to inform if the design is concluded
completedComponents=[]# list to hold the componentIDs that are concluded
# # find all the components
forcomponentinorderComponents:
componentID=component["componentID"]
route=component["route"]
# # figure out if they are defined in the WIP
ifcomponentIDinself.getWIPIds():
work=wip[componentID]
# # extract WIP information
workStation=work["station"]
entryTime=float(work.pop("entry"),0)
exitTime=float(work.pop("exit",0))
task_id=work["task_id"]
assertlen(route)>0,"the OrderComponent must have a route defined with length more than 0"
asserttask_id,"there must be a task_id defined for the OrderComponent in the WIP"
# # get the step identified by task_id, hold the step_index to see if the entity's route is concluded
forstep_index,stepinenumerate(route):
ifstep["task_id"]==task_id:
last_step=step
break
# # check if the entity has left the station
# the entity is a machine if there is no exitTime
ifnotexitTime:
# # calculate remaining processing time
remainingProcessingTime=currentTime-entryTime
currentStation=workStation
current_step=last_step
# the entity is in a buffer if the step_index is no larger than the length of the route
eliflen(route)-1>=step_index:
current_step=route[step_index+1]
currentStation=current_step["stationIdsList"][0]
# the entity has concluded it's route; it should be removed from the WIP
else:
wipToBeRemoved.append(componentID)
# # check if this part is a design and update the flag