MotionLib  1.0.0
SamBuCa motion library
Axis.hpp
1 /*
2  * Copyright (C) 2021 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: 2021-11-09
21  * Author: Michal Mysior <mmysior> <michal.mysior@cern.ch>
22  *
23  */
24 
25 #ifndef AXIS_HPP__
26 #define AXIS_HPP__
27 
28 #include <chrono>
29 #include <future>
30 #include <memory>
31 
32 #include "../Units.hpp"
33 #include "DeviceBase.hpp"
34 
35 namespace smc {
36 
42 class Axis : public DeviceBase
43 {
44 public:
45  typedef std::shared_ptr<Axis> Shared;
46 
53  enum State
54  {
55  UNKNOWN,
56  IDLE,
57  RUNNING,
58  ERROR,
59  };
60 
68  Axis(const std::string &address);
69 
75  DeviceType type() const override;
76 
83  virtual std::future<void> moveTo(const units::Value &position) const = 0;
84 
91  virtual std::future<void> moveBy(const units::Value &distance) const = 0;
92 
102  virtual std::future<void> stop() const = 0;
103 
110  virtual std::future<void> pause() const;
111 
118  virtual std::future<void> resume() const;
119 
125  virtual std::future<units::value_t> getPosition(units::unit_t unit) const = 0;
126 
133  virtual units::value_t lastPosition(units::unit_t unit) const = 0;
134 
141  virtual std::future<void> setActualPosition(
142  const units::Value &position) const;
143 
151  virtual std::future<void> takeReference(
152  const std::chrono::milliseconds &timeout = std::chrono::seconds{
153  120}) const;
154 
162  virtual std::future<State> getState() const = 0;
163 };
164 
171 const std::string &to_string(Axis::State state);
172 
174 } /* namespace smc */
175 
176 #endif /* #define AXIS_HPP__ */
virtual std::future< void > resume() const
Resume paused motion.
virtual units::value_t lastPosition(units::unit_t unit) const =0
Get last known position of the axis.
virtual std::future< void > takeReference(const std::chrono::milliseconds &timeout=std::chrono::seconds{ 120}) const
Start a homing sequence.
DeviceType type() const override
Get device type.
virtual std::future< units::value_t > getPosition(units::unit_t unit) const =0
Get current position of this axis.
virtual std::future< void > moveBy(const units::Value &distance) const =0
Move this axis by given distance.
Axis(const std::string &address)
Construct a new Axis Device at given location on given platform.
virtual std::future< void > stop() const =0
Stop any ongoing motion, flush the motion-queue.
State
Axis State.
Definition: Axis.hpp:54
virtual std::future< void > setActualPosition(const units::Value &position) const
Set current axis position.
virtual std::future< State > getState() const =0
Get the current axis state.
virtual std::future< void > pause() const
Pause ongoing motion, prevent queued motions from running.
virtual std::future< void > moveTo(const units::Value &position) const =0
Move this axis to given position.
const std::string & to_string(Axis::State state)
convert State to string
Definition: Axis.cpp:78
DeviceType
List of possible device types supported.
Definition: DeviceBase.hpp:52
main motion-lib namespace
Definition: Client.cpp:30