$darkmode
#include <cmath>#include <map>#include <memory>#include <string>#include <type_traits>#include <utility>#include <boost/algorithm/string.hpp>#include <cloe/core.hpp>#include <cloe/trigger.hpp>Go to the source code of this file.
Classes | |
| class | cloe::utility::Contact< D > |
| class | cloe::utility::ContactMap< D > |
| class | cloe::utility::UseContact< D > |
| class | cloe::utility::ContactFactory< D > |
| class | cloe::utility::Switch< D > |
| class | cloe::utility::PushButton< D > |
Namespaces | |
| cloe::utility::contact | |
Functions | |
| template<typename N > | |
| std::enable_if< std::is_integral< N >::value, N >::type | cloe::utility::contact::round_step (N target, N increment) |
| template<typename N > | |
| std::enable_if< std::is_floating_point< N >::value, N >::type | cloe::utility::contact::round_step (N target, N increment) |
| template<typename D = Duration> | |
| Switch< D > * | cloe::utility::contact::make_switch (bool *ptr) |
| template<typename D = Duration> | |
| PushButton< D > | cloe::utility::contact::make_toggle (bool *ptr) |
| template<typename D = Duration, typename N > | |
| PushButton< D > | cloe::utility::contact::make_step (N *ptr, N single) |
| template<typename D = Duration, typename N > | |
| PushButton< D > | cloe::utility::contact::make_step (N *ptr, N single, N multiple) |
| template<typename D = Duration, typename N > | |
| PushButton< D > | cloe::utility::contact::make_round_step (N *ptr, N single) |
| template<typename D = Duration, typename N > | |
| PushButton< D > | cloe::utility::contact::make_round_step (N *ptr, N single, N multiple) |
| template<typename D = Duration, typename N > | |
| PushButton< D > | cloe::utility::contact::make_round_step_nonnegative (N *ptr, N single) |
| template<typename D = Duration, typename N > | |
| PushButton< D > | cloe::utility::contact::make_round_step_nonnegative (N *ptr, N single, N multiple) |
This file defines several HMI (electric) contacts that allow intuitive triggering across multiple cycles.
Note: this header file and the associated test are not specific to the basic controller, but they are currently placed here until further use-cases present themselves.
Two electrical contacts are modelled in this file:
The classes defined in this header should be used in roughly the following way:
class Controller {
ContactMap hmi_;
bool active{false};
double target_speed{0.0};
public:
Controller() {
// clang-format off
hmi_.add("power", PushButton{
[&]() { active = true; },
});
hmi_.add("plus", PushButton{
[&]() { target_speed += 10.0; },
[&]() { target_speed += 5.0; },
});
hmi_.add("minus", PushButton{
[&]() { target_speed = max(0.0, target_speed - 10.0); },
[&]() { target_speed = max(0.0, target_speed - 5.0); },
});
// clang-format on
}
void init(Registrar* r) {
r->register_factory("hmi", ContactFactory(&hmi_));
r->register_handler("/state/hmi", handler::ToJson<ContactMap>(&hmi_));
r->register_handler("/state/hmi/set", handler::FromConf<ContactMap>(&hmi_));
}
Duration control(const Sync& sync) { hmi_.update(sync.time()); }
};