Ocean
Ocean::Devices::Sensor Class Reference

This class implements the base class for all sensors. More...

Inheritance diagram for Ocean::Devices::Sensor:

Public Types

enum  SensorType : uint32_t {
  SENSOR_INVALID = MINOR_INVALID , SENSOR_ACCELERATION_3DOF , SENSOR_LINEAR_ACCELERATION_3DOF , SENSOR_GYRO_RAW_3DOF ,
  SENSOR_GYRO_UNBIASED_3DOF
}
 Definition of different sensor types. More...
 
- Public Types inherited from Ocean::Devices::Measurement
enum  InterpolationStrategy { IS_INVALID , IS_TIMESTAMP_NEAREST , IS_TIMESTAMP_INTERPOLATE }
 Definition of individual interpolation strategies for samples. More...
 
typedef unsigned int ObjectId
 Definition of an object id. More...
 
typedef std::vector< ObjectIdObjectIds
 Definition of a vector holding object ids. More...
 
typedef std::unordered_set< ObjectIdObjectIdSet
 Definition of an unordered set holding object ids. More...
 
typedef std::unordered_map< std::string, ValueMetadata
 Definition of an unordered map mapping keys to values. More...
 
typedef ObjectRef< SampleSampleRef
 Definition of an object reference for samples. More...
 
typedef Callback< void, const Measurement *, const SampleRef & > SampleCallback
 Definition of a callback function to subscribe for new measurement sample events. More...
 
- Public Types inherited from Ocean::Devices::Device
enum  MajorType : uint32_t { DEVICE_INVALID = 0u , DEVICE_MEASUREMENT = (1u << 0u) , DEVICE_SENSOR = (1u << 1u) | DEVICE_MEASUREMENT , DEVICE_TRACKER = (1u << 2u) | DEVICE_MEASUREMENT }
 Definition of all major device types. More...
 
enum  MinorType : uint32_t { MINOR_INVALID = 0u }
 Base definition of a minor type. More...
 

Static Public Member Functions

static std::string translateSensorType (const SensorType sensorType)
 Translates the sensor type to a readable string. More...
 
static SensorType translateSensorType (const std::string &sensorType)
 Translates the sensor type from a readable string to a value. More...
 
- Static Public Member Functions inherited from Ocean::Devices::Measurement
static constexpr ObjectId invalidObjectId ()
 Returns an invalid object id. More...
 
- Static Public Member Functions inherited from Ocean::Devices::Device
static std::string translateMajorType (const MajorType majorType)
 Translates the major devices type to a readable string. More...
 
static MajorType translateMajorType (const std::string &majorType)
 Translates the major devices type from a readable string to a value. More...
 

Protected Member Functions

 Sensor (const std::string &name, const DeviceType type)
 Creates a new sensor object. More...
 
virtual ~Sensor ()
 Destructs a sensor object. More...
 
- Protected Member Functions inherited from Ocean::Devices::Measurement
 Measurement (const std::string &name, const DeviceType type)
 Creates a new measurement object. More...
 
 ~Measurement () override
 Destructs a measurement object. More...
 
void postNewSample (const SampleRef &newSample)
 Posts a new measurement sample. More...
 
ObjectId addUniqueObjectId (const std::string &description)
 Creates a unique object id for a new object (e.g., a tracking object like an image, a marker, or a location). More...
 
void unsubscribeSampleEvent (const SubscriptionId subscriptionId)
 Unsubscribes a sample event callback function. More...
 
- Protected Member Functions inherited from Ocean::Devices::Device
 Device (const Device &device)=delete
 Disabled copy constructor. More...
 
 Device (const std::string &name, const DeviceType type)
 Creates a new device by is name. More...
 
virtual ~Device ()
 Destructs a device. More...
 
Deviceoperator= (const Device &device)=delete
 Disabled copy operator. More...
 

Additional Inherited Members

- Public Member Functions inherited from Ocean::Devices::Measurement
size_t sampleCapacity () const
 Returns the capacity of the internal sample container. More...
 
bool setSampleCapacity (const size_t capacity)
 Sets the capacity of the internal sample container. More...
 
virtual SampleRef sample () const
 Returns the most recent sample. More...
 
virtual SampleRef sample (const Timestamp timestamp) const
 Returns the sample with a specific timestamp. More...
 
virtual SampleRef sample (const Timestamp &timestamp, const InterpolationStrategy interpolationStrategy) const
 Returns the sample best matching with a specified timestamp. More...
 
SampleEventSubscription subscribeSampleEvent (SampleCallback &&callback)
 Subscribes a callback event function for new measurement sample events. More...
 
ObjectId objectId (const std::string &description) const
 Returns the object id for an object description. More...
 
Strings objectDescriptions () const
 Returns descriptions of all objects currently available. More...
 
std::string objectDescription (const ObjectId objectId) const
 Returns the description of one object of this measurement. More...
 
- Public Member Functions inherited from Ocean::Devices::Device
const std::string & name () const
 Returns the name of this device. More...
 
virtual const std::string & library () const =0
 Returns the name of the owner library. More...
 
virtual bool isStarted () const
 Returns whether this device is active. More...
 
bool isValid () const
 Returns whether this device is valid. More...
 
bool isExclusive () const
 Returns whether this device can be use exclusively. More...
 
virtual bool start ()
 Starts the device. More...
 
virtual bool pause ()
 Pauses the device. More...
 
virtual bool stop ()
 Stops the device. More...
 
virtual bool setParameter (const std::string &parameter, const Value &value)
 Sets an abstract parameter of this device. More...
 
virtual bool parameter (const std::string &parameter, Value &value)
 Returns an abstract parameter of this device. More...
 
DeviceType type () const
 Returns the major and minor type of this device. More...
 
- Protected Types inherited from Ocean::Devices::Measurement
typedef std::map< Timestamp, SampleRefSampleMap
 Definition of a map holding the most recent samples. More...
 
typedef std::unordered_map< std::string, ObjectIdObjectDescriptionToIdMap
 Definition of an unordered map mapping descriptions to unique object ids. More...
 
typedef std::unordered_map< ObjectId, std::string > ObjectIdToDescriptionMap
 Definition of an unordered map mapping unique object ids to descriptions. More...
 
typedef std::unordered_map< SubscriptionId, SampleCallbackSampleSubscriptionMap
 Definition of a map mapping subscription ids to event sample callback functions. More...
 
- Protected Types inherited from Ocean::Devices::Device
typedef unsigned int SubscriptionId
 Definition of a subscription id for event callbacks. More...
 
- Static Protected Member Functions inherited from Ocean::Devices::Device
static constexpr SubscriptionId invalidSubscriptionId ()
 Returns an invalid subscription id. More...
 
- Protected Attributes inherited from Ocean::Devices::Measurement
Lock samplesLock_
 Sample lock. More...
 
Lock subscriptionLock_
 Subscription lock. More...
 
- Protected Attributes inherited from Ocean::Devices::Device
std::string deviceName
 Name of this device. More...
 
DeviceType deviceType
 Major and minor type of this device. More...
 
bool deviceIsValid
 Flag determining whether this device is valid. More...
 
Lock deviceLock
 Device lock. More...
 

Detailed Description

This class implements the base class for all sensors.

Sensor provides measurement values, their types depend on the sensors.

Member Enumeration Documentation

◆ SensorType

Definition of different sensor types.

Enumerator
SENSOR_INVALID 

Invalid sensor.

SENSOR_ACCELERATION_3DOF 

3DOF acceleration sensor.

SENSOR_LINEAR_ACCELERATION_3DOF 

3DOF linear acceleration sensor (excluding gravity).

SENSOR_GYRO_RAW_3DOF 

3DOF gyro sensor (raw samples).

SENSOR_GYRO_UNBIASED_3DOF 

3DOF gyro sensor (unbiased samples).

Constructor & Destructor Documentation

◆ Sensor()

Ocean::Devices::Sensor::Sensor ( const std::string &  name,
const DeviceType  type 
)
protected

Creates a new sensor object.

Parameters
nameThe name of the sensor
typeMajor and minor device type of the device

◆ ~Sensor()

virtual Ocean::Devices::Sensor::~Sensor ( )
protectedvirtual

Destructs a sensor object.

Member Function Documentation

◆ translateSensorType() [1/2]

static std::string Ocean::Devices::Sensor::translateSensorType ( const SensorType  sensorType)
static

Translates the sensor type to a readable string.

Parameters
sensorTypeThe sensor type to translate
Returns
The readable string, empty if the type is unknown

◆ translateSensorType() [2/2]

static SensorType Ocean::Devices::Sensor::translateSensorType ( const std::string &  sensorType)
static

Translates the sensor type from a readable string to a value.

Parameters
sensorTypeThe sensor type to translate
Returns
The tanslated value

The documentation for this class was generated from the following file: