Motorcortex Core  version: 2.7.6
ecat_module.h
1 /*
2  * Developer : Alexey Zakharov (alexey.zakharov@vectioneer.com)
3  * All rights reserved. Copyright (c) 2015 - 2018 VECTIONEER.
4  */
5 
6 #ifndef MOTORCORTEX_LIB_ECAT_MODULE_H
7 #define MOTORCORTEX_LIB_ECAT_MODULE_H
8 
9 #include "ct_module.h"
10 #include "ecat_base.h"
11 #include "ecat_domain.h"
12 #include "ecat_state.h"
13 #include <memory>
14 #include <vector>
15 
16 namespace mcx::ecat {
17 
18 class Module : public container::Module {
19 
20  struct DistributedClockSync {
21  bool enabled;
22  unsigned int ref_counter;
23  };
24 
25 public:
26  Module() = delete;
27 
28  Module(std::shared_ptr<EthercatBase> master, const std::vector<Domain>& domain_list);
29 
30  Module(std::shared_ptr<EthercatBase> master, const Domain& domain);
31 
32 private:
33  struct DomainData {
34  Domain domain;
35  int handle;
36  };
37 
38  void create_(const char* name, parameter_server::Parameter* parameter_server, uint64_t dt_micro_s) override;
39 
40  bool initPhase1_() override;
41 
42  bool initPhase2_() override;
43 
44  bool startOp_() override;
45 
46  bool stopOp_() override;
47 
48  bool iterateOp_(const container::TaskTime& system_time, container::UserTime* user_time) override;
49 
50  std::shared_ptr<EthercatBase> master_;
51 
52  std::vector<DomainData> domains_;
53 
54  bool error_{};
55  unsigned long counter_{};
56  unsigned int master_id_{};
57  int cpu_affinity_{0};
58 
59  parameter_server::ParamHandle sync_factor_handle_;
60  parameter_server::ParamHandle cpu_affinity_handle_;
61  unsigned int sync_factor_{};
62  struct {
63  bool read_sdo;
64  SdoState sdo_state;
65  } sdo_state_{};
66 };
67 
68 } // namespace mcx::ecat
69 
70 #endif // MOTORCORTEX_LIB_ECAT_MODULE_H
mcx::parameter_server::Parameter
Definition: ps_parameter.h:45
mcx::ecat::Domain
Definition: ecat_domain.h:31
mcx::container::TaskTime
Internal time source.
Definition: ct_time.h:25
mcx::ecat::Module
Definition: ecat_module.h:18
mcx::container::UserTime
External time source.
Definition: ct_time.h:40
mcx::container::Module
A building block of the Motorcortex components.
Definition: ct_module.h:64
mcx::parameter_server::ParamHandle
Definition: ps_handlers.h:43