In the element <workflow>
, one or more global
callbacks (either for Project Schematic or Workbench operations)
can be defined in a child element <callbacks>
.
ACT currently provides 11 Project Schematic operations, each of which supports both a pre-operation and post-operation callback. ACT also provides one non-Project Schematic Workbench operation for changing design points, which also supports both a pre-operation and post-operation callback.
The basic structure of a global callback definition follows.
<callbacks> <onbeforetaskreset></onbeforetaskreset> <onaftertaskreset></onaftertaskreset> <onbeforetaskrefresh></onbeforetaskrefresh> <onaftertaskrefresh></onaftertaskrefresh> <onbeforetaskupdate></onbeforetaskupdate> <onaftertaskupdate></onaftertaskupdate> <onbeforetaskduplicate></onbeforetaskduplicate> <onaftertaskduplicate></onaftertaskduplicate> <onbeforetasksourceschanged></onbeforetasksourceschanged> <onaftertasksourceschanged></onaftertasksourceschanged> <onbeforetaskcreation></onbeforetaskcreation> <onaftertaskcreation></onaftertaskcreation> <onbeforetaskdeletion></onbeforetaskdeletion> <onaftertaskdeletion></onaftertaskdeletion> <onbeforetaskcanusetransfer></onbeforetaskcanusetransfer> <onaftertaskcanusetransfer></onaftertaskcanusetransfer> <onbeforetaskcanduplicate></onbeforetaskcanduplicate> <onaftertaskcanduplicate></onaftertaskcanduplicate> <onbeforetaskstatus></onbeforetaskstatus> <onaftertaskstatus></onaftertaskstatus> <onbeforetaskpropertyretrieval></onbeforetaskpropertyretrieval> <onaftertaskpropertyretrieval></onaftertaskpropertyretrieval> <onbeforedesignpointchanged></onbeforedesignpointchanged> <onafterdesignpointchanged></onaftersignpointchanged> </callbacks>
See the following topics for additional information:
By default, if a global Project Schematic callback is
defined in the XML file, it is called for each instance of the Project
Schematic task associated with it. This applies to both
Ansys-installed and ACT-defined tasks. For example, if you have defined the
callback <onaftertaskupdate>
, it is invoked for
each task that is updated. If three tasks in the Project
Schematic are updated, the callback is invoked three times, once
after each update.
Unless otherwise noted, a global Project Schematic workflow callback receives a task as the method argument. Depending on the callback, the task is the concrete task displayed in the Project Schematic or the task template.
To specify that a callback is processed only for a specific location in the project, such as the task or template, you can perform a check within the callback implementation based on the supplied arguments. For example, in the following IronPython code sample:
The method
onBeforeUpdate
is unfiltered. The actions are invoked before the update of each eligible task in the Project Schematic.The method
onAfterUpdate
is filtered. It produces different messages for Engineering Data tasks and the second Setup task, while printing 'ignored' for all other tasks.Note: The Setup tasks for multiple Fluent task groups would be identified in the following sequence:
Setup
,Setup 1
,Setup 2
, and so on.The method
onBeforeDuplicate
is filtered. It prints a specific message for the Setup tasks for all Fluent tasks on the Project Schematic.
... def onBeforeUpdate(task): msg = getPrintMessage('pre-update', task) print msg def onAfterUpdate(task): if task.Name == "Engineering Data": msg = getPrintMessage('post-update', task) print msg elif task.Name == "Setup 2": print("fluent setup 2") else: print("ignored") def onBeforeDuplicate(task): if task.Container.Type == "Ansys.Fluent.Addin:SetupContainer": print("all fluent setups") else: print("ignored") ...
When multiple callbacks are defined for the same pre- or post-operation
Project Schematic action, you can specify their order
of execution by adding the order
attribute to the
callback declaration:
<workflow ...>
<callbacks>
<onbeforetaskreset order=”1”>...</onbeforetaskreset>
...
</callbacks>
</workflow>
ACT executes the callbacks from lowest order to highest order. This means that a callback with an order of 2 executes after a callback with an of order of 1. When values are identical, the order in which the extension is loaded dictates the collision resolution.
This section describes the global callback and corresponding methods and arguments for each Project Schematic operation.
-
Reset
Resets a component back to its pristine, new state.
Global Callbacks Methods Arguments <onbeforetaskreset>
onBeforeReset
task
<onaftertaskreset>
onAfterReset
-
Refresh
Consumes all upstream data and prepares any local data for an ensuing update.
Global Callbacks Methods Arguments <onbeforetaskrefresh>
onBeforeRefresh
task
<onaftertaskrefresh>
onAfterRefresh
-
Update
Generates all broadcast output types that render the component fully solved.
Global Callbacks Methods Arguments <onbeforetaskupdate>
onBeforeUpdate
task
<onaftertaskupdate>
onAfterUpdate
-
Create
Creates a task based on an underlying template.
Global Callbacks Methods Arguments <onbeforetaskcreate>
onBeforeCreate
templateTask
Note:This is a task representing the template. Some components do not include the template as a parameter to the command
create
. As a result, this could be null in some situations.<onaftertaskcreate>
onAfterCreate
task -
Delete
Removes a task from a task group.
Global Callbacks Methods Arguments <onbeforetaskdelete>
onBeforeDelete
task
<onaftertaskdelete>
onAfterDelete
-
Duplicate
Creates an identical, yet independent, clone of the task.
Global Callbacks Methods Arguments <onbeforetaskduplicate>
onBeforeDuplicate
task
<onaftertaskduplicate>
onAfterDuplicate
-
SourcesChanged
Processes a change in upstream sources.
Global Callbacks Methods Arguments <onbeforetasksourceschanged>
onBeforeSourcesChanged
task
<onaftertasksourceschanged>
onAfterSourcesChanged
-
CanUseTransfer
Checks whether the task can consume data from a specific upstream task.
Callback receives two tasks as arguments: the
source
(upstream producer) task andtarget
(downstream consumer) task.Global Callbacks Methods Arguments <onbeforetaskcanusetransfer>
onBeforeCanUseTransfer
sourceTask
,targetTask
<onaftertaskcanusetransfer>
onAfterCanUseTransfer
sourceTask
,targetTask
,systemCalculatedCanUse
Note: The argument
systemCalculatedCanUse
provides the result that the original task determined. The return value of this callback (Boolean) alters the originally calculated value.-
CanDuplicate
Checks whether the task permits duplication.
Callback receives no arguments. The Project Schematic does not provide any workable information to construct or provide tasks (either container-based or template-based). Callback only serves as a general “processing” hook if exposed.
Global Callbacks Methods Arguments <onbeforetaskcanduplicate>
onBeforeCanDuplicate
None <onaftertaskcanduplicate>
onAfterCanDuplicate
systemCalculatedCanUse
Note: The argument
systemCalculatedCanDuplicate
provides the result that the original task determined. The return value of this callback (Boolean) alters the originally calculated value.-
Status
Calculates the task’s current state.
Global Callbacks Methods Arguments <onbeforetaskstatus>
onBeforeStatus
task
<onaftertaskstatus>
onAfterStatus
task
,systemCalculatedStatus
Note: The argument
systemCalculatedStatus
provides the result that the original task determined. The return value of this callback component state alters the originally calculated value.-
PropertyRetrieval
Determines the visibility of property-containing objects.
Global Callbacks Methods Arguments <onbeforetaskpropertyretrieval>
onBeforePropertyRetrieval
task
<onaftertaskpropertyretrieval>
onAfterPropertyRetrieval
task
,systemCalculatedPropertyObject
Note: The argument
systemCalculatedPropertyObjects
provides the result that the original task determined. The return value of the callback (list of data references) alters the originally calculated value.
This section describes the global callback and corresponding methods for the non-Project Schematic Workbench operation for changing design points:
-
designpointchanged
Signals to workflow that a design point change is about to or has occurred.
Global Callbacks Methods <onbeforedesignpointchanged>
onBeforeDesignPointChanged
<onafterdesignpointchanged>
onAfterDesignPointChanged