| Index: device/generic_sensor/linux/sensor_data_linux.h
|
| diff --git a/device/generic_sensor/linux/sensor_data_linux.h b/device/generic_sensor/linux/sensor_data_linux.h
|
| index 3336a8e3d414911ac5b1acee468ac21b21c61989..b98523d044fc65b2b4e11bf2c5e0ff5af2181f31 100644
|
| --- a/device/generic_sensor/linux/sensor_data_linux.h
|
| +++ b/device/generic_sensor/linux/sensor_data_linux.h
|
| @@ -10,19 +10,21 @@
|
|
|
| namespace device {
|
|
|
| +class PlatformSensorConfiguration;
|
| struct SensorReading;
|
|
|
| -// This structure represents a context that is used to
|
| -// create a type specific SensorReader and a concrete
|
| -// sensor that uses the SensorReader to read sensor
|
| -// data from files specified in the |sensor_file_names|.
|
| -struct DEVICE_GENERIC_SENSOR_EXPORT SensorDataLinux {
|
| - using ReaderFunctor =
|
| - base::Callback<void(double scaling, SensorReading& reading)>;
|
| -
|
| - SensorDataLinux();
|
| - ~SensorDataLinux();
|
| - SensorDataLinux(const SensorDataLinux& other);
|
| +// This structure represents a context that is used to identify a udev device
|
| +// and create a type specific SensorInfoLinux. For example, when a
|
| +// SensorDeviceManager receives a udev device, it uses this structure to
|
| +// identify what type of sensor that is and creates a SensorInfoLinux structure
|
| +// that holds all the necessary information to create a PlatformSensorLinux.
|
| +struct DEVICE_GENERIC_SENSOR_EXPORT SensorPathsLinux {
|
| + using ReaderFunctor = base::Callback<
|
| + void(double scaling, double offset, SensorReading& reading)>;
|
| +
|
| + SensorPathsLinux();
|
| + ~SensorPathsLinux();
|
| + SensorPathsLinux(const SensorPathsLinux& other);
|
| // Provides a base path to all sensors.
|
| const base::FilePath::CharType* base_path_sensor_linux;
|
| // Provides an array of sensor file names to be searched for.
|
| @@ -31,16 +33,51 @@ struct DEVICE_GENERIC_SENSOR_EXPORT SensorDataLinux {
|
| std::vector<std::vector<std::string>> sensor_file_names;
|
| // Scaling file to be found.
|
| std::string sensor_scale_name;
|
| + // Frequency file to be found.
|
| + std::string sensor_frequency_file_name;
|
| + // Offset file to be found.
|
| + std::string sensor_offset_file_name;
|
| // Used to apply scalings to raw sensor data.
|
| ReaderFunctor apply_scaling_func;
|
| - // Reporting mode of a sensor.
|
| - mojom::ReportingMode reporting_mode;
|
| + // Sensor type
|
| + mojom::SensorType type;
|
| // Default configuration of a sensor.
|
| PlatformSensorConfiguration default_configuration;
|
| };
|
|
|
| -// Initializes a sensor type specific data.
|
| -bool InitSensorData(mojom::SensorType type, SensorDataLinux* data);
|
| +// Initializes sensor data according to |type|.
|
| +bool DEVICE_GENERIC_SENSOR_EXPORT InitSensorData(mojom::SensorType type,
|
| + SensorPathsLinux* data);
|
| +
|
| +// This structure represents an iio device, which info is taken
|
| +// from udev service. If a client requests a sensor from a provider,
|
| +// the provider takes this initialized and stored structure and uses it to
|
| +// create a requested PlatformSensorLinux of a certain type.
|
| +struct SensorInfoLinux {
|
| + // Represents current sensor device node.
|
| + const std::string device_node;
|
| + // Represents frequency of a sensor.
|
| + const double device_frequency;
|
| + // Represents scaling value to be applied on raw data.
|
| + const double device_scaling_value;
|
| + // Represents offset value that must be applied on raw data.
|
| + const double device_offset_value;
|
| + // Reporting mode of a sensor taken from SensorDataLinux.
|
| + const mojom::ReportingMode reporting_mode;
|
| + // Functor that is used to convert raw data.
|
| + const SensorPathsLinux::ReaderFunctor apply_scaling_func;
|
| + // Sensor files in sysfs. Used to poll data.
|
| + const std::vector<base::FilePath> device_reading_files;
|
| +
|
| + SensorInfoLinux(const std::string& sensor_device_node,
|
| + double sensor_device_frequency,
|
| + double sensor_device_scaling_value,
|
| + double sensor_device_offset_value,
|
| + mojom::ReportingMode mode,
|
| + SensorPathsLinux::ReaderFunctor scaling_func,
|
| + std::vector<base::FilePath> iio_device_reading_files);
|
| + ~SensorInfoLinux();
|
| +};
|
|
|
| } // namespace device
|
|
|
|
|