RobotUnitModuleManagement.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 * @package RobotAPI::ArmarXObjects::RobotUnit
17 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include "RobotUnitModuleBase.h"
26
28{
29
31 {
32 public:
34 {
36 "AdditionalObjectSchedulerCount", 10, "Number of ObjectSchedulers to be added");
37
39 "HeartbeatRequired", true, "Whether the Heatbeat is required.");
40 defineOptionalProperty<long>("HeartbeatMaxCycleMS", 100, "The heartbeats cycle time");
42 "HeartbeatStartupMarginMS", 1000, "Startup time for heartbeats");
43 defineOptionalProperty<std::string>("AggregatedRobotHealthTopicName",
44 "AggregatedRobotHealthTopic",
45 "Name of the AggregatedRobotHealthTopic");
46 }
47 };
48
49 /**
50 * @ingroup Library-RobotUnit-Modules
51 * @brief This \ref ModuleBase "Module" handles some general management tasks.
52 * It implements the \ref RobotUnitManagementInterface.
53 *
54 * @see ModuleBase
55 */
56 class Management : virtual public ModuleBase, virtual public RobotUnitManagementInterface
57 {
58 friend class ModuleBase;
59
60 public:
61 /**
62 * @brief Returns the singleton instance of this class
63 * @return The singleton instance of this class
64 */
65 static Management&
70
71 // //////////////////////////////////////////////////////////////////////////////////////// //
72 // ///////////////////////////////// RobotUnitModule hooks //////////////////////////////// //
73 // //////////////////////////////////////////////////////////////////////////////////////// //
74 private:
75 /// @see ModuleBase::_preOnInitRobotUnit
76 void _preOnInitRobotUnit();
77 void _postFinishControlThreadInitialization();
78 // //////////////////////////////////////////////////////////////////////////////////////// //
79 // ///////////////////////////////////// ice interface //////////////////////////////////// //
80 // //////////////////////////////////////////////////////////////////////////////////////// //
81 public:
82 /**
83 * @brief Returns whether the RobotUnit is running.
84 * @return Whether the RobotUnit is running.
85 */
86 bool
87 isRunning(const Ice::Current& = Ice::emptyCurrent) const override
88 {
89 throwIfInControlThread(BOOST_CURRENT_FUNCTION);
91 }
92
93 void aggregatedHeartbeat(RobotHealthState overallHealthState, const Ice::Current&) override;
94
95 bool
96 isSimulation(const Ice::Current& = Ice::emptyCurrent) const override
97 {
98 return false;
99 }
100
101 // //////////////////////////////////////////////////////////////////////////////////////// //
102 // ///////////////////////////////////////// Data ///////////////////////////////////////// //
103 // //////////////////////////////////////////////////////////////////////////////////////// //
104 private:
105 /// @brief The number of additional object schedulers
106 std::int64_t additionalObjectSchedulerCount{0};
107 std::int64_t controlLoopStartTime{0};
108 std::int64_t heartbeatStartupMarginMS{0};
109 std::atomic_bool heartbeatRequired{false};
110 std::atomic_long heartbeatMaxCycleMS{100};
111 std::atomic_long lastHeartbeat{0};
112
113 // //////////////////////////////////////////////////////////////////////////////////////// //
114 // /////////////////////////////////////// Attorneys ////////////////////////////////////// //
115 // //////////////////////////////////////////////////////////////////////////////////////// //
116 private:
117 /**
118 * \brief This class allows minimal access to private members of \ref Management in a sane fashion for \ref ControlThread.
119 * \warning !! DO NOT ADD ADDITIONAL FRIENDS IF YOU DO NOT KNOW WAHT YOU ARE DOING! IF YOU DO SOMETHING WRONG YOU WILL CAUSE UNDEFINED BEHAVIOUR !!
120 */
122 };
123} // namespace armarx::RobotUnitModule
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
This Module handles some general management tasks.
static Management & Instance()
Returns the singleton instance of this class.
bool isRunning(const Ice::Current &=Ice::emptyCurrent) const override
Returns whether the RobotUnit is running.
bool isSimulation(const Ice::Current &=Ice::emptyCurrent) const override
friend class ManagementAttorneyForControlThread
This class allows minimal access to private members of Management in a sane fashion for ControlThread...
void aggregatedHeartbeat(RobotHealthState overallHealthState, const Ice::Current &) override
RobotUnitState getRobotUnitState() const
Returns the RobotUnit's State.
void throwIfInControlThread(const std::string &fnc) const
Throws if the current thread is the ControlThread.
static ModuleBase & Instance()
Returns the singleton instance of this class.