GLG Data Gateway, C/C++ API Library  Version 4.6
GLG Data Gateway, C/C++ API Library Documentation

The GLG Data Gateway is a data and message distribution library for SCADA and HMI projects. It is built upon the ZeroMQ library and provides a robust middleware layer that facilitates real-time data exchange between diverse system components.

The GLG Data Gateway is a high-performance light-weight solution for distributing data from a central server to multiple C/C++, C#, or Java clients. It ensures reliable, secure communication with automatic fault recovery and built-in data serialization/deserialization for efficient network messaging. With optional CURVE-based encryption, comprehensive configuration, logging, statistics and troubleshooting tools, it is ideal for secure, real-time, cross-platform data exchange.

This API documentation describes the C/C++ version for Linux and Windows platforms. The C# .NET and Java versions are also available and are fully interoperable.

The gateway download includes examples for the standalone use. For a more comprehensive example, which queries data and alarms and sends commands using multiple message formats based on user input, refer to the SCADAViewer directory within the GLG Toolkit download.

The Gateway employs ZeroMQ as its transport mechanism and implements extensions to simplify its use in the following three areas:

  1. Client/Server (Request/Reply)
  2. Publish/Subscribe
  3. Data serialization, Configuration, and Logging
  • Client/Server (Request/Reply):
    • Reliable request-reply with automatic fault recovery: Implemented by monitoring server replies, automatically reconnecting to the server, and resending the last request if no response is received within a configured timeout.
    • Communication slowdown notification: Alerts the application if the server response takes longer than a configured warning threshold.
    • Request queuing: An ability to queue multiple requests for sending while waiting for a reply from a previous request.
    • Message type support: Integrated support for message types to handle request and reply messages of different formats.
    • Peer ID support: Integrated support for peer IDs to facilitate discarding replies if the requesting peer has been deleted.
    • Singularity Support: Requests, such as data updates, can be marked as singular to prevent queue buildup. This functionality ensures that only one request of a specific message type is queued; subsequent duplicates are ignored until a response to the initial pending request is received.
    • Debugging configuration options: Provides options for:
      • Debugging sent and received messages.
      • Monitoring the elapsed time of a round trip.
      • Generating statistical output.
  • Publish/Subscribe:
    • Unique topic matching: Unique matching of string subscription topics of different lengths.
    • Subscription topic flexibility: A choice of string-based or integer-based subscription topics.
    • Message grouping: Support for message types that can be used for grouping several message types within a single subscription topic.
    • Automatic message dropping: Automatically drops old messages that are delayed beyond the configured threshold.
    • Detecting gaps in received messages: Integrated sequence IDs allow subscribers to monitor gaps in message delivery. An API is provided to query the number of missing messages.
    • Automatic reconnection and resubscription: Automatic reconnection to the server and resubscription if no messages are received within a configured threshold.
    • Communication slowdown notification: Notifies the application about communication slowdown if no messages are received within a configured warning threshold.
    • Debugging configuration options: Provides several options for:
      • Debugging subscription topics.
      • Debugging received messages.
      • Debugging dropped messages.
      • Analyzing message latency (time elapsed since sending the received message, as well as since receiving the previous message).
  • Data serialization, Configuration, and Logging:
    • Data serialization utilities: The Data Serialization API provides utilities for converting data structures to a network-neutral format for transmission, and for reconstructing the original data from the received message (deserialization).
    • Data integrity checks: The deserialization process performs type validation, issuing an error message if the retrieved data fails to match the expected data type.
    • Dynamic message buffering: The size of the message data buffer is automatically adjusted to accumulate data written into the message, utilizing message and buffer caches to minimize memory allocations.
    • Configuration flexibility: Support for configuration files and optional environment variables for socket configuration, in addition to using hardcoded values.
    • Error logging: Integrated support for an error logging and logging API to simplify troubleshooting and monitoring.