MotionLib  1.0.0
SamBuCa motion library
MFEPlatform.hpp
1 /*
2 ** Copyright (C) 2022 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: 2022-11-22T14:47:04
21 ** Author: Sylvain Fargier <sylvain.fargier@cern.ch>
22 */
23 
24 #ifndef MFEPLATFORM_HPP__
25 #define MFEPLATFORM_HPP__
26 
27 #include <memory>
28 
29 #include "MFEAxisPositionMonitor.hpp"
30 #include "platform/specialized/MGrblPlatform/MGrblPlatform.hpp"
31 
32 struct edge_reg;
33 namespace smc {
34 namespace internal {
44 class MFEPlatform : public MGrblPlatform
45 {
46 public:
47  typedef std::shared_ptr<MFEPlatform> Shared;
48 
49  struct RegInfo;
50  struct ResolverInfo;
51  struct Context;
52 
57  static inline PlatformBase::Shared create(const ccut::yml::NodeRef &config)
58  {
59  return PlatformBase::Shared(new MFEPlatform(config));
60  }
61  virtual ~MFEPlatform();
62 
63  inline std::shared_ptr<MFEPlatform> shared_from_this()
64  {
65  return std::static_pointer_cast<MFEPlatform>(
66  PlatformBase::shared_from_this());
67  }
68 
69  inline std::shared_ptr<const MFEPlatform> shared_from_this() const
70  {
71  return std::static_pointer_cast<const MFEPlatform>(
72  PlatformBase::shared_from_this());
73  }
74 
75  DeviceTypeList getSupportedDevices() const override;
76 
77  DeviceList generateDevices(const DeviceTypeList &deviceType) override;
78 
83  grbl::Axis getResolverAxis(const std::string &uid) const;
84 
88  grbl::Axis getResolverMonitorAxis(const std::string &uid) const;
89 
93  void updateResolverSetting(const std::string &resolverId,
94  grbl::SettingId settingId,
95  const std::string &value);
96 
97  units::value_t getResolverPosition(const std::string &uid,
98  const units::unit_t unit) const;
99  units::value_t getResolverMode(const std::string &uid) const;
100  AxisPositionMonitor::State getResolverMonitorState(const std::string &uid,
101  uint32_t &diff);
102 
103  static const std::string s_loggerCat;
104  static const std::string s_resolverMonitorSuffix;
105  static const std::string s_resolverSettingPrefix;
106  static const std::string s_stepLostConfig;
107  static const std::set<std::string> s_resolverConfigHidden;
108  static const std::set<std::string> s_monitorConfigHidden;
109 
110  void processUpdate(MGrblPlatform::Context &ctx) override;
111 
112 protected:
113  explicit MFEPlatform(const ccut::yml::NodeRef &ref);
114 
115  MGrblAxis::Shared createAxis(
116  const std::string &uid,
117  const std::shared_ptr<GrblPlatform> &grbl) override;
118 
119  const ResolverInfo &_getResolverInfo(const std::string &uid) const;
120 
121  void generateGpios(Context &ctx, std::list<DeviceBase::Shared> &out);
122 
123  std::map<std::string, ResolverInfo> m_resolvers;
124 };
125 
128 } // namespace internal
129 } // namespace smc
130 
131 #include "MFEPlatformData.hpp"
132 
133 #endif
SAMBuCa MFC_MFE platform.
Definition: MFEPlatform.hpp:45
void processUpdate(MGrblPlatform::Context &ctx) override
device status update function
static PlatformBase::Shared create(const ccut::yml::NodeRef &config)
Create new instance of MFEPlatform and return shared_ptr owning it.
Definition: MFEPlatform.hpp:57
void updateResolverSetting(const std::string &resolverId, grbl::SettingId settingId, const std::string &value)
hook invoked on getSetting/setSetting on resolvers
grbl::Axis getResolverMonitorAxis(const std::string &uid) const
Get the axis associated with the given AxisPositionMonitor.
grbl::Axis getResolverAxis(const std::string &uid) const
Get the axis associated to resolver.
main motion-lib namespace
Definition: Client.cpp:30