//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;
}