TCPServer Library

DevOps Model RealTime provides a library, the TCPServer library, which you can use for integrating an application generated by Model RealTime with other applications by means of TCP-based communication. For example, you can send or invoke events on a port in the generated application from an external Java program, Python script or Node-RED flow (or any other language that supports communication over TCP). You can also set-up an external TCP server and route all events that arrive at a certain port in the application to that server.

The API provided by the TCPServer library is based on sending and receiving JSON strings on TCP ports (one port in the generated application to be used for sending and invoking events, and another port in the external application for receiving events that the application sends or invokes).

To start to use the TCPServer library in your Model RealTime application, perform the command Libraries - Import TCPServer Library to import the library into your workspace. The library is implemented in the form of a capsule called TCPServer, from which one of your capsules should inherit. You can then add a capsule part for that capsule and connect it to one or several ports of your application, to allow an external application to send or invoke events to those ports. Events which your application sends or invokes on those ports can be routed to a TCP server in the external application. In short the TCPServer library provides a bidirectional, asynchronous (send) or synchronous (invoke) communication between an external application, and an Model RealTime application.

Here is an example of using the TCPServer library:

The source code of the TCPServer library is available on GitHub and there you can also find more detailed documentation on how to use the library.

Using the TCPServer Library to control the TrafficLight sample application from a Node-RED flow