# Features

Here are a few of the key features of Data Engine.

## Publish-subscribe model

Data Engine acts as a middle-hand and communicates with connected clients using the SAPcore API over TCP/IP. A client
can either register itself as a producer or a consumer. Whenever a producer writes to a signal which is registered in
Data Engine, that signal will be sent to any other client which have registered themselves as a consumer of that signal.

## Number of clients and signals

Data Engine supports up to 10 clients and 2000 signals simultaneously.

## Data types

The communication protocol supports the most common data types:

* `bool`
* `signed char`, `unsigned char`
* `signed short`, `unsigned short`
* `signed int`, `unsigned int`
* `float`
* `blob` (up to 1024 bytes)

Blob allows for flexible data transmissions between connected clients when the transmitted data either is varying in
size or requires more than 8 bytes.

## Heartbeats

Whenever a client connects with Data Engine, it will create a heartbeat signal (sync). This signal can be subscribed
by other clients in order to know if the producing client is connected or not. This is useful when it is crucial to know
if a specific (producing or consuming) client is available or not. The name of the heartbeat signal is the same as the
producing client.

## Signal updates

A client which connects as a consumer for a specific signal will immediately receives the last known value for that
signal (if updated by a producer). This allows clients to stay in sync with each other even when connected in different
point in time.

It is possible to disable this feature so the client only receive value updates when a producer updates the signal. This
is useful for signals which are used as triggers (only valid when they are sent). It is disabled during the subscription
phase.

## Subscription locks

A client registers itself either as a producer or consumer of a specific signals. When a signal is subscribed, it is
required to state the subscription type. The information is maintained by Data Engine and is used to control if a client
may register the signal or not.

There are no restrictions on the number of consuming clients of a signal, but it is possible to control how many that is
allowed to produce (write) data to a specific signal. This feature can be used to restrict where data is received from
and catch clients which are not configured correctly.

### Subscription types

| Type           | Nr of Producers | Nr of Consumers |
|----------------|-----------------|-----------------|
| Producer       | 1               | N               |
| Consumer       | 1               | N               |
| Many producers | N               | N               |
| Bidirectional  | N               | N               |

## Administrative interface

An alternative API is available which offers diagnostic and testing features, sush as:

* Number of writes to signal
* Connected clients
* Override of transmitted values
* Subscription errors

This API is provided on request.
