Skip to main content

Get Started on Windows

Requirements

  • Get an API key -> see with Axioroute

Setup your app environment

Ask Axioroute to download the AxioSDK from Axioroute server

AxioSDK Library is a dynamic library that must be loaded in your program.

To load the library, you can use the windows API method LoadLibraryA

HMODULE LoadLibraryA(
[in] LPCSTR lpLibFileName
);

Or the corresponding function in the development langage you are using

Examples

Delphi
uses Winapi.Windows;

function LoadDLL : THandle;
begin
Result := LoadLibrary('AxioSDK.dll');
end;

procedure Main;
var DllHandle : THandle;
begin
DllHandle := LoadDll;

if DllHandle <> 0 then
//Library is loaded, you can use it
else
//Library failed to load
end;
C++
#include <windows.h>

HMODULE LoadDLL();
{
return LoadLibraryA('AxioSDK.dll');
}

void main()
{
HMODULE DllHandle;

DllHandle = LoadDLL();

if (DllHandle) {
//Library is loaded, you can use it
}
else
{
//Library failed to load
}
}

Retrieve AxioSDK exported functions addresses

AxioSDK library exports 6 functions:

  • LoadSDK : function used to initialize the SDK
  • UnloadSDK : function used to finalize the SDK
  • SetParam : function used to set SDK parameters values
  • SendEvent : function used to send event messages to be processed by the SDK
  • MPTCalculation : function used to send an asynchronous route optimization to be processed by the SDK
  • MCICalculation : function used to send an asynchronous itinerary calculation to be processed by the SDK

The addresses can be retrieved using the Windows API method GetProcAddress

FARPROC GetProcAddress(
[in] HMODULE hModule,
[in] LPCSTR lpProcName
);

Or the corresponbding function in the developpment langage you are using

Examples

Delphi
type fCallBack = procedure(Data: PWideChar); stdcall;

var
DllLoadSDK : function(CallBack: fCallBack; Buffered: int32): int32; stdcall;
DllSetParam : function(Name, Value: PWideChar): int32; stdcall;
DllSendEvent : function(Event: PWideChar): int32; stdcall;
DllUnloadSDK : function: int32; stdcall;
DllMPTCalculation : function(const AMptProblem: PWideChar): PWideChar; stdcall;
DllMCICalculation : function(const AMciProblem: PWideChar): PWideChar; stdcall;

procedure GetDLLMethods();
begin
@DllLoadSDK := GetProcAddress(DllHandle, 'LoadSDK');
if @DllLoadSDK <> nil then
//Address for method "LoadSDK" found
else
//No method named "LoadSDK" found

@DllUnloadSDK := GetProcAddress(DllHandle, 'UnloadSDK');
if @DllUnloadSDK <> nil then
//Address for method "UnloadSDK" found
else
//No method named "UnloadSDK" found

@DllSetParam := GetProcAddress(DllHandle, 'SetParam');
if @DllSetParam <> nil then
//Address for method "SetParam" found
else
//No method named "SetParam" found

@DllSendEvent := GetProcAddress(DllHandle, 'SendEvent');
if @DllSendEvent <> nil then
//Address for method "SendEvent" found
else
//No method named "SendEvent" found

@DllMPTCalculation := GetProcAddress(DLLHandle, 'MPTCalculation');
if @DLLMPTCalculation <> nil then
//Address for method "MPTCalculation" found
else
//No method named "MPTCalculation" found

@DllMCICalculation := GetProcAddress(DLLHandle, 'MCICalculation');
if @DllMCICalculation <> nil then
//Address for method "MCICalculation" found
else
//No method named "MCICalculation" found
end;
C++
typedef int (__stdcall *fLoadSDK)(void (*pCallBack)(wchar_t*), int);
typedef int (__stdcall *fUnloadSDK)();
typedef int (__stdcall *fSetParam)(wchar_t*, wchar_t*);
typedef int (__stdcall *fSendEvent)(wchar_t*);
typedef wchar_t* (__stdcall *fMptCalculation)(wchar_t*);
typedef wchar_t* (__stdcall *fMciCalculation)(wchar_t*);

fLoadSDK DllLoadSDK;
fSetParam DllSetParam;
fSendEvent DllSendEvent;
fUnloadSDK DllUnloadSDK;
fMptCalculation DllMPTCalculation;
fMciCalculation DllMCICalculation;

void GetDLLMethods() {
DllLoadSDK = (fLoadSDK)GetProcAddress(DllHandle, "LoadSDK");
if (DllLoadSDK) {
//Address for method "LoadSDK" found
}
else
{
//No method named "LoadSDK" found
}

DllUnloadSDK = (fUnloadSDK)GetProcAddress(DllHandle, "UnloadSDK");
if (DllUnloadSDK) {
//Address for method "UnloadSDK" found
}
else
{
//No method named "UnloadSDK" found
}

DllSetParam = (fSetParam)GetProcAddress(DllHandle, "SetParam");
if (DllSetParam) {
//Address for method "SetParam" found
}
else
{
//No method named "SetParam" found
}

DllSendEvent = (fSendEvent)GetProcAddress(DllHandle, "SendEvent");
if (DllSendEvent) {
//Address for method "SendEvent" found
}
else
{
//No method named "SendEvent" found
}

DllMPTCalculation = (fMptCalculation)GetProcAddress(DllHandle, "MPTCalculation");
if (DllMPTCalculation) {
//Address for method "MPTCalculation" found
}
else
{
//No method named "MPTCalculation" found
}

DllMCICalculation = (fMciCalculation)GetProcAddress(DllHandle, "MCICalculation");
if (DllMCICalculation) {
//Address for method "MCICalculation" found
}
else
{
//No method named "MCICalculation" found
}


}

Initialize SDK

In order to start the SDK you must call the LoadSDK method providing:

  • a pointer to the callback function to be called by the SDK
  • an integer value defining if you want the SDK to use (1) or not (0) a queue, allowing the SDK to process the events independantly from the callbacks processing

Examples

Delphi
procedure Callback(Data : PWideChar); stdcall;
begin
//Process the callback Json string received thru Data parameter
end;

procedure Main;
begin
//Load the library and get the methods address

if DllLoadSDK(@CallBack,0) = 0 then
//SDK initialized
else
//Failed to initialize
end;
C++
void __stdcall CallBack(wchar_t* Data)
{
//Process the callback Json string received thru Data parameter
}

void main()
{
//Load the library and get the methods address

if (DllLoadSDK(&Callback)==0) {
//SDK initialized
}
else
{
//Failed to initialize
}
}

See error codes to know the possible values and their meaning

Setting SDK parameters

A few parameters can be set once the library loaded, using the SetParam method.

NameDescriptionDefault Value
LOGDIRECTORYDefine the directory where the logs should be written
See LOGDIRECTORY for details
not defined
LOGLEVELThe level of details.
See LOGLEVEL for details
NONE
LOGRETENTIONThe retention periods for the log files.
See LOGRETENTION for details
5

Example

Delphi
procedure Main;
begin
//Load the library and get the methods address

//Set SDK Log Parameters
if DllSetParam(PWideChar('LOGDIRECTORY'), PWideChar('C:\SDK_LOGS')) = 0 then
//Log Directory successfully set
else
//Failed to set log directory

if DllSetParam(PWideChar('LOGLEVEL'), PWideChar('DEBUG')) = 0 then
//Log level successfully set
else
//Failed to set log level

if DllSetParam(PWideChar('LOGRETENTION'), PWideChar('10')) = 0 then
//Log retention successfully set
else
//Failed to set log retention
end;
C++
void main()
{
//Load the library and get the methods address

//Set SDK Log Parameters
int ErrorCode;
wchar_t* Param;
wchar_t* Value;

Param = const_cast<wchar_t*>(L"LOGDIRECTORY");
Value = const_cast<wchar_t*>(L"C:\\SDK_LOGS");
ErrorCode = DllSetParam(Param, Value);
if (ErrorCode == 0) {
//Log Directory successfully set
} else {
//Failed to set log directory
}

Param = (wchar_t*)L"LOGLEVEL";
Value = (wchar_t*)L"DEBUG";
ErrorCode = DllSetParam(Param, Value);
if (ErrorCode == 0) {
//Log level successfully set
} else {
//Failed to set log level
}

Param = (wchar_t*)L"LOGRETENTION";
Value = (wchar_t*)L"10";
ErrorCode = DllSetParam(Param, Value);
if (ErrorCode == 0) {
//Log retention successfully set
} else {
//Failed to set log retention
}
}

Connect SDK to APIs and Map Viewer

In order to connect the SDK to the APIs and the Map Viewer, you must use the SendEvent method to send an initialization message to the SDK providing the required informations

Examples

Delphi
procedure Main;
var initEvent : String;
begin
//Load the library and do your stuff

//build the initEvent json string
initEvent = <initialization message>;

if DllSendEvent(initEvent) = 0 then
//Event successfully submitted to SDK
else
//Failed to submit event
end;
C++
void main()
{
wchar_t* initEvent;

//Load the library and do your stuff

//build the initEvent json string
initEvent = <initialization message>;

if (DllSendEvent(initEvent)==0) {
//Event successfully submitted to SDK
}
else
{
//Failed to submit event
}
}

See error codes to know the possible values and their meaning

Closing the SDK

In order to stop the SDK you must call the UnloadSDK method before unloading the library.
The method allows the SDK to:

  • write pending log messages and stop the logging thread
  • stop the callback thread if active (see Initialize SDK )
  • release the internal SDK objets

Examples

Delphi
procedure Main;
begin
//Load the library and do your stuff

if DllUnloadSDK = 0 then
//SDK closed
else
//Failed to close
end;
C++
void main()
{
//Load the library and do your stuff

if (DllUnloadSDK()==0) {
//SDK closed
}
else
{
//Failed to close
}
}

See error codes to know the possible values and their meaning

Release AxioSDK library

Since AxioSDK Library is a dynamic library, you need to release it when you are done with it, for instance when exiting your program.

To release the library, you can use the windows API method FreeLibrary

BOOL FreeLibrary(
[in] HMODULE hLibModule
););

Or the corresponding function in the development langage you are using

Examples

Delphi
procedure Main;
begin
//Load the library and do your stuff


//Release the library before leaving the program
FreeLibrary(DllHandle);
end;
C++
void Main();
{
//Load the library and do your stuff


//Release the library before leaving the program
FreeLibrary(DllHandle);
}