26#include <shared_mutex>
30#include <ArmarXCore/interface/components/EmergencyStopInterface.h>
45 "EmergencyStopMaster",
46 "The name of the emergencyStop-proxy.");
50 "The name of the topic over which changes of the emergencyStopState are sent.");
63 "The name of the topic over which changes of the emergencyStopState are sent.");
146 virtual public armarx::EmergencyStopMasterInterface
154 const ::Ice::Current& = Ice::emptyCurrent)
override;
166 const ::Ice::Current& = Ice::emptyCurrent)
override;
196 return "EmergencyStopMaster";
200 EmergencyStopListenerPrx emergencyStopTopic;
201 mutable std::shared_mutex ss2StateMutex;
203 EmergencyStopState currentSS2State;
218 virtual public armarx::EmergencyStopNodeInterface
220 typedef void (
T::*method_type)(void);
222 struct CallbackFunction
225 method_type function;
228 using CallbackFunctionsMap = std::multimap<EmergencyStopState, CallbackFunction>;
243 cb.function = callbackFunction;
246 callbackFunctions.insert(std::pair<EmergencyStopState, CallbackFunction>(state, cb));
248 ARMARX_INFO <<
"Registered function: " << callbackFunction <<
" - " << state;
260 method_type callbackFunction,
261 EmergencyStopState state)
263 std::pair<
typename CallbackFunctionsMap::iterator,
264 typename CallbackFunctionsMap::iterator>
266 range = callbackFunctions.equal_range(state);
268 for (
typename CallbackFunctionsMap::iterator it = range.first; it != range.second;
271 if ((it->second).parent == parent && (it->second).function == callbackFunction)
273 callbackFunctions.erase(it++);
288 return this->currentState;
296 return "EmergencyStopNode";
301 callback(CallbackFunction callback)
303 T* parent = callback.parent;
304 method_type function = callback.function;
308 (parent->*function)();
317 reportEmergencyStopState(EmergencyStopState state,
const Ice::Current&)
override
319 currentState = state;
321 std::pair<
typename CallbackFunctionsMap::iterator,
322 typename CallbackFunctionsMap::iterator>
324 range = callbackFunctions.equal_range(state);
326 for (
typename CallbackFunctionsMap::iterator it = range.first; it != range.second; ++it)
328 callback(it->second);
332 CallbackFunctionsMap callbackFunctions;
333 std::atomic<EmergencyStopState> currentState;
349 currentState = stopMaster->getEmergencyStopState();
353 currentState = eEmergencyStopInactive;
Default component property definition container.
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Baseclass for all ArmarX ManagedIceObjects requiring properties.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
The EmergencyStopMaster stores the current state of the EmergencyStop and broadcasts any changes to t...
void onInitComponent() override
EmergencyStopState getEmergencyStopState(const ::Ice::Current &=Ice::emptyCurrent) const override
void setEmergencyStopState(EmergencyStopState state, const ::Ice::Current &=Ice::emptyCurrent) override
Sets the state of the EmergencyStop and sends the new state immediatly over the specified topic.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
EmergencyStopState trySetEmergencyStopState(EmergencyStopState targetState, const ::Ice::Current &=Ice::emptyCurrent) override
Try set the SS2 emergency stop state if it is safe.
std::string getDefaultName() const override
EmergencyStopNodePropertyDefinitions(std::string prefix)
This component listens on the specified topic (default value: EmergencyStop) and changes its state co...
void onInitComponent() override
Pure virtual hook for the subclass.
EmergencyStopState getEmergencyStopState() const
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
IceInternal::Handle< EmergencyStopNode< T > > EmergencyStopNodePtr
void onConnectComponent() override
Pure virtual hook for the subclass.
void unregisterCallbackFunction(T *parent, method_type callbackFunction, EmergencyStopState state)
unregisterCallbackFunction Unregisters the given function for the given state.
std::string getDefaultName() const override
Retrieve default name of component.
void registerCallbackFunction(T *parent, method_type callbackFunction, EmergencyStopState state)
registerCallbackFunction Registers the given function to be called, if the reported emergencyStopStat...
EmergencyStopPropertyMasterDefinitions(std::string prefix)
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
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)
Represents a point in time.
#define ARMARX_INFO
The normal logging level.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.