Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: device/generic_sensor/linux/sensor_data_linux.h

Issue 2533793002: [sensors](CrOS/Linux) Implement Sensor device manager for sensors (Closed)
Patch Set: construct manager Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_ 5 #ifndef DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
6 #define DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_ 6 #define DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
7 7
8 #include "device/generic_sensor/generic_sensor_export.h" 8 #include "device/generic_sensor/generic_sensor_export.h"
9 #include "device/generic_sensor/public/interfaces/sensor.mojom.h" 9 #include "device/generic_sensor/public/interfaces/sensor.mojom.h"
10 10
11 namespace device { 11 namespace device {
12 12
13 class PlatformSensorConfiguration;
13 struct SensorReading; 14 struct SensorReading;
14 15
15 // This structure represents a context that is used to 16 // This structure represents a context that is used to identify a udev device
16 // create a type specific SensorReader and a concrete 17 // and create a type specific SensorInfoLinux. For example, when a
17 // sensor that uses the SensorReader to read sensor 18 // SensorDeviceManager receives a udev device, it uses this structure to
18 // data from files specified in the |sensor_file_names|. 19 // identify what type of sensor that is and creates a SensorInfoLinux structure
19 struct DEVICE_GENERIC_SENSOR_EXPORT SensorDataLinux { 20 // that holds all the necessary information to create a PlatformSensorLinux.
20 using ReaderFunctor = 21 struct DEVICE_GENERIC_SENSOR_EXPORT SensorPathsLinux {
21 base::Callback<void(double scaling, SensorReading& reading)>; 22 using ReaderFunctor = base::Callback<
23 void(double scaling, double offset, SensorReading& reading)>;
22 24
23 SensorDataLinux(); 25 SensorPathsLinux();
24 ~SensorDataLinux(); 26 ~SensorPathsLinux();
25 SensorDataLinux(const SensorDataLinux& other); 27 SensorPathsLinux(const SensorPathsLinux& other);
26 // Provides a base path to all sensors. 28 // Provides a base path to all sensors.
27 const base::FilePath::CharType* base_path_sensor_linux; 29 const base::FilePath::CharType* base_path_sensor_linux;
28 // Provides an array of sensor file names to be searched for. 30 // Provides an array of sensor file names to be searched for.
29 // Different sensors might have up to 3 different file name arrays. 31 // Different sensors might have up to 3 different file name arrays.
30 // One file must be found from each array. 32 // One file must be found from each array.
31 std::vector<std::vector<std::string>> sensor_file_names; 33 std::vector<std::vector<std::string>> sensor_file_names;
32 // Scaling file to be found. 34 // Scaling file to be found.
33 std::string sensor_scale_name; 35 std::string sensor_scale_name;
36 // Frequency file to be found.
37 std::string sensor_frequency_file_name;
38 // Offset file to be found.
39 std::string sensor_offset_file_name;
34 // Used to apply scalings to raw sensor data. 40 // Used to apply scalings to raw sensor data.
35 ReaderFunctor apply_scaling_func; 41 ReaderFunctor apply_scaling_func;
36 // Reporting mode of a sensor. 42 // Sensor type
37 mojom::ReportingMode reporting_mode; 43 mojom::SensorType type;
38 // Default configuration of a sensor. 44 // Default configuration of a sensor.
39 PlatformSensorConfiguration default_configuration; 45 PlatformSensorConfiguration default_configuration;
40 }; 46 };
41 47
42 // Initializes a sensor type specific data. 48 // Initializes sensor data according to |type|.
43 bool InitSensorData(mojom::SensorType type, SensorDataLinux* data); 49 bool DEVICE_GENERIC_SENSOR_EXPORT InitSensorData(mojom::SensorType type,
50 SensorPathsLinux* data);
51
52 // This structure represents an iio device, which info is taken
53 // from udev service. If a client requests a sensor from a provider,
54 // the provider takes this initialized and stored structure and uses it to
55 // create a requested PlatformSensorLinux of a certain type.
56 struct SensorInfoLinux {
57 // Represents current sensor device node.
58 const std::string device_node;
59 // Represents frequency of a sensor.
60 const double device_frequency;
61 // Represents scaling value to be applied on raw data.
62 const double device_scaling_value;
63 // Represents offset value that must be applied on raw data.
64 const double device_offset_value;
65 // Reporting mode of a sensor taken from SensorDataLinux.
66 const mojom::ReportingMode reporting_mode;
67 // Functor that is used to convert raw data.
68 const SensorPathsLinux::ReaderFunctor apply_scaling_func;
69 // Sensor files in sysfs. Used to poll data.
70 const std::vector<base::FilePath> device_reading_files;
71
72 SensorInfoLinux(const std::string& sensor_device_node,
73 double sensor_device_frequency,
74 double sensor_device_scaling_value,
75 double sensor_device_offset_value,
76 mojom::ReportingMode mode,
77 SensorPathsLinux::ReaderFunctor scaling_func,
78 std::vector<base::FilePath> iio_device_reading_files);
79 ~SensorInfoLinux();
80 };
44 81
45 } // namespace device 82 } // namespace device
46 83
47 #endif // DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_ 84 #endif // DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698