2.2.1 CADIBroker

The CADIBroker is is the central element of the target connection mechanism. It establishes the connection to existing simulations and the instantiation of new simulations. This section describes it.

CADIBroker creation

The CreateCADIBroker() function in a model library indicates the presence of a CADI interface. The function returns a pointer to a CADIBroker object.

You can implement the function in one of two ways depending on how the broker is implemented in the addressed library:

  • The CADI broker is a singleton object and the call returns a pointer to it.
  • A new CADI broker object is instantiated and the call returns a pointer to it.

Example 2-1 Obtaining a pointer from a new CADIBroker object

CADI_WEXP eslapi::CADIBroker* CreateCADIBroker()
{
    return (new MyCADIBroker());
}            

CADI simulation connection

This section describes mechanisms for connecting to a simulation.

Connect to an existing simulation
The broker returns details of all running simulations. This information is used to create a connection to an existing simulation.
Create a simulation and connect to it
The broker returns a list of simulation factories. This information is used to instantiate a new simulation.

For both connection methods, the debugger must cleanly disconnect from running simulations. Disconnection is required for:

  • Shutting down a simulation because of an event in the simulation or debugger.
  • Ending the debugger session, but keeping alive the simulation for other current or future debug connections.

Connect to an existing simulation: simulation selection and connection

The SelectSimulation() method receives two pointers to callback objects (CADISimulationCallback and CADIErrorCallback) and an array containing the enable vector for CADISimulationCallback. These callback objects might be used during the SelectSimulation() call if, for example, the simulation wants to shut down at the same moment that the debugger starts connecting to it.

SelectSimulation() also forwards the callback objects to the returned CADI simulation.

The CADISimulationCallback object provides the CADISimulation object with a mechanism to guarantee a clean disconnect of the debugger.

This way of connecting is typically associated with a server-client technique where a CADI broker represents the client. The server might be, for example, directly embedded into a simulation platform or implemented within an environment that runs the simulation.

Create a simulation and connect to it: simulation factory list retrieval and simulation instantiation

The broker returns a list of pointers to the available simulation factories. The broker controls the simulation factory objects. It must destroy them before it is released.

After a CADI simulation factory is obtained, it is used to establish a connection to a newly instantiated CADI simulation:

  1. The simulation is instantiated.
  2. The new simulation returns a pointer to the corresponding CADISimulation object.
  3. The pointer is used to select a target in the simulation and connect to it.

In addition to managing the simulation factories, the CADI broker is also responsible for the CADI simulation objects (especially if the broker directly owns the simulation objects).

Preprocessor define settings

This section describes the preprocessor define settings.

Example 2-2 Obtaining a pointer from a new CADIBroker object

CADI_WEXP eslapi::CADIBroker* CreateCADIBroker()
{
    return (new MyCADIBroker());
}            

The MyCADIBroker class implements the CADI broker. The macro CADI_WEXP preceding the function prototype is only relevant for exporting this symbol from a Windows DLL:

  • Setting the preprocessor define EXPORT_CADI sets CADI_WEXP to __declspec(dllexport) that makes the CreateCADIBroker() function call to be an exported symbol for the built model DLL.
  • Not setting the preprocessor defines EXPORT_CADI and NO_IMPORT_CADI causes CADI_WEXP to be set to __declspec(dllimport). This makes the CreateCADIBroker() function call an imported symbol for the built model DLL.
  • Not setting the preprocessor define EXPORT_CADI, but setting the preprocessor define NO_IMPORT_CADI, defines CADI_WEXP to be empty.

For more information on these settings, see the CADICommon.h file.

A similar scheme applies to the macro ESLAPI_WEXP and the preprocessor defines EXPORT_ESLAPI and NO_IMPORT_ESLAPI. This macro declares the symbol attributes for CAInterface. Because CADI is derived from CAInterface, these preprocessor defines must be set if building a model DLL that exposes a CADI interface.

Non-ConfidentialPDF file icon PDF versionARM 100963_0200_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.