29 #include <ccut/async.hpp>
31 #include "MGrblAxis.hpp"
32 #include "MGrblGpio.hpp"
33 #include "MGrblMainTrigger.hpp"
34 #include "MGrblPlatform.hpp"
35 #include "MGrblPlatformDevice.hpp"
36 #include "device/DeviceBase.hpp"
41 PlatformBase::DeviceTypeList MGrblPlatform::getSupportedDevices()
const
47 PlatformBase::DeviceList MGrblPlatform::generateDevices(
48 const DeviceTypeList &deviceType)
51 std::vector<GrblPlatform::Shared> platforms{getPlatforms()};
54 if (platforms.empty())
60 for (
const std::shared_ptr<GrblPlatform> &p : platforms)
66 for (
auto &axis : axes)
68 ret.emplace_back(createAxis(axis->uid(), platforms.back()));
74 bool hasTriggers =
false;
75 for (
size_t i = 0; i < platforms.size(); i++)
77 DeviceList triggers = platforms[i]->generateDevices(
79 if (triggers.size() == 1)
81 const std::string platformUrl = triggers.front()->uid() +
"/" +
83 ret.emplace_back(std::make_shared<MGrblTrigger>(
84 platformUrl, shared_from_this(), platforms[i]));
86 std::lock_guard<std::mutex> guard{m_lock};
87 m_triggers[platformUrl] = i;
95 ret.emplace_back(std::make_shared<MGrblMainTrigger>(
96 m_mainTriggerUrl, shared_from_this()));
101 for (
size_t i = 0; i < platforms.size(); i++)
103 DeviceList gpios = platforms[i]->generateDevices(
107 decltype(gpios)::const_iterator it = std::find_if(
108 gpios.begin(), gpios.end(), [](DeviceBase::Shared d) {
109 return (d->uid().find(
"pauseResume") != std::string::npos);
111 if (it != gpios.end())
113 const std::string platformUrl = (*it)->uid() +
"/" +
115 ret.emplace_back(std::make_shared<MGrblGpio>(
116 platformUrl, shared_from_this(), platforms[i]));
118 std::lock_guard<std::mutex> guard{m_lock};
119 m_gpios[platformUrl] = i;
126 ret.emplace_back(std::make_shared<MGrblPlatformDevice>(
127 m_ctx->prefix + m_ctx->id +
"/platform", shared_from_this(),
133 void MGrblPlatform::setNotificationWorker(
134 const NotificationWorker::Shared &worker)
136 PlatformBase::setNotificationWorker(worker);
137 for (
const std::shared_ptr<GrblPlatform> &p : getPlatforms())
138 p->setNotificationWorker(worker);
const std::string & to_string(Axis::State state)
convert State to string
@ PLATFORM
special device representing the platform itself
@ TRIGGER
hardware/software trigger device
main motion-lib namespace