Change in the calculation of remainingProcessingTime. ReadJSWIP inherits from...

Change in the calculation of remainingProcessingTime. ReadJSWIP inherits from ReadJSWorkPlan. + minor corrections
parent 6a727d79
......@@ -30,19 +30,19 @@ class ReadJSCompleted(plugin.InputPreparationPlugin):
if not completed:
routeConcluded = False
# check the WIP and see if the current part already resides there
if not part["componentID"] in wip.keys():
if not component["componentID"] in wip.keys():
# if there is a previous task
if index:
previousStep = route[index-1]
# XXX: no entry/exit/stationID is defined
wip[part["componentID"]] = {
wip[component["componentID"]] = {
"task_id": previousStep["task_id"],
"station": previousStep["technology"],
"remainingProcessingTime": 0,
"sequence": previousStep["sequence"]
}
if routeConcluded:
wip[part["componentID"]] = {
wip[component["componentID"]] = {
"task_id": step["task_id"],
"station": step["technology"],
"remainingProcessingTime": 0,
......
......@@ -18,6 +18,9 @@ class ReadJSOrders(plugin.InputPreparationPlugin):
"""
POdata = data["input"].get("production_orders_spreadsheet",[])
productionOrders = []
BOM = data["input"].get("BOM",{})
if not BOM:
BOM = data["input"]["BOM"] = {}
data["input"]["BOM"]["orders"] = productionOrders
if POdata:
POdata.pop(0) # pop the column names
......
......@@ -7,9 +7,10 @@ import datetime
import copy
from dream.plugins import plugin
from dream.plugins import ReadJSWorkPlan
from dream.plugins.TimeSupport import TimeSupportMixin
class ReadJSWIP(plugin.InputPreparationPlugin, TimeSupportMixin):
class ReadJSWIP(ReadJSWorkPlan.ReadJSWorkPlan, TimeSupportMixin):
""" Input preparation
reads the wip from the spreadsheet and inserts it to the BOM
"""
......@@ -17,26 +18,27 @@ class ReadJSWIP(plugin.InputPreparationPlugin, TimeSupportMixin):
def preprocess(self, data):
""" inserts the wip as introduced in the GUI to the BOM
"""
self.data = data
strptime = datetime.datetime.strptime
# read the current date and define dateFormat from it
try:
[nowDate, nowTime] = data['general']['currentDate'].split(" ")
now = strptime(data['general']['currentDate'], '%Y/%m/%d %H:%M')
data['general']['dateFormat']='%Y/%m/%d %H:%M'
except ValueError:
nowDate = data['general']['currentDate']
nowTime = str(datetime.datetime.now().hour)+":"+str(datetime.datetime.now().minute)
now = strptime(data['general']['currentDate'], '%Y/%m/%d')
data['general']['dateFormat']='%Y/%m/%d'
self.initializeTimeSupport(data)
WIPdata = data["input"].get("wip_spreadsheet",[])
workPlanData = data["input"].get("workplan_spreadsheet",[])
try:
BOM = data["input"]["BOM"]
except:
BOM = data["input"]["BOM"]={}
try:
wip = BOM["WIP"]
except:
wip = BOM["WIP"] = {}
BOM = data["input"].get("BOM",{})
if not BOM:
BOM = data["input"]["BOM"] = {}
wip = BOM.get("WIP",{})
if not wip:
wip = data["input"]["WIP"] = {}
if WIPdata:
WIPdata.pop(0) # pop the column names
for WIPitem in WIPdata:
......@@ -47,14 +49,27 @@ class ReadJSWIP(plugin.InputPreparationPlugin, TimeSupportMixin):
operatorID = WIPitem[4]
sequence = WIPitem[1]
WP_id = WIPitem[2]
# start = WIPitem[5]
start = self.convertToSimulationTime(strptime("%s %s" % (data['general']['currentDate'], WIPitem[5]), '%Y/%m/%d %H:%M'))
remainingProcessinTime = start - now
# calculate the time that the part has been already processed for
startTime = self.convertToSimulationTime(strptime("%s %s" % (nowDate, WIPitem[5]), '%Y/%m/%d %H:%M'))
currentTime = self.convertToSimulationTime(strptime("%s %s" % (nowDate, nowTime), '%Y/%m/%d %H:%M'))
elapsedTime = currentTime - startTime
# find the processing time of part for the WP_id
part = self.findEntityByID(partID)
assert part, "the parts must already be defined before calculating the remaining processing time"
route = part.get("route",[])
for step in route:
if step["task_id"] == WP_id:
processingTime = step.get("processingTime", {"fixed":{"meam":0}})
# the distribution of the processing time is supposed to be fixed (see ReadJSWorkPlan))
processingTime = float(processingTime["fixed"].get("mean",0))
# calculate the remaining Processing Time
remainingProcessingTime = processingTime - elapsedTime
assert remainingProcessingTime>=0, "the remaining processing cannot be negative"
wip[partID] = {
"task_id": WP_id,
"operator": operatorID,
"station": stationID,
"remainingProcessinTime": remainingProcessing,
"remainingProcessingTime": remainingProcessingTime,
"sequence": sequence
}
return data
......
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