Skip to main content

QSP Improvements to Model Debugger

K
Written by Kay Chen

This article outlines several improvements made to the Model Debugger in QSP Designer. These enhancements are designed to boost debugging capabilities and enhance overall ease of use.

Enhancements to the Model Code Debugger in QSP Designer

The model code debugger in QSP Designer is a powerful tool that allows for model simulation while providing additional information to help locate and identify problems. Similar to a typical Integrated Development Environment (IDE), it enables viewing the executable code that comprises the composite model. During simulation, users can pause and examine the values of quantities and reactions at times of interest. This can be done manually or via breakpoints that pause execution when certain (optional) conditions are met. When the debugger is paused, it is possible to “step through” the execution of the model code line-by-line.

This project introduces several enhancements to the debugger:

  1. Debugging the Initialization Function

    The initialization function is responsible for creating model quantities at the beginning of the simulation, calculating and assigning initial values, and determining the values of various auxiliary variables such as runtime index sizes. Previously, it was not possible to pause execution or inspect the values of created quantities/variables within this function. This project adds the capability to debug the initialization function, allowing for more thorough examination and troubleshooting.

  2. Search Functionality

    Users can now search through the currently displayed function for strings of interest. This quality-of-life improvement allows for quicker navigation and easier identification of specific code segments.

These enhancements significantly improve the debugging capabilities and overall ease of use of the QSP Designer model code debugger.

Change to the User Interface

Debugging the Initialization Function

The initialization function now behaves like other debuggable functions, allowing breakpoints to be set. However, unlike the Rate Step function, breakpoints in the initialization function cannot have associated conditions. This limitation arises because conditions can only be applied once all quantities are determined, necessitating the full initialization of the model.

As a result, an active breakpoint in the initialization function does not display a downward "select condition" arrow, unlike other functions.

Active breakpoints can be set on all functions except the "Initialization" function.

Another consequence is that the Breakpoint Conditions tab in the Break Manager window does not permit the creation of breakpoint conditions until the Initialization function has fully executed. If you open this window before that stage, a warning message will appear (as shown in the screenshot below), and the controls for creating and editing breakpoint conditions will be disabled. However, Global Triggers remain supported, and their controls function as usual.

Enhanced Search Within Functions

A simple search capability has been added to the top-right of the function view, available for all functions. If the search field is empty, no additional information is displayed, and the "Find" button is disabled.

Users can type a string and click the "Find" button to search within the function. The number of matches is displayed below, along with buttons to navigate between matches (left and right arrow buttons). Matching results are highlighted in yellow within the function text, as shown in the screenshot below (where the string "MD" is highlighted throughout the function).

Clicking the arrows sequentially focuses on each matched string, moving forwards or backwards, with the current focused match highlighted in orange. The function view will also auto-scroll to the focused match when these arrows are clicked.

If no matches are found for the entered string, a "No matches" message is displayed to the user, as shown in the screenshot below.

Did this answer your question?