Home · All Commands · First Steps · Tutorials · Demos · FAQ
 

Remote Interface Documentation

Classes | Functions | Variables

RoutePlanning: Calc a route and retrieve route information

Classes

struct  RI_CRoutePlanning
 Data structure for the Request "RoutePlanning". More...

Functions

LRESULT RI_RoutePlanning_ReadData (LPARAM, RI_CRoutePlanning &)
 Read data from shared memory for "Route Planning".
LRESULT RI_RoutePlanning_WriteData (LPARAM, RI_CRoutePlanning &)
 Write data to shared memory for "Route Planning".

Variables

const UINT RI_MESSAGE_ROUTEPLANNING = RegisterWindowMessage(TEXT("RI_MESSAGE_ROUTEPLANNING"))

Variable Documentation

const UINT RI_MESSAGE_ROUTEPLANNING = RegisterWindowMessage(TEXT("RI_MESSAGE_ROUTEPLANNING"))

Message ID for the Request "route planning":
RI_MESSAGE_ROUTEPLANNING

Write Memory:

RI_RoutePlanning_WriteData(LPARAM id, RI_CRoutePlanning data );

Read Memory:

RI_RoutePlanning_ReadData(LPARAM id, RI_CRoutePlanning data );

Return Values for RoutePlanning:

RI_NOERROR = Route planning started
RI_NOTADDED = Route planning not started, because RoutingStart or RoutingEnd failed
RI_NOTLINKABLE = Route planning not started, because route calculation failed

Description:

Calculate the route with the previously sent start- and endstations. The first read packet includes the number of maneuvers of the calculated route. The user have to explicitly send a new message to get the next maneuver description until all maneuvers are transfered. The remote interface will disable user interaction before executing the command and allow user interaction after the command if there was no previously call to BlockUserInteraction.

Can return multiple packages.

Example:

#define USE_LOADLIBRARY
#include "TNSRemoteInterfaceDll.h"

LPARAM GetUniqueID()
{
    //generate unique ID
    static LPARAM id = 0;
    if (++id == 0) ++id; // do not use 0 !!!!!
    return id;
}

inline LRESULT RI_MESSAGE( const UINT request, HWND h_client, LPARAM id )
{
    //check if RI handle is valid
    if ( !IsWindow( RI_GetTNS() ) ) 
        return RI_NAVIGATIONNOTACTIVE;
    //send the request
    PostMessage( RI_GetTNS(), request, WPARAM(h_client), id );
    return RI_NOERROR;
}

LRESULT CDlgMFC_RoutePlanning::WindowProc ( UINT  message , WPARAM  wParam , LPARAM  lParam )
{
    //check messages for answer from RI
    if ( message == RI_MESSAGE_ROUTEPLANNING )
    {
        if ( (LRESULT)wParam == RI_NOERROR )
        {
            RI_CRoutePlanning data;
            LRESULT read_suc = RI_RoutePlanning_ReadData( lParam, data );
            if (data.m_flag != true)
            {
                //Route planning started. errorcode (0)
                TRACE(TEXT("Retracted: %i"), data.m_Retracted);
                TRACE(TEXT("Number of Manoeuvres: %i"),data.m_ListCount);
                TRACE(TEXT("Total Road: %i"),data.m_TotalTime);
                TRACE(TEXT("Total Duration: %i"),data.m_TotalDistance);
            }
            if (data.m_index <= data.m_ListCount )
            {
                TRACE(TEXT("Station: %i"),data.m_index);
                TRACE(TEXT("Manoeuvre Text: %s"),data.m_ManeuverText);
                TRACE(TEXT("Road: %i"),data.m_Road);
                TRACE(TEXT("Direction: %i"),data.m_Direction);
                TRACE(TEXT("Coordinates: %i,%i"),data.m_mercator_x, data.m_mercator_y);
                //advance station counter 1
                data.m_index = data.m_index + 1;
                //flag suppresses succedd the message for the next station
                data.m_flag = true;
                //write data
                LRESULT sharing_ret = RI_RoutePlanning_WriteData( data.m_ID, data );
                //get next station from the list
                RI_MESSAGE( RI_MESSAGE_ROUTEPLANNING, GetSafeHwnd(), data.m_ID );
            }
        }
        else if ( (LRESULT)wParam == RI_NOTADDED )
            //Route planning not started, because RoutingStart or RoutingEnd failed. errorcode (11)
        else if ( (LRESULT)wParam == RI_NOTLINKABLE )
            //Route planning not started, because route calculation failed. errorcode (10)
    }
    return CDialog::WindowProc( message, wParam, lParam );
}

void CDlgMFC_RoutePlanning::foo()
{
    //define struct
    RI_CRoutePlanning data;
    data.m_index = 1;
    data.m_flag = false;
    // *** write data in the Shared memory***
    LPARAM id = GetUniqueID();
    LRESULT sharing_ret = RI_RoutePlanning_WriteData( id, data );
    if ( sharing_ret != RI_NOERROR ) 
        return;
    if ( RI_MESSAGE( RI_MESSAGE_ROUTEPLANNING, GetSafeHwnd(), id ) == RI_NOERROR )
        //message sending succeeded
    else
        //navigation software not running
}


Flowchart:

RI-StartRouteplanning.gif



© PTV AG 2011 Generated on Fri Oct 14 2011 10:17:32 for RI by doxygen 1.7.1