buffers not displayed in component Gantt. task_id also displayed

parent 8a42de9a
......@@ -7,12 +7,15 @@ from dream.plugins.TimeSupport import TimeSupportMixin
import datetime
class JSComponentGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
# XXX hardoced classes of different components to be displayed in the gantt
'''class that gets the results and prepares the data for the component gantt graph'''
# XXX hard-coded classes of different components to be displayed in the gantt
COMPONENT_CLASS_SET = set(["Dream.OrderComponent", "Dream.OrderDesign", "Dream.Mould"])
# XXX hard-coded classes of stations to be displayed in the gantt
STATION_CLASS_SET = set(["Dream.MachineJobShop", "Dream.MouldAssembly"])
def postprocess(self, data):
"""Post process the data for Gantt gadget
"""
print "trying to prepare gantt data for components"
strptime = datetime.datetime.strptime
# read the current date and define dateFormat from it
try:
......@@ -29,7 +32,6 @@ class JSComponentGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
# loop in the results to find Operators
for element in resultElements:
if element['_class'] in self.COMPONENT_CLASS_SET:
print element["id"]
componentId=element['id']
# add the component in the task_dict
task_dict[element['id']] = dict(
......@@ -43,24 +45,38 @@ class JSComponentGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
schedule=element['results'].get('schedule', [])
if schedule:
for record in schedule:
stationId = record['stationId']
stationClass = data["graph"]["node"][stationId]["_class"]
entranceTime=record['entranceTime']
try:
exitTime=schedule[k]['entranceTime']
except IndexError:
exitTime=maxSimTime
k+=1
task_dict[componentId+record['stationId']+str(k)] = dict(
id=componentId+record['stationId']+str(k),
parent=componentId,
text=record['stationId'],
start_date=self.convertToRealWorldTime(
entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(
exitTime).strftime(date_format),
open=False,
entranceTime=entranceTime,
duration=exitTime-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 = record['stationId']+"; "+taskId
# 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]
......
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