2.2.1. CADIBroker

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

The CreateCADIBroker() function in a model library indicates the presence of a CADI interface. The function returns a pointer to a CADIBroker object. The function can be implemented in one of two ways depending on how the broker is implemented in the addressed library:

The following mechanisms support connecting to a simulation:

Connecting 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 new 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:

Selecting and connecting to a simulation

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 exactly at the same moment 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 the client is represented by a CADI broker. The server might be, for example, directly embedded into a simulation platform or implemented within an environment that runs the simulation.

Retrieving a list of simulation factories and instantiating a new simulation

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 simulation objects are directly owned by the broker).

For more information on this connection mechanism, see the CADISimulationFactory.

Setting preprocessor defines

In Example 2.1, 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 pre-processor 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 pre-processor 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 pre-processor define EXPORT_CADI, but setting the pre-processor 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 pre-processor defines EXPORT_ESLAPI and NO_IMPORT_ESLAPI. This macro declares the symbol attributes for CAInterface. Because CADI is derived from CAInterface, these pre-processor defines must be set if building a model DLL that exposes a CADI interface.

Copyright © 2008-2011 ARM. All rights reserved.ARM DUI 0444H