26 #include <ArmarXCore/interface/components/EmergencyStopInterface.h>
42 defineOptionalProperty<std::string>(
"EmergencyStopProxy",
"EmergencyStopMaster",
"The name of the emergencyStop-proxy.");
43 defineOptionalProperty<std::string>(
"EmergencyStopTopic",
"EmergencyStop",
"The name of the topic over which changes of the emergencyStopState are sent.");
54 defineOptionalProperty<std::string>(
"EmergencyStopTopic",
"EmergencyStop",
"The name of the topic over which changes of the emergencyStopState are sent.");
137 virtual public armarx::EmergencyStopMasterInterface
145 void setEmergencyStopState(EmergencyStopState state, const ::Ice::Current& = Ice::emptyCurrent)
override;
172 return "EmergencyStopMaster";
176 EmergencyStopListenerPrx emergencyStopTopic;
177 std::atomic<EmergencyStopState> emergencyStopState;
192 virtual public armarx::EmergencyStopNodeInterface
194 typedef void (
T::*method_type)(void);
196 struct CallbackFunction
199 method_type
function;
202 using CallbackFunctionsMap = std::multimap<EmergencyStopState, CallbackFunction>;
217 cb.function = callbackFunction;
220 callbackFunctions.insert(std::pair<EmergencyStopState, CallbackFunction>(state, cb));
222 ARMARX_INFO <<
"Registered function: " << callbackFunction <<
" - " << state;
234 std::pair<typename CallbackFunctionsMap::iterator, typename CallbackFunctionsMap::iterator> range;
235 range = callbackFunctions.equal_range(state);
237 for (
typename CallbackFunctionsMap::iterator it = range.first; it != range.second; )
239 if ((it->second).parent == parent && (it->second).function == callbackFunction)
241 callbackFunctions.erase(it++);
255 return this->currentState;
262 return "EmergencyStopNode";
266 void callback(CallbackFunction callback)
268 T* parent = callback.parent;
269 method_type
function = callback.function;
273 (parent->*
function)();
281 void reportEmergencyStopState(EmergencyStopState state,
const Ice::Current&)
override
283 currentState = state;
285 std::pair<typename CallbackFunctionsMap::iterator, typename CallbackFunctionsMap::iterator> range;
286 range = callbackFunctions.equal_range(state);
288 for (
typename CallbackFunctionsMap::iterator it = range.first; it != range.second; ++it)
290 callback(it->second);
294 CallbackFunctionsMap callbackFunctions;
295 std::atomic<EmergencyStopState> currentState;
300 usingTopic(getProperty<std::string>(
"EmergencyStopTopic").getValue());
305 EmergencyStopMasterInterfacePrx stopMaster = getProxy<EmergencyStopMasterInterfacePrx>(getProperty<std::string>(
"EmergencyStopProxy").getValue(),
false,
"",
false);
308 currentState = stopMaster->getEmergencyStopState();
312 currentState = eEmergencyStopInactive;