24 #include "MGrblMainTrigger.hpp"
26 #include <ccut/async.hpp>
28 #include "MGrblPlatform.hpp"
30 using namespace logger;
32 using namespace smc::internal;
33 using namespace smc::units;
36 MGrblMainTrigger::MGrblMainTrigger(
const std::string &uid,
37 const std::shared_ptr<MGrblPlatform> &mgrbl) :
42 std::future<void> MGrblMainTrigger::arm()
const
46 std::shared_ptr<MGrblPlatform> mgrbl(m_mgrbl.lock());
48 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
50 return mgrbl->run<
void>(
52 grbl::ErrorCode rc = ctx.device->send(
53 mgrbl::ControlSymbol + mgrbl::gen::Control::TrigArm +
"=1");
55 cmd.prom->get<
void>().set_value();
60 return ccut::make_future_error(ex);
68 std::shared_ptr<MGrblPlatform> mgrbl(m_mgrbl.lock());
70 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
72 return mgrbl->run<
void>(
74 grbl::ErrorCode rc = ctx.device->send(
75 mgrbl::ControlSymbol + mgrbl::gen::Control::TrigArm +
"=0");
77 cmd.prom->get<
void>().set_value();
82 return ccut::make_future_error(ex);
90 std::shared_ptr<MGrblPlatform> mgrbl(m_mgrbl.lock());
92 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
97 grbl::ErrorCode rc = ctx.device->send(
98 (mgrbl::ControlSymbol + mgrbl::gen::Control::TrigArm),
99 [&ret](
const std::string &line) {
103 cmd.prom->get<
bool>().set_value(ret);
108 return ccut::make_future_error<bool>(ex);
116 std::shared_ptr<MGrblPlatform> mgrbl(m_mgrbl.lock());
118 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
120 return mgrbl->run<
void>(
122 grbl::ErrorCode rc = ctx.device->send(
123 mgrbl::ControlSymbol + mgrbl::gen::Control::TrigSoft);
125 cmd.prom->get<
void>().set_value();
130 return ccut::make_future_error(ex);
static bool parseIsArmed(const std::string &line, bool &isArmed)
parse isArmed reply
Exception thrown by MotionController in case of issues with command.
std::future< void > disarm() const override
disarm the trigger
std::future< void > trig() const override
soft-trigger the trigger
std::future< bool > isArmed() const override
check if trigger is armed
main motion-lib namespace