43 return "Unexpected Event";
47 return "Invalid input parameters";
55StringVariantContainerBaseMap
58 StringVariantContainerBaseMap setValueMap;
60 for (StateParameterMap::const_iterator it = paramMap.begin(); it != paramMap.end(); it++)
64 setValueMap[it->first] = it->second->value;
71StringVariantContainerBaseMap
74 StringVariantContainerBaseMap
ValueMap;
76 for (StateParameterMap::const_iterator it = paramMap.begin(); it != paramMap.end(); it++)
78 ValueMap[it->first] = it->second->value->cloneContainer();
88 StringVariantContainerBaseMap& dictionary =
event->properties;
89 StringVariantContainerBaseMap::iterator it = dictionary.find(key);
91 if (it != dictionary.end())
102 const std::string key,
106 StringVariantContainerBaseMap& dictionary =
event->properties;
107 StringVariantContainerBaseMap::iterator it = dictionary.find(key);
109 if (it != dictionary.end())
114 dictionary[key] = valueList->cloneContainer();
125 for (StateParameterMap::const_iterator it = dict1.begin(); it != dict1.end(); it++)
127 StateParameterMap::const_iterator it2 = dict2.find(it->first);
129 if (it2 == dict2.end() ||
131 it->second->value->getContainerType()))
144 const StringVariantContainerBaseMap& dict2)
148 for (StringVariantContainerBaseMap::const_iterator it = dict1.begin(); it != dict1.end(); it++)
150 StringVariantContainerBaseMap::const_iterator it2 = dict2.find(it->first);
153 it->second->getContainerType()))
165 StringVariantContainerBaseMap& destination)
167 for (StringVariantContainerBaseMap::const_iterator it = source.begin(); it != source.end();
170 StringVariantContainerBaseMap::iterator itDest = destination.find(it->first);
172 if (itDest != destination.end())
174 *itDest->second = *it->second;
181 StateParameterMap& destination)
183 for (StringVariantContainerBaseMap::const_iterator it = source.begin(); it != source.end();
186 StateParameterMap::iterator itDest = destination.find(it->first);
188 if (itDest != destination.end())
190 itDest->second->value = it->second->cloneContainer();
191 itDest->second->set =
true;
198 StringVariantContainerBaseMap& destination)
202 for (StringVariantContainerBaseMap::const_iterator it = source.begin(); it != source.end();
205 destination[it->first] = it->second->cloneContainer();
214 for (StateParameterMap::const_iterator it = source.begin(); it != source.end(); it++)
216 destination[it->first] = StateParameterIceBasePtr::dynamicCast(it->second->ice_clone());
222 StringVariantContainerBaseMap& destination)
226 for (StateParameterMap::const_iterator it = source.begin(); it != source.end(); it++)
228 destination[it->first] = it->second->value->cloneContainer();
234 StateParameterMap& destination)
239 for (StringVariantContainerBaseMap::const_iterator it = source.begin(); it != source.end();
243 param->value = it->second->cloneContainer();
244 param->optionalParam =
false;
246 destination[it->first] = param;
253 std::stringstream result;
256 for (StringVariantContainerBaseMap::const_iterator it = mymap.begin(); it != mymap.end(); it++)
259 result <<
"\t" << it->first <<
" ("
262 if (!it->second->getContainerType()->subType)
268 throw LocalException(
"Could not cast to SingleVariant");
272 result << var->getOutputValueOnly() <<
"\n";
277 json->serializeIceObject(it->second);
278 result << json->asString(
true) <<
"\n";
306 std::stringstream result;
309 for (StateParameterMap::const_iterator it = mymap.begin(); it != mymap.end(); it++)
323 if (!it->second->value->getContainerType()->subType)
330 throw LocalException(
"Could not cast to SingleVariant");
340 result <<
"\t#" << i <<
" " <<
getVariantString(var, it->first) <<
" (" << setStr
347 json->serializeIceObject(it->second->value);
348 result <<
"\t#" << i <<
" " << it->first <<
": " << json->asString(
true) <<
"\n";
373 std::string* logOutput)
377 for (StateParameterMap::const_iterator it = paramMap.begin(); it != paramMap.end(); it++)
379 if (!it->second->optionalParam && !it->second->set)
383 *logOutput +=
"\tRequired parameter '" + it->first +
"' was not set.\n";
388 else if (!it->second->optionalParam || it->second->set)
392 result &= it->second->value->validateElements();
396 ARMARX_DEBUG_S <<
"Incomplete type for key: " << it->first <<
" - " << e.what();
410 IceUtil::Int64 timeoutDura = 4000;
413 bool allInitialized =
true;
414 int waitIntervallMs = 10;
415 IceUtil::Time waitStartTime = IceUtil::Time::now();
417 IceUtil::Time timeout = IceUtil::Time::milliSeconds(timeoutDura);
418 std::vector<std::string> notInitList;
420 IceUtil::Time lastOutput = IceUtil::Time::milliSeconds(0);
422 while (!allInitialized &&
423 IceUtil::Time(waitStartTime + timeout - IceUtil::Time::now()).toMilliSeconds() > 0)
425 allInitialized =
true;
428 for (StateParameterMap::const_iterator it = paramMap.begin(); it != paramMap.end(); it++)
432 if (param->value->getContainerType()->typeId ==
435 if (!VariantPtr::dynamicCast(param->value)
439 allInitialized =
false;
440 notInitList.push_back(it->first);
445 if (!allInitialized && IceUtil::Time(IceUtil::Time::now() - lastOutput).toSeconds() >=
451 usleep(waitIntervallMs * 1000);
453 if (waitIntervallMs < timeoutDura * 0.5f)
455 waitIntervallMs *= 2;
472 StateParameterMap::iterator it = paramMap.begin();
474 for (; it != paramMap.end(); ++it)
476 it->second->set =
false;
489 std::stringstream
str;
490 str << name <<
":\n" << var;
The ChannelRef class is a reference to a channel on an Observer.
The JSONObject class is used to represent and (de)serialize JSON objects.
The SingleVariant class is required to store single Variant instances in VariantContainer subclasses.
static StateParameterPtr create()
static std::string allTypesToString(const ContainerTypePtr &type)
static bool compare(const ContainerTypePtr &type1, const ContainerTypePtr &secondType)
The Variant class is described here: Variants.
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
#define ARMARX_DEBUG_S
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
std::map< std::string, ValueVariant > ValueMap
std::string getVariantString(const VariantBasePtr &var, const std::string &name="")
void copyDictionary(const StringVariantContainerBaseMap &source, StringVariantContainerBaseMap &destination)
Clears the destination map and copies the parameters of the source in it.
std::string transitionErrorToString(TransitionErrorType type)
std::string getDictionaryString(const StringVariantContainerBaseMap &mymap)
Converts the map into a string-representation.
StringVariantContainerBaseMap getValues(const StateParameterMap ¶mMap)
bool checkForCompleteParameters(const StateParameterMap ¶mMap, std::string *logOutput=nullptr)
void unsetParameters(StateParameterMap ¶mMap)
Sets all entries of the given dictionary to the stored default values.
StringVariantContainerBaseMap getSetValues(const StateParameterMap ¶mMap)
bool equalKeys(const StringVariantContainerBaseMap &dict1, const StringVariantContainerBaseMap &dict2)
Checks whether the maps have equal keys and equal Types.
void fillDictionary(const StringVariantContainerBaseMap &source, StringVariantContainerBaseMap &destination)
Tries to fill the destination map with matching entries of the source map. Entries that could not be ...
bool waitForChannelRefs(const StateParameterMap ¶mMap)
Waits for all ChannelRefs to be initialized in the given Map.
bool addToDictionary(EventPtr event, const std::string key, const Variant &value)
Adds the (key,defaulfValue) pair to the event-dictionary.
const VariantTypeId ChannelRef
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< SingleTypeVariantList > SingleTypeVariantListPtr
@ eTransitionErrorUnexpectedEvent
IceInternal::Handle< StateParameter > StateParameterPtr
IceInternal::Handle< SingleVariant > SingleVariantPtr
IceInternal::Handle< Variant > VariantPtr
IceInternal::Handle< JSONObject > JSONObjectPtr
const LogSender::manipulator flush
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr
IceInternal::Handle< Event > EventPtr
Typedef of EventPtr as IceInternal::Handle<Event> for convenience.