Coupling the the behavior of your Application with other tools using AutoFOCUS3 (AF3)

Introduction

AF3 alone cannot satisfy all the needs of system development: other tools are often needed, e.g., for modeling continuous behavior (for the environment or for analog parts of a system), for interoperability with legacy tools, or simply for using non-AF3 features in combination with AF3 (e.g., visualization).
In such cases, AF3 has cosimulation capabilities which allows to use AF3 simulation with other tools in a synchronous manner. This feature offers a web service interface that provides capabilities for other tools to follow and even manipulate a simulation of your AF3 model. This section describes how to configure and start a cosimulation in your AF3 model, and how cosimulation can be accessed by other tools.

Creating a Cosimulation Specification

To use the cosimulation feature, you have to create a cosimulation specification for the component you want to cosimulate. You can simulate either your entire component architecture or only some subcomponent.

To create a cosimulation specification for a component, open the context menu of the component and select "Cosimulation specification".



The Cosimulation Specification consists of two sections.

General Section


In this section you can set the following attributes that are used to configure the web service. From these three attributes, AF3 forms a location to which the cosimulation web service will be published by the following rule:
http://<ServiceHost>:<ServicePort>/<ServiceName>
That means, in the default case, the service will be published to: http://localhost:9999/ws/cosimulation

Type Representation Section


The cosimulation web service exports simulation data from your AF3 model. Depending on how you want to use this data, it is sometimes necessary to configure the service in a way that the data is suitably exported. In this section you can set the following attributes that are used to configure how simulation data and data types are represented in the web service. Save the cosimulation specification after you made any changes by entering <Strg> + S or selecting File -> Save from the menu.

Running a Cosimulation

To start the cosimulation, right-click on the Cosimulation Specification element in the Model Navigator and select "Run Cosimulation".


AF3 now publishes the web service to the location specified in the cosimulation specification and switches to the Simulation Perspective. The successful start of your web service is acknowledged by an information message popping up. After you have read it, you can simply close this message by clicking OK.



The Simulation Perspective is updated continously during the cosimulation, which means that you can watch and follow the behavior of your AF3 model even if it is completely controlled by another application.

Accessing a Cosimulation from another tool

While the cosimulation web service is running, you have access to AF3 simulation data from outside AF3. This includes information about the simulated model (e.g., inputs, outputs, data types), about the current simulation values, but also provides a possibility to manipulate the simulation from outside (e.g., by setting input values). All the possible operations are specified in the Cosimulation Service that is introduced in the following.

The Cosimulation Service

The Cosimulation Service provides the following methods that can be called from outside AF3. All data that that the web service takes or provides is encoded as simple Strings.

How to access the web service from another tool depends on the programming environment of the specific tool.
Here are some links to well known environments: