JobShop post_proc gadgets now work on all different results

parent 69bab6d0
......@@ -27,63 +27,66 @@ class JSComponentGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
maxSimTime=data['general']['maxSimTime']
self.initializeTimeSupport(data)
date_format = '%d-%m-%Y %H:%M'
resultElements=data['result']['result_list'][-1]['elementList']
task_dict = {}
# loop in the results to find Operators
for element in resultElements:
if element['_class'] in self.COMPONENT_CLASS_SET:
componentId=element['id']
# add the component in the task_dict
task_dict[element['id']] = dict(
id=componentId,
text=componentId,
type='component',
open=False)
k=1
schedule=element['results'].get('schedule', [])
if schedule:
for record in schedule:
stationId = record['stationId']
stationClass = data["graph"]["node"][stationId]["_class"]
entranceTime=record['entranceTime']
taskId = record.get("task_id", None)
# text to be displayed (if there is no task id display just the stationId)
if not taskId:
task_to_display = record['stationId']
else:
task_to_display = taskId + "; " + record['stationId']
# get the exitTime from the record
exitTime = record.get("exitTime", None)
if exitTime == None:
# if there is no exitTime get it from the entranceTime of the next step
try:
exitTime=schedule[k]['entranceTime']
# if there is no next step
except IndexError:
exitTime=maxSimTime
k+=1
if stationClass in self.STATION_CLASS_SET:
task_dict[componentId+record['stationId']+str(k)] = dict(
id=componentId+record['stationId']+str(k),
parent=componentId,
text=task_to_display, #record['stationId']+"; "+taskId,
start_date=self.convertToRealWorldTime(
entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(
exitTime).strftime(date_format),
open=False,
entranceTime=entranceTime,
duration=exitTime-entranceTime,
)
# return the result to the gadget
result = data['result']['result_list'][-1]
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'project',
task.get('entranceTime'),task.get('id'))))
'''read the results'''
for result in data['result']['result_list']:
resultElements=result['elementList']
task_dict = {}
# loop in the results to find Operators
for element in resultElements:
if element['_class'] in self.COMPONENT_CLASS_SET:
componentId=element['id']
# add the component in the task_dict
task_dict[element['id']] = dict(
id=componentId,
text=componentId,
type='component',
open=False)
k=1
schedule=element['results'].get('schedule', [])
if schedule:
for record in schedule:
stationId = record['stationId']
stationClass = data["graph"]["node"][stationId]["_class"]
entranceTime=record['entranceTime']
taskId = record.get("task_id", None)
# text to be displayed (if there is no task id display just the stationId)
if not taskId:
task_to_display = record['stationId']
else:
task_to_display = taskId + "; " + record['stationId']
# get the exitTime from the record
exitTime = record.get("exitTime", None)
if exitTime == None:
# if there is no exitTime get it from the entranceTime of the next step
try:
exitTime=schedule[k]['entranceTime']
# if there is no next step
except IndexError:
exitTime=maxSimTime
k+=1
if stationClass in self.STATION_CLASS_SET:
task_dict[componentId+record['stationId']+str(k)] = dict(
id=componentId+record['stationId']+str(k),
parent=componentId,
text=task_to_display, #record['stationId']+"; "+taskId,
start_date=self.convertToRealWorldTime(
entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(
exitTime).strftime(date_format),
open=False,
entranceTime=entranceTime,
duration=exitTime-entranceTime,
)
# return the result to the gadget
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'project',
task.get('entranceTime'),task.get('id'))))
return data
......@@ -24,7 +24,7 @@ class JSComponentTabSchedule(plugin.OutputPreparationPlugin, TimeSupportMixin):
'''returns the id of the operator that has performed a certain task'''
# XXX searching in the last solution only
# XXX synchronize with the solution that is used by postprocess method
resultElements=self.data['result']['result_list'][-1]['elementList']
resultElements=self.result['elementList']
for element in resultElements:
if element.get("_class", None) in self.OPERATOR_CLASS_SET:
schedule = element["results"].get("schedule", [])
......@@ -38,7 +38,7 @@ class JSComponentTabSchedule(plugin.OutputPreparationPlugin, TimeSupportMixin):
STATION_CLASS_SET = set(["Dream.MouldAssembly", "Dream.MachineJobShop"])
def isActiveStation(self, ID):
'''returns True if station is an active station'''
resultElements=self.data['result']['result_list'][-1]['elementList']
resultElements=self.result['elementList']
for element in resultElements:
if element.get("_class", None) in self.STATION_CLASS_SET:
if element.get("id", None) == ID:
......@@ -63,54 +63,56 @@ class JSComponentTabSchedule(plugin.OutputPreparationPlugin, TimeSupportMixin):
data['general']['dateFormat']='%Y/%m/%d'
self.initializeTimeSupport(data)
date_format = '%d-%m-%Y %H:%M'
'''reading results'''
resultElements=data['result']['result_list'][-1]['elementList']
# create the titles row
result = data['result']['result_list'][-1]
result[self.configuration_dict['output_id']] = [['Job ID',
'Order',
'Due Date',
'Task ID',
'Station ID',
'Entrance Time',
'Processing Time',
'Operator']]
for element in resultElements:
if element.get("_class",None) in self.COMPONENT_CLASS_SET:
elementId = element.get("id", None)
order = self.findParentOrderById(elementId)
# due date
dueDate = order.get("dueDate", None)
# order
orderName = order.get("name", None)
'''schedule'''
results = element.get("results", {})
schedule = results.get("schedule", [])
if schedule:
for step in schedule:
# entranceTime
entranceTime = step.get("entranceTime", None)
exitTime = step.get("exitTime", None)
# processing time
processingTime = 0
if exitTime != None:
processingTime = round(exitTime - entranceTime, 2)
# stationId
stationId = step.get("stationId", None)
# task_id
task_id = step.get("task_id", None)
# operator
operatorId = ""
if self.isActiveStation(stationId):
operatorId = self.findOperatorByTaskId(task_id)
# if there is a taskId defined or the station is an assembly station (order decomposition is presented)
if task_id or stationId.startswith("ASSM"):
result[self.configuration_dict['output_id']].append([elementId,
orderName,
self.convertToFormattedRealWorldTime(dueDate),
task_id,
stationId,
self.convertToFormattedRealWorldTime(entranceTime),
processingTime,
operatorId])
for result in data['result']['result_list']:
self.result = result
resultElements=result['elementList']
# create the titles row
result[self.configuration_dict['output_id']] = [['Job ID',
'Order',
'Due Date',
'Task ID',
'Station ID',
'Entrance Time',
'Processing Time',
'Operator']]
for element in resultElements:
if element.get("_class",None) in self.COMPONENT_CLASS_SET:
elementId = element.get("id", None)
order = self.findParentOrderById(elementId)
# due date
dueDate = order.get("dueDate", None)
# order
orderName = order.get("name", None)
'''schedule'''
results = element.get("results", {})
schedule = results.get("schedule", [])
if schedule:
for step in schedule:
# entranceTime
entranceTime = step.get("entranceTime", None)
exitTime = step.get("exitTime", None)
# processing time
processingTime = 0
if exitTime != None:
processingTime = round(exitTime - entranceTime, 2)
# stationId
stationId = step.get("stationId", None)
# task_id
task_id = step.get("task_id", None)
# operator
operatorId = ""
if self.isActiveStation(stationId):
operatorId = self.findOperatorByTaskId(task_id)
# if there is a taskId defined or the station is an assembly station (order decomposition is presented)
if task_id or stationId.startswith("ASSM"):
result[self.configuration_dict['output_id']].append([elementId,
orderName,
self.convertToFormattedRealWorldTime(dueDate),
task_id,
stationId,
self.convertToFormattedRealWorldTime(entranceTime),
processingTime,
operatorId])
return data
......@@ -23,62 +23,63 @@ class JSOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
maxSimTime=data['general']['maxSimTime']
self.initializeTimeSupport(data)
date_format = '%d-%m-%Y %H:%M'
resultElements=data['result']['result_list'][-1]['elementList']
task_dict = {}
# loop in the results to find Operators
for element in resultElements:
if element['_class'] in self.OPERATOR_CLASS_SET:
operatorId=element['id']
k=1
schedule=element['results'].get('schedule', [])
if schedule:
for result in data['result']['result_list']:
resultElements=result['elementList']
task_dict = {}
# loop in the results to find Operators
for element in resultElements:
if element['_class'] in self.OPERATOR_CLASS_SET:
operatorId=element['id']
k=1
schedule=element['results'].get('schedule', [])
if schedule:
# add the operator in the task_dict
task_dict[element['id']] = dict(
id=operatorId,
text=operatorId,
type='operator',
open=False)
# add the operator in the task_dict
task_dict[element['id']] = dict(
id=operatorId,
text=operatorId,
type='operator',
open=False)
for record in schedule:
entranceTime=record['entranceTime']
exitTime = record.get("exitTime", None)
if not exitTime:
try:
exitTime=schedule[k]['entranceTime']
except IndexError:
exitTime=maxSimTime
k+=1
task_id = record.get("task_id", None)
if not task_id:
task_id = record["stationId"]
text_to_display = task_id
else:
entityId = record.get("entityId", None)
if not entityId:
text_to_display = task_id + " " + record["stationId"]
for record in schedule:
entranceTime=record['entranceTime']
exitTime = record.get("exitTime", None)
if not exitTime:
try:
exitTime=schedule[k]['entranceTime']
except IndexError:
exitTime=maxSimTime
k+=1
task_id = record.get("task_id", None)
if not task_id:
task_id = record["stationId"]
text_to_display = task_id
else:
text_to_display = task_id + " " + record["stationId"] + " " + entityId
task_dict[operatorId+task_id+str(k)] = dict(
id=operatorId+task_id+str(k),
parent=operatorId,
text=text_to_display,
start_date=self.convertToRealWorldTime(
entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(
exitTime).strftime(date_format),
open=False,
entranceTime=entranceTime,
duration=exitTime-entranceTime,
)
# return the result to the gadget
result = data['result']['result_list'][-1]
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'project',
task.get('entranceTime'),task.get('id'))))
entityId = record.get("entityId", None)
if not entityId:
text_to_display = task_id + " " + record["stationId"]
else:
text_to_display = task_id + " " + record["stationId"] + " " + entityId
task_dict[operatorId+task_id+str(k)] = dict(
id=operatorId+task_id+str(k),
parent=operatorId,
text=text_to_display,
start_date=self.convertToRealWorldTime(
entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(
exitTime).strftime(date_format),
open=False,
entranceTime=entranceTime,
duration=exitTime-entranceTime,
)
# return the result to the gadget
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'project',
task.get('entranceTime'),task.get('id'))))
return data
......@@ -7,61 +7,61 @@ class JSOperatorUtilization(plugin.OutputPreparationPlugin):
# XXX hardcoded values
JS_OPERATOR_CLASS_SET = set(["Dream.Operator"])
def postprocess(self, data):
result = data['result']['result_list'][-1]
for result in data['result']['result_list']:
ticks = []
working_data = []
waiting_data = []
failure_data = []
blockage_data = []
off_shift_data = []
ticks = []
working_data = []
waiting_data = []
failure_data = []
blockage_data = []
off_shift_data = []
options = {
"xaxis": {
"minTickSize": 1,
"ticks": ticks
},
"yaxis": {
"max": 100
},
"series": {
"bars": {
"show": True,
"barWidth": 0.8,
"align": "center"
options = {
"xaxis": {
"minTickSize": 1,
"ticks": ticks
},
"stack": True
"yaxis": {
"max": 100
},
"series": {
"bars": {
"show": True,
"barWidth": 0.8,
"align": "center"
},
"stack": True
}
}
}
series = [{
"label": "Working",
"data": working_data
}, {
"label": "Waiting",
"data": waiting_data
}, {
"label": "off_shift",
"data": off_shift_data
}];
series = [{
"label": "Working",
"data": working_data
}, {
"label": "Waiting",
"data": waiting_data
}, {
"label": "off_shift",
"data": off_shift_data
}];
out = result[self.configuration_dict['output_id']] = {
"series": series,
"options": options
}
out = result[self.configuration_dict['output_id']] = {
"series": series,
"options": options
}
i = 0
for obj in result['elementList']:
if obj.get('_class') in self.JS_OPERATOR_CLASS_SET:
objResults=copy(obj['results'])
if objResults['working_ratio']:
working_data.append((i, objResults['working_ratio'][0]))
if objResults['waiting_ratio']:
waiting_data.append((i, objResults['waiting_ratio'][0]))
if objResults['off_shift_ratio']:
off_shift_data.append((i, objResults['off_shift_ratio'][0]))
i = 0
for obj in result['elementList']:
if obj.get('_class') in self.JS_OPERATOR_CLASS_SET:
objResults=copy(obj['results'])
if objResults['working_ratio']:
working_data.append((i, objResults['working_ratio'][0]))
if objResults['waiting_ratio']:
waiting_data.append((i, objResults['waiting_ratio'][0]))
if objResults['off_shift_ratio']:
off_shift_data.append((i, objResults['off_shift_ratio'][0]))
ticks.append((i, obj.get('name', self.getNameFromId(data, obj['id']))))
i += 1
ticks.append((i, obj.get('name', self.getNameFromId(data, obj['id']))))
i += 1
return data
......@@ -7,72 +7,72 @@ class JSStationUtilization(plugin.OutputPreparationPlugin):
# XXX hardcoded values
JS_STATION_CLASS_SET = set(["Dream.MouldAssembly", "Dream.MachineJobShop"])
def postprocess(self, data):
result = data['result']['result_list'][-1]
for result in data['result']['result_list']:
ticks = []
working_data = []
waiting_data = []
failure_data = []
blockage_data = []
off_shift_data = []
ticks = []
working_data = []
waiting_data = []
failure_data = []
blockage_data = []
off_shift_data = []
options = {
"xaxis": {
"minTickSize": 1,
"ticks": ticks
},
"yaxis": {
"max": 100
},
"series": {
"bars": {
"show": True,
"barWidth": 0.8,
"align": "center"
options = {
"xaxis": {
"minTickSize": 1,
"ticks": ticks
},
"yaxis": {
"max": 100
},
"stack": True
"series": {
"bars": {
"show": True,
"barWidth": 0.8,
"align": "center"
},
"stack": True
}
}
}
series = [{
"label": "Working",
"data": working_data
}, {
"label": "Waiting",
"data": waiting_data
}, {
"label": "Failures",
"data": failure_data
}, {
"label": "Blockage",
"data": blockage_data
},
{
"label": "off_shift",
"data": off_shift_data
}];
series = [{
"label": "Working",
"data": working_data
}, {
"label": "Waiting",
"data": waiting_data
}, {
"label": "Failures",
"data": failure_data
}, {
"label": "Blockage",
"data": blockage_data
},
{
"label": "off_shift",
"data": off_shift_data
}];
out = result[self.configuration_dict['output_id']] = {
"series": series,
"options": options
}
out = result[self.configuration_dict['output_id']] = {
"series": series,
"options": options
}
i = 0
for obj in result['elementList']:
if obj.get('_class') in self.JS_STATION_CLASS_SET:
objResults=copy(obj['results'])
if objResults['working_ratio']:
working_data.append((i, objResults['working_ratio'][0]))
if objResults['waiting_ratio']:
waiting_data.append((i, objResults['waiting_ratio'][0]))
if objResults['failure_ratio']:
failure_data.append((i, objResults['failure_ratio'][0]))
if objResults['blockage_ratio']:
blockage_data.append((i, objResults['blockage_ratio'][0]))
if objResults['off_shift_ratio']:
off_shift_data.append((i, objResults['off_shift_ratio'][0]))
i = 0
for obj in result['elementList']:
if obj.get('_class') in self.JS_STATION_CLASS_SET:
objResults=copy(obj['results'])
if objResults['working_ratio']:
working_data.append((i, objResults['working_ratio'][0]))
if objResults['waiting_ratio']:
waiting_data.append((i, objResults['waiting_ratio'][0]))
if objResults['failure_ratio']:
failure_data.append((i, objResults['failure_ratio'][0]))
if objResults['blockage_ratio']:
blockage_data.append((i, objResults['blockage_ratio'][0]))
if objResults['off_shift_ratio']:
off_shift_data.append((i, objResults['off_shift_ratio'][0]))
ticks.append((i, obj.get('name', self.getNameFromId(data, obj['id']))))
i += 1
ticks.append((i, obj.get('name', self.getNameFromId(data, obj['id']))))
i += 1
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