39 std::unique_lock lock(updateMutex);
41 if (childs.size() != 1)
47 if ((!fired || !onlyFireOnce) && (!childs.at(0) || childs.at(0)->getValue()))
50 ARMARX_DEBUG_S <<
"Condition fulfilled, sending event " <<
event->eventName
54 event->properties.clear();
55 for (
const DatafieldRefBasePtr& ref : refs)
59 event->properties[r->getDataFieldIdentifier()->getIdentifierStr()] =
63 listener->begin_reportEvent(event);
65 catch (std::exception& e)
77 std::unique_lock lock(updateMutex);
79 if (childs.size() != 1)
85 if ((!fired || !onlyFireOnce) && (!childs.at(0) || childs.at(0)->getValue()))
88 ARMARX_VERBOSE_S <<
"Condition fulfilled, sending event with data " <<
event->eventName
93 event->properties.clear();
95 for (
auto& v : values)
97 const Variant&
data = *VariantPtr::dynamicCast(v.second);
100 << VariantPtr::dynamicCast(v.second)->getOutputValueOnly();
102 for (
const DatafieldRefBasePtr& ref : refs)
105 auto id = r->getDataFieldIdentifier()->getIdentifierStr();
106 if (event->properties.count(
id) > 0)
112 ARMARX_INFO_S << r->getDataFieldIdentifier()->getIdentifierStr()
113 <<
" val: " << r->getDataField()->getOutputValueOnly();
117 listener->begin_reportEvent(event);
119 catch (std::exception& e)
131 out <<
"Event: " <<
event->eventName <<
" - ";
133 if (childs.size() > 0)
135 out <<
"Expression: " << TermImplPtr::dynamicCast(childs.at(0));
141 type = eConditionRoot;
145 const EventBasePtr& event,
146 const std::string& description,
148 const DatafieldRefList& refs)
150 type = eConditionRoot;
151 this->listener = listener->ice_collocationOptimized(
154 this->description = description;
155 this->onlyFireOnce = onlyFireOnce;
159 std::vector<LiteralImplPtr>
162 std::list<TermImplPtr> terms;
163 std::vector<LiteralImplPtr> literals;
165 terms.push_back(TermImplPtr::dynamicCast(expression));
167 while (terms.size() != 0)
174 if (term->getType() == eLiteral)
176 literals.push_back(LiteralImplPtr::dynamicCast(term));
181 TermImplSequence childs = term->getChilds();
182 TermImplSequence::iterator iterChilds = childs.begin();
184 while (iterChilds != childs.end())
186 terms.push_back(TermImplPtr::dynamicCast(*iterChilds));
void update(const Ice::Current &c=Ice::emptyCurrent) override
Update state f the ConditionRoot object based on the child.
void updateWithData(const Ice::Current &c=Ice::emptyCurrent) override
void output(std::ostream &out) const override
output to stream.
static std::vector< LiteralImplPtr > ExtractLiterals(const TermImplBasePtr &expression)
ConditionRoot()
Creates an empty ConditionRoot.
The SingleVariant class is required to store single Variant instances in VariantContainer subclasses.
The Variant class is described here: Variants.
#define ARMARX_DEBUG_S
The logging level for output that is only interesting while debugging.
#define ARMARX_ERROR_S
The logging level for unexpected behaviour, that must be fixed.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceInternal::Handle< DatafieldRef > DatafieldRefPtr
IceInternal::Handle< TermImpl > TermImplPtr
Typedef of TermImplPtr as IceInternal::Handle<TermImpl> for convenience.