[Previous] [Next] [Contents] [Index]


    The PostMaster

This chapter is a reference to the communication mechanism in the Telelogic Tau tools, the PostMaster. The functionality of the PostMaster makes it possible to integrate applications by using a well-defined means of communication.

Table of Contents 

Introduction to the PostMaster

Caution! 

The PostMaster was originally designed and implemented for integrating tools in the SDT environment. Currently it integrates tools in the Telelogic Tau environment. Our experience is that the PostMaster is also suitable for integrating external tools and applications with the Telelogic Tau applications; one application area is for instance quick prototyping.

However, Telelogic does not support using the PostMaster as a communication mechanism between real-time applications, in a run-time environment.

The PostMaster is the mechanism used for communication between the different tools in Telelogic Tau. A C program generated by the Telelogic Tau tools can also take advantage of this communication mechanism. It can communicate with any application connected to the PostMaster that send messages according to a defined format. This makes it possible for an SDT simulator to communicate with, for instance, a user interface process for the Simulator.

The PostMaster also provides the basic means for the Open Telelogic Tau concept, see The Telelogic Tau Public Interface.

The PostMaster provides the following functionality:

The PostMaster is a message passing service based on a selective broadcasting mechanism. It will distribute a copy of each message it receives to the tools subscribing to that type of message. By this, the PostMaster provides an integration mechanism between tools without the hard coupling between them that follows from conventional two part communication mechanisms.

Figure 172 illustrates some of the PostMaster concepts. The PostMaster maintains a list of which messages each tool subscribes to. Each tool has a PostMaster part for sending and receiving messages. In the figure, tool F broadcasts a message, i.e. the message is sent to the PostMaster. The subscription lists of tool A and C (but not the lists of B and F) contains the message type. Accordingly the PostMaster broadcasts the message to tool A and C.

Figure 172  : Example of a PostMaster broadcast

Extracted pic [1]

The PostMaster configuration is a file that informs the PostMaster about what tools and messages exist in the current context, i.e. it contains the message subscription lists. To include new tools or add new messages, the configuration must be edited.

For detailed information on the configuration, see The PostMaster Configuration.

PostMaster Reference

This section describes the external interface to the PostMaster, including messages to send and their format, contents of the configuration, and functions to call.

Note: 

In order to promote a high throughput, it is strongly recommended that the PostMaster messages are consumed as soon as they are available.

PostMaster Messages

The PostMaster configuration defines a large number of messages that can be utilized in a Telelogic Tau system. A broad range of these messages are public, that is, they can be used externally. A description of these are found in The Telelogic Tau Public Interface.

All messages contain information about the identity of the sender, the time it was sent, the message type, and the size of an optional data part.

The optional data part can be seen as parameters to the message and is not interpreted by the PostMaster.

Note: 

It is the responsibility of the tools using the PostMaster to define the format of the data part and to interpret it correctly.

The PostMaster Configuration

The PostMaster can be configured either statically at start up or dynamically during runtime. When a dynamic configuration is performed, the services Add Tool or Add Tool Subscription is used. The PostMaster is configured statically using the PostMaster configuration file(s)

The PostMaster configuration file(s) informs the PostMaster about what tools and messages exist in the current context. These files are often referred to as simply the configuration.

At start-up the PostMaster reads an environment variable POSTPATH which is a list of directories separated by colons (on UNIX) or semicolons (in Windows). In these directories, the PostMaster searches for configuration files.

Such files should be named post.cfd and are read by the PostMaster whenever it is invoked, for instance when SDT, ORCA1 or ITEX is started.

It is not possible to use C preprocessor statements or symbols in the configuration file.

Caution! 

The file post.cfd residing in $telelogic/sdt/bin and
$telelogic/itex/bin
(on UNIX), or in the Telelogic Tau installation directory (in Windows), defines the existing tools in the environment and must not be edited; otherwise unpredictable behavior may occur.

It is possible to have local configurations which extends the standard PostMaster configuration set up by the Telelogic Tau tools, by simply defining the POSTPATH variable with a directory holding the extended configuration.

File Contents and Syntax

The configuration is a list of tool identities. Each tool identity is bound to an executable, a subscription list of messages and optionally a limit of instances of that tool. Each tool in the file is described in the following way:

Description

Adding Tools and Messages

To include new tools or add new messages, the configuration file must be edited. However, the tools and subscription lists existing in the original configuration must not be changed.

To include a new tool, follow the steps below. Note that it is not required to include a new tool in the configuration if it only serves as an SDL/TTCN environment that does not need to be started from other tools by using the Start service.

  1. Select a tool number not conflicting with the ones already existing in the configuration, preferably a number greater than 100,000. The number chosen must be divisible by 1,000.
  2. Make a new tool description in the configuration, using the syntax described above.
  3. Define a new SET_ (IET_)symbol in the file sdt.h (itex.h) so that the tool number can be easily accessed in the code.

Example 24       

To add a new message, follow these steps:

  1. Decide upon a tool that the new message "belongs to" or "is defined by," which should not be one of the pre-defined tools in the original configuration.
  2. Define a new SE (IE) symbol in the file sdt.h (itex.h)as the tool symbol plus an ordinal number, not conflicting with any other message symbol.

Example 25       

  1. Use the numeric value of the message symbol when adding the new message to a subscription list in the configuration.

Example 26       

Environment Variables

The PostMaster recognizes a number of environment variables setting the context in which the PostMaster is to operate. They are read when the PostMaster starts.

PostMaster Environment Variables

The following environment variables are recognized by the PostMaster:

PostMaster Application Library Environment Variables

The following environment variables are recognized by the PostMaster application library. These environment variables are read in the SPInit function.

Functional Interface

Communication with the PostMaster is based on a small set of fundamental functions:


 SPInit

initialization


 SPExit

termination


 SPBroadcast

output message, broadcast


 SPSendToTool

output message, sent to a certain tool


 SPSendToPid

output message, sent to a certain PId


 SPRead

input message

 SPFree

frees memory allocated by SPRead or SPFindActivePostMasters

 SPConvert

translate a symbolic message to an id

 SPErrorString

Error string conversion

 SPRegisterPMCallback

Message notification (Windows only)

 SPQuoteString

Quoting strings

 SPUnquoteString

Unquoting strings

 SPFindActivePostMasters

find all PostMasters

Every function returns a value denoting success or failure of the associated operation.

Calling Conventions

The PostMaster functions should be called in the following ways from the external tool:

Variables

The following variables are defined.

sperrno contains an error code when a call to a PostMaster function failed. The error codes are defined in sdt.h and should be self-explanatory.

On UNIX, spPortNO contains a descriptor to the port where incoming messages from the PostMaster are found. In Windows, spPortNO contains a process identifier associated with the current process. The state of the variable prior to the call of SPInitis undefined.

These variables are found in the file post.h.

Caution! 

Windows only: When linking with the PostMaster's dynamically linked libraries (post.lib and post.dll), the environment variable USING_DLL must be defined before including post.h. Example:

#define USING_DLL
#include "post.h"
#undef USING_DLL

Error Codes

When a function returns SPERROR which indicates an error or an not expected result of the function. In this case sperrno is set to one of the following values.

Error Code Explanation

SPNOSESSION

The function SPInit has not been called successfully


SPALREADYCONNECTED

When calling SPInit more than once without disconnecting


SPNOPOSTMASTER

No PostMaster could be found when trying to connect


SPNOCHANNEL

The contact with the PostMaster is lost.


SPNOMESSAGE

No message available when trying to read by polling or after a timeout.


SPTIMEDOUT

The connection to the PostMaster timed out.


SPNOSUCHPID

Sending to a PId with a non positive value (<=0)


SPNOMEMORY

Cannot allocate anymore dynamic memory (rare)


SPTOOLNOTFOUND

When sending to a tool, this tool is not found in PostMaster configuration list


SPINVALIDMESSAGE

Sending a message with a NULL parameter but specifying the length greater than 0.


SPBADMESSAGE

A not supported message was to be sent.


SPMANYPOSTMASTERS

Many PostMasters running. Could not decide which one to connect to. (Windows only)


SPOLDPOSTMASTER

Old PostMaster running. (Windows only)

Functional Description

The available PostMaster functions are described on the following pages. The descriptions use the following format.

First, the function declaration is shown, including data types of parameters, followed by a short explanation of what the function does.

After that, in- and out parameters are described, together with possible return values and error codes.

SPInit

SPInit initiates a session and establishes a connection with the PostMaster. See Multiple PostMaster Instances for information on how to connect to a specific instance of the PostMaster.

Inparameters
Returns
Errors

SPExit

SPExit exits a session and disconnects the connection with the PostMaster. Subsequent calls to PostMaster functions will return the error code SPNOSESSION until a new SPInitis performed.

Returns
Errors

SPSendToTool

SPSendToTool sends a message to the process of kind type.

Inparameters
Returns
Errors

SPSendToPid

SPSendToPid sends a message to the process which has process id toPid.

Inparameters
Returns
Errors

SPBroadcast

SPBroadcast sends a message to all processes that subscribes on the message type.

Inparameters
Returns
Errors

SPRead

SPRead reads a message from the queue of unread messages that the PostMaster has sent. When the message is read, it is also consumed, i.e. removed from the queue. The function allocates the necessary amount of memory needed for the data component in the message. The application using this function is responsible for freeing the allocated memory with SPFree when it is no longer needed.

Inparameters
Outparameters
Returns
Errors

SPFree

SPFree should be used to free the memory allocated by SPRead. This is necessary when different compilers with different memory management are used.

Inparameters
Returns

N/A.

SPErrorString

Converts an error code into a textual string description of a tool or a message from the corresponding integer value.

Inparameters
Returns

An descriptive error string corresponding to the error code.

SPConvert

Converts a textual description of a tool or a message to the corresponding integer value as provided by the parameter list in SPInit.

Inparameters
Returns

An integer value for the tool or message. If no mapping is found, SPERROR is returned.

SPRegisterPMCallback

Windows only: Registers a callback function that gets called every time a new PostMaster message arrives. Registering this callback enables (32-bit) Windows applications to function correctly. Console applications need not use this function.

Inparameters
Returns

N/A.

SPQuoteString

SPQuoteString quotes a string. The following operations are performed:

The quoted string can later be unquoted with a call to SPUnquoteString.

Inparameters
Outparameters
Returns

SPUnquoteString

SPUnquoteString unquotes a string previously quoted with SPQuoteString, ignoring leading white-space characters. The following operations are performed:

Several concatenated quoted strings can be extracted with subsequent calls to this function by using the value returned in the position out parameter, see below.

Inparameters
Outparameters
Returns

SPFindActivePostMasters

Finds all PostMasters available for the application on the computer. Information retrieved is process id and a description in plain text.

Inparameters
Outparamters
Returns

Number of PostMasters found.

Run-Time Considerations

Starting Up the PostMaster (in Windows)

When Telelogic Tau is started in Windows, an instance of the PostMaster is automatically started. No additional commands are needed for the PostMaster. There might however be situations when it is necessary to start the PostMaster stand-alone. This is described in the following sections. The examples only handle how SDT is started from the "DOS" command prompt, but in many cases a shortcut with the analogous parameters can be created.

SDT Start-Up

There are several possible ways to start the PostMaster itself and the tools that wish to communicate via the PostMaster. In principle, there are two main alternatives:

We will exemplify the start-up methods by using the DemonGame simulator and a User Interface to the DemonGame simulator.

Note: 

The PostMaster must be started first, but the communicating tools may be started in any order. An SDT simulator must also execute the commands Start-SDT-Env and Go before communication with another tool can start.

Starting When SDT Is Present

When SDT is started from the "DOS" or UNIX prompt, an instance of the PostMaster is automatically started. No additional commands are needed for the PostMaster in this case.

The DemonGame simulator is preferably started from SDT, thus giving access to all simulation features. It can also be started directly from the "DOS" or UNIX prompt.

Starting from the "DOS" Prompt

Use the following command from the "DOS" prompt:

Note: 

In Windows, the simulator is a Windows GUI application and not a Console application. It is therefore not possible to run the simulator stand-alone, i.e. without -post.

Starting from the UNIX Prompt

Use the following command from the UNIX prompt:

(Without the parameter, the simulator runs stand-alone, which is not desired in this case.) Starting the simulator this way restricts the possibilities of the simulation since there is no connection to the SDT tools. For instance, graphical trace is disabled.

The UI is preferably started directly from the UNIX prompt. It can also be started from the DemonGame simulator with the command Start-ITEX-Com, but this requires that the executable is named sdtenv. This is the name specified in the configuration for tool number 27000.

Starting Without SDT

When SDT is not running, the PostMaster must be started directly from the "DOS" or UNIX prompt with the command:

(using one of the start-up arguments, see below).

The DemonGame simulator must also be started directly from the "DOS" or UNIX prompt, as described above.

Note: 

On UNIX: If activating the PostMaster this way, the environment variable POSTPATH must be set to include the directory where the SDT executables resides, typically $sdtbin.

The UI can be started in the same way as when SDT is running (see above). It can also be started indirectly when starting the PostMaster by using the "DOS" or UNIX command:

This requires that the executable is named sdtenv, the name specified in the configuration for tool number 27000.

Note: 

A tool communicating through the PostMaster can also be started from another tool by using the SESTART message. This requires that the tool to be started is specified in the configuration.

Start-Up Arguments

The PostMaster recognizes the following arguments at start-up. Normally they are not needed, but could be used for special purposes

All other arguments are passed to the tool started.

SDT-2 Connections (UNIX only)

Applications or tools linked with an SDT 2.X PostMaster application library will not be compatible with SDT 3.X PostMaster. Trying to connect such an old application to an SDT 3.X PostMaster will result in an error message:

on standard output, if externally started, or as a service reply, if started via the start service, and the connection is aborted.

Version 3.4 PostMaster (Windows only)

If an old PostMaster (version 3.4 or older) is used the SPInit function will fail. The error code is SPOLDPOSTMASTER.

Applications or tools linked with an SDT 3.4 PostMaster application library will not be compatible with the SDT 3.5 PostMaster. Trying to connect such an old application to an SDT 3.5 PostMaster with the SPInit function will fail. The error code is SPNOPOSTMASTER.

Multiple PostMaster Instances

It is possible to have multiple instances of the PostMaster running, for instance when more than one Telelogic Tau tool has been started. In this case it should be made sure that the communicating tools are connected to the correct instance of the PostMaster.

On UNIX, the function SPInitby default looks for the PostMaster instance with the highest process id (PId) number and connects to it.

On Windows, the function SPInitby default fails if more than one PostMaster is found.

To connect to another PostMaster instance, you can set the environment variable POSTPID to the PId number of the desired PostMaster. If this variable is set, SPInitconnects to the PostMaster instance with that PId number.

Configuration and Tool Search

The PostMaster configuration is read whenever a PostMaster instance is invoked. The environment variable POSTPATH defines a list of directories where the PostMaster looks for a configuration file named post.cfd.

The user can extend the normal configuration by defining the POSTPATH variable to a directory containing an extended configuration. When a Telelogic Tau tool is started normally, the directories containing the binaries are put as the first directories in the POSTPATH variable.

The same search order is applied when the start service is used. The supplied tool number is matched against the name of an executable in the configuration, which is then searched for as above.


1. ORCA is part of the Telelogic product suite and stands for Object oriented Requirement Capture and Analysis.


[Previous] [Next] [Contents] [Index]