When you have one or more MIL applications running locally or on remote computers, it can be convenient to monitor or manipulate some of the applications' MIL objects, such as buffers or contexts, from an application on your local computer. Distributed MIL can allow one MIL application on the local computer, known as the monitoring application, to monitor MIL objects of separate MIL applications, typically on separate computers, known as the publishing applications. The monitoring application is able to access only those MIL objects explicitly designated by the publishing applications. All other processes and MIL objects of the publishing application are not accessible to the monitoring application.
When initially allocating a monitoring or publishing MIL application context, you must specify a computer as a cluster manager. The cluster manager keeps all the application identifiers unique within the cluster. The default cluster manager is specified using the MILConfig utility.
The publishing applications can designate a permission level, either read only or read/write, for each of their own MIL objects; by default, all MIL objects' permission levels are set to non-accessible. When you publish an object, the publishing application opens the Distributed MIL server, which allows the monitoring application to then connect to the publishing application. Once connected, the monitoring application inquires a list of the MIL objects that the publishing application has designated as read only or read/write, and then interacts with these MIL objects according to their permission level. In a monitoring configuration cluster, both monitoring and publishing applications run independently, except for the explicit monitoring mentioned above.
A simple monitoring configuration cluster is illustrated below:
The following steps provide a basic methodology for creating a Distributed MIL monitoring configuration cluster:
Set a computer as the cluster manager.
Setup the publishing applications.
Setup the monitoring application.
Before you can run a Distributed MIL application, you must prepare all the computers with the appropriate software and licenses. See the Preparing computers for Distributed MIL section earlier in this chapter.
A MIL cluster manager manages the identifiers of MIL application contexts in a Distributed MIL monitoring configuration cluster. This assures that application context identifiers are unique; duplicate identifiers can cause a conflict.
The MIL cluster manager is a designated computer that has a valid version of MIL/MIL-Lite installed with the Distributed MIL option selected. The MIL cluster manager can be on a computer running the monitoring application, a publishing application, or any other stand alone MIL application. It can also be a computer not currently running any MIL application.
When allocating a MIL application context, you must specify a MIL cluster manager that is currently active. You can activate a MIL cluster manager using the MILConfig utility on the computer designated as the cluster manager. The activation prompt is found in the Cluster Manager pane, accessible from the Distributed MIL item. To ensure the uniqueness of MIL application context identifiers across the cluster, all computers within a cluster must specify the same cluster manager.
A publishing application allows individual MIL objects to be accessed by a monitoring application. This is called publishing a MIL object. A publishing application can only be connected to a single monitoring application at a time.
To create a publishing application:
Allocate a MIL application context using MappAlloc() with its ServerDescription parameter set to the name or IP address of the computer designated as the cluster manager.
Optionally, specify a non-default listening port for the publishing application using M_DMIL_CONNECTION_PORT. To use the default listening port, set using the MILConfig utility, you do not need to explicitly specify it.
Note that the port must be unique if more than one MIL application will publish objects from the same computer.
Set the global permission level for the application's objects to read/write or read only, using MappControl() with M_DMIL_CONNECTION set to either M_DMIL_CONTROL or M_DMIL_MONITOR, respectively.
This activates the Distributed MIL server and allows the monitoring application to connect to this publishing application.
Set the access to a particular MIL object, using MappControlObject() with M_DMIL_PUBLISH set to either M_READ_WRITE or M_READ_ONLY. Any MIL object with a MIL identifier can be published in this manner, except for MIL displays (MdispAlloc()).
A MIL object cannot have greater permission than the global permission level for the application. For instance, if the application permission level is set to read only, no individual MIL object in the application can be set to read/write. If the application permission level is set to disable (MappControl() with M_DMIL_CONNECTION set to M_DISABLE), no individual MIL object in the application can be set to either read only or read/write.
Optionally, name the published MIL objects, using MappControlObject() with M_OBJECT_NAME set to any string. If an object is named, you can more easily identify it from the monitoring application using either MappInquireConnection() or MappInquireObject().
A monitoring application can access MIL objects published by a publishing application. This access can be read/write or read only. A monitoring application can be connected to multiple publishing applications at the same time.
To create a monitoring application:
Allocate a MIL application context using MappAlloc() with its ServerDescription parameter set to the name or IP address of the computer designated as the cluster manager.
Open a connection to a remote or local computer that is running a publishing application, using MappOpenConnection(). You must specify the monitoring application's connection port if its default connection port, set using the MILConfig utility, is different from the publishing application's listening port.
Note that the publishing application must have called MappControl() with M_DMIL_CONNECTION set to either M_DMIL_CONTROL or M_DMIL_MONITOR before a connection can take place.
Inquire the MIL object's MIL_ID from the publishing application, using MappInquireConnection().
If you know the name that the publishing application assigned to the object (using MappControlObject() with M_OBJECT_NAME), inquire that MIL object's MIL identifier using MappInquireConnection() set to M_DMIL_PUBLISHED_NAME.
Inquire a list of published MIL identifiers using MappInquireConnection() with InquireType set to M_DMIL_PUBLISHED_LIST. You can limit this list to all published MIL identifiers of a single MIL object type by also specifying the required type of object. For example, you can inquire the list of all image buffers published by a specific publishing computer using MappInquireConnection() with M_DMIL_PUBLISHED_LIST and M_IMAGE.
Repeat step 2 and step 3 for each publishing application you want the monitoring application to connect to.
A monitoring application uses the inquired MIL identifier from a publishing application as it would a local MIL identifier. The only difference is that it uses the MIL identifier of a published object rather than a local object.
A monitoring application will typically process its functions on the local computer. For example, the monitoring application could call MimResize() and use an image buffer published by a publishing application as the source image. For the destination image, the function could specify a local image buffer or a published image buffer that is set to read/write. Regardless of the destination, the function would be processed on the local computer.
In the process of using a published object, the monitoring application creates a local temporary copy of the published object, and then quickly deletes the local copy after using it. Despite deleting the local copy, the monitoring application retains a link to the original published object.
The monitoring application can display an image buffer from a publishing application, provided that the published image buffer had originally been allocated with the M_DISP attribute. Note that the monitoring application cannot use a display from a publishing application. Publishing a display object will result in an error.
To display a published image buffer, the monitoring application must allocate a display using MdispAlloc(). It must then select the published displayable image buffer using MdispSelect().
Any changes to the published image buffer in the publishing application will trigger the monitoring application to get the new version of the image buffer and automatically update its display. The publishing application does not have to display its own displayable image buffer for the monitoring application to display the image buffer.
Note that if both the monitoring and publishing applications are displaying the same image buffer, there might be a small difference in the rate at which images grabbed or altered in this buffer are displayed on both computers, due to bandwidth limitations.