SlaveConfig.cpp
Go to the documentation of this file.
1 #include "SlaveConfig.h"
2 
4 {
5 
7  std::optional<std::string> type,
8  std::optional<std::string> name) :
9  identifier(identifier), type(type), name(name)
10  {
11  }
12 
14  std::optional<std::string> type,
15  std::optional<std::string> name,
16  std::shared_ptr<SlaveProfile> profile) :
17  identifier(identifier), type(type), name(name)
18  {
19  this->items = profile->items;
20  }
21 
24  {
25  identifierRead = true;
26  return identifier;
27  }
28 
29  std::optional<std::string>
31  {
32  return type;
33  }
34 
35  std::optional<std::string>
37  {
38  return name;
39  }
40 
41  bool
42  SlaveConfig::checkAllItemsRead(std::vector<std::string>& errors) const
43  {
44  bool succ = true;
45 
46  if (!identifierRead)
47  {
48  succ = false;
49  std::stringstream s;
50  s << "Identifier of slave not read. ";
51  s << "Identifier details: " << identifier;
52  errors.push_back(s.str());
53  }
54  succ &= Config::checkAllItemsRead(errors);
55  return succ;
56  }
57 
58  void
59  SlaveConfig::print(std::stringstream& s, int indention) const
60  {
61  for (int i = 0; i < indention; i++)
62  {
63  s << "\t";
64  }
65  s << "Slave:" << std::endl;
66  for (int i = 0; i < indention + 1; i++)
67  {
68  s << "\t";
69  }
70  s << "Type: " << getType().value_or("<no type>") << std::endl;
71  for (int i = 0; i < indention + 1; i++)
72  {
73  s << "\t";
74  }
75  s << "Name: " << getName().value_or("<no name>") << std::endl;
76  for (int i = 0; i < indention + 1; i++)
77  {
78  s << "\t";
79  }
80  s << "Identifier: " << identifier << std::endl;
81 
82  for (int i = 0; i < indention + 1; i++)
83  {
84  s << "\t";
85  }
86  s << "Config:" << std::endl;
87  Config::print(s, indention + 2);
88  }
89 
90  void
92  {
93  identifierRead = false;
94  }
95 
96  std::string
98  {
99  return name;
100  }
101 
102  std::string
104  {
105  return type;
106  }
107 
110  {
111  return identifier;
112  }
113 
114 } // namespace armarx::control::hardware_config
armarx::control::hardware_config::SlaveConfig::onParsingFinished
void onParsingFinished() override
This method is called when the config is completely read form the HardwareConfig file.
Definition: SlaveConfig.cpp:91
armarx::control::hardware_config::SlaveIdentifierConfig
Data structure holding the information necessary to create a SlaveIdentifier.
Definition: SlaveIdentifierConfig.h:15
armarx::control::hardware_config::SlaveProfile::getType
std::string getType()
Definition: SlaveConfig.cpp:103
SlaveConfig.h
armarx::control::hardware_config::SlaveProfile::getName
std::string getName()
Definition: SlaveConfig.cpp:97
armarx::control::hardware_config::SlaveProfile::getIdentifier
SlaveIdentifierConfig & getIdentifier()
Definition: SlaveConfig.cpp:109
armarx::control::hardware_config
Definition: Config.cpp:3
armarx::control::hardware_config::SlaveConfig::getName
std::optional< std::string > getName() const
Definition: SlaveConfig.cpp:36
armarx::control::hardware_config::SlaveConfig::SlaveConfig
SlaveConfig(SlaveIdentifierConfig identifier, std::optional< std::string > type, std::optional< std::string > name)
Definition: SlaveConfig.cpp:6
armarx::control::hardware_config::SlaveConfig::getIdentifier
SlaveIdentifierConfig & getIdentifier()
Definition: SlaveConfig.cpp:23
armarx::control::hardware_config::SlaveConfig::print
void print(std::stringstream &s, int indention) const override
Print this configuration.
Definition: SlaveConfig.cpp:59
armarx::control::hardware_config::Config::items
std::map< std::string, ConfigItemWithMetadata > items
Definition: Config.h:250
armarx::control::hardware_config::SlaveConfig::checkAllItemsRead
bool checkAllItemsRead(std::vector< std::string > &errors) const override
This method is called once the device has read the configuration data it needs.
Definition: SlaveConfig.cpp:42
armarx::control::hardware_config::SlaveConfig::getType
std::optional< std::string > getType() const
Definition: SlaveConfig.cpp:30
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::control::hardware_config::Config::checkAllItemsRead
virtual bool checkAllItemsRead(std::vector< std::string > &errors) const
This method is called once the device has read the configuration data it needs.
Definition: Config.cpp:76
armarx::control::hardware_config::Config::print
virtual void print(std::stringstream &s, int indention) const
Print this configuration.
Definition: Config.cpp:121