Defining a Global Callback

Within the <workflow> block, one or more global callbacks (either for schematic or Workbench operations) can be defined in a child <callbacks> block.

ACT currently provides 22 schematic callbacks. Each of the 11 operations available on the Project Schematic support both a pre- and post-operation callback.

ACT also provides two non-schematic, Workbench callbacks. The change design point operation supports both a pre- 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>

Related Topics:

Invoking Global Callbacks

By default, if a global schematic callback is defined in the XML definition file, it is called for each instance of the schematic task associated with it. This applies to both pre-installed (non-ACT) and custom tasks. For example, if you have defined the callback <onaftertaskupdate>, it is invoked for each task that is updated. If three tasks on the Project Schematic are updated, the callback is invoked three times, once after each update.

Unless otherwise noted, a global schematic workflow callback receives a task as the method argument. Depending on the callback, the task is the concrete task displayed in the schematic or the task template.

Filtering Global Callbacks

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 on the 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 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")
...

Specifying Global Callback Execution Order

When multiple callbacks are defined for the same pre- or post-operation 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.

Available Schematic Callbacks

This section describes the global callback and corresponding methods and arguments for each schematic operation.


Note:  Any hyphenation within long table entries can be ignored. Callbacks and methods do not include hyphens.


Reset

Resets a component back to its pristine, new state.

Global CallbacksMethodsArguments

<onbeforetaskreset>

onBeforeReset

task

<onaftertaskreset>

onAfterReset

Refresh

Consumes all upstream data and prepares any local data for an ensuing update.

Global CallbacksMethodsArguments

<onbeforetaskrefresh>

onBeforeRefresh

task

<onaftertaskrefresh>

onAfterRefresh

Update

Generates all broadcast output types that render the component fully solved.

Global CallbacksMethodsArguments

<onbeforetaskupdate>

onBeforeUpdate

task

<onaftertaskupdate>

onAfterUpdate

Create

Creates a task based on an underlying template.

Global CallbacksMethodsArguments

<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 CallbacksMethodsArguments

<onbeforetaskdelete>

onBeforeDelete

task

<onaftertaskdelete>

onAfterDelete

Duplicate

Creates an identical, yet independent, clone of the task.

Global CallbacksMethodsArguments

<onbeforetaskduplicate>

onBeforeDuplicate

task

<onaftertaskduplicate>

onAfterDuplicate

SourcesChanged

Processes a change in upstream sources.

Global CallbacksMethodsArguments

<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 and target (downstream consumer) task.

Global CallbacksMethodsArguments

<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 schematic does not provide any workable information to construct or provide tasks (either container-based or template-based). Callback only serve as a general “processing” hook if exposed.

Global CallbacksMethodsArguments

<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 CallbacksMethodsArguments

<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 CallbacksMethodsArguments

<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.

Available Workbench Callbacks

This section describes the global callback and corresponding methods for each non-schematic Workbench operation.

designpointchanged

Signals to workflow that a design point change is about to or has occurred.

Global CallbacksMethods

<onbeforedesignpointchanged>

onBeforeDesignPointChanged

<onafterdesignpointchanged>

onAfterDesignPointChanged


Release 18.2 - © ANSYS, Inc. All rights reserved.