26 #include <shared_mutex>
30 #include <ArmarXCore/interface/components/EmergencyStopInterface.h>
44 defineOptionalProperty<std::string>(
"EmergencyStopProxy",
45 "EmergencyStopMaster",
46 "The name of the emergencyStop-proxy.");
47 defineOptionalProperty<std::string>(
50 "The name of the topic over which changes of the emergencyStopState are sent.");
60 defineOptionalProperty<std::string>(
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;
339 usingTopic(getProperty<std::string>(
"EmergencyStopTopic").getValue());
345 EmergencyStopMasterInterfacePrx stopMaster = getProxy<EmergencyStopMasterInterfacePrx>(
346 getProperty<std::string>(
"EmergencyStopProxy").getValue(),
false,
"",
false);
349 currentState = stopMaster->getEmergencyStopState();
353 currentState = eEmergencyStopInactive;