You can use callbacks to change the structure of a workflow if certain conditions are met. In the following example, if the input raster for ISODATA classification has fewer than five bands, the workflow will skip the smoothing step. If the input raster has more than five bands, the workflow will execute the smoothing step.

Copy and paste this code into the IDL Editor. Save the file as rewire_workflow.pro. Then compile and run the program.

; This is the routine to invoke using the POSTEXECUTE callback.
; It accepts the workflow as an argument.
 
PRO rewire_workflow_postexecute, workflow, _REF_EXTRA=refExtra
COMPILE_OPT IDL2
 
; Access steps by their NAME property
step1 = workflow.GetStep('step_1')
step2 = workflow.GetStep('step_2')
step3 = workflow.GetStep('step_3')
 
; Check the input number of bands and connect steps accordingly
IF (workflow.CURRENT_STEP.task.NUMBER_OF_CLASSES LE 5) THEN BEGIN
  workflow.Disconnect, step1, step2
  workflow.Disconnect, step2, step3
  workflow.Connect, step1, 'OUTPUT_RASTER', step3, 'INPUT_RASTER'
ENDIF ELSE BEGIN
  workflow.Disconnect, step1, step3
  workflow.Connect, step1, 'OUTPUT_RASTER', step2, 'INPUT_RASTER'
  workflow.Connect, step2, 'OUTPUT_RASTER', step3, 'INPUT_RASTER'
ENDELSE
END
 
; ----------------------------------------------------
; This is the workflow routine
 
PRO rewire_workflow
COMPILE_OPT IDL2
 
; Start the application
e = ENVI()
 
; Create and customize a workflow
workflow = ENVIWorkflow()
workflow.TITLE = 'Classification Workflow'
workflow.DESCRIPTION = 'Goal: to segment an image into meaningful categories'
 
; Add a step for ISODATA classification
step1 = ENVIWorkflowStep()
step1.TASK = ENVITask('ISODATAClassification')
step1.TIMELINE_TITLE = 'Classification'
step1.NAME = 'step_1'
 
; After the task runs, call the
; rewire_workflow_postexecute routine
step1.CALLBACK_POSTEXECUTE = 'rewire_workflow_postexecute'
 
; Add a step for classification smoothing
step2 = ENVIWorkflowStep()
step2.TASK = ENVITask('ClassificationSmoothing')
step2.TIMELINE_TITLE = 'Smoothing'
step2.NAME = 'step_2'
 
step3 = ENVIWorkflowStep()
step3.TASK = ENVITask('ClassificationToShapefile')
step3.TIMELINE_TITLE = 'Export'
step3.NAME = 'step_3'
 
workflow.Connect, step1, 'OUTPUT_RASTER', step2, 'INPUT_RASTER'
workflow.Connect, step2, 'OUTPUT_RASTER', step3, 'INPUT_RASTER'
 
envi.UI.CreateWorkflowDialog, workflow
END

See Also


Customize Workflows