//MODA C++ for VC2005 sample code
//Light source blink sample, using LightSource group
#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)
{
//find devices
ModaCPP::DeviceLightSource *pLight1=robot->QueryDeviceLightSource("light0/l");
ModaCPP::DeviceLightSource *pLight2=robot->QueryDeviceLightSource("light1/l");
if(pLight1 && pLight2)
{
//create group
ModaCPP::DevicesGroupLightSource group(connection);
group.AddDevice(pLight1);
group.AddDevice(pLight2);
//blink !
float intensities[2]={1.0f,0.5f};
while(!_kbhit())
{
group.SetIntensity(0);
connection->Sleep(100);
group.SetIntensities(intensities,2);
connection->Sleep(100);
}
//delete objects
delete pLight1;
delete pLight2;
}
_cprintf("robot found\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;
}