Dispatching on classes during simulations of activity diagrams

Hello,

I would like to ask if there is a good way or modeling pattern to dispatch on classes during simulations of activity diagrams.

A simple example is attached.

  • The activity diagram is provided with 'sel' and 'dispatch' actions.
  • Action 'sel' decides, based on user inputs, whether one class or another should be selected. Classes from either branch are merged using a merge block.
  • With action 'dispatch' I would like the simulation to automatically determine what is being conveyed by the token and dispatch based on the class (creating one model if a basic toaster was selected as an option, creating another model if a toaster with optionals was selected as an option).

I was trying using 'instanceof' as I would do in Python, although that does not seem to work and the user is prompted with a selection (as opposed to one being picked automatically).

Is it feasible to automatically dispatch based on the class of the given AnyToaster?

I am using CSM 2021x

Thanks!