Ejemplo n.º 1
0
bool getHapticInput(btTransform &trans0, bool buttons0[2], btTransform &trans1, bool buttons1[2]) {
    Vector3d start_proxy_pos, end_proxy_pos;
    Matrix3d start_proxy_rot, end_proxy_rot;
    if (!getDeviceState(start_proxy_pos, start_proxy_rot, buttons0,
                        end_proxy_pos, end_proxy_rot, buttons1))
        return false;
    trans0 = btTransform(toHapticBtMatrix(start_proxy_rot) * HAPTIC_ROTATION,
                         HAPTIC_TRANS_SCALE*toHapticBtVector(start_proxy_pos) + HAPTIC_OFFSET0);
    trans1 = btTransform(toHapticBtMatrix(end_proxy_rot) * HAPTIC_ROTATION,
                         HAPTIC_TRANS_SCALE*toHapticBtVector(end_proxy_pos) + HAPTIC_OFFSET1);
    return true;
}
Ejemplo n.º 2
0
int main(int argc, const char * argv[])
{
	HelloSoundplaneDriverListener listener;
	const auto driver = SoundplaneDriver::create(&listener);

	std::cout << "Hello, Soundplane?\n";
	std::cout << "Initial device state: " << driver->getDeviceState() << std::endl;

	for (;;)
	{
		sleep(1);
	}

    return 0;
}
Ejemplo n.º 3
0
/** \brief
 *
 *  \type         local
 *
 *  \param[in]	  pvData    not used
 *
 *  \return       void
 *
 ******************************************************************************/
void vConnectionTask(void *pvData) {
	
		//nRF8001 initialisieren
		nRF8001();
		vTaskDelay(10);

    while (1) {
			

			
			//Check the current DeviceState
			deviceCurrentState=getDeviceState();
			switch(deviceCurrentState)
			{
					case Initial:
						setup(); 				//DeviceStartedEvent
						break;
					
					case Setup:
						break;
					
					case Standby:
						
						//Check the current connectionState
						connectionState=getConnectionStatus();
						switch(connectionState)
						{
								//Is not connected
								case Disconnected:
									connect(0x3f,0xff,0x40,0x00);
									poll(0x200);		//CommandResponseEvent
									pollvoid();			//ConnectEvent
								break;
								
								//Is connected
								case Connected:
											//Open the Pipe to Receive
											openRemotePipe(1);
											pollvoid();				//CommandResponseEvent
								
											//Request the Data
											requestData(1);
											pollvoid();				//DataReceivedEvent
										
											//Write the Data in local varible
											length = rxEvent->length;
											for(txcount=0;txcount<=length-3;txcount++)
											{
												Data[txcount]=rxEvent->msg.dataReceived.data[txcount];
											}
											
											//Close the Pipe
											closeRemotePipe(1);
											pollvoid();								

											// Check the Received Message from the PeerDevice
											switch((Data[0]<<8)|Data[1])
											{
												//Turn the Socket on
												case PLUG_ON:
													//Sets the Control LED
													GPIO_SetBits(GPIOB, GPIO_Pin_11);
													//Solid State Relay active
													GPIO_SetBits(GPIOB, GPIO_Pin_0);
													break;
												
												//Turn the Socket off
												case PLUG_OFF:
													//Resets the Control LED
													GPIO_ResetBits(GPIOB, GPIO_Pin_11);
													//Resets the Solid State Relay
													GPIO_ResetBits(GPIOB, GPIO_Pin_0);
													break;
												
												// Get the data
												case GET_DATA:
														//write the received time in a local varible
														CurrentTime.hour[0]=Data[4];
														CurrentTime.hour[1]=Data[3];
														
														CurrentTime.minute[0]=Data[6];
														CurrentTime.minute[1]=Data[5];
												
														//update the time
														xQueueSend(xQueueTime, (void *) &CurrentTime, portMAX_DELAY);

														//Receive PowerMessage from Logger Task
													
														xQueueReceive( xQueuePowerMessage, &( PowerMessage ), portMAX_DELAY );
															active=(float)PowerMessage.active/60;
															voltage=(float)PowerMessage.voltage/4;
															current=(float)PowerMessage.current*4;
														
														switch(Data[2])
														{
															case ACTIVE_POWER:
																//write the active Power in the Outgoing Message
																sprintf(OutMessage,"P:%4.1f W %c%c:%c%c",active, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case REACTIVE_POWER:
																//write the reactive Power in the Outgoing Message
																sprintf(OutMessage,"Q:%d mVAr %c%c:%c%c",PowerMessage.reactive, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case APPARENT_POWER:
																//write the apparent Power in the Outgoing Message
																sprintf(OutMessage,"S:%d mVA %c%c:%c%c",PowerMessage.apparent, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case U_RMS:
																//write the RMS voltage in the Outgoing Message
																sprintf(OutMessage,"U:%4.1f V %c%c:%c%c",voltage, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															
															case I_RMS:
																//write the RMS current in the Outgoing Message
																sprintf(OutMessage,"I:%4.1f mA %c%c:%c%c",current, PowerMessage.hour[1], PowerMessage.hour[0], PowerMessage.minute[1], PowerMessage.minute[0]);
																break;
															default:
																break;
												
															
														}		
														
														//Open the send Pipe
														openRemotePipe(2);
														pollvoid();				//CommandResponseEvent
												
														// Send the Output Message to the Peer Device
														sendData(2,20,OutMessage);//s135k
														
														for(txcount=0;txcount<20;txcount++)
														{
															OutMessage[txcount]=0;
														}
												
														//Close the Send Pipe
														closeRemotePipe(2);
														pollvoid();							
													break;
												default:
													break;
											}
									break;
									
								//Is connecting
								case Connecting:
									break;
							
								default:
									break;	
						}
						break;
					
					case Invalid:
						break;
					
					default:
						break;			
			}

			
			vTaskDelay(10);
	}
}