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