Пример #1
0
	virtual void Execute(SActivationInfo *pActInfo)
	{
		bool bResult = false;
		if (udpListener->IsWorking()) {
			if (udpListener->ReceiveLine() != -1) {
				string chaine = udpListener->GetRecMessage();
				string token0 = udpListener->GetToken(0);
				Quat gyro = udpListener->TokenToQuat(token0);
				string token1 = udpListener->GetToken(1);
				Vec3 accel = udpListener->TokenToVec3(token1);
				string token2 = udpListener->GetToken(2);
				float compass = udpListener->TokenToFloat(token2);
				
				//if(!gyro.IsValid()) CryLogAlways("NOT VALID");

				ActivateOutput(pActInfo, EOP_Gyro_xyz, Vec3(gyro.v.x,gyro.v.y,gyro.v.z));
				ActivateOutput(pActInfo, EOP_Gyro_w, gyro.w);
				
				ActivateOutput(pActInfo, EOP_Accel, accel);
				ActivateOutput(pActInfo, EOP_Compass, compass);
				
				bResult = true;
			}
		}
		return;
	}
Пример #2
0
	virtual void Execute(SActivationInfo *pActInfo)
	{
		bool bResult = false;
		if (udpListener->IsWorking()) {
			if (udpListener->ReceiveLine() != -1) {
				
				int analogs = udpListener->GetTokenCount();
				CryLogAlways("Nombre d'event %i",analogs);
				for(int i=0;i<analogs;i++){
					string token = udpListener->GetToken(i);
					float value = udpListener->TokenToFloat(token);
					
					int id = udpListener->GetId(token);
					if(id >= 10) {
						CryLogAlways("Error index out of bounds : token %s ",token);
						return;
					}

					if(current_values[id]!=value){
						current_values[id] = value;
						ActivateOutput(pActInfo,id+1,value);
					}
				}
				bResult = true;
			}
		}
		return;
	}
Пример #3
0
	virtual void Execute(SActivationInfo *pActInfo)
	{
		bool bResult = false;
		if (udpListener->IsWorking()) {
			if (udpListener->ReceiveLine() != -1) {
				
				int buttons = udpListener->GetTokenCount();
				
				for (int i=0;i<buttons;i++){
					string token = udpListener->GetToken(i);
					//CryLogAlways("%s",token);
					int id = udpListener->GetId(token);
					bool state = udpListener->TokenToBool(token);
					if(id>=12) {
						CryLogAlways("Index array out of bounds");
						break;
					}
					if(tab_state[id] != state){
						tab_state[id] = state;
						ActivateOutput(pActInfo,(id+1),state);
					}
				}
				
				bResult = true;
			}
		}
	
		//if (bResult) ActivateOutput(pActInfo, EOP_Received, true);
		return;
	}
Пример #4
0
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
	{
		switch (event)
		{
		case eFE_Initialize : 
			{
				current_values = new float[5];
				for(int i = 0 ;i<5;i++) current_values[i]= 0;
				break;
			}
			case eFE_Activate:
			{
				if (IsPortActive(pActInfo, EIP_Enable)) {
					
					if (udpListener->IsWorking()) udpListener->EndSocket();
					
					m_bEnabled = true;
					udpListener->StartSocket(GetPortInt(pActInfo, EIP_Port));

					Execute(pActInfo);
					pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, true);
				}

				if (IsPortActive(pActInfo, EIP_Disable)) {
					m_bEnabled = false;
					udpListener->EndSocket();
					pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, false);
				}
			}
			break;

			case eFE_Update:
			{
				CTimeValue currTime(gEnv->pTimer->GetCurrTime());
				float delay = 0;  // processing delay
				delay -= (currTime-m_lastTime).GetSeconds();
				m_lastTime = currTime;

				if (delay <= 0.0f)
				{
					Execute(pActInfo);
				}
			}
			break;
		}
	}
Пример #5
0
	virtual ~CryVR_AndroidDevice(void)
	{
		if (udpListener->IsWorking())udpListener->EndSocket();
	}