Skip to content

.NET-Wrapper

The .NET-Wrapper translates the remote interface calls into a .NET-compatible interface.


Including the interface

You will need the .NET Framework 2 to use the wrapper, other Frameworks are not supported.

To use the wrapper, you need to add the RiDNWrapper.dll to the references of your project. Next, you have to include the library into your sources with

using RiDNWrapper; Now you are ready to use the functions.

Getting Started

The .NET-Wrapper provides a number of classes to interact with the navigator:

  • IRI is the main class which provides the access to the remote interface.
  • cWndMsgs is the container for all messages the remote interface provides.

Let's start with declaring a member which is of type IRI-class:

private int m_ID = 0;
private IRI m_RI;

m_ID is a unique ID needed to communicate with the Remote Interface. IRI is the main access class to the remote interface functionality, it provides methods to send requests and data. The answers to these requests will be received in a method called RIDataArrived() which will be described later on. We do not instantiate IRI directly but cRI which is derived from IRI and adds some more functionality.

No we create an instance of cRI, and initialize it:

m_RI = new cRI();
m_RI.Init(this);

The next step is to get the handle from the remote interface, which we will need in further communications:

int hWnd = m_RI.GetTNS();
if (hWnd == 0)
{
    //Error: Navigator not running
}

Sending and receiving commands

As decribed in the First Steps, the RI-Interface is based on window messages and therefore, the interface is asynchronous. After you have sent a message to the navigator (with or without data transfer) the navigator will process the request and send back an acknowledgement message to your client after he finished his work. You can only be sure that a command succeeded if you check this acknowledgement message in RiDataArrived() !

There are two different types of commands, the ones without data-transfer and the other ones with data-transfer. Sending a command without data-transfer is done like this (we will send the command to set the navigator back to the main menu):

m_ID++;
int iRet = m_RI.PostMessage(cWndMsgs.MESSAGE_ROLLBACKTOMAINMENU, m_ID);
if (iRet != (int)RI_Errors.RI_NOERROR)
{
}

Initially, we increase m_ID to get a unique number. Then we call the method cRI::PostMessage() with the appropriate parameters (the message you want to send, and the id). This is pretty much the same as in C++ . Sending a command with data-transfer: The data to be transfered will be handled by the class which corresponds to the message. Before sending the command we have to create a new instance of the needed class and fill the members of it appropriately (in our example, we will send a request to get the list of stop-off-points):

cRI_CGetStopOffPointList data = new cRI_CGetStopOffPointList();
data.m_index = 0;

We want the first entry of the list, so we set m_index to 0.

int iRet = m_RI.GetStopOffPointList_WriteData(m_ID, data);

Now we write the data to the remote interface. This will send the message automatically (all writer functions will do this for us, no expicit call to PostMessage() is needed).

Receiving messages and data

To receive messages and data, we have to implement the method RIDataArrived():

public void RIDataArrived(int RIMessage, object data, int ReturnValue)
{
}

The handling in this method is similar to the handling in the wndproc method in C++, check for the message you previously sent and handle it:

if (RIMessage == cWndMsgs.MESSAGE_GETSTOPOFFPOINTLIST)
{
    if (ReturnValue != (int)RI_Errors.RI_NOERROR)
    {
        // error handling...
    }
    else if (data is cRI_CGetStopOffPointList)
    {
        cRI_CGetStopOffPointList a = (cRI_CGetStopOffPointList)data;
        if (a.m_ID == m_ID)
        {
            if (a.m_index < a.m_listcount)
            {
                // access data...
            }
        }
    }
}

It is important that you call the Reader-Function after the navigator sent back the acknowledgement message, otherwise, it is not guaranteed that the data is complete and correct.