Skip to content

Create Additional Sources

Aleksandar Adamovic edited this page Mar 7, 2015 · 1 revision

The application contains ISensorReadingService interface that can be used to implement additional data sources. To create a new custom implementation of the reading service create a new class in SensorReading namespace and implement the interface. Make sure to name the class based on the data source you will be implementing. If it will be using the internal Accelerometer, for example, name your service AccelerometerReadingService. The OpenTrackService will call GetCurrentReading to obtain the latest sensor reading.

Once the class is implemented, edit the SensorReaderFactory and add the new DataSource initialization in GetSensorReadingService method and add the appropriate SensorReaderType. Do not change the default DataSource.

Following the naming example with AccelerometerDataSource the GetSensorReadingService will look like:

public ISensorReadingService GetSensorReadingService(SensorReaderType type)
{
	switch (type)
	{
		case SensorReaderType.Accelerometer:
			return new AccelerometerReadingService();
		default:
			return new GyroscopeReadingService();
	}
}

And the SensorReadingType

public enum SensorReaderType
{
	Gyroscope,
	Accelerometer
}

And that's it. The rest will fall in place. Create a new pull request for your code. Once accepted it will be released in the next version. If the mapping for the new data source differs from default Gyroscope, please create a new wiki page with the instructions. If you would like to be mentioned in the credits, make sure to include the name you would like to use in the pull request description.

Clone this wiki locally