summaryrefslogtreecommitdiff
path: root/implementation/configuration/include/debounce.hpp
blob: 30ad9848eda37a670dff8af419016be0a32607d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2017-2021 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef VSOMEIP_V3_CFG_DEBOUNCE_HPP
#define VSOMEIP_V3_CFG_DEBOUNCE_HPP

#include <map>

namespace vsomeip_v3 {
namespace cfg {

// Messages are forwarded either because their value differs from the
// last received message (on_change=true) or because the specified time
// (interval_) between two messages has elapsed. A message that is forwarded
// because of a changed value may reset the time until the next unchanged
// message is forwarded or not (on_change_resets_interval). By specifiying
// indexes and bit masks, the comparison that is carried out to decide whether
// or not two message values differ is configurable (ignore_).
struct debounce {
    debounce() : on_change_(false),
            on_change_resets_interval_(false),
            interval_(-1), // aka "never"
            last_forwarded_((std::chrono::steady_clock::time_point::max)()) {
    }

    bool on_change_;
    bool on_change_resets_interval_;
    std::map<std::size_t, byte_t> ignore_;

    long interval_;
    std::chrono::steady_clock::time_point last_forwarded_;
};

} // namespace cfg
} // namespace vsomeip_v3

#endif // VSOMEIP_V3_CFG_DEBOUNCE_HPP