Home | History | Annotate | Download | only in vhal_v2_0
      1 /*
      2  * Copyright (C) 2016 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_DefaultConfig_H_
     18 #define android_hardware_automotive_vehicle_V2_0_impl_DefaultConfig_H_
     19 
     20 #include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
     21 #include <vhal_v2_0/VehicleUtils.h>
     22 
     23 namespace android {
     24 namespace hardware {
     25 namespace automotive {
     26 namespace vehicle {
     27 namespace V2_0 {
     28 
     29 namespace impl {
     30 
     31 /*
     32  * This property is used for test purpose to generate fake events.
     33  *
     34  * It has the following format:
     35  *
     36  * int32Values[0] - command (1 - start fake data generation, 0 - stop)
     37  * int32Values[1] - VehicleProperty to which command applies
     38  *
     39  * For start command, additional data should be provided:
     40  *   int64Values[0] - periodic interval in nanoseconds
     41  *   floatValues[0] - initial value
     42  *   floatValues[1] - dispersion defines min and max range relative to initial value
     43  *   floatValues[2] - increment, with every timer tick the value will be incremented by this amount
     44  */
     45 const int32_t kGenerateFakeDataControllingProperty = 0x0666
     46         | VehiclePropertyGroup::VENDOR
     47         | VehicleArea::GLOBAL
     48         | VehiclePropertyType::COMPLEX;
     49 
     50 const int32_t kHvacPowerProperties[] = {
     51     toInt(VehicleProperty::HVAC_FAN_SPEED),
     52     toInt(VehicleProperty::HVAC_FAN_DIRECTION),
     53 };
     54 
     55 struct ConfigDeclaration {
     56     VehiclePropConfig config;
     57 
     58     /* This value will be used as an initial value for the property. If this field is specified for
     59      * property that supports multiple areas then it will be used for all areas unless particular
     60      * area is overridden in initialAreaValue field. */
     61     VehiclePropValue::RawValue initialValue;
     62     /* Use initialAreaValues if it is necessary to specify different values per each area. */
     63     std::map<int32_t, VehiclePropValue::RawValue> initialAreaValues;
     64 };
     65 
     66 const ConfigDeclaration kVehicleProperties[]{
     67     {.config =
     68          {
     69              .prop = toInt(VehicleProperty::INFO_MAKE),
     70              .access = VehiclePropertyAccess::READ,
     71              .changeMode = VehiclePropertyChangeMode::STATIC,
     72          },
     73      .initialValue = {.stringValue = "Toy Vehicle"}},
     74     {.config =
     75          {
     76              .prop = toInt(VehicleProperty::PERF_VEHICLE_SPEED),
     77              .access = VehiclePropertyAccess::READ,
     78              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
     79              .minSampleRate = 1.0f,
     80              .maxSampleRate = 1000.0f,
     81          },
     82      .initialValue = {.floatValues = {0.0f}}},
     83 
     84     {.config =
     85          {
     86              .prop = toInt(VehicleProperty::PERF_ODOMETER),
     87              .access = VehiclePropertyAccess::READ,
     88              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
     89          },
     90      .initialValue = {.floatValues = {0.0f}}},
     91 
     92     {
     93         .config =
     94             {
     95                 .prop = toInt(VehicleProperty::ENGINE_RPM),
     96                 .access = VehiclePropertyAccess::READ,
     97                 .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
     98                 .minSampleRate = 1.0f,
     99                 .maxSampleRate = 1000.0f,
    100             },
    101         .initialValue = {.floatValues = {0.0f}},
    102     },
    103 
    104     {.config =
    105          {
    106              .prop = toInt(VehicleProperty::CURRENT_GEAR),
    107              .access = VehiclePropertyAccess::READ,
    108              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    109          },
    110      .initialValue = {.int32Values = {toInt(VehicleGear::GEAR_PARK)}}},
    111 
    112     {.config =
    113          {
    114              .prop = toInt(VehicleProperty::PARKING_BRAKE_ON),
    115              .access = VehiclePropertyAccess::READ,
    116              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    117          },
    118      .initialValue = {.int32Values = {1}}},
    119 
    120     {.config =
    121          {
    122              .prop = toInt(VehicleProperty::FUEL_LEVEL_LOW),
    123              .access = VehiclePropertyAccess::READ,
    124              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    125          },
    126      .initialValue = {.int32Values = {0}}},
    127 
    128     {.config =
    129          {
    130              .prop = toInt(VehicleProperty::HVAC_POWER_ON),
    131              .access = VehiclePropertyAccess::READ_WRITE,
    132              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    133              .supportedAreas = toInt(VehicleAreaZone::ROW_1),
    134              // TODO(bryaneyler): Ideally, this is generated dynamically from
    135              // kHvacPowerProperties.
    136              .configString = "0x12400500,0x12400501"  // HVAC_FAN_SPEED,HVAC_FAN_DIRECTION
    137          },
    138      .initialValue = {.int32Values = {1}}},
    139 
    140     {
    141         .config = {.prop = toInt(VehicleProperty::HVAC_DEFROSTER),
    142                    .access = VehiclePropertyAccess::READ_WRITE,
    143                    .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    144                    .supportedAreas =
    145                        VehicleAreaWindow::FRONT_WINDSHIELD | VehicleAreaWindow::REAR_WINDSHIELD},
    146         .initialValue = {.int32Values = {0}}  // Will be used for all areas.
    147     },
    148 
    149     {.config = {.prop = toInt(VehicleProperty::HVAC_RECIRC_ON),
    150                 .access = VehiclePropertyAccess::READ_WRITE,
    151                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    152                 .supportedAreas = toInt(VehicleAreaZone::ROW_1)},
    153      .initialValue = {.int32Values = {1}}},
    154 
    155     {.config = {.prop = toInt(VehicleProperty::HVAC_AC_ON),
    156                 .access = VehiclePropertyAccess::READ_WRITE,
    157                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    158                 .supportedAreas = toInt(VehicleAreaZone::ROW_1)},
    159      .initialValue = {.int32Values = {1}}},
    160 
    161     {.config = {.prop = toInt(VehicleProperty::HVAC_AUTO_ON),
    162                 .access = VehiclePropertyAccess::READ_WRITE,
    163                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    164                 .supportedAreas = toInt(VehicleAreaZone::ROW_1)},
    165      .initialValue = {.int32Values = {1}}},
    166 
    167     {.config = {.prop = toInt(VehicleProperty::HVAC_FAN_SPEED),
    168                 .access = VehiclePropertyAccess::READ_WRITE,
    169                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    170                 .supportedAreas = toInt(VehicleAreaZone::ROW_1),
    171                 .areaConfigs = {VehicleAreaConfig{.areaId = toInt(VehicleAreaZone::ROW_1),
    172                                                   .minInt32Value = 1,
    173                                                   .maxInt32Value = 7}}},
    174      .initialValue = {.int32Values = {3}}},
    175 
    176     {.config =
    177          {
    178              .prop = toInt(VehicleProperty::HVAC_FAN_DIRECTION),
    179              .access = VehiclePropertyAccess::READ_WRITE,
    180              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    181              .supportedAreas = toInt(VehicleAreaZone::ROW_1),
    182          },
    183      .initialValue = {.int32Values = {toInt(VehicleHvacFanDirection::FACE)}}},
    184 
    185     {.config = {.prop = toInt(VehicleProperty::HVAC_TEMPERATURE_SET),
    186                 .access = VehiclePropertyAccess::READ_WRITE,
    187                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    188                 .supportedAreas = VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT,
    189                 .areaConfigs = {VehicleAreaConfig{
    190                                     .areaId = toInt(VehicleAreaZone::ROW_1_LEFT),
    191                                     .minFloatValue = 16,
    192                                     .maxFloatValue = 32,
    193                                 },
    194                                 VehicleAreaConfig{
    195                                     .areaId = toInt(VehicleAreaZone::ROW_1_RIGHT),
    196                                     .minFloatValue = 16,
    197                                     .maxFloatValue = 32,
    198                                 }}},
    199      .initialAreaValues = {{toInt(VehicleAreaZone::ROW_1_LEFT), {.floatValues = {16}}},
    200                            {toInt(VehicleAreaZone::ROW_1_RIGHT), {.floatValues = {20}}}}},
    201 
    202     {.config =
    203          {
    204              .prop = toInt(VehicleProperty::ENV_OUTSIDE_TEMPERATURE),
    205              .access = VehiclePropertyAccess::READ,
    206              // TODO(bryaneyler): Support ON_CHANGE as well.
    207              .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
    208              .minSampleRate = 1.0f,
    209              .maxSampleRate = 2.0f,
    210          },
    211      .initialValue = {.floatValues = {25.0f}}},
    212 
    213     {.config =
    214          {
    215              .prop = toInt(VehicleProperty::NIGHT_MODE),
    216              .access = VehiclePropertyAccess::READ,
    217              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    218          },
    219      .initialValue = {.int32Values = {0}}},
    220 
    221     {.config =
    222          {
    223              .prop = toInt(VehicleProperty::DRIVING_STATUS),
    224              .access = VehiclePropertyAccess::READ,
    225              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    226          },
    227      .initialValue = {.int32Values = {toInt(VehicleDrivingStatus::UNRESTRICTED)}}},
    228 
    229     {.config =
    230          {
    231              .prop = toInt(VehicleProperty::GEAR_SELECTION),
    232              .access = VehiclePropertyAccess::READ,
    233              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    234          },
    235      .initialValue = {.int32Values = {toInt(VehicleGear::GEAR_PARK)}}},
    236 
    237     {
    238         .config =
    239             {
    240                 .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY),
    241                 .access = VehiclePropertyAccess::READ,
    242                 .changeMode = VehiclePropertyChangeMode::STATIC,
    243             },
    244         .initialValue = {.floatValues = {123000.0f}}  // In Milliliters
    245     },
    246 
    247     {.config = {.prop = toInt(VehicleProperty::DISPLAY_BRIGHTNESS),
    248                 .access = VehiclePropertyAccess::READ_WRITE,
    249                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    250                 .areaConfigs = {VehicleAreaConfig{.minInt32Value = 0, .maxInt32Value = 10}}},
    251      .initialValue = {.int32Values = {7}}},
    252 
    253     {.config =
    254          {
    255              .prop = toInt(VehicleProperty::IGNITION_STATE),
    256              .access = VehiclePropertyAccess::READ,
    257              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    258          },
    259      .initialValue = {.int32Values = {toInt(VehicleIgnitionState::ON)}}},
    260 
    261     {.config =
    262          {
    263              .prop = toInt(VehicleProperty::ENGINE_OIL_TEMP),
    264              .access = VehiclePropertyAccess::READ,
    265              .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
    266              .minSampleRate = 0.1,  // 0.1 Hz, every 10 seconds
    267              .maxSampleRate = 10,   // 10 Hz, every 100 ms
    268          },
    269      .initialValue = {.floatValues = {101.0f}}},
    270 
    271     {
    272         .config =
    273             {
    274                 .prop = kGenerateFakeDataControllingProperty,
    275                 .access = VehiclePropertyAccess::WRITE,
    276                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    277             },
    278     },
    279 
    280     {.config =
    281          {
    282              .prop = toInt(VehicleProperty::DOOR_LOCK),
    283              .access = VehiclePropertyAccess::READ,
    284              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
    285          },
    286      .initialValue = {.int32Values = {1}}}
    287 
    288 };
    289 
    290 }  // impl
    291 
    292 }  // namespace V2_0
    293 }  // namespace vehicle
    294 }  // namespace automotive
    295 }  // namespace hardware
    296 }  // namespace android
    297 
    298 #endif // android_hardware_automotive_vehicle_V2_0_impl_DefaultConfig_H_
    299