MotionLib  1.0.0
SamBuCa motion library
GrblAxis.hpp
1 /*
2 ** Copyright (C) 2025 CERN
3 **
4 ** This software is provided 'as-is', without any express or implied
5 ** warranty. In no event will the authors be held liable for any damages
6 ** arising from the use of this software.
7 **
8 ** Permission is granted to anyone to use this software for any purpose,
9 ** including commercial applications, and to alter it and redistribute it
10 ** freely, subject to the following restrictions:
11 **
12 ** 1. The origin of this software must not be misrepresented; you must not
13 ** claim that you wrote the original software. If you use this software
14 ** in a product, an acknowledgment in the product documentation would be
15 ** appreciated but is not required.
16 ** 2. Altered source versions must be plainly marked as such, and must not be
17 ** misrepresented as being the original software.
18 ** 3. This notice may not be removed or altered from any source distribution.
19 **
20 ** Created on: 2025-04-16T15:40:27
21 ** Author: Sylvain Fargier <sylvain.fargier@cern.ch>
22 */
23 
24 #ifndef GRBLAXIS_HPP__
25 #define GRBLAXIS_HPP__
26 
27 #include <memory>
28 
29 #include "device/Axis.hpp"
30 
31 namespace smc {
32 namespace internal {
33 
34 class GrblPlatform;
35 
36 class GrblAxis : public Axis
37 {
38 public:
39  typedef std::shared_ptr<GrblAxis> Shared;
40 
41  GrblAxis(const std::string &uid, const std::shared_ptr<GrblPlatform> &grbl);
42 
43  std::future<void> moveTo(const units::Value &position) const override;
44 
45  std::future<void> moveBy(const units::Value &distance) const override;
46 
47  std::future<void> stop() const override;
48 
49  std::future<void> pause() const override;
50 
51  std::future<void> resume() const override;
52 
53  std::future<units::value_t> getPosition(units::unit_t unit) const override;
54 
55  units::value_t lastPosition(units::unit_t unit) const override;
56 
57  std::future<void> setActualPosition(
58  const units::Value &position) const override;
59 
60  std::future<void> takeReference(
61  const std::chrono::milliseconds &timeout = std::chrono::seconds{
62  120}) const override;
63 
64  std::future<State> getState() const override;
65 
66  std::future<std::set<std::string>> listConfig() const override;
67 
68  std::future<std::string> getConfig(const std::string &name) const override;
69 
70  std::future<void> setConfig(const std::string &name,
71  const std::string &value) const override;
72 
73  bool canConvert(const units::Value &value,
74  units::unit_t unit) const override;
75 
76  bool convert(units::Value &value, units::unit_t unit) const override;
77 
78 protected:
79  std::weak_ptr<GrblPlatform> m_grbl;
80 };
81 
82 } // namespace internal
83 } // namespace smc
84 
85 #endif
DeviceId uid() const
Get the address of device.
Definition: DeviceBase.cpp:76
std::future< State > getState() const override
Get the current axis state.
Definition: GrblAxis.cpp:391
bool canConvert(const units::Value &value, units::unit_t unit) const override
Check if unit conversion is possible in a manner specific to this device.
Definition: GrblAxis.cpp:506
std::future< void > resume() const override
Resume paused motion.
Definition: GrblAxis.cpp:216
std::future< void > pause() const override
Pause ongoing motion, prevent queued motions from running.
Definition: GrblAxis.cpp:195
std::future< void > setConfig(const std::string &name, const std::string &value) const override
set device configuration value
Definition: GrblAxis.cpp:478
std::future< void > takeReference(const std::chrono::milliseconds &timeout=std::chrono::seconds{ 120}) const override
Start a homing sequence.
Definition: GrblAxis.cpp:329
std::future< std::set< std::string > > listConfig() const override
list device configuration options
Definition: GrblAxis.cpp:413
std::future< units::value_t > getPosition(units::unit_t unit) const override
Get current position of this axis.
Definition: GrblAxis.cpp:238
units::value_t lastPosition(units::unit_t unit) const override
Get last known position of the axis.
Definition: GrblAxis.cpp:308
std::future< void > setActualPosition(const units::Value &position) const override
Set current axis position.
Definition: GrblAxis.cpp:273
std::future< void > stop() const override
Stop any ongoing motion, flush the motion-queue.
Definition: GrblAxis.cpp:172
std::future< std::string > getConfig(const std::string &name) const override
get device configuration value
Definition: GrblAxis.cpp:434
bool convert(units::Value &value, units::unit_t unit) const override
Convert value in a manner specific to this device.
Definition: GrblAxis.cpp:512
std::future< void > moveBy(const units::Value &distance) const override
Move this axis by given distance.
Definition: GrblAxis.cpp:92
std::future< void > moveTo(const units::Value &position) const override
Move this axis to given position.
Definition: GrblAxis.cpp:48
main motion-lib namespace
Definition: Client.cpp:30