$darkmode
brake_sensor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 Robert Bosch GmbH
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  * SPDX-License-Identifier: Apache-2.0
17  */
22 #pragma once
23 #ifndef CLOE_COMPONENT_BRAKE_SENSOR_HPP_
24 #define CLOE_COMPONENT_BRAKE_SENSOR_HPP_
25 
26 #include <cloe/component.hpp> // for Component, Json
27 
28 namespace cloe {
29 
30 class BrakeSensor : public Component {
31  public:
32  using Component::Component;
33  BrakeSensor() : Component("brake_sensor") {}
34  virtual ~BrakeSensor() noexcept = default;
35 
41  virtual double pedal_position_brake() const = 0;
42 
46  Json active_state() const override {
47  return Json{{"pedal_position_brake", pedal_position_brake()}};
48  }
49 };
50 
54 class NopBrakeSensor : public BrakeSensor {
55  public:
56  using BrakeSensor::BrakeSensor;
57  NopBrakeSensor() : BrakeSensor("nop_brake_sensor") {}
58  virtual ~NopBrakeSensor() noexcept {};
59 
60  double pedal_position_brake() const override { return pedal_position_brake_; }
61 
62  void reset() override { pedal_position_brake_ = 0.0; }
63 
64  protected:
65  double pedal_position_brake_{0.0};
66 };
67 
68 } // namespace cloe
69 
70 #endif // CLOE_COMPONENT_BRAKE_SENSOR_HPP_
Json active_state() const override
Definition: brake_sensor.hpp:46
Definition: coordinator.hpp:36
virtual double pedal_position_brake() const =0
Definition: brake_sensor.hpp:54
Definition: component.hpp:144
Definition: brake_sensor.hpp:30
double pedal_position_brake() const override
Definition: brake_sensor.hpp:60
void reset() override
Definition: brake_sensor.hpp:62