MotionLib  1.0.0
SamBuCa motion library
MGrblAxis.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-17T11:28:13
21 ** Author: Sylvain Fargier <sylvain.fargier@cern.ch>
22 */
23 
24 #ifndef MGRBLAXIS_HPP__
25 #define MGRBLAXIS_HPP__
26 
27 #include <memory>
28 
29 #include "platform/specialized/GrblPlatform/GrblAxis.hpp"
30 
31 namespace smc {
32 namespace internal {
33 
34 class MGrblPlatform;
35 
36 class MGrblAxis : public GrblAxis
37 {
38 public:
39  typedef std::shared_ptr<MGrblAxis> Shared;
40 
41  MGrblAxis(const std::string &uid,
42  const std::shared_ptr<MGrblPlatform> &mgrbl,
43  const std::shared_ptr<GrblPlatform> &grbl);
44 
45  std::future<void> moveTo(const units::Value &position) const override;
46 
47  std::future<void> moveBy(const units::Value &distance) const override;
48 
49  std::future<void> stop() const override;
50 
51  std::future<void> pause() const override;
52 
53  std::future<void> resume() const override;
54 
55  std::future<units::value_t> getPosition(units::unit_t unit) const override;
56 
57  units::value_t lastPosition(units::unit_t unit) const override;
58 
59  std::future<void> setActualPosition(
60  const units::Value &position) const override;
61 
62  std::future<void> takeReference(
63  const std::chrono::milliseconds &timeout = std::chrono::seconds{
64  120}) const override;
65 
66  std::future<State> getState() const override;
67 
68  std::future<std::set<std::string>> listConfig() const override;
69 
70  std::future<std::string> getConfig(const std::string &name) const override;
71 
72  std::future<void> setConfig(const std::string &name,
73  const std::string &value) const override;
74 
75  bool canConvert(const units::Value &value,
76  units::unit_t unit) const override;
77 
78  bool convert(units::Value &value, units::unit_t unit) const override;
79 
80 protected:
81  friend class MGrblPlatform;
82 
83  void updateInstance() const;
84 
85  std::weak_ptr<MGrblPlatform> m_mgrbl;
86 };
87 
88 } // namespace internal
89 
90 } // namespace smc
91 
92 #endif
DeviceId uid() const
Get the address of device.
Definition: DeviceBase.cpp:76
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: MGrblAxis.cpp:248
std::future< std::set< std::string > > listConfig() const override
list device configuration options
Definition: MGrblAxis.cpp:178
std::future< void > moveBy(const units::Value &distance) const override
Move this axis by given distance.
Definition: MGrblAxis.cpp:67
bool convert(units::Value &value, units::unit_t unit) const override
Convert value in a manner specific to this device.
Definition: MGrblAxis.cpp:254
std::future< void > moveTo(const units::Value &position) const override
Move this axis to given position.
Definition: MGrblAxis.cpp:54
std::future< void > takeReference(const std::chrono::milliseconds &timeout=std::chrono::seconds{ 120}) const override
Start a homing sequence.
Definition: MGrblAxis.cpp:151
std::future< void > stop() const override
Stop any ongoing motion, flush the motion-queue.
Definition: MGrblAxis.cpp:80
std::future< State > getState() const override
Get the current axis state.
Definition: MGrblAxis.cpp:165
units::value_t lastPosition(units::unit_t unit) const override
Get last known position of the axis.
Definition: MGrblAxis.cpp:132
std::future< std::string > getConfig(const std::string &name) const override
get device configuration value
Definition: MGrblAxis.cpp:191
std::future< void > setConfig(const std::string &name, const std::string &value) const override
set device configuration value
Definition: MGrblAxis.cpp:204
std::future< void > pause() const override
Pause ongoing motion, prevent queued motions from running.
Definition: MGrblAxis.cpp:93
std::future< void > resume() const override
Resume paused motion.
Definition: MGrblAxis.cpp:106
std::future< void > setActualPosition(const units::Value &position) const override
Set current axis position.
Definition: MGrblAxis.cpp:138
std::future< units::value_t > getPosition(units::unit_t unit) const override
Get current position of this axis.
Definition: MGrblAxis.cpp:119
main motion-lib namespace
Definition: Client.cpp:30