• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef android_hardware_automotive_vehicle_V2_0_impl_LinearFakeValueGenerator_H_
18 #define android_hardware_automotive_vehicle_V2_0_impl_LinearFakeValueGenerator_H_
19 
20 #include "FakeValueGenerator.h"
21 
22 namespace android {
23 namespace hardware {
24 namespace automotive {
25 namespace vehicle {
26 namespace V2_0 {
27 
28 namespace impl {
29 
30 class LinearFakeValueGenerator : public FakeValueGenerator {
31 private:
32     // In every timer tick we may want to generate new value based on initial value for debug
33     // purpose. It's better to have sequential values to see if events gets delivered in order
34     // to the client.
35 
36     struct GeneratorCfg {
37         int32_t propId;
38         float initialValue;
39         float currentValue;  //  Should be in range (initialValue +/- dispersion).
40         float dispersion;    //  Defines minimum and maximum value based on initial value.
41         float increment;     //  Value that we will be added to currentValue with each timer tick.
42         Nanos interval;
43     };
44 
45 public:
46     LinearFakeValueGenerator(const VehiclePropValue& request);
47     ~LinearFakeValueGenerator() = default;
48 
49     VehiclePropValue nextEvent();
50 
51     bool hasNext();
52 
53 private:
54     GeneratorCfg mGenCfg;
55 };
56 
57 }  // namespace impl
58 
59 }  // namespace V2_0
60 }  // namespace vehicle
61 }  // namespace automotive
62 }  // namespace hardware
63 }  // namespace android
64 
65 #endif  // android_hardware_automotive_vehicle_V2_0_impl_LinearFakeValueGenerator_H_
66