Aller au contenu principal

Debugging

When you execute a simulation scenario, you might not reach the expected behavior. However, there are several steps that you can follow to find where the issues come from.

Using Virtual Bench

First and foremost, do not assume that the problem comes from your Designer Papyrus model, it is a good practice to first examine into your Virtual Bench scenario in order to monitor your flows and thus understand if the issue is related to the scenario or related to the model. For this, you can refer to this page. The simulation may also help you understand where in your model, the source of the issue comes from.

Designer

How to log the traces?

Once you know which flows are displayed in the Debug HMI, you might know if the issue is coming from the model or not. If it is potentially the case, you can check which flows or activities are triggered inside your model. The way you can trace these flows and activities in Sim4Sys Designer is by accessing their bodies (Right Click on a flow/activity > Edit > Edit body).

Accessing the body of the activity with the bulb example

Now you need to look at the first line, which should look like this by default (if it is not the case, you can manually write it yourself):



Commented std cout line

The green color indicates that the line is commented (it means that it is disabled). Removing the "//" at the beginning of the line will uncomment it, and enable the log.

You can display log directly into the console using std::cout << "your_text_here" << std::endl;

Uncommented std cout line

remarque

You need to regenerate the code once you made changes. After adding new logs in your code, press the Generate and Build button to make the modifications effective.

For example, when triggering a simu-to-model flow, you should see a log as in the picture below:

Log in console with the bulb example

What should we look in the logs?

You can now see which flows are triggered in your model. By creating a log in the bodies of every flows and activities, you can detect an error more easily.

If some logs are missing, you can check:

  • If the logic of the diagram is correct
  • If the state machine is correctly generated. You may need to delete and recreate the state machine's transition. You may also check that each trigger has a unique behavior (meaning it does not appear twice in the state machine). Find more information about generating state machines here.
  • If the parameters values are correct. For this, you can add logs in an activity or in a flow in order to display its value. You can follow the example below:
Logging speed value in designer

Console display:



Logging speed value in console