C#

This guide provides step-by-step instructions on how to configure a project to start developing with the PMP C# API.

During this guide you will learn how to:

  • Create a .NET Framework C# console application in Microsoft Visual Studio.

  • Reference the PMP C# API in the project configuration.

Requirements

The PMP C# API requires .NET Framework version of at least 4.7.2.

Project configuration

During this quick start guide, the 2019 version of Visual Studio is used. However, newer versions of Visual Studio can be used as well.

Create project

  • Open Visual Studio and select Create a new project:

Create a project in Visual Studio.

Create a project in Visual Studio

  • Select a C# Console App (.NET Framework), and press Next:

Select C# console application.

Select C# console application

  • Select Project name, Location, Framework, and press Create:

Select project name and directory.

Select project name and directory

Configure solution

Now that the console application has been created, let us configure the project solution. The default console project generated by Visual Studio contains a build target for the AnyCPU platform. The PMP API is only available in 64-bit, so the AnyCPU target should be replaced with a x64 target.

  1. Right-click on the solution name and select Properties.

  2. Go to Configuration Properties ‣ Configuration.

Configure project solution platform.

Configure project solution

Create the x64 target platform:

  1. Click on Configuration Manager.

  2. In Platform, select New.

  3. In the New platform select x64 and copy the setting from AnyCPU.

Configure project solution - configure x64 platform.

Configure x64 platform

Remove the AnyCPU platform as follows:

  1. In Platform, select Edit.

  2. Select Any CPU and remove it from the list.

Configure project solution - remove AnyCPU configuration.

Configure project solution - remove AnyCPU configuration

Configure project

Now that the solution is configured, let us configure the project settings.

PMP Library

Add the PMP API library by adding the pmpclient.net.dll file to the project references.

  1. In the Solution Explorer, right click on Reference ‣ Add References.

  2. Click on Browse and select pmpclient.net.dll, which can be found in the installation folder C:\Program Files\Prodrive Motion Platform\96.2.0.0915fd88\bin

Add pmpclient.net.dll to project references.

Add pmpclient.net.dll to project references

Build Events

The PMP .NET assembly depends on the unmanaged pmpclient.dll library. To run our console application it needs to be able to find this library. We will configure a post-build event to copy the file to the output folder.

In the Solution Explorer, right click on the project name and select Properties.

Configure project settings.

Project setting configuration

  1. Go to Build Events.

  2. in the Post-build event add the following command:

copy /y "C:\Program Files\Prodrive Motion Platform\96.2.0.0915fd88\bin\pmpclient.dll"
Configure post-build event.

Configure post-build event

Example

Now that the project is fully configured, a PMP system instance can be created. To verify the system is functioning we can for example get the the API version of the system as shown in the following code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
using System;

namespace ProjectConfiguration
{
    class Program
    {
        static int Main()
        {

            var system = new Pmp.System("localhost");
            var apiVersion = system.Version;

            Console.WriteLine($"PMP API version: {apiVersion.Major}.{apiVersion.Minor}.{apiVersion.Patch}");

            return 0;
        }  
    }
}
  1. From the main menu tab select Debug ‣ Start Without Debugging (or press Ctrl-F5).

  2. The API version is displayed in a console and should look similar to:

    PMP API version: 96.2.0
    Press any key to continue . . .
    

A guide for creating a simulated system using C# can be found in the next Create a simulator Quick start chapter.