//MODA C++ for VC2005 sample code
//Light source blink sample
#include "Modacpp.h"
#define MODASERVER "localhost"
#define MYROBOTNAME "/"
int main(int argc, char* argv[])
{
ModaCPP::Connection *connection=new ModaCPP::Connection(true);
//Try connect to MODA server
if(connection->Connect(MODASERVER))
{
_cprintf("Connection ok to moda server\r\n");
//Find the robot
ModaCPP::RobotPHX *robot=connection->QueryRobotPHX(MYROBOTNAME);
if(robot)
{
//query light sources
ModaCPP::DeviceLightSource *pLight1=robot->QueryDeviceLightSource("light0/l");
ModaCPP::DeviceLightSource *pLight2=robot->QueryDeviceLightSource("light1/l");
if(pLight1 && pLight2)
{
//power on lights
pLight1->On();
pLight2->On();
//blink !
while(!_kbhit())
{
//off
pLight1->SetIntensity(0);
pLight2->SetIntensity(0);
connection->Sleep(100);
//on
pLight1->SetIntensity(1.0f);
pLight2->SetIntensity(0.5f);
connection->Sleep(100);
}
//delete objects
delete pLight1;
delete pLight2;
}
else
{
_cprintf("missing light source(s)\r\n");
}
}
else
{
_cprintf("robot not found\r\n");
}
}
else
{
_cprintf("Unable to connect to moda server\r\n");
}
//Disconnect & delete
connection->Disconnect();
delete connection;
_getch();
return 0;
}