MotionLib  1.0.0
SamBuCa motion library
MockAxis.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-16T10:27:22
21 ** Author: Sylvain Fargier <sylvain.fargier@cern.ch>
22 */
23 
24 #ifndef MOCKAXIS_HPP__
25 #define MOCKAXIS_HPP__
26 
27 #include <memory>
28 
29 #include "device/Axis.hpp"
30 
31 namespace smc {
32 namespace internal {
33 
34 class MockPlatform;
35 
36 class MockAxis : public Axis
37 {
38 public:
39  MockAxis(const std::string &uid,
40  const std::shared_ptr<MockPlatform> &platform);
41 
42  std::future<void> moveTo(const units::Value &position) const override;
43 
44  std::future<void> moveBy(const units::Value &distance) const override;
45 
46  std::future<void> stop() const override;
47 
48  std::future<void> pause() const override;
49 
50  std::future<void> resume() const override;
51 
52  std::future<units::value_t> getPosition(units::unit_t unit) const override;
53 
54  units::value_t lastPosition(units::unit_t unit) const override;
55 
56  std::future<void> setActualPosition(
57  const units::Value &position) const override;
58 
59  std::future<void> takeReference(
60  const std::chrono::milliseconds &timeout) const override;
61 
62  std::future<State> getState() const override;
63 
64 protected:
65  std::weak_ptr<MockPlatform> m_mock;
66 };
67 
68 } // namespace internal
69 } // namespace smc
70 
71 #endif
DeviceId uid() const
Get the address of device.
Definition: DeviceBase.cpp:76
std::future< units::value_t > getPosition(units::unit_t unit) const override
Get current position of this axis.
Definition: MockAxis.cpp:116
units::value_t lastPosition(units::unit_t unit) const override
Get last known position of the axis.
Definition: MockAxis.cpp:219
std::future< void > resume() const override
Resume paused motion.
Definition: MockAxis.cpp:168
std::future< void > moveBy(const units::Value &distance) const override
Move this axis by given distance.
Definition: MockAxis.cpp:77
std::future< State > getState() const override
Get the current axis state.
Definition: MockAxis.cpp:255
std::future< void > pause() const override
Pause ongoing motion, prevent queued motions from running.
Definition: MockAxis.cpp:154
std::future< void > setActualPosition(const units::Value &position) const override
Set current axis position.
Definition: MockAxis.cpp:182
std::future< void > stop() const override
Stop any ongoing motion, flush the motion-queue.
Definition: MockAxis.cpp:140
std::future< void > moveTo(const units::Value &position) const override
Move this axis to given position.
Definition: MockAxis.cpp:41
std::future< void > takeReference(const std::chrono::milliseconds &timeout) const override
Start a homing sequence.
Definition: MockAxis.cpp:234
main motion-lib namespace
Definition: Client.cpp:30