SlaveIdentifierConfig.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <inttypes.h>
4 
5 #include <string>
6 
8 
10 {
11  /**
12  * @brief Data structure holding the information necessary to create a SlaveIdentifier.
13  * Can be printed to streams and compared for equality.
14  */
16  {
17  friend class ConfigParser;
18 
19  public:
20  SlaveIdentifierConfig() = default;
21 
22  std::uint32_t getVendorID();
23  std::uint32_t getProductCode();
24  std::uint32_t getSerialNumber();
25  std::string getName();
26 
27  /**
28  * @brief Check if the SlaveIdentifierConfig is complete and valid.
29  * @param errorMessages vector that receives the messages describing the cause if invalid.
30  * If true is returned then no message is appended to the vector.
31  * @return iff this SlaveIdentifierConfig is valid
32  */
33  bool isValid(std::vector<std::string>& errorMessages);
34 
35  friend std::ostream&
36  operator<<(std::ostream& stream, const SlaveIdentifierConfig& rhs)
37  {
38  stream << "Name: " << rhs.name;
39 
40  if (rhs.vendorTag != ConfigTag::Invalid)
41  {
42  stream << ", VendorID: 0x" << std::hex << rhs.vendorID << std::dec << " ("
43  << rhs.vendorID << ")";
44  }
45  if (rhs.productTag != ConfigTag::Invalid)
46  {
47  stream << ", ProductCode: 0x" << std::hex << rhs.productCode << std::dec << " ("
48  << rhs.productCode << ")";
49  }
50  if (rhs.serialTag != ConfigTag::Invalid)
51  {
52  stream << ", SerialNumber: 0x" << std::hex << rhs.serialNumber << std::dec << " ("
53  << rhs.serialNumber << ")";
54  }
55  return stream;
56  }
57 
58  bool
59  operator==(const SlaveIdentifierConfig& other) const
60  {
61  return vendorID == other.vendorID && productCode == other.productCode &&
62  serialNumber == other.serialNumber;
63  }
64 
65  private:
66  std::uint32_t vendorID;
67  std::uint32_t productCode;
68  std::uint32_t serialNumber;
69  std::string name = "unknown";
70  ConfigTag vendorTag = ConfigTag::Invalid;
71  ConfigTag productTag = ConfigTag::Invalid;
72  ConfigTag serialTag = ConfigTag::Invalid;
73  ConfigTag nameTag = ConfigTag::Invalid;
74 
75  private:
76  void setVendorID(std::uint32_t vendorID, ConfigTag tag);
77  void setProductCode(std::uint32_t productCode, ConfigTag tag);
78  void setSerialNumber(std::uint32_t serial, ConfigTag tag);
79  void setName(std::string name, ConfigTag tag);
80 
81  template <typename T>
82  void
83  set(T value, ConfigTag tag, T& field, ConfigTag& tagField)
84  {
85  if (tagField == tag)
86  {
87  throw ConfigInsertError("Config Node with name " + name +
88  " is defined multiple times in " + tagName(tag) + " nodes");
89  }
90  else if (tagField > tag)
91  {
92  // The config nodes have been parsed in the wrong order.
93  // But the new node should not overwrite the old one
94  // So we just return and don't change the entry
95  return;
96  }
97 
98  field = value;
99  tagField = tag;
100  }
101  };
102 
103 } // namespace armarx::control::hardware_config
armarx::control::hardware_config::SlaveIdentifierConfig
Data structure holding the information necessary to create a SlaveIdentifier.
Definition: SlaveIdentifierConfig.h:15
armarx::control::hardware_config::SlaveIdentifierConfig::getProductCode
std::uint32_t getProductCode()
Definition: SlaveIdentifierConfig.cpp:12
armarx::control::hardware_config::SlaveIdentifierConfig::operator<<
friend std::ostream & operator<<(std::ostream &stream, const SlaveIdentifierConfig &rhs)
Definition: SlaveIdentifierConfig.h:36
armarx::control::hardware_config::SlaveIdentifierConfig::getVendorID
std::uint32_t getVendorID()
Definition: SlaveIdentifierConfig.cpp:6
armarx::control::hardware_config
Definition: Config.cpp:3
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::control::hardware_config::SlaveIdentifierConfig::getSerialNumber
std::uint32_t getSerialNumber()
Definition: SlaveIdentifierConfig.cpp:18
armarx::VariantType::Invalid
const VariantTypeId Invalid
Definition: Variant.h:914
armarx::control::hardware_config::ConfigParser
Definition: ConfigParser.h:19
armarx::control::hardware_config::ConfigTag
ConfigTag
The ConfigTag is used when setting a config value.
Definition: Config.h:61
armarx::control::hardware_config::SlaveIdentifierConfig::isValid
bool isValid(std::vector< std::string > &errorMessages)
Check if the SlaveIdentifierConfig is complete and valid.
Definition: SlaveIdentifierConfig.cpp:30
armarx::control::hardware_config::ConfigInsertError
The ConfigInsertError class represents an error that is thrown if an attempt is mode to set a config ...
Definition: Errors.h:12
armarx::control::hardware_config::tagName
std::string tagName(ConfigTag tag)
Definition: Config.cpp:302
Config.h
armarx::control::hardware_config::SlaveIdentifierConfig::getName
std::string getName()
Definition: SlaveIdentifierConfig.cpp:24
armarx::control::hardware_config::SlaveIdentifierConfig::SlaveIdentifierConfig
SlaveIdentifierConfig()=default
set
set(LIBS ArmarXCoreInterfaces ${CMAKE_THREAD_LIBS_INIT} ${dl_LIBRARIES} ${rt_LIBRARIES} ${QT_LIBRARIES} ${Boost_LIBRARIES} BoostAssertionHandler ArmarXCPPUtility SimoxUtility) set(LIB_FILES ArmarXManager.cpp ArmarXMultipleObjectsScheduler.cpp ArmarXObjectScheduler.cpp ManagedIceObject.cpp ManagedIceObjectPlugin.cpp Component.cpp ComponentPlugin.cpp IceGridAdmin.cpp ArmarXObjectObserver.cpp IceManager.cpp PackagePath.cpp RemoteReferenceCount.cpp logging/LoggingUtil.cpp logging/Logging.cpp logging/LogSender.cpp logging/ArmarXLogBuf.cpp system/ArmarXDataPath.cpp system/DynamicLibrary.cpp system/ProcessWatcher.cpp system/FactoryCollectionBase.cpp system/cmake/CMakePackageFinder.cpp system/cmake/CMakePackageFinderCache.cpp system/cmake/ArmarXPackageToolInterface.cpp system/RemoteObjectNode.cpp services/sharedmemory/HardwareId.cpp services/tasks/RunningTask.cpp services/tasks/ThreadList.cpp services/tasks/ThreadPool.cpp services/profiler/Profiler.cpp services/profiler/FileLoggingStrategy.cpp services/profiler/IceLoggingStrategy.cpp application/Application.cpp application/ApplicationOptions.cpp application/ApplicationProcessFacet.cpp application/ApplicationNetworkStats.cpp application/properties/PropertyUser.cpp application/properties/Property.cpp application/properties/PropertyDefinition.cpp application/properties/PropertyDefinitionContainer.cpp application/properties/PropertyDefinitionHelpFormatter.cpp application/properties/PropertyDefinitionConfigFormatter.cpp application/properties/PropertyDefinitionBriefHelpFormatter.cpp application/properties/PropertyDefinitionXmlFormatter.cpp application/properties/PropertyDefinitionDoxygenFormatter.cpp application/properties/PropertyDefinitionDoxygenComponentPagesFormatter.cpp application/properties/PropertyDefinitionContainerBriefHelpFormatter.cpp application/properties/IceProperties.cpp exceptions/Exception.cpp exceptions/local/UnexpectedEnumValueException.cpp util/FileSystemPathBuilder.cpp util/StringHelpers.cpp util/IceReportSkipper.cpp util/Throttler.cpp util/distributed/AMDCallbackCollection.cpp util/distributed/RemoteHandle/ClientSideRemoteHandleControlBlock.cpp util/distributed/RemoteHandle/RemoteHandle.cpp util/distributed/RemoteHandle/RemoteHandleControlBlock.cpp time/ice_conversions.cpp time/json_conversions.cpp time/CallbackWaitLock.cpp time/Clock.cpp time/ClockType.cpp time/ClockTypeNames.cpp time/CycleUtil.cpp time/DateTime.cpp time/Duration.cpp time/Frequency.cpp time/LocalTimeServer.cpp time/Metronome.cpp time/ScopedStopWatch.cpp time/StopWatch.cpp time/Timer.cpp time/TimeKeeper.cpp time/TimeUtil.cpp csv/CsvWriter.cpp csv/CsvReader.cpp eigen/conversions.cpp eigen/ice_conversions.cpp) set(LIB_HEADERS ArmarXManager.h ArmarXDummyManager.h ArmarXMultipleObjectsScheduler.h ArmarXObjectObserver.h ArmarXObjectScheduler.h ArmarXFwd.h Component.h ComponentPlugin.h ComponentFactories.h CoreObjectFactories.h IceGridAdmin.h IceManager.h IceManagerImpl.h json_conversions.h ManagedIceObject.h ManagedIceObjectPlugin.h ManagedIceObjectImpl.h ManagedIceObjectDependency.h ManagedIceObjectRegistryInterface.h PackagePath.h RemoteReferenceCount.h system/ImportExport.h system/ImportExportComponent.h system/AbstractFactoryMethod.h system/FactoryCollectionBase.h system/Synchronization.h system/ArmarXDataPath.h system/DynamicLibrary.h system/ProcessWatcher.h system/ConditionSynchronization.h system/cmake/CMakePackageFinder.h system/cmake/CMakePackageFinderCache.h system/cmake/FindPackageX.cmake system/cmake/ArmarXPackageToolInterface.h system/RemoteObjectNode.h logging/LoggingUtil.h logging/LogSender.h logging/Logging.h logging/ArmarXLogBuf.h logging/SpamFilterData.h services/tasks/RunningTask.h services/tasks/PeriodicTask.h services/tasks/ThreadList.h services/tasks/TaskUtil.h services/tasks/ThreadPool.h services/sharedmemory/SharedMemoryProvider.h services/sharedmemory/SharedMemoryConsumer.h services/sharedmemory/IceSharedMemoryProvider.h services/sharedmemory/IceSharedMemoryConsumer.h services/sharedmemory/HardwareIdentifierProvider.h services/sharedmemory/HardwareId.h services/sharedmemory/exceptions/SharedMemoryExceptions.h services/profiler/Profiler.h services/profiler/LoggingStrategy.h services/profiler/FileLoggingStrategy.h services/profiler/IceLoggingStrategy.h application/Application.h application/ApplicationOptions.h application/ApplicationProcessFacet.h application/ApplicationNetworkStats.h application/properties/forward_declarations.h application/properties/Properties.h application/properties/Property.h application/properties/PluginEigen.h application/properties/PluginEnumNames.h application/properties/PluginCfgStruct.h application/properties/PluginAll.h application/properties/PropertyUser.h application/properties/PropertyDefinition.h application/properties/PropertyDefinition.hpp application/properties/PropertyDefinitionInterface.h application/properties/PropertyDefinitionContainer.h application/properties/PropertyDefinitionFormatter.h application/properties/PropertyDefinitionContainerFormatter.h application/properties/PropertyDefinitionConfigFormatter.h application/properties/PropertyDefinitionHelpFormatter.h application/properties/PropertyDefinitionBriefHelpFormatter.h application/properties/PropertyDefinitionXmlFormatter.h application/properties/PropertyDefinitionDoxygenFormatter.h application/properties/PropertyDefinitionDoxygenComponentPagesFormatter.h application/properties/PropertyDefinitionContainerBriefHelpFormatter.h application/properties/ProxyPropertyDefinition.h application/properties/IceProperties.h exceptions/Exception.h exceptions/LocalException.h exceptions/local/DynamicLibraryException.h exceptions/local/ExpressionException.h exceptions/local/FileIOException.h exceptions/local/InvalidPropertyValueException.h exceptions/local/MissingRequiredPropertyException.h exceptions/local/PropertyInheritanceCycleException.h exceptions/local/ProxyNotInitializedException.h exceptions/local/UnexpectedEnumValueException.h exceptions/local/UnmappedValueException.h exceptions/local/ValueRangeExceededException.h exceptions/user/NotImplementedYetException.h rapidxml/rapidxml.hpp rapidxml/rapidxml_print.hpp rapidxml/rapidxml_iterators.hpp rapidxml/rapidxml_utils.hpp rapidxml/wrapper/RapidXmlReader.h rapidxml/wrapper/RapidXmlWriter.h rapidxml/wrapper/DefaultRapidXmlReader.h rapidxml/wrapper/MultiNodeRapidXMLReader.h util/IceBlobToObject.h util/ObjectToIceBlob.h util/FileSystemPathBuilder.h util/FiniteStateMachine.h util/StringHelpers.h util/StringHelperTemplates.h util/algorithm.h util/OnScopeExit.h util/Predicates.h util/Preprocessor.h util/PropagateConst.h util/Registrar.h util/TemplateMetaProgramming.h util/TripleBuffer.h util/IceReportSkipper.h util/Throttler.h util/distributed/AMDCallbackCollection.h util/distributed/RemoteHandle/ClientSideRemoteHandleControlBlock.h util/distributed/RemoteHandle/RemoteHandle.h util/distributed/RemoteHandle/RemoteHandleControlBlock.h util/SimpleStatemachine.h time.h time_minimal.h time/forward_declarations.h time/ice_conversions.h time/json_conversions.h time/CallbackWaitLock.h time/Clock.h time/ClockType.h time/ClockTypeNames.h time/CycleUtil.h time/DateTime.h time/Duration.h time/Frequency.h time/LocalTimeServer.h time/Metronome.h time/ScopedStopWatch.h time/StopWatch.h time/Timer.h time/TimeUtil.h time/TimeKeeper.h csv/CsvWriter.h csv/CsvReader.h eigen/conversions.h eigen/ice_conversions.h ice_conversions.h ice_conversions/ice_conversions_boost_templates.h ice_conversions/ice_conversions_templates.h ice_conversions/ice_conversions_templates.tpp $
Definition: CMakeLists.txt:12
T
float T
Definition: UnscentedKalmanFilterTest.cpp:35
armarx::control::hardware_config::SlaveIdentifierConfig::operator==
bool operator==(const SlaveIdentifierConfig &other) const
Definition: SlaveIdentifierConfig.h:59