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

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