1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-30 00:00:11 +01:00

Driver Interface

Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
This commit is contained in:
Pascal Bauer 2024-08-23 19:22:07 +02:00
parent fadb14cd1e
commit ae3ab18488
2 changed files with 13 additions and 13 deletions

View file

@ -10,6 +10,7 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <villas/kernel/devices/driver.hpp>
namespace villas { namespace villas {
namespace kernel { namespace kernel {
@ -17,7 +18,7 @@ namespace devices {
class PlatformDevice; class PlatformDevice;
class PlatformDriver { class PlatformDriver : public Driver {
private: private:
static constexpr char BIND_DEFAULT[] = "bind"; static constexpr char BIND_DEFAULT[] = "bind";
static constexpr char UNBIND_DEFAULT[] = "unbind"; static constexpr char UNBIND_DEFAULT[] = "unbind";
@ -39,13 +40,12 @@ public:
const std::filesystem::path unbind_path) const std::filesystem::path unbind_path)
: path(path), bind_path(bind_path), unbind_path(unbind_path){}; : path(path), bind_path(bind_path), unbind_path(unbind_path){};
std::string name() const; public:
void attach(const PlatformDevice &device) const; std::string name() const override;
void attach(const Device &device) const override;
private: void bind(const Device &device) const override;
void bind(const PlatformDevice &device) const; void unbind(const Device &device) const override;
void unbind(const PlatformDevice &device) const; void override(const Device &device) const override;
void override(const PlatformDevice &device) const;
}; };
} // namespace devices } // namespace devices

View file

@ -18,21 +18,21 @@ std::string PlatformDriver::name() const {
return path.u8string().substr(pos + 1); return path.u8string().substr(pos + 1);
} }
void PlatformDriver::bind(const PlatformDevice &device) const { void PlatformDriver::bind(const Device &device) const {
write_to_file(device.name(), this->bind_path); write_to_file(device.name(), this->bind_path);
}; };
void PlatformDriver::unbind(const PlatformDevice &device) const { void PlatformDriver::unbind(const Device &device) const {
write_to_file(device.name(), this->unbind_path); write_to_file(device.name(), this->unbind_path);
}; };
void PlatformDriver::override(const PlatformDevice &device) const { void PlatformDriver::override(const Device &device) const {
write_to_file(this->name(), device.override_path()); write_to_file(this->name(), device.override_path());
}; };
void PlatformDriver::attach(const PlatformDevice &device) const { void PlatformDriver::attach(const Device &device) const {
if (device.driver().has_value()) { if (device.driver().has_value()) {
device.driver().value().unbind(device); device.driver().value()->unbind(device);
} }
this->override(device); this->override(device);
device.probe(); device.probe();