25 #ifndef MGRBL_PLATFORM_HPP__
26 #define MGRBL_PLATFORM_HPP__
32 #include <ccut/Queue.hpp>
33 #include <ccut/Thread.hpp>
34 #include <ccut/yml.hpp>
36 #include "MGrblAxis.hpp"
37 #include "MGrblGpio.hpp"
38 #include "MGrblTrigger.hpp"
39 #include "platform/PlatformBase.hpp"
40 #include "platform/specialized/GrblPlatform/GrblPlatform.hpp"
41 #include "util/grbl/MGrblParser.hpp"
56 typedef std::shared_ptr<MGrblPlatform> Shared;
66 static inline PlatformBase::Shared
create(
const ccut::yml::NodeRef &config)
73 inline std::shared_ptr<MGrblPlatform> shared_from_this()
75 return std::static_pointer_cast<MGrblPlatform>(
76 PlatformBase::shared_from_this());
79 inline std::shared_ptr<const MGrblPlatform> shared_from_this()
const
81 return std::static_pointer_cast<const MGrblPlatform>(
82 PlatformBase::shared_from_this());
86 DeviceTypeList getSupportedDevices()
const override;
87 DeviceList generateDevices(
const DeviceTypeList &deviceType)
override;
88 void setNotificationWorker(
const NotificationWorker::Shared &worker)
override;
116 inline const std::string &mainTriggerUrl()
const
118 return m_mainTriggerUrl;
133 mgrbl::Instance instance)
const
135 std::lock_guard<std::mutex> guard(m_lock);
136 if (instance >= m_platforms.size())
137 throw Exception(ErrorCode::InternalError,
138 "axis not bound to an instance");
140 return m_platforms[instance];
150 std::function<
void(GrblPlatform::Shared &platform,
152 bool onlyFirst =
false)
const;
155 std::future<T> run(std::function<
void(
ImmediateCmd &, Context &)> fun);
157 void loadLayout(Context &ctx);
158 void getBuildInfo(Context &ctx);
168 Context *data =
nullptr);
170 void processMessage(
const std::string &message);
172 virtual MGrblAxis::Shared createAxis(
173 const std::string &uid,
174 const std::shared_ptr<GrblPlatform> &grbl);
176 void thread_func()
override;
184 bool processImmediate(Context &ctx);
185 void createPlatforms(Context &ctx);
186 void clearQueue(
const std::string &msg);
188 inline std::vector<std::shared_ptr<GrblPlatform>> getPlatforms()
const
190 std::lock_guard<std::mutex> guard(m_lock);
194 std::unique_ptr<Context> m_ctx;
196 mutable std::mutex m_lock;
197 std::vector<std::shared_ptr<GrblPlatform>> m_platforms;
198 std::map<std::string, std::size_t> m_triggers;
199 std::map<std::string, std::size_t> m_gpios;
200 const std::string m_mainTriggerUrl;
201 mgrbl::Layout m_layout;
202 ccut::Connection m_dataConn;
203 std::queue<ImmediateCmd> m_immediate;
211 #include "MGrblPlatformData.hpp"
Exception thrown by MotionController in case of issues with command.
main motion-lib namespace