MotionLib  1.0.0
SamBuCa motion library
MotionController.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-10-04
21  * Author: Michal Mysior <mmysior> <michal.mysior@cern.ch>
22  *
23  */
24 
25 #ifndef MOTION_CONTROLLER_HPP__
26 #define MOTION_CONTROLLER_HPP__
27 
28 #include <cstdint>
29 #include <exception>
30 #include <set>
31 #include <string>
32 
33 /* convenience includes */
34 #include "device/Axis.hpp"
35 #include "device/DeviceBase.hpp"
36 #include "device/Gpio.hpp"
37 #include "device/PlatformDevice.hpp"
38 #include "device/PositionSensor.hpp"
39 #include "device/Trigger.hpp"
40 
45 namespace smc {
46 
47 namespace internal {
48 class PlatformFactory;
49 class DeviceStore;
50 class NotificationWorker;
51 } // namespace internal
52 
63 {
64 public:
71 
78  std::size_t load(const std::string &config);
79 
85  std::size_t getDeviceCount() const;
86 
93  DeviceBase::Shared getDevice(const DeviceId &address);
94 
101  template<typename T>
102  std::shared_ptr<T> getDevice(const DeviceId &address);
103 
107  std::set<DeviceId> getDeviceList() const;
108 
115  std::set<DeviceId> getDeviceList(DeviceType type) const;
116 
120  std::set<std::string> getAliasList() const;
121 
126  DeviceId getAlias(const std::string &alias) const;
127 
136  bool addAlias(const std::string &alias,
137  const DeviceId &deviceId,
138  bool override = true);
139 
143  void removeAlias(const std::string &alias);
144 
148  inline std::shared_ptr<internal::PlatformFactory> getPlatformFactory() const
149  {
150  return m_platformFactory;
151  }
152 
156  inline std::shared_ptr<internal::DeviceStore> getDeviceStore() const
157  {
158  return m_deviceStore;
159  }
160 
161 protected:
162  std::shared_ptr<internal::PlatformFactory> m_platformFactory;
163  std::shared_ptr<internal::DeviceStore> m_deviceStore;
164  std::shared_ptr<internal::NotificationWorker> m_notificationWorker;
165 };
166 
169 } /* namespace smc */
170 
171 #include "MotionController.hxx"
172 
173 #endif /* MOTION_CONTROLLER_HPP__ */
DeviceId getAlias(const std::string &alias) const
Get the given alias.
MotionController()
Construct a new MotionController object.
std::size_t load(const std::string &config)
Construct platforms and devices based on given configuration string.
std::set< DeviceId > getDeviceList() const
retrieve complete list of devices
std::shared_ptr< internal::PlatformFactory > getPlatformFactory() const
for internal use and debugging purpose
std::size_t getDeviceCount() const
Get the number of registered devices.
std::shared_ptr< internal::DeviceStore > getDeviceStore() const
for internal use and debugging purpose
bool addAlias(const std::string &alias, const DeviceId &deviceId, bool override=true)
add an alias
void removeAlias(const std::string &alias)
remove an alias
std::set< std::string > getAliasList() const
Get current Alias list.
DeviceBase::Shared getDevice(const DeviceId &address)
get a generic device according to its address
DeviceType
List of possible device types supported.
Definition: DeviceBase.hpp:52
main motion-lib namespace
Definition: Client.cpp:30