anyKode Marilou
ContentsIndexHome
PreviousUpNext
Connection::WaitMODAServerIsRunningOnLocalhost

Waits for the complete simulation engine (Exec) startup.

C++
static bool WaitMODAServerIsRunningOnLocalhost(DWORD dwWaitTimeOut);
Parameters 
Description 
DWORD dwWaitTimeOut 
[in] Milli seconds to wait for Exec complete startup. 

true is exec is running and engine is fully mounted, false otherwise.

You can use this function only when Exec and calling program are on the same computer (localhost). 

 

The function check if the Exec 'startup named event' is set inside the delay specified in parameter. If the event is set, the function waits for the complete engine startup during an infinite time (checking the 'end of startup named event').

//Shows how to wait complete exec startup before connecting to MODA server

#include "Modacpp.h"
#include "conio.h"

#define MODASERVER "localhost"
#define MYROBOTNAME    "/"

int main(int argc, TCHAR* argv[])
{
ModaCPP::Connection *connection=new ModaCPP::Connection(true);

if(connection->WaitMODAServerIsRunningOnLocalhost(5000))
    {
    //exec is running and all servers are running
    if(connection->Connect(MODASERVER))
        {
        _cprintf("Connection ok to moda server\r\n");
        ModaCPP::RobotPHX *robot=connection->QueryRobotPHX(MYROBOTNAME);
        if(robot)
            {
            _cprintf("robot found\r\n");
            // ... your program here

            delete robot;
            }
        else
            {
            _cprintf("robot not found\r\n");
            }
        }
    else
        {
        _cprintf("Unable to connect to moda server\r\n");
        }
    }
else
    {
    _cprintf("Exec is not running ...\r\n");
    }

connection->Disconnect();
delete connection;
return 0;
}
Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.
What do you think about this topic? Send feedback!