MAK Data Logger API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
11 - C# Remote Control API

Table of Contents

The MAK Logger C# Remote Control API extends the VR-Link for C# interface to allow calls to the Logger Remote Control API.

It requires .NET framework 2.0 or newer.

For details on setting up connections using VR-Link for C#, please refer to the VR-Link for C# documentation, and to the examples provided with the MAK Logger C# remote control. This documentation is freely available on the VT MAK web site. In particular, refer to sections 9.3 Initializing an Exercise Connection and 9.4 Using the Application Initializer Class.

The C# Remote Control API supports most of the same commands as the C++ Remote Control API, with only a slight change in syntax from C++ to C#. So for details on API calls, refer to the C++ remote control API documentation.

11.1 Setting Up Your Project

To use VR-Link for C# in your application you must add vrLinkSharp.dll and loggerControlMessages.dll reference to your project.

To do so:

Right click on your project and select Add Reference. Select the Browse tab. Navigate to the ./bin64 directory inside the root VR-Link install folder. Select vrLinkSharp.dll from the list.

Repeat for loggerControlMessages.dll.

Add the following using statement to access the C# library:

using makVrl;

11.2 Command Messages

Command messages are issued by the C# remote control application. They follow a naming convention relative to the methods used in the C++ remote control API.

For example, the C++ class DtRemoteControlPlaybackInterface has a member method:

openFile(
const DtFilename &filename,
bool constructFilePathAndName,
bool checkMediafile,
const DtEntityIdentifier &destination=DtRemoteControlInterface::wildcardAddress())

and the corresponding C# message is LgrOpenFileMessage with members:

string filename;
bool constructFilePathAndName;
bool checkMediafile;
string loggerId;

The message properties have the identical meaning of the C++ method parameters. The C# interface simply calls the C++ method with the message data.

11.3 Response Callbacks

Response callbacks are made to the C# control application when the C++ API receives callbacks in response to issued commands. The argument values in the C++ callback methods are stored in C# messages and forwarded to the C# control application.

Before the C# control application receives these callback messages, a message handler must be registered with the exercise connection, to indicate which C# function will be called when a corresponding message is received. For example:

myExConn.addMessageHandler(LgrFileOpenedMessage.theName, new MessageDelegate(fileOpened));

The will register interest in the LgrFileOpenedMessage (received when a Logger opens a file), and the member function:

fileOpened(Message msg)

will be called with the LgrFileOpenedMessage, filled with data received from the C++ callback:

fileOpened(
const DtEntityIdentifier &source,
const DtString &fileName,
const DtAbsoluteTime &firstTime,
const DtAbsoluteTime &lastTime)

Because all MessageDelegate functions receive the messages of the base class Message, you must cast to the particular message expected. Typically, each received message type is registered with a single delegate function, so this cast should always succeed. If multiple messages are registered with a single delegate function this is permitted, but it is left up to the user implementation to decide which message type is received.

Response callback messages follow a naming convention relative to the methods used in the C++ remote control API. The message properties have the identical meaning of the C++ method parameters. The C# interface simply calls the C++ method with the message data.

The LgrFileOpenedMessage contains the properties:

string sourceId;
string filename;
double firstTime;
double lastTime;

11.4 Example Applications

Two example applications are provided in the C-sharp/examples directory: loggerRemoteControl (demonstrates playback) and loggerRemoteControlRecord (demonstrates recording). Both open an exercise connection, issue Logger remote control commands, and receive response callbacks. Both are organied as finite state machines, where state transitions are triggered by response callbacks. These examples are not intended as useful or stand-alone utilities, but only to illustrate how to write C# code using the interface.

[<< Configuring the Remote Control Interface] [Home] [Top of Page]


Document ID: Generated on Mon Mar 22 15:30:17 EDT 2021 from SVN revision 226440
Copyright © 2021 MAK Technologies. All Rights Reserved (www.mak.com)