24 #include "GrblTrigger.hpp"
26 #include <ccut/async.hpp>
28 #include "GrblPlatform.hpp"
29 #include "device/Trigger.hpp"
30 #include "util/grbl/GrblDeviceBase.hpp"
31 #include "util/grbl/GrblGenerator.hpp"
33 using namespace logger;
35 using namespace smc::internal;
39 GrblTrigger::GrblTrigger(
const std::string &uid,
40 const std::shared_ptr<GrblPlatform> &grbl) :
45 std::future<void> GrblTrigger::arm()
const
49 std::shared_ptr<GrblPlatform> grbl(m_grbl.lock());
51 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
53 uint8_t trigPin = grbl->getTrigger(
uid());
54 return grbl->run<
void>(
56 grbl::ErrorCode rc = ctx.device->send(
57 grbl::gen::DigitalOut::on(trigPin,
true).value);
59 cmd.prom->get<
void>().set_value();
62 catch (
const std::exception &e)
64 return ccut::make_future_error(e);
72 std::shared_ptr<GrblPlatform> grbl(m_grbl.lock());
74 throw Exception(ErrorCode::Canceled,
"platform stopped (deleted)");
76 uint8_t trigPin = grbl->getTrigger(
uid());
77 return grbl->run<
void>(
79 grbl::ErrorCode rc = ctx.device->send(
80 grbl::gen::DigitalOut::off(trigPin,
true).value);
82 cmd.prom->get<
void>().set_value();
85 catch (
const std::exception &e)
87 return ccut::make_future_error(e);
93 return ccut::make_future_error<bool>(
Exception{
94 ErrorCode::InvalidArguments,
95 std::string(
"Cannot check if non-MGrbl trigger is armed: ") +
uid()});
DeviceId uid() const
Get the address of device.
Exception thrown by MotionController in case of issues with command.
std::future< bool > isArmed() const override
check if trigger is armed
std::future< void > trig() const override
soft-trigger the trigger
std::future< void > disarm() const override
disarm the trigger
main motion-lib namespace