2.4. Using GetSimulationFactories()

One way to establish a connection to a simulation target within
CADI is to instantiate a CADI simulation and to connect to one of
its targets.

To retrieve the list of available CADI simulation factories,
the caller must execute the GetSimulationFactories() method
in the CADI broker as shown in Figure 2.4. The result of this call is an array
of CADISimulationFactory pointers.

The list of simulation factories is static for a CADI broker,
therefore it is only required to retrieve the list once at the beginning
of a debug session.

Note

The caller is responsible for releasing, but not deleting,
all obtained simulation factory objects. It is not sufficient to
release only those that have been used to instantiate a simulation.

Figure 2.4. Getting the CADI simulation factories

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.

After retrieving the list of available simulation factories,
the next step is to call the ObtainInterface() method
of the CADI broker to check the compatibility of the requested factory.
A static_cast() is required for the interface
as described in Creating the CADIBroker.

After obtaining the appropriate CADI simulation factory, the
caller must prepare the configuration of the targeted platform.
This includes retrieving the available parameters and their settings.

Call the GetParamterInfos() method of CADISimulationFactory to
retrieve the parameter information. It returns a list with descriptions
of the configurable parameters (that is of data type CADIParameterInfo_t).
This includes information such as the parameter ID for later reference, the
parameter type, and the default value.

The caller can create a list of parameter values (of type CADIParameterValue_t)
that are used for configuration of the platform. This list must
end with an extra element that has the parameter ID 0xFFFFFFFF.
It is required to add this element because not all parameters require
setting and the order of the parameters within the list is undefined.

Note

Parameters that are not part of the value list sent by the
caller are set to their default value.

The ID 0xFFFFFFFF is equal to static_cast<uint32_t>(-1).

Figure 2.5. Instantiating a CADI simulation

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.

The list of parameter values is forwarded to the Instantiate() method
of the simulation factory. This call creates the actual CADI simulation.
It might also receive a pointer to a CADIErrorCallback object
and a pointer to a CADISimulationCallback object.
These objects are automatically registered to the newly instantiated
CADI simulation and must be provided by the caller.

The result of the simulation instantiation is a pointer to
a CADISimulation object as shown in Figure 2.5. A compatibility
check consisting of its ObtainInterface() method
and calling static_cast() must be performed.

After the CADI simulation is created, the simulation factory
is no longer required. The pointer to the corresponding CADISimulationFactory
can therefore be released. This can be safely done for the following
reasons:

the CADI
simulation is managed by the CADI broker

the simulation factory can be retrieved again from
the broker if required.