$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 
24 #include <cloe/component.hpp> // for Component
25 #include <fable/json.hpp> // for Json
26 
27 namespace cloe {
28 
29 class BrakeSensor : public Component {
30  public:
31  using Component::Component;
32  BrakeSensor() : Component("brake_sensor") {}
33  virtual ~BrakeSensor() noexcept = default;
34 
40  virtual double pedal_position_brake() const = 0;
41 
45  fable::Json active_state() const override {
46  return fable::Json{{"pedal_position_brake", pedal_position_brake()}};
47  }
48 };
49 
53 class NopBrakeSensor : public BrakeSensor {
54  public:
55  using BrakeSensor::BrakeSensor;
56  NopBrakeSensor() : BrakeSensor("nop_brake_sensor") {}
57  virtual ~NopBrakeSensor() noexcept {};
58 
59  double pedal_position_brake() const override { return pedal_position_brake_; }
60 
61  void reset() override { pedal_position_brake_ = 0.0; }
62 
63  protected:
64  double pedal_position_brake_{0.0};
65 };
66 
67 } // namespace cloe
Definition: brake_sensor.hpp:29
virtual double pedal_position_brake() const =0
fable::Json active_state() const override
Definition: brake_sensor.hpp:45
Definition: component.hpp:143
Definition: brake_sensor.hpp:53
double pedal_position_brake() const override
Definition: brake_sensor.hpp:59
void reset() override
Definition: brake_sensor.hpp:61
nlohmann::json Json
Definition: fable_fwd.hpp:35