operators not presented in Gantt if they have no schedule

parent d3eaf9c2
......@@ -29,17 +29,19 @@ class JSOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
for element in resultElements:
if element['_class'] in self.OPERATOR_CLASS_SET:
operatorId=element['id']
# add the operator in the task_dict
task_dict[element['id']] = dict(
id=operatorId,
text=operatorId,
type='operator',
open=False)
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)
for record in schedule:
entranceTime=record['entranceTime']
exitTime = record.get("exitTime", None)
......@@ -48,11 +50,21 @@ class JSOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
exitTime=schedule[k]['entranceTime']
except IndexError:
exitTime=maxSimTime
k+=1
task_dict[operatorId+record['stationId']+str(k)] = dict(
id=operatorId+record['stationId']+str(k),
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"]
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=record['stationId'],
text=text_to_display,
start_date=self.convertToRealWorldTime(
entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(
......@@ -60,8 +72,7 @@ class JSOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
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(
......
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