HeartbeatComponentPlugin.h
Go to the documentation of this file.
1 /**
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Fabian Reister ( fabian dot reister at kit dot edu )
17  * @date 2021
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 #pragma once
23 
27 
28 #include <RobotAPI/interface/components/RobotHealthInterface.h>
29 
30 namespace armarx::plugins
31 {
32 
34  {
35  public:
36  using ComponentPlugin::ComponentPlugin;
37 
38  /**
39  * @brief register component to heartbeat
40  */
41  void signUp(const std::string& channelName = "",
42  const std::vector<std::string>& aliases = {},
43  const std::string& description = "");
44 
45  /**
46  * @brief register component to heartbeat
47  */
48  void signUp(const armarx::core::time::Duration& warning,
49  const armarx::core::time::Duration& error,
50  const std::vector<std::string>& aliases = {},
51  const std::string& description = "");
52 
53  /**
54  * @brief register component to heartbeat
55  */
56  void signUp(const std::string& channelName,
57  const armarx::core::time::Duration& warning,
58  const armarx::core::time::Duration& error,
59  const std::vector<std::string>& aliases = {},
60  const std::string& description = "");
61 
62  /**
63  * @brief register component to heartbeat, possibly with different component name
64  */
65  void signUp(const RobotHealthHeartbeatArgs& args);
66 
67  /**
68  * @brief Sends out a heartbeat using the default config
69  *
70  */
71  void heartbeat();
72 
73  /**
74  * @brief Sends out a heartbeat for a subchannel.
75  *
76  * Note: You must call configureHeartbeatChannel(...) first to register the channel config!
77  *
78  * @param channel Identifier of the heartbeat channel
79  */
80  void heartbeatOnChannel(const std::string& channelName);
81 
82  protected:
83  void preOnInitComponent() override;
84  void postOnInitComponent() override;
85  // void preOnConnectComponent() override;
86  void postOnConnectComponent() override;
87 
88  void postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties) override;
89 
90  private:
91  RobotHealthComponentInterfacePrx robotHealthComponentPrx;
92 
93  //
94  static constexpr auto healthPropertyName = "heartbeat.ComponentName";
95  static constexpr auto maximumCycleTimeWarningMSPropertyName =
96  "heartbeat.maximumCycleTimeWarningMS";
97  static constexpr auto maximumCycleTimeErrorMSPropertyName =
98  "heartbeat.maximumCycleTimeErrorMS";
99 
100  struct Properties
101  {
102  long maximumCycleTimeWarningMS = 100; // [ms]
103  long maximumCycleTimeErrorMS = 200; // [ms]
104  } p;
105 
106  //! default config used in heartbeat(), set via properties
107  RobotHealthHeartbeatArgs defaultHeartbeatArgs;
108  };
109 } // namespace armarx::plugins
armarx::plugins::HeartbeatComponentPlugin::heartbeat
void heartbeat()
Sends out a heartbeat using the default config.
Definition: HeartbeatComponentPlugin.cpp:80
armarx::plugins::HeartbeatComponentPlugin::signUp
void signUp(const std::string &channelName="", const std::vector< std::string > &aliases={}, const std::string &description="")
register component to heartbeat
Definition: HeartbeatComponentPlugin.cpp:14
armarx::plugins::HeartbeatComponentPlugin::preOnInitComponent
void preOnInitComponent() override
Definition: HeartbeatComponentPlugin.cpp:110
Duration.h
armarx::plugins::HeartbeatComponentPlugin::postOnConnectComponent
void postOnConnectComponent() override
Definition: HeartbeatComponentPlugin.cpp:132
armarx::plugins::HeartbeatComponentPlugin
Definition: HeartbeatComponentPlugin.h:33
ManagedIceObject.h
armarx::plugins
This file is part of ArmarX.
Definition: DebugObserverComponentPlugin.cpp:28
armarx::ComponentPlugin
Definition: ComponentPlugin.h:38
armarx::plugins::HeartbeatComponentPlugin::postOnInitComponent
void postOnInitComponent() override
Definition: HeartbeatComponentPlugin.cpp:122
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:17
armarx::plugins::HeartbeatComponentPlugin::heartbeatOnChannel
void heartbeatOnChannel(const std::string &channelName)
Sends out a heartbeat for a subchannel.
Definition: HeartbeatComponentPlugin.cpp:95
ComponentPlugin.h
armarx::plugins::HeartbeatComponentPlugin::postCreatePropertyDefinitions
void postCreatePropertyDefinitions(PropertyDefinitionsPtr &properties) override
Definition: HeartbeatComponentPlugin.cpp:138