Delegate Modules

A delegate module is a JAR file containing the custom Java delegates for a simulation. Behavior Execution Engine loads the delegate module at the start of the simulation, and executes the delegate code contained within when it evaluates the corresponding opaque expressions in the state machines.

Building

Once you have created the project structure for your custom delegate module, you will need to build and deploy a JAR file, which Behavior Execution Engine will load at the start of the simulation. The JAR file contains delegate providers and the custom delegate code that will execute as the opaque expressions in your state machines are evaluated. Gradle is the build tool we use, as it has support for a number of IDEs, including Eclipse, IntelliJ IDEA, VS Code, and others. You can even use it from the command line. Behavior Execution Engine provides a build.gradle script with the samples and tutorials included in the installation; for more information, check out the README.txt file in the same location. However, you may build delegate modules using any Java build tool you prefer.

To learn more about Gradle, go to https://gradle.org.

Deploying

In order for Behavior Execution Engine to load the classes in your JAR file, you must either copy the JAR file to a subdirectory in your delegate module home directory or use the MoxieDelegateModulePaths stereotype to specify the directory that directly contains the JAR file. Your home directory is specified by the DelegateModuleHomePath that you may have configured during installation. You can use the install task in the sample Gradle build script to automatically copy the JAR file to a subdirectory in the directory you specify in the gradle.properties file.

Behavior Execution Engine will load JAR files in directories that exist directly under your delegate module home directory when running simulations. An example is <DelegateModuleHomePath>\com.agi.moxie.samples.balloonride\sample-balloon-ride.jar. Behavior Execution Engine will not load JAR files located directly in the root of your delegate module home directory or in subdirectories more than one level below it.

Debugging

As you write your delegates, you will likely want to have the ability to debug them as your simulation executes. For details on running the SysML client application to start the execution, see Running Simulations.

Using Debug Mode

The SysML Client offers a way to debug your delegates after deploying them to your project. On the Select Install Directory screen, there is a checkbox to enter Debug Mode. Selecting it gives the option to specify a port number. Once the session has started, connect to this port number in your preferred IDE and run a simulation. From that point, whenever the simulation runs, the process will stop at any breakpoints set in your delegate code, allowing you to step through your code as the engine executes the SysML model.

Figure 1: Debug Mode in the SysML Client Tool

The user-specified port number in the install screen may not be the actual port number used by the tool if that port is already being used by another process. In this case, the next available port number will be used. Verify this at the top of the page after hitting Continue.