Dixon/src/RobotNode/DixonNodeState.cpp
Russell Gilbert 3a4e00a409 Adds basic logging and refactors main loop
Adds a basic logging system using std::clog with color codes for different log levels.
Refactors the main loop to use the logging system and improve readability.
Changes DixonNodeState to use atomic exchange for setting node status and logs status changes.
Removes the old main.cpp and adds a new one that uses a separate thread for signal handling.
Updates the CMakeLists.txt to link against gpiod and spdlog.
Moves version information into a version.txt file and creates a custom target to bump the version using a python script.
2026-02-20 15:27:42 +00:00

34 lines
664 B
C++

#include "DixonNodeState.h"
#include <iostream>
#include <ostream>
DixonNodeState& DixonNodeState::instance()
{
static DixonNodeState instance;
return instance;
}
void DixonNodeState::setConnected(const bool value)
{
connected_ = value;
}
bool DixonNodeState::isConnected() const
{
return connected_;
}
void DixonNodeState::setNodeStatus(NodeStatus value)
{
NodeStatus oldStatus = node_status_.exchange(value);
logger_.info("Node status changed: {} -> {}",
static_cast<int>(oldStatus),
static_cast<int>(value));
}
NodeStatus DixonNodeState::getNodeStatus() const
{
return node_status_.load();
}