fast: Design with 7 models executed 10.000.000 ticks in 1.55 sec on Ubuntu.
easy to use: must implement only 2 methods: update() and is_source() in which you call add_input/add_output and get_input/set_output.
portable: Tested on Windows 10(Visual Studio 2019), Debian VM(GCC 8.3) and Raspbian(GCC 4.9).
syncronous and asyncronous execution(based on execution order) available with the controller.
Clone and build
Clone and build:
git clone https://github.com/mehecip/mbd.git
cd mbd
cmake -DBUILD_CONTROLLER=On -DBUILD_EXAMPLES=On .
make f=Makefile
Usage - mbd::model
Implement:
#include"model.hpp"classgain : publicmodel
{
public:/** Build your model: add inputs, outputs and parameters. */gain(const std::string& name, double gain) : model(name)
{
model::add_input<double>("In 0", 0.0);
model::add_output<double>("Out 0", 0.0);
model::add_param<double>("gain_factor", gain);
}
/** Update your model: read inputs/parameters and set outputs/parameters. */voidupdate(std::uint64_t tick) override
{
constdouble in = model::get_input<double>(0);
constdouble gain = model::get_param<double>("gain_factor");
model::set_output<double>(0, in * gain);
}
/** Let the controller know if the model behaves as a source. */boolis_source() constoverride
{
returnfalse;
}
};