2.5. Getting existing CADI simulations

If the caller connects to a running CADI simulation, it must retrieve information on already existing simulations by calling the GetSimulationInfos() method of the CADI broker as shown in Figure 2.6. This call returns an internal list of available simulations that is maintained by the broker. The number of elements retrieved depends on:

The list of existent simulations held by the broker can change dynamically, so it might be necessary to update this list regularly to detect the creation or destruction of CADI simulations.

Figure 2.6. Getting information on existing CADI simulations

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.


Based on the acquired information, the caller uses SelectSimulation() to select a simulation to attach to. To specify a simulation, its ID (as part of the simulation info) must be used.

SelectSimulation() might receive pointers to a CADIErrorCallback object and a CADISimulationCallback object. These objects are automatically registered to the requested simulation and must be provided by the caller.

Note

It is not required that a specific simulation ID matches the corresponding index for the simulation within the internal list held by the broker.

Figure 2.7. Getting an existing 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 result of SelectSimulation() is a CADISimulation pointer to the requested simulation. The ObtainInterface() method and the static_cast scheme must be applied to check validity.

Example 2.4 shows a typical implementation:

Example 2.4. Getting an existing CADI simulation

//having already obtained a pointer to the CADIBroker before
//which is called cadi_broker
MyCADIErrorCallback errorCallbackObject;
MyCADISimulationCallback simulationCallbackObject;
char simulationCallbacksEnable[eslapi::CADI_SIM_CB_Count];
memset(simulationCallbacksEnable,
       1, eslapi::CADI_SIM_CB_Count * sizeof(char)); //enable all callbacks
uint32_t desiredNumberOfSimulations = 10;
uint32_t startSimulationInfoIndex = 0;
uint32_t actualNumberOfSimulations = 0;
eslapi::CADISimulationInfo_t* simulationList = new
              eslapi::CADISimulationInfo_t[desiredNumberOfSimulations]();
eslapi::CADIReturn_t status;
status = cadi_broker->GetSimulationInfos(startSimulationInfoIndex,
                                         desiredNumberOfSimulations,
                                         simulationList,
                                         &actualNumberOfSimulations);
if (status != eslapi::CADI_STATUS_OK)
{
     //GetSimulationInfos() failed
}
//... decide which simulation to connect to, for this example using the
//second one (index '\1'!!)...
CADISimulation* cadi_simulation 
               = cadi_broker->SelectSimulation(simulationList[1].id,
                                               &errorCallbackObject,
                                               &simulationCallbackObject,
                                               simulationCallbacksEnable);
if (cadi_simulation == NULL)
{
     //connection to simulation failed
}
//check compatibility
eslapi::if_name_t ifNameSimulation = "eslapi.CADISimulation2";
eslapi::if_rev_t  minRevSimulation = 0;
eslapi::if_rev_t  actualRevSimulation = 0;
if (cadi_simulation->ObtainInterface(ifNameSimulation,
                                     minRevSimulation,
                                     &actualRevSimulation) == NULL)

Note

The size of eslapi::CADISimulationInfo_t is approximately 8kB. When allocating arrays of this object on the stack, you must take care that stack allocation limits are not exceeded.

Copyright © 2008-2014 ARM. All rights reserved.ARM DUI 0444M
Non-ConfidentialID051314