Generic VRPC
The Generic VRPC protocol is an interface for managing a custom implementation of any arbitrary protocol, where VRPC (Variadic Remote Procedure Calls via MQTT, http://vrpc.io ) is used as the configuration and life cycle management interface from the Connectware to the custom implementation.
The data interface for the actual process data, on the other hand, needs to be implemented by the custom code itself. This can be any sort of data format and transport protocol as required by the concrete application, for example JSON over MQTT, but could be anything. The Generic VRPC protocol just serves as an integration layer of the custom implementation into the configuration and life cycle layer of the Connectware.
Using VRPC offers the following benefits:
The custom implementation can be written in any programming language for which VRPC bindings exist, i.e. Javascript/Node.js, Python, or C++
VRPC wraps the state machine function calls which are needed when implementing the details of a protocol life cycle
The parameter values for the custom protocol can be configured directly inside Connectware’s service commissioning files (see Structure of Commissioning Files) and are transparently passed through to the custom implementation, hence eliminating any need for separate parameter management solutions (e.g. separate config files).
The interface from the Connectware to the custom implementation relies on the following requirements:
The custom code runs a
VrpcAdapter
instance that registers at the Connectware’s MQTT brokerThe custom code implements the protocol state machine as a class that implements these seven methods:
connect
,disconnect
,isConnected
,subscribe
,unsubscribe
,read
,write
There are no further requirements on the custom code except these seven methods.
Service Commissioning File Example
This part of the commissioning file describes one connection and one endpoint in a custom protocol implementation.
The custom implementation runs an instance of VrpcAdapter which registered itself at the Connectware’s MQTT broker using the vrpc domain mycustom.vrpc
and the agent name mycustom.implementation
. The protocol implementation itself is written in a class named MyProtocol
. These three arguments are the only parts needed for configuring the GenericVrpc protocol.
All values below args
of the connection are passed on to the MyProtocol
class transparently, specifically to the constructor of each MyProtocol
instance. In this example, three values of various types are shown.
All values below subscribe
of the endpoint are passed on to the MyProtocol::subscribe
method call. In this example, two values are shown. The same sort of additional parameters can be added at the read
and write
sections of endpoints.
Example Protocol implementation
This example code shows the seven methods as mentioned above in a Node.js/Javascript implementation of the MyProtocol
class, which is derived from Node.js’s standard EventEmitter
class. The EventEmitter base class is used for notification of successful connect/disconnect but most importantly for notification of newly arriving data to which the Connectware should be subscribed.
This class needs to be registered at a local VrpcAdapter instance. In a Node.js/Javascript application this is done in the top-level index.js
file as follows:
Last updated