refactor: moved common kernel stuff to KernelBase #WIP
Dieser Commit ist enthalten in:
Ursprung
11ac7d6909
Commit
ec2f42ba27
@ -38,7 +38,6 @@ namespace DCCPlusPlus {
|
||||
|
||||
Kernel::Kernel(std::string logId_, const Config& config, bool simulation)
|
||||
: KernelBase(std::move(logId_))
|
||||
, m_ioContext{1}
|
||||
, m_simulation{simulation}
|
||||
, m_startupDelayTimer{m_ioContext}
|
||||
, m_decoderController{nullptr}
|
||||
|
||||
@ -25,9 +25,7 @@
|
||||
|
||||
#include "../kernelbase.hpp"
|
||||
#include <array>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <traintastic/enum/tristate.hpp>
|
||||
#include "config.hpp"
|
||||
@ -72,10 +70,8 @@ class Kernel : public ::KernelBase
|
||||
};
|
||||
|
||||
private:
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
const bool m_simulation;
|
||||
std::thread m_thread;
|
||||
boost::asio::steady_timer m_startupDelayTimer;
|
||||
|
||||
TriState m_powerOn;
|
||||
@ -112,13 +108,6 @@ class Kernel : public ::KernelBase
|
||||
Kernel(const Kernel&) = delete;
|
||||
Kernel& operator =(const Kernel&) = delete;
|
||||
|
||||
/**
|
||||
* @brief IO context for DCC++ kernel and IO handler
|
||||
*
|
||||
* @return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* @brief Create kernel and IO handler
|
||||
*
|
||||
|
||||
@ -74,7 +74,6 @@ static constexpr DecoderProtocol toDecoderProtocol(LocomotiveProtocol locomotive
|
||||
|
||||
Kernel::Kernel(std::string logId_, const Config& config, bool simulation)
|
||||
: KernelBase(std::move(logId_))
|
||||
, m_ioContext{1}
|
||||
, m_simulation{simulation}
|
||||
, m_decoderController{nullptr}
|
||||
, m_inputController{nullptr}
|
||||
|
||||
@ -24,9 +24,7 @@
|
||||
#define TRAINTASTIC_SERVER_HARDWARE_PROTOCOL_ECOS_KERNEL_HPP
|
||||
|
||||
#include "../kernelbase.hpp"
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <traintastic/enum/tristate.hpp>
|
||||
#include <traintastic/enum/decoderprotocol.hpp>
|
||||
#include "config.hpp"
|
||||
@ -109,10 +107,8 @@ class Kernel : public ::KernelBase
|
||||
}
|
||||
};
|
||||
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
const bool m_simulation;
|
||||
std::thread m_thread;
|
||||
|
||||
Objects m_objects;
|
||||
|
||||
@ -152,12 +148,6 @@ class Kernel : public ::KernelBase
|
||||
Kernel(const Kernel&) = delete;
|
||||
Kernel& operator =(const Kernel&) = delete;
|
||||
|
||||
/**
|
||||
* @brief IO context for ECoS kernel and IO handler
|
||||
* @return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* @brief Create kernel and IO handler
|
||||
* @param[in] config LocoNet configuration
|
||||
|
||||
@ -24,7 +24,8 @@
|
||||
#include "../../core/eventloop.hpp"
|
||||
|
||||
KernelBase::KernelBase(std::string logId_)
|
||||
: logId{logId_}
|
||||
: m_ioContext{1}
|
||||
, logId{logId_}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
class KernelBase
|
||||
{
|
||||
@ -33,6 +35,9 @@ class KernelBase
|
||||
std::function<void()> m_onError;
|
||||
|
||||
protected:
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::thread m_thread;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool m_started = false;
|
||||
#endif
|
||||
@ -44,6 +49,16 @@ class KernelBase
|
||||
public:
|
||||
const std::string logId; //!< Object id for log messages.
|
||||
|
||||
/**
|
||||
* \brief IO context for LocoNet kernel and IO handler
|
||||
*
|
||||
* \return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext()
|
||||
{
|
||||
return m_ioContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief ...
|
||||
*
|
||||
|
||||
@ -67,7 +67,6 @@ constexpr Kernel::Priority& operator ++(Kernel::Priority& value)
|
||||
|
||||
Kernel::Kernel(std::string logId_, const Config& config, bool simulation)
|
||||
: KernelBase(std::move(logId_))
|
||||
, m_ioContext{1}
|
||||
, m_simulation{simulation}
|
||||
, m_waitingForEcho{false}
|
||||
, m_waitingForEchoTimer{m_ioContext}
|
||||
|
||||
@ -26,9 +26,7 @@
|
||||
#include "../kernelbase.hpp"
|
||||
#include <array>
|
||||
#include <unordered_map>
|
||||
#include <thread>
|
||||
#include <filesystem>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <boost/signals2/connection.hpp>
|
||||
#include <tcb/span.hpp>
|
||||
@ -138,10 +136,8 @@ class Kernel : public ::KernelBase
|
||||
};
|
||||
static_assert(sizeof(FastClock) == 4);
|
||||
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
const bool m_simulation;
|
||||
std::thread m_thread;
|
||||
|
||||
std::array<SendQueue, 3> m_sendQueue;
|
||||
Priority m_sentMessagePriority;
|
||||
@ -275,13 +271,6 @@ class Kernel : public ::KernelBase
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief IO context for LocoNet kernel and IO handler
|
||||
*
|
||||
* @return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* @brief Create kernel and IO handler
|
||||
*
|
||||
|
||||
@ -66,7 +66,6 @@ static std::tuple<bool, DecoderProtocol, uint16_t> uidToProtocolAddress(uint32_t
|
||||
|
||||
Kernel::Kernel(std::string logId_, const Config& config, bool simulation)
|
||||
: KernelBase(std::move(logId_))
|
||||
, m_ioContext{1}
|
||||
, m_simulation{simulation}
|
||||
, m_statusDataConfigRequestTimer{m_ioContext}
|
||||
, m_debugDir{Traintastic::instance->debugDir()}
|
||||
|
||||
@ -28,10 +28,8 @@
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <thread>
|
||||
#include <filesystem>
|
||||
#include <queue>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <traintastic/enum/tristate.hpp>
|
||||
#include "config.hpp"
|
||||
@ -110,10 +108,8 @@ class Kernel : public ::KernelBase
|
||||
|
||||
static constexpr int statusDataConfigRequestRetryCount = 3;
|
||||
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
const bool m_simulation;
|
||||
std::thread m_thread;
|
||||
State m_state = State::Initial;
|
||||
std::function<void(const Node& node)> m_onNodeChanged;
|
||||
std::queue<StatusDataConfigRequest> m_statusDataConfigRequestQueue; //<! UID+index to request config data from
|
||||
@ -174,13 +170,6 @@ class Kernel : public ::KernelBase
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief IO context for kernel and IO handler
|
||||
*
|
||||
* \return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* \brief Create kernel and IO handler
|
||||
*
|
||||
|
||||
@ -74,7 +74,6 @@ constexpr TriState toTriState(OutputState value)
|
||||
Kernel::Kernel(std::string logId_, World& world, const Config& config, bool simulation)
|
||||
: KernelBase(std::move(logId_))
|
||||
, m_world{world}
|
||||
, m_ioContext{1}
|
||||
, m_simulation{simulation}
|
||||
, m_heartbeatTimeout{m_ioContext}
|
||||
, m_inputController{nullptr}
|
||||
|
||||
@ -26,8 +26,6 @@
|
||||
#include "../kernelbase.hpp"
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <traintastic/enum/tristate.hpp>
|
||||
@ -58,10 +56,8 @@ class Kernel : public ::KernelBase
|
||||
};
|
||||
|
||||
World& m_world;
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
const bool m_simulation;
|
||||
std::thread m_thread;
|
||||
std::string m_logId;
|
||||
boost::asio::steady_timer m_heartbeatTimeout;
|
||||
|
||||
@ -118,13 +114,6 @@ class Kernel : public ::KernelBase
|
||||
Kernel(const Kernel&) = delete;
|
||||
Kernel& operator =(const Kernel&) = delete;
|
||||
|
||||
/**
|
||||
* \brief IO context for TraintasticDIY kernel and IO handler
|
||||
*
|
||||
* \return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* \brief Create kernel and IO handler
|
||||
*
|
||||
|
||||
@ -24,9 +24,7 @@
|
||||
#define TRAINTASTIC_SERVER_HARDWARE_PROTOCOL_WITHROTTLE_KERNEL_HPP
|
||||
|
||||
#include "../kernelbase.hpp"
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/signals2/connection.hpp>
|
||||
#include <traintastic/enum/tristate.hpp>
|
||||
#include "config.hpp"
|
||||
@ -58,9 +56,7 @@ class Kernel : public ::KernelBase
|
||||
std::unordered_map<char, MultiThrottle> multiThrottles;
|
||||
};
|
||||
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
std::thread m_thread;
|
||||
|
||||
TriState m_powerOn;
|
||||
|
||||
@ -118,13 +114,6 @@ class Kernel : public ::KernelBase
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief IO context for WiThrottle kernel and IO handler
|
||||
*
|
||||
* \return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* \brief Create kernel and IO handler
|
||||
*
|
||||
|
||||
@ -34,7 +34,6 @@ namespace XpressNet {
|
||||
|
||||
Kernel::Kernel(std::string logId_, const Config& config, bool simulation)
|
||||
: KernelBase(std::move(logId_))
|
||||
, m_ioContext{1}
|
||||
, m_simulation{simulation}
|
||||
, m_decoderController{nullptr}
|
||||
, m_inputController{nullptr}
|
||||
|
||||
@ -25,8 +25,6 @@
|
||||
|
||||
#include "../kernelbase.hpp"
|
||||
#include <array>
|
||||
#include <thread>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <traintastic/enum/tristate.hpp>
|
||||
#include "config.hpp"
|
||||
@ -46,10 +44,8 @@ struct Message;
|
||||
class Kernel : public ::KernelBase
|
||||
{
|
||||
private:
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
const bool m_simulation;
|
||||
std::thread m_thread;
|
||||
|
||||
TriState m_trackPowerOn;
|
||||
TriState m_emergencyStop;
|
||||
@ -90,13 +86,6 @@ class Kernel : public ::KernelBase
|
||||
Kernel(const Kernel&) = delete;
|
||||
Kernel& operator =(const Kernel&) = delete;
|
||||
|
||||
/**
|
||||
* @brief IO context for XpressNet kernel and IO handler
|
||||
*
|
||||
* @return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* @brief Create kernel and IO handler
|
||||
*
|
||||
|
||||
@ -35,7 +35,6 @@ namespace Z21 {
|
||||
|
||||
Kernel::Kernel(std::string logId_)
|
||||
: KernelBase(std::move(logId_))
|
||||
, m_ioContext{1}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -26,8 +26,6 @@
|
||||
#include "../kernelbase.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <thread>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "iohandler/iohandler.hpp"
|
||||
@ -43,11 +41,7 @@ enum HardwareType : uint32_t;
|
||||
|
||||
class Kernel : public ::KernelBase
|
||||
{
|
||||
private:
|
||||
std::thread m_thread;
|
||||
|
||||
protected:
|
||||
boost::asio::io_context m_ioContext;
|
||||
std::unique_ptr<IOHandler> m_ioHandler;
|
||||
|
||||
Kernel(std::string logId_);
|
||||
@ -62,13 +56,6 @@ class Kernel : public ::KernelBase
|
||||
Kernel(const Kernel&) = delete;
|
||||
Kernel& operator =(const Kernel&) = delete;
|
||||
|
||||
/**
|
||||
* @brief IO context for Z21 kernel and IO handler
|
||||
*
|
||||
* @return The IO context
|
||||
*/
|
||||
boost::asio::io_context& ioContext() { return m_ioContext; }
|
||||
|
||||
/**
|
||||
* @brief Start the kernel and IO handler
|
||||
*/
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren