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

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

Issue 2865263002: Move //device/generic_sensor to be part of the internal implementation of the Device Service. (Closed)
Patch Set: code rebase Created 3 years, 7 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
6 #define DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
7
8 #include "device/generic_sensor/generic_sensor_export.h"
9 #include "device/generic_sensor/public/interfaces/sensor.mojom.h"
10
11 namespace device {
12
13 class PlatformSensorConfiguration;
14 struct SensorReading;
15
16 // This structure represents a context that is used to identify a udev device
17 // and create a type specific SensorInfoLinux. For example, when a
18 // SensorDeviceManager receives a udev device, it uses this structure to
19 // identify what type of sensor that is and creates a SensorInfoLinux structure
20 // that holds all the necessary information to create a PlatformSensorLinux.
21 struct DEVICE_GENERIC_SENSOR_EXPORT SensorPathsLinux {
22 using ReaderFunctor = base::Callback<
23 void(double scaling, double offset, SensorReading& reading)>;
24
25 SensorPathsLinux();
26 ~SensorPathsLinux();
27 SensorPathsLinux(const SensorPathsLinux& other);
28 // Provides an array of sensor file names to be searched for.
29 // Different sensors might have up to 3 different file name arrays.
30 // One file must be found from each array.
31 std::vector<std::vector<std::string>> sensor_file_names;
32 // Scaling file to be found.
33 std::string sensor_scale_name;
34 // Frequency file to be found.
35 std::string sensor_frequency_file_name;
36 // Offset file to be found.
37 std::string sensor_offset_file_name;
38 // Used to apply scalings to raw sensor data.
39 ReaderFunctor apply_scaling_func;
40 // Sensor type
41 mojom::SensorType type;
42 // Default configuration of a sensor.
43 PlatformSensorConfiguration default_configuration;
44 };
45
46 // Initializes sensor data according to |type|.
47 bool DEVICE_GENERIC_SENSOR_EXPORT InitSensorData(mojom::SensorType type,
48 SensorPathsLinux* data);
49
50 // This structure represents an iio device, which info is taken
51 // from udev service. If a client requests a sensor from a provider,
52 // the provider takes this initialized and stored structure and uses it to
53 // create a requested PlatformSensorLinux of a certain type.
54 struct SensorInfoLinux {
55 // Represents current sensor device node.
56 const std::string device_node;
57 // Represents frequency of a sensor.
58 const double device_frequency;
59 // Represents scaling value to be applied on raw data.
60 const double device_scaling_value;
61 // Represents offset value that must be applied on raw data.
62 const double device_offset_value;
63 // Reporting mode of a sensor taken from SensorDataLinux.
64 const mojom::ReportingMode reporting_mode;
65 // Functor that is used to convert raw data.
66 const SensorPathsLinux::ReaderFunctor apply_scaling_func;
67 // Sensor files in sysfs. Used to poll data.
68 const std::vector<base::FilePath> device_reading_files;
69
70 SensorInfoLinux(const std::string& sensor_device_node,
71 double sensor_device_frequency,
72 double sensor_device_scaling_value,
73 double sensor_device_offset_value,
74 mojom::ReportingMode mode,
75 SensorPathsLinux::ReaderFunctor scaling_func,
76 std::vector<base::FilePath> iio_device_reading_files);
77 ~SensorInfoLinux();
78 };
79
80 } // namespace device
81
82 #endif // DEVICE_GENERIC_SENSOR_LINUX_SENSOR_DATA_LINUX_H_
OLDNEW
« no previous file with comments | « device/generic_sensor/generic_sensor_export.h ('k') | device/generic_sensor/linux/sensor_data_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698