using System;
using Matrox.MatroxImagingLibrary;
namespace MonitoringApplication
{
class Program
{
private const string WINDOW_TITLE = "Monitoring Application";
#if (CONNECT_TO_RTOS)
private const string PUBLISH_SYSTEM_NAME = "dmilshmrt:
#else
private const string PUBLISH_SYSTEM_NAME = "dmilshm:
#endif
static void Main(string[] args)
{
MIL_ID MilApplication = MIL.M_NULL,
MilSystem = MIL.M_NULL,
LocalDisplay = MIL.M_NULL,
LocalDisplayImage = MIL.M_NULL,
LocalOverlayImage = MIL.M_NULL;
MIL_ID RemoteDisplayImage = MIL.M_NULL,
RemoteOverlayImage = MIL.M_NULL,
MilRemoteApplication = MIL.M_NULL;
MIL.MappAllocDefault(MIL.M_DEFAULT, ref MilApplication, ref MilSystem, ref LocalDisplay, MIL.M_NULL, MIL.M_NULL);
MIL.MappControl(MIL.M_DEFAULT, MIL.M_ERROR, MIL.M_PRINT_DISABLE);
MIL.MappOpenConnection(PUBLISH_SYSTEM_NAME, MIL.M_DEFAULT, MIL.M_DEFAULT, ref MilRemoteApplication);
MIL.MappControl(MIL.M_DEFAULT, MIL.M_ERROR, MIL.M_PRINT_ENABLE);
if (MilRemoteApplication == 0)
{
Console.WriteLine("Cannot open a connection to the remote application.");
Console.WriteLine("Please make sure the publishing example is running.");
Console.WriteLine("Press <Enter> to end.");
Console.ReadLine();
}
else
{
MIL.MappInquireConnection(MilRemoteApplication, MIL.M_DMIL_PUBLISHED_NAME,
"DisplayImage", MIL.M_DEFAULT, ref RemoteDisplayImage);
MIL.MappInquireConnection(MilRemoteApplication, MIL.M_DMIL_PUBLISHED_NAME,
"OverlayImage", MIL.M_DEFAULT, ref RemoteOverlayImage);
if (MIL.M_NULL != RemoteDisplayImage)
{
MIL.MbufAllocColor(MilSystem,
MIL.MbufInquire(RemoteDisplayImage, MIL.M_SIZE_BAND, MIL.M_NULL),
MIL.MbufInquire(RemoteDisplayImage, MIL.M_SIZE_X, MIL.M_NULL),
MIL.MbufInquire(RemoteDisplayImage, MIL.M_SIZE_Y, MIL.M_NULL),
MIL.MbufInquire(RemoteDisplayImage, MIL.M_TYPE, MIL.M_NULL),
MIL.M_IMAGE + MIL.M_DISP,
ref LocalDisplayImage);
MIL.MbufCopy(RemoteDisplayImage, LocalDisplayImage);
MIL.MdispSelect(LocalDisplay, LocalDisplayImage);
MIL.MdispControl(LocalDisplay, MIL.M_TITLE, WINDOW_TITLE);
MIL.MbufLink(RemoteDisplayImage, LocalDisplayImage, MIL.M_LINK, MIL.M_DEFAULT);
if (MIL.M_NULL != RemoteOverlayImage)
{
MIL.MdispControl(LocalDisplay, MIL.M_OVERLAY, MIL.M_ENABLE);
LocalOverlayImage = (MIL_ID)MIL.MdispInquire(LocalDisplay, MIL.M_OVERLAY_ID, MIL.M_NULL);
MIL.MbufCopy(RemoteOverlayImage, LocalOverlayImage);
MIL.MbufLink(RemoteOverlayImage, LocalOverlayImage, MIL.M_LINK, MIL.M_DEFAULT);
}
Console.WriteLine("DMIL MONITORING (Monitoring):");
Console.WriteLine("-------------------------------------------");
Console.WriteLine("The image displayed is the image published by another");
Console.WriteLine("application for DMIL monitoring.\n");
Console.WriteLine("Press <Enter> to end.");
Console.ReadLine();
MIL.MbufLink(RemoteDisplayImage, LocalDisplayImage, MIL.M_UNLINK, MIL.M_DEFAULT);
if (MIL.M_NULL != RemoteOverlayImage)
MIL.MbufLink(RemoteOverlayImage, LocalOverlayImage, MIL.M_UNLINK, MIL.M_DEFAULT);
}
else
{
Console.WriteLine("No image to display.");
Console.WriteLine("Press <Enter> to continue.\n");
Console.ReadLine();
}
MIL.MappCloseConnection(MilRemoteApplication);
}
MIL.MappFreeDefault(MilApplication, MilSystem, LocalDisplay, MIL.M_NULL, LocalDisplayImage);
}
}
}