Skip to content
Snippets Groups Projects
Commit 17a37915 authored by Christoph Pohl's avatar Christoph Pohl
Browse files

Fix HeatbeatComponentPlugin not using properties

parent cd6b04fb
No related branches found
No related tags found
No related merge requests found
......@@ -7,92 +7,79 @@
namespace armarx::plugins
{
void
HeartbeatComponentPlugin::configureHeartbeatChannel(const std::string& channel,
const RobotHealthHeartbeatArgs& args)
void HeartbeatComponentPlugin::configureHeartbeatChannel(const std::string& channel,
const RobotHealthHeartbeatArgs& args)
{
channelHeartbeatConfig.emplace(channel, args);
}
void
HeartbeatComponentPlugin::heartbeat()
void HeartbeatComponentPlugin::heartbeat()
{
if (robotHealthTopic)
{
robotHealthTopic->heartbeat(componentName, heartbeatArgs);
}
else
} else
{
ARMARX_WARNING << "No robot health topic available!";
}
}
void
HeartbeatComponentPlugin::heartbeat(const std::string& channel)
void HeartbeatComponentPlugin::heartbeat(const std::string& channel)
{
const auto argsIt = channelHeartbeatConfig.find(channel);
ARMARX_CHECK(argsIt != channelHeartbeatConfig.end())
<< "heartbeat() called for unknown channel '" << channel << "'."
<< "You must register the config using configureHeartbeatChannel(channel) first!";
ARMARX_CHECK(argsIt != channelHeartbeatConfig.end()) << "heartbeat() called for unknown channel '" << channel
<< "'."
<< "You must register the config using configureHeartbeatChannel(channel) first!";
const auto& args = argsIt->second;
if (robotHealthTopic)
{
robotHealthTopic->heartbeat(componentName + "_" + channel, args);
}
else
} else
{
ARMARX_WARNING << "No robot health topic available!";
}
}
void
HeartbeatComponentPlugin::preOnInitComponent()
void HeartbeatComponentPlugin::preOnInitComponent()
{
if (topicName.empty())
{
parent<Component>().getProperty(topicName, makePropertyName(topicPropertyName));
}
parent<Component>().offeringTopic(topicName);
// if (topicName.empty())
// {
// parent<Component>().getProperty(topicName, makePropertyName(topicPropertyName));
// }
// parent<Component>().offeringTopic(topicName);
}
void
HeartbeatComponentPlugin::postOnInitComponent()
void HeartbeatComponentPlugin::postOnInitComponent()
{
}
void
HeartbeatComponentPlugin::preOnConnectComponent()
void HeartbeatComponentPlugin::preOnConnectComponent()
{
robotHealthTopic = parent<Component>().getTopic<RobotHealthInterfacePrx>(topicName);
// robotHealthTopic = parent<Component>().getTopic<RobotHealthInterfacePrx>(topicName);
componentName = parent<Component>().getName();
}
void
HeartbeatComponentPlugin::postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties)
void HeartbeatComponentPlugin::postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties)
{
if (!properties->hasDefinition(makePropertyName(topicPropertyName)))
{
properties->defineOptionalProperty<std::string>(
makePropertyName(topicPropertyName),
"DebugObserver",
"Name of the topic the DebugObserver listens on");
properties->topic(robotHealthTopic, topicName, topicPropertyName,
"Name of the topic the DebugObserver listens on");
}
if (not properties->hasDefinition(makePropertyName(maximumCycleTimeWarningMSPropertyName)))
{
properties->defineRequiredProperty<std::string>(
makePropertyName(maximumCycleTimeWarningMSPropertyName),
"TODO: maximumCycleTimeWarningMS");
properties->required(heartbeatArgs.maximumCycleTimeWarningMS, maximumCycleTimeWarningMSPropertyName,
"maximum cycle time before warning is emitted");
}
if (not properties->hasDefinition(makePropertyName(maximumCycleTimeErrorMSPropertyName)))
{
properties->defineRequiredProperty<std::string>(
makePropertyName(maximumCycleTimeErrorMSPropertyName),
"TODO: maximumCycleTimeErrorMS");
properties->required(heartbeatArgs.maximumCycleTimeErrorMS, maximumCycleTimeErrorMSPropertyName,
"maximum cycle time before error is emitted");
}
}
......
......@@ -66,7 +66,7 @@ namespace armarx::plugins
private:
//! heartbeat topic name (outgoing)
std::string topicName;
std::string topicName{"DebugObserver"};
//! name of this component used as identifier for heartbeats
std::string componentName;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment