#include <pid/signal_manager.h>
#include <pid/log.h>
#include <pid/real_time.h>
#include <pid/synchro.h>
#include <CLI11/CLI11.hpp>
#include <chrono>
int main(int argc, char* argv[]) {
CLI::App app{"EL1018 driver example"};
std::string network_interface;
app.add_option("-i,--interface", network_interface, "Network interface")
->required();
double control_period{0.001};
app.add_option("-p,--period", control_period, "Control period (seconds)");
CLI11_PARSE(app, argc, argv);
auto memory_locker = pid::make_current_thread_real_time();
bool stop = false;
pid::SignalManager::add(pid::SignalManager::Interrupt, "SigInt stop",
[&stop]() { stop = true; });
const auto period = std::chrono::duration<double>(control_period);
pid::Period loop(period);
pid_log << "Starting periodic loop" << pid::endl;
while (not stop) {
pid_log << "EL1018 state:" << pid::endl;
pid_log << "Channel 1 state = "
<< pid::endl;
pid_log << "Channel 2 state = "
<< pid::endl;
pid_log << "Channel 3 state = "
<< pid::endl;
pid_log << "Channel 4 state = "
<< pid::endl;
pid_log << pid::flush;
}
loop.sleep();
}
pid::SignalManager::remove(pid::SignalManager::Interrupt, "SigInt stop");
}