Creating Your First SysML v2 Delegate Module
In the first exercise, you explored how to use Behavior Execution Engine to build and execute a simple model for the race between the tortoise and the hare. This exercise is going to take the concepts you previously learned and use Behavior Execution Engine delegates to expand and refine the functionality. In the first example, you intentionally introduced several deficiencies: fixed timestep, imprecise event finding, etc. This tutorial will help you remedy them through your use of delegates. You will also be able to simplify the part definitions and associated state diagrams.
After you complete this exercise, you will understand the basics of the following:
- Building a simulation intending to use delegates during execution
- Customizing delegate implementations
- Building, deploying, and executing a simulation with delegates
Before you start, if you have not already completed the first tutorial (Simple Version), we highly recommend you do so. Also, it may be useful to read through the materials in the Developing Delegate Modules section of the help so you are familiar with the terms that will be used during this training.
Also, ensure that you have downloaded and configured Gradle version 5.6 or newer. This lesson will assume you are using an integrated software development environment (IDE), but it does not require one. If you are interested in guidance for setting up an IDE, review the Developer Environment section of the help.
Section | Description |
---|---|
Updating the Part Definitions for the System |
The basic design of the race, in terms of part definitions, will be the same as the previous version. The part definitions specified for Race, a Racer, etc. still meet all the underlying needs and concepts for an animal race. However, because you will be leveraging the delegate system to implement this version, you will need to make several changes. |
Updating the Diagrams |
This step involves replacing functionality for the start and stop racing actions. When delegating for an action, it is important to keep in mind that Behavior Execution Engine will ignore any of the delegated action’s owned actions. For our model, this means the implementation details of the Racer diagram are no longer necessary, and can be deleted. |
Code Creation |
Now that you have finished updating the state diagrams to reflect the new approach to modeling the behavior, you are ready to start writing some code. Ensure that you have Gradle installed and configured correctly, as that is the build script you will be using for this example. Behavior Execution Engine provides a delegate source code project template to assist you in authoring the code base for execution. The folder can be found in the <BEE Install Directory>/samples/sysml2/build. The prepared template files will serve as the skeleton to which you can add all the meat (backing code) that facilitates the bespoke functionality you need for the simulation. To start this process, you’ll need to configure the directory to work with the delegate files. |
Writing and Modifying Delegates |
Now you need to provide the code implementation for overriding the distance covered by the racers. Building a delegate module with the SysML v2 API has never been easier. The code required to get up is small and only needs to be setup once. The <BEE Install Directory>/samples/sysml2/tutorialTortoiseVsHare/part-2 contains the completed delegate module that you can reference at any time. |
Start Tutorial!