コード例 #1
0
ファイル: v_repExtWii.cpp プロジェクト: ehsan1384/Vrep
VREP_DLLEXPORT void* v_repMessage(int message,int* auxiliaryData,void* customData,int* replyData)
{ // This is called quite often. Just watch out for messages/events you want to handle
	simLockInterface(1);
	// This function should not generate any error messages:
	int errorModeSaved;
	simGetIntegerParameter(sim_intparam_error_report_mode,&errorModeSaved);
	simSetIntegerParameter(sim_intparam_error_report_mode,sim_api_errormessage_ignore);

	void* retVal=NULL;


	// Acknowledgment message display:
	// *****************************************************************
	static int auxConsoleHandleForAcknowledgmentDisplay=-1;
	static int acknowledgmentDisplayStartTime=0;
	if (displayAcknowledgment)
	{
		auxConsoleHandleForAcknowledgmentDisplay=simAuxiliaryConsoleOpen("Acknowledgments",10,2+4+16,NULL,NULL,NULL,NULL);
		simAuxiliaryConsolePrint(auxConsoleHandleForAcknowledgmentDisplay,"The wiimote plugin is courtesy of Eric Rohmer.\n\nThe wiimote plugin contains WiiYourself! wiimote code by gl.tter\nhttp://gl.tter.org");
		acknowledgmentDisplayStartTime=timeGetTime();
		displayAcknowledgment=false;
	}
	if ( (auxConsoleHandleForAcknowledgmentDisplay!=-1)&&(timeGetTime()-acknowledgmentDisplayStartTime>5000) )
	{
		simAuxiliaryConsoleClose(auxConsoleHandleForAcknowledgmentDisplay);
		auxConsoleHandleForAcknowledgmentDisplay=-1;
	}
	// *****************************************************************

	// Clean-up at simulation end:
	// *****************************************************************
	if (message==sim_message_eventcallback_simulationended)
	{
		if (auxConsoleHandleForAcknowledgmentDisplay!=-1)
		{
			simAuxiliaryConsoleClose(auxConsoleHandleForAcknowledgmentDisplay);
			auxConsoleHandleForAcknowledgmentDisplay=-1;
		}
		for (int i=0;i<4;i++) // for the 4 devices
		{
			while (startCountPerDevice[i]>0)
			{
				startCountOverall--;
				startCountPerDevice[i]--;
				if (startCountOverall==0)
					killThread();
			}
		}
	}
	// *****************************************************************

	simSetIntegerParameter(sim_intparam_error_report_mode,errorModeSaved); // restore previous settings
	simLockInterface(0);
	return(retVal);
}
コード例 #2
0
ファイル: commonFunctions.cpp プロジェクト: ehsan1384/Vrep
void printToConsole(const char* txt)
{
	static int handle=-1;
	std::string text(txt);
	text+="\n";
	std::cout << text;
	if (simAuxiliaryConsolePrint(handle,text.c_str())<=0)
	{
		handle=simAuxiliaryConsoleOpen("URDF import",5000,2+4,NULL,NULL,NULL,NULL);
		simAuxiliaryConsolePrint(handle,text.c_str());
	}
}
コード例 #3
0
CSimxSocket::CSimxSocket(int portNb,bool simulationOnly,bool debug,int maxPacketSize,bool waitForTriggerFunctionAuthorized)
{
	_commThreadLaunched=false;
	_commThreadEnded=true;
	clientIsConnected=false;
	otherSideIsBigEndian=false;
	_portNb=portNb;
	_simulationOnly=simulationOnly;
	_debug=debug;
	_maxPacketSize=maxPacketSize;
	_auxConsoleHandle=-1;
	_waitForTrigger=true;
	_waitForTriggerFunctionEnabled=false;
	_waitForTriggerFunctionAuthorized=waitForTriggerFunctionAuthorized;
	if (debug)
	{
		int options=4;
		if (_simulationOnly)
			options|=1;
		else
			options|=16;
		std::stringstream strStream;
		strStream << "Remote Api monitor on port " << _portNb;
		_auxConsoleHandle=simAuxiliaryConsoleOpen(strStream.str().c_str(),100,options,NULL,NULL,NULL,NULL);
	}

	_receivedCommands=new CSimxContainer(true);
	_dataToSend=new CSimxContainer(false);
	_lockLevel=0;
#ifdef _WIN32
	_mutex=CreateMutex(0,FALSE,0);
	_mutexAux=CreateMutex(0,FALSE,0);
#elif defined (__linux) || defined (__APPLE__)
	pthread_mutex_init(&_mutex, NULL);
	pthread_mutex_init(&_mutexAux, NULL);
#endif /* __linux || __APPLE__ */
}