Ocean
AndroidAccelerationSensor3DOF.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_DEVICES_ANDROID_ANDROID_ACCELERATION_SENSOR_3_DOF_H
9 #define META_OCEAN_DEVICES_ANDROID_ANDROID_ACCELERATION_SENSOR_3_DOF_H
10 
13 
15 
16 namespace Ocean
17 {
18 
19 namespace Devices
20 {
21 
22 namespace Android
23 {
24 
25 /**
26  * This class implements all 3DOF acceleration sensors (including the linear acceleration sensors).
27  * @ingroup devicesandroid
28  */
29 class OCEAN_DEVICES_EXPORT AndroidAccelerationSensor3DOF :
30  virtual public AndroidSensor,
31  virtual public AccelerationSensor3DOF
32 {
33  friend class AndroidFactory;
34 
35  public:
36 
37  /**
38  * Returns the name of this sensor.
39  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
40  * @return The sensor's name
41  */
42  static inline std::string deviceNameAndroidAccelerationSensor3DOF(const SensorType sensorType);
43 
44  /**
45  * Returns the device type of this sensor.
46  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
47  * @return The sensor's device type
48  */
49  static inline DeviceType deviceTypeAndroidAccelerationSensor3DOF(const SensorType sensorType);
50 
51  protected:
52 
53  /**
54  * Creates a new 3DOF acceleration sensor device.
55  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
56  * @param sensor The Android sensor providing the sensor measurements, must be valid
57  */
58  AndroidAccelerationSensor3DOF(const SensorType sensorType, const ASensor* sensor);
59 
60  /**
61  * Destructs a 3DOF acceleration sensor device.
62  */
64 
65  /**
66  * The actual event function of this device.
67  * @see AndroidDevice::onEventFunction().
68  */
69  int onEventFunction() override;
70 
71  protected:
72 
73  /// The Android event timestamp of the first sensor event.
74  int64_t firstAndroidEventTimestamp_ = 0ll;
75 
76  /// The Unix event timestamp of the first sensor event.
77  Timestamp firstUnixEventTimestamp_ = Timestamp(false);
78 };
79 
81 {
82  ocean_assert(sensorType == SENSOR_ACCELERATION_3DOF || sensorType == SENSOR_LINEAR_ACCELERATION_3DOF);
83 
84  if (sensorType == SENSOR_ACCELERATION_3DOF)
85  {
86  return std::string("Android 3DOF Acceleration Sensor");
87  }
88 
89  return std::string("Android 3DOF Linear Acceleration Sensor");
90 }
91 
93 {
94  ocean_assert(sensorType == SENSOR_ACCELERATION_3DOF || sensorType == SENSOR_LINEAR_ACCELERATION_3DOF);
95 
96  return deviceTypeAccelerationSensor3DOF(sensorType);
97 }
98 
99 }
100 
101 }
102 
103 }
104 
105 #endif // META_OCEAN_DEVICES_ANDROID_ANDROID_ACCELERATION_SENSOR_3_DOF_H
This class is the base class for all 3DOF acceleration sensors.
Definition: AccelerationSensor3DOF.h:40
static DeviceType deviceTypeAccelerationSensor3DOF(const SensorType sensorType)
Returns this device type.
Definition: AccelerationSensor3DOF.h:118
This class implements all 3DOF acceleration sensors (including the linear acceleration sensors).
Definition: AndroidAccelerationSensor3DOF.h:32
AndroidAccelerationSensor3DOF(const SensorType sensorType, const ASensor *sensor)
Creates a new 3DOF acceleration sensor device.
~AndroidAccelerationSensor3DOF() override
Destructs a 3DOF acceleration sensor device.
static DeviceType deviceTypeAndroidAccelerationSensor3DOF(const SensorType sensorType)
Returns the device type of this sensor.
Definition: AndroidAccelerationSensor3DOF.h:92
static std::string deviceNameAndroidAccelerationSensor3DOF(const SensorType sensorType)
Returns the name of this sensor.
Definition: AndroidAccelerationSensor3DOF.h:80
int onEventFunction() override
The actual event function of this device.
This class implements a device factory for the Android feature based tracking system.
Definition: AndroidFactory.h:31
This class implements a sensor for the Android library.
Definition: AndroidSensor.h:41
Definition of a class holding the major and minor device type.
Definition: devices/Device.h:62
SensorType
Definition of different sensor types.
Definition: Sensor.h:43
@ SENSOR_ACCELERATION_3DOF
3DOF acceleration sensor.
Definition: Sensor.h:47
@ SENSOR_LINEAR_ACCELERATION_3DOF
3DOF linear acceleration sensor (excluding gravity).
Definition: Sensor.h:49
This class implements a timestamp.
Definition: Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15