MBLogic for an open world in automation
"Generic clients" are external add-on modules which can be used to implement additional functionality. The main purpose for having generic clients is to make it easier to write serial (RS-232) client interfaces. However, generic clients can also be used for Ethernet communications, file or database access, or any other application where it is desired to add custom functionality.
Generic clients are experimental at this stage, and the interface is subject to change. If you intend to make use of this feature at this stage in its development, be prepared to make minor modifications to your custom generic clients in future versions.
Generic clients associate with the main system by communicating with it via the "generic client" server interface. This uses a remote procedure call mechanism called "Perspective Broker" which is part of the Twisted communications framework.
A generic client runs as a seperate program that communicates with the main system through the generic server interface. The generic server interface must be configured and running before any generic clients may work with the main system.
Each instance of a generic client must be given a unique name. That means that even when running two or more copies of the same type of client, each copy must have its own name. The name of the client does not necessarily mean the name of the file containing the client. Two or more clients may use the same code from the same file, but be given different names. The name is simply a parameter passed to the client which it uses to identify itself to the server when it starts up.
For example, the system may need to interface with two identical weigh scales. The same client program file can be used for both, but they must be given different names when they are started so the correct parameters can be passed to them.
The parameters for each generic client instance are defined in the client communications configuration file ("mbclient.config") just like all other client configurations. These parameters follow a similar format to those used with TCP clients. In addition, each client can have custom parameters which are not "understood" by the server, but are simply passed on to the client for its own use. This allows the standard configuration system to load and parse the parameters while allowing each type of client to have whatever parameters are appropriate to the application.
Details of the configuration parameters can be found in the section on communications configuration.
Generic clients are located in a directory called "genclient". The system will automatically look in that directory for any specified files.
Generic clients are primarily intended to allow the addition of protocols and custom interfaces. These typically include serial protocols, but can also include protocols that use HTTP and low level socket access. Since the generic client runs independently from the main system, it will not block or interrupt the operation of the main system. However, the client should not block (stop) execution of the main client loop for long periods of time as the main system may interpret that behaviour as indicating the client has faulted ("locked-up").
Some available libraries for implementing client protcols are: