Skip to content

Commit beaab34

Browse files
Add onSuccess event (#1604)
* Add onSuccess event * Add true condition
1 parent 4a8f3b1 commit beaab34

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ConstraintsChecker::ConstraintsChecker(qReal::ErrorReporterInterface &errorRepor
4141
mDefferedSuccessTriggered = true;
4242
} else {
4343
mSuccessTriggered = true;
44-
emit success();
44+
onSuccess();
4545
}
4646
});
4747
connect(&mStatus, &details::StatusReporter::fail, this, [this]() { mFailTriggered = true; });
@@ -293,9 +293,21 @@ void ConstraintsChecker::programFinished(qReal::interpretation::StopReason reaso
293293
{
294294
if (!mSuccessTriggered && !mFailTriggered && mEnabled) {
295295
if (mDefferedSuccessTriggered && reason == qReal::interpretation::StopReason::finised) {
296-
emit success();
296+
onSuccess();
297297
} else {
298298
emit fail(tr("Program has finished, but the task is not accomplished."));
299299
}
300300
}
301301
}
302+
303+
void ConstraintsChecker::onSuccess()
304+
{
305+
for (const auto &event : mEvents) {
306+
if (event->id() == "on_success") {
307+
event->setUp();
308+
event->check();
309+
break;
310+
}
311+
}
312+
emit success();
313+
}

plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class ConstraintsChecker : public QObject
119119
void programStarted();
120120
void programFinished(qReal::interpretation::StopReason reason);
121121

122+
void onSuccess();
123+
122124
qReal::ErrorReporterInterface &mErrorReporter;
123125
model::Model &mModel;
124126
details::StatusReporter mStatus;

plugins/robots/common/twoDModel/src/engine/constraints/details/constraintsParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ Condition ConstraintsParser::parseConditionContents(const QDomElement &element,
294294
return parseNegationTag(element, event);
295295
}
296296

297+
if (tag == "true") {
298+
return mConditions.constant(true);
299+
}
300+
297301
if (tag == "equals" || tag.startsWith("notequal")
298302
|| tag == "greater" || tag == "less"
299303
|| tag == "notgreater" || tag == "notless")

qrtranslations/fr/plugins/robots/twoDModel_fr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<translation>Attribut &quot;glue&quot; doit avoir une valeur &quot;and&quot; ou &quot;or&quot;.</translation>
6969
</message>
7070
<message>
71-
<location line="+55"/>
71+
<location line="+59"/>
7272
<location line="+183"/>
7373
<source>Unknown tag &quot;%1&quot;.</source>
7474
<translation>Balise inconnue &quot;%1&quot;.</translation>

qrtranslations/ru/plugins/robots/twoDModel_ru.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
<translation>Аттрибут &quot;glue&quot; должен иметь значение &quot;and&quot; или &quot;or&quot;.</translation>
238238
</message>
239239
<message>
240-
<location line="+55"/>
240+
<location line="+59"/>
241241
<location line="+183"/>
242242
<source>Unknown tag &quot;%1&quot;.</source>
243243
<translation>Неизвестный тэг &quot;%1&quot;.</translation>

0 commit comments

Comments
 (0)