Co-simulation

Co-simulation allows the simulation of a POOSL model to interact with the outside world, and to synchronize multiple simulations. The POOSL mechanism for co-simulation is based on external system ports. Each external system port is implemented via an adapter that is specified in an external port configuration file (.ini). The examples bundle (download) contain three examples (FileCopy, SocketExample, and SocketExampleDistributed) that use co-simulation.

When debugging a POOSL model, the adapter instances are visible in the Debug View and in the Sequence Diagram. Moreover they can be inspected in the Execution Tree View after selecting one:

External System Ports: Model Syntax

External system ports are defined in the optional ports section of the system definition. The syntax for this section is identical to the syntax for ports of a cluster or process class.

Example

The following example POOSL model has 4 external system ports:

        system
        ports
            ep1
            ep2
            ep3
            ep4
        instances
            proc : MyProcess()
        channels
            { ep1, proc.port1 }
            { ep2, proc.port2 }
            { ep3, proc.port3 }
            { ep4, proc.port4 }
			

External System Ports: Configuration File

External system ports are connected to adapters as specified in the external port configuration file. This file is in the INI file format:

	[section]
	key1=value1
	key2=value2
			
Each external system port is described in one section of the file, where the name of the section is equal to the name of the external system port in the model. Each section has one mandatory key, namely the key "type", which defines the type of adapter for the external system port.

When launching a new POOSL model with an INI file in the same directory, this INI file will automatically be used. To manually select a different INI file, or adding one later on, the Launch Configuration settings can be used.

Example

The following example .ini file describes four external system ports of different types:

	[ep1]
	type=SocketClient
	hostname=localhost
	port_number=9060

	[ep2]
	type=SocketServer
	port_number=9060
	
	[ep3]
	type=FileIn
	filename=../FileToCopy.txt

	[ep4]
	type=FileOut
	filename=../CopiedFile.txt
			

External System Ports: Supported Adapter Types

The following list describes the currently supported adapter types, and their keys for specifying additional properties (if any):

* : The size of the buffer determines the maximum number of bytes can be received in one message. The default value is 10kbyte. Only adjust this option if you need to read more then 10kbyte of data in one receive statement.

Connection Status

When starting the simulation of a POOSL model, these adapters will automatically try to set-up their file or socket connection. If afterwards the file or socket connection is lost or closed, the adapter will not try to reconnect.

After the connection has been lost or closed, the adapter blocks all messages except for status messages like isConnected(Boolean) as specified below. Thus the simulation engine can determine that the model has terminated if the model is only waiting for external input.

Supported messages on external ports

The following lists contain the messages that can be send and received by the various adapters. The supported messages can also be observed in the Execution Tree view by selecting an adapter instance in the Debug View; see the earlier screenshot on this page. Note that the messages that can be received by the adapter need to be send by the rest of the model, for example, ep!writeString("word").

Be aware that the IDE does not validate whether the used external port messages in the POOSL model are supported by the adapter selected in the INI file.

SocketClient and SocketServer messages

FileOut messages

FileIn messages

Console messages