How to stop processing a step in a nested State Machine in Automate using MIQ_STOP


#1

The following steps describe how to stop processing of a state machine within another state machine, allowing the higher level state machine to continue processing.

Using “exit MIQ_ABORT” in an Automate method will stop ALL subsequent resolutions in the current instantiation.
Using “exit MIQ_STOP” in an Automate method will stop the processing of the current resolution. It does not affect subsequent resolutions.

State Machine 1 (SM1) calls State Machine 2 (SM2).

You are running a step in SM2 (SM22) and you wish to stop running SM2 and return to SM1.

If you configure SM2 like this, an exit MIQ_STOP will stop SM2 and return to SM1 and continue SM1.
image

If you configure SM2 like this, an exit MIQ_STOP will stop SM2 and return to SM1 and continue SM1.

image

If you configure SM2 like this, an exit MIQ_STOP will continue to the next step in SM2.

If you configure SM2 like this, an exit MIQ_ABORT will abort SM2 and SM1.

image

Workaround:

You could make the following changes to have this behave the same way as a METHOD:: call.

In miq_stop method:

You could set a root variable in the method and then have the On Error, On Exit or On Entry State Machine check for that value and then issue the exit MIQ_STOP.

  1. Set a root variable in the method to value = ‘stop’. Notice the exit MIQ_STOP is commented out:

#

# miq_stop method for workaround

#

$evm.root['stopme'] = 'stop'

$evm.log("info","Setting a root variable to 'stop' .")

# exit MIQ_STOP

  1. In your On Error, On Exit or On Entry State Machine method, check the value of the root variable and if true, exit MIQ_STOP:

#  

# On Error, On Entry, On Exit method

#

$evm.log("info","If root variable = 'stop' then exit MIQ_STOP")

if $evm.root['stopme'] = 'stop'

  exit MIQ_STOP

end