CMM-Manager Pipe Server - IPC

Pipe Server IPC

CMM-Manager supports interprocess communication (IPC) in the form of named pipes. The pipe server can exchange data with any connected client application. The CMM-Manager pipe server can be used to access information otherwise unavailable, such as scale position, program running status, and Report pass-fail results.

Enabling Pipe

To enable pipe server support, pass command-line switch (“/pipe”) to CMM-Manager application at startup.
c:\Program Files\QxSoft\CMM-Manager 2020>CMMMgr.exe /pipe

c:\Program Files\QxSoft\CMM-Manager 2020>

Creating a Client

The Pipe Client is an external program that connects to the CMM-Manager Pipe server using a named pipe.  Several programming languages support named pipes. 
Here is an example of creating a pipe client in C#:
using System.IO.Pipes;

class Program
{
    static void Main(string[] args)
    {
        var client = new NamedPipeClientStream(".", "CMMManagerDataTransferPipe");
        client.Connect(20000);
    }
}
This example creates a pipe client to CMM-Manager's pipe server and connects.

Using a Client

To use the pipe, you have to write to and read from it.
Here is an example of using the pipe in C#:
using System;
using System.Text;
using System.IO;
using System.IO.Pipes;

class Program
{
    static void Main(string[] args)
    {
        var client = new NamedPipeClientStream(".", "CMMManagerDataTransferPipe");
        client.Connect(20000);

        // Create the reader and writer streams
        StreamReader reader = new StreamReader(client, Encoding.Unicode);
        StreamWriter writer = new StreamWriter(client, Encoding.Unicode);
        
        // Write to the pipe. 
        Write(writer, "0002 EnumVersions()");

        // Read from the pipe.
        string response = Read(reader);

        // Output response
        Console.Write(response);
    }

    static void Write(StreamWriter writer, string command)
    {
        writer.WriteLine(command);
        writer.Flush();
    }

    static string Read(StreamReader reader)
    {
        string response = reader.ReadLine();
        return response;
    }
}
Output:
C:\PipeClient>PipeClient.exe
0002 #1.0, #1.1, #1.2
This example writes to the pipe a command requesting the possible versions of the pipe.  It then reads the response and outputs it to the console.

Example

using System;
using System.Text;
using System.IO;
using System.IO.Pipes;

class Program
{
    static void Main(string[] args)
    {
        string[] commands = { "01 GetVersion()", "02 EnumVersions()", "03 SetVersion(#1.2)" };
        var client = new NamedPipeClientStream(".", "CMMManagerDataTransferPipe");
        client.Connect(20000);

        // Create the reader and writer streams
        StreamReader reader = new StreamReader(client, Encoding.Unicode);
        StreamWriter writer = new StreamWriter(client, Encoding.Unicode);
        int cmdNo = 0;
        int numberOfCmds = commands.Length;

        while (true)
        {
            string command = "";

            if (0 >= numberOfCmds)
            {
                Console.WriteLine("\n<Enter message to send to server:>");

                 // Read message from the console.

                 command = Console.ReadLine();
            }
            else
            {
                // Use message from the command line argument.

                command = commands[cmdNo];
                cmdNo++;
                numberOfCmds--;
            }

            Console.WriteLine("\n<Sending message to server as follows:>");

            // Write to the pipe. 
            Write(writer, command);
            Console.WriteLine(command);
            Console.WriteLine("\n<Message sent to server, receiving reply as follows:>");

            // Read from the pipe.
            string response = Read(reader);

            // Output response
            Console.Write(response);
        }
    }

    static void Write(StreamWriter writer, string command)
    {
        writer.WriteLine(command);
        writer.Flush();
    }

    static string Read(StreamReader reader)
    {
        string response = reader.ReadLine();
        return response;
    }
}

Output:

C:\PipeClient>PipeClient.exe

<Sending message to server as follows:>
01 GetVersion()

<Message sent to server, receiving reply as follows:>
01 #1.0

<Sending message to server as follows:>
02 EnumVersions()

<Message sent to server, receiving reply as follows:>
02 #1.0, #1.1, #1.2

<Sending message to server as follows:>
03 SetVersion(#1.2)

<Message sent to server, receiving reply as follows:>
03 #1.2

<Enter message to send to server:>
01 GetScalePosition()

<Sending message to server as follows:>
01 GetScalePosition()

<Message sent to server, receiving reply as follows:>
01 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, nan, nan

<Enter message to send to server:>

This example shows how to connect setup and have user input for commands.

Before you start using commands, set the pipe version to a version that contains all of the commands you want to use.  Generally, this will be the latest version.  This is done with the SetVersion() command ie "0003 SetVersion(#1.2)."
From here, you can add in different commands for the pipe. The available commands are listed in the attached PDF.
Also attached is the source for the example.