Simulink Real-Time .NET API Application Creation

Before creating your Microsoft® .NET Framework custom client application, set up the development environment. In addition to installing the products listed in the system requirements at www.mathworks.com/products/xpctarget/requirements.html, do the following setup.

Visual Studio Coding Environment

  • To build a custom application that calls the Simulink® Real-Time™ API for the .NET Framework, use a third-party development environment that can interact with .NET, such as Microsoft Visual Studio®.

  • To build an application (.exe or DLL) that calls functions from the Simulink Real-Time API libraries, use a third-party compiler that generates code for Win64 computers. You can write client applications that call these functions in another high-level language, such as C#, C++, or C.

  • Create a Windows® application.

  • To run the application on a 64-bit computer, copy xpcapi.dll file from matlabroot\toolbox\rtw\targets\xpc\api\x64 to the folder where you build the executable application.

  • Add a reference for xPCFramework.dll to your project by including the following in your code.

    using MathWorks.xPCTarget.FrameWork;

    You can then access the types available from the Simulink Real-Time environment, for example, when creating a console or graphic display application.

  • Compile your Microsoft .NET Framework client application as a 64-bit application.

You can connect a target computer to only one development computer at a time. Before starting your .NET application, be sure to disconnect the target computer from the development computer (xPCTargetPC.Disconnect). You can use slrtpingtarget from the Command Window to check whether the development and target computers are connected. When execution is finished, this function disconnects from the target computer.

If your development computer has additional network resources, you can connect additional target computers to the same development computer.

When your .NET application starts, first connect the development computer to the target computer (xPCTargetPC.Connect), and then test the link between the development and target computers (xPCTargetPC.Ping).

Visual Studio Design Environment

Optionally, you can use the design-time capability of the Microsoft Visual Studio environment with the xPCTargetPC nonvisual component. To make these capabilities available, carry out the following steps.

  1. Add xPCFramework.dll to the Visual Studio Toolbox.

  2. Add an xPCTargetPC object to the application form by dragging an xPCTargetPC control from the Toolbox window to the design surface.

  3. To explore and customize the xPCTargetPC properties, click the xPCTargetPC control in the design surface.

    The Visual Studio Properties window opens. In the Properties window, the xPCTargetPC control makes available its data and appearance properties.