Skip to content

Commit ae35d72

Browse files
committed
Resurrecting Sequence Graph Capabilities to Task Class2:
- fixing other instances where Tasks are generated in irma.py with names being mentioned as the first argument, - sequence Graph updates duration and actions_ti - allowing actions fed into tasks to be either list or dictionary for flexibility
1 parent 793667e commit ae35d72

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

famodel/irma/irma.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,11 @@ def registerTask(self, task):
350350
self.tasks[task.name] = task
351351

352352

353-
def addTask(self, actions, action_sequence, task_name, **kwargs):
353+
def addTask(self, task_name, actions, action_sequence, **kwargs):
354354
'''Creates a task and adds it to the register'''
355355

356356
# Create the action
357-
task = Task(actions, action_sequence, task_name, **kwargs)
357+
task = Task(task_name, actions, action_sequence, **kwargs)
358358

359359
# Register the action
360360
self.registerTask(task)
@@ -454,7 +454,7 @@ def implementStrategy_staged(sc):
454454
act_sequence[acts[i].name] = [ acts[i-1].name ] # (previous action must be done first)
455455

456456
# create the task, passing in the sequence of actions
457-
sc.addTask(acts, act_sequence, 'install_all_anchors')
457+
sc.addTask('install_all_anchors', acts, act_sequence)
458458

459459
# ----- Create a Task for all the mooring installs -----
460460

@@ -478,7 +478,7 @@ def implementStrategy_staged(sc):
478478
act_sequence[acts[i].name] = [ acts[i-1].name ] # (previous action must be done first)
479479

480480
# create the task, passing in the sequence of actions
481-
sc.addTask(acts, act_sequence, 'install_all_moorings')
481+
sc.addTask('install_all_moorings', acts, act_sequence)
482482

483483

484484
# ----- Create a Task for the platform tow-out and hookup -----
@@ -501,7 +501,7 @@ def implementStrategy_staged(sc):
501501
act_sequence[acts[i].name] = [ acts[i-1].name ] # (previous action must be done first)
502502

503503
# create the task, passing in the sequence of actions
504-
sc.addTask(acts, act_sequence, 'tow_and_hookup')
504+
sc.addTask('tow_and_hookup', acts, act_sequence)
505505

506506

507507

famodel/irma/task.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def __init__(self, name, actions, action_sequence=None, **kwargs):
5858

5959

6060
self.name = name
61-
self.actions = {a.name: a for a in actions.values()}
61+
62+
if isinstance(actions, dict):
63+
self.actions = actions
64+
elif isinstance(actions, list):
65+
self.actions = {a.name: a for a in actions}
66+
6267

6368
if action_sequence is None:
6469
self.stageActions(from_deps=True)
@@ -186,6 +191,8 @@ def level_of(a: str, b: set[str]) -> int:
186191
elif acts and lv > num_cps:
187192
cp_string.append(f"End: {', '.join(acts)}")
188193
# Assign to self:
194+
self.duration = task_duration
195+
self.actions_ti = {a: level_start_time[lv] for a, lv in levels.items()}
189196
self.sequence_graph = H
190197
title_str = f"Task {self.name}. Duration {self.duration:.2f} : " + " | ".join(cp_string)
191198
if plot:

0 commit comments

Comments
 (0)