Skip to content

Commit

Permalink
Add onSuccess event (#1604)
Browse files Browse the repository at this point in the history
* Add onSuccess event

* Add true condition
  • Loading branch information
IKhonakhbeeva committed Oct 17, 2022
1 parent 4a8f3b1 commit beaab34
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ConstraintsChecker::ConstraintsChecker(qReal::ErrorReporterInterface &errorRepor
mDefferedSuccessTriggered = true;
} else {
mSuccessTriggered = true;
emit success();
onSuccess();
}
});
connect(&mStatus, &details::StatusReporter::fail, this, [this]() { mFailTriggered = true; });
Expand Down Expand Up @@ -293,9 +293,21 @@ void ConstraintsChecker::programFinished(qReal::interpretation::StopReason reaso
{
if (!mSuccessTriggered && !mFailTriggered && mEnabled) {
if (mDefferedSuccessTriggered && reason == qReal::interpretation::StopReason::finised) {
emit success();
onSuccess();
} else {
emit fail(tr("Program has finished, but the task is not accomplished."));
}
}
}

void ConstraintsChecker::onSuccess()
{
for (const auto &event : mEvents) {
if (event->id() == "on_success") {
event->setUp();
event->check();
break;
}
}
emit success();
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class ConstraintsChecker : public QObject
void programStarted();
void programFinished(qReal::interpretation::StopReason reason);

void onSuccess();

qReal::ErrorReporterInterface &mErrorReporter;
model::Model &mModel;
details::StatusReporter mStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ Condition ConstraintsParser::parseConditionContents(const QDomElement &element,
return parseNegationTag(element, event);
}

if (tag == "true") {
return mConditions.constant(true);
}

if (tag == "equals" || tag.startsWith("notequal")
|| tag == "greater" || tag == "less"
|| tag == "notgreater" || tag == "notless")
Expand Down
2 changes: 1 addition & 1 deletion qrtranslations/fr/plugins/robots/twoDModel_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<translation>Attribut &quot;glue&quot; doit avoir une valeur &quot;and&quot; ou &quot;or&quot;.</translation>
</message>
<message>
<location line="+55"/>
<location line="+59"/>
<location line="+183"/>
<source>Unknown tag &quot;%1&quot;.</source>
<translation>Balise inconnue &quot;%1&quot;.</translation>
Expand Down
2 changes: 1 addition & 1 deletion qrtranslations/ru/plugins/robots/twoDModel_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
<translation>Аттрибут &quot;glue&quot; должен иметь значение &quot;and&quot; или &quot;or&quot;.</translation>
</message>
<message>
<location line="+55"/>
<location line="+59"/>
<location line="+183"/>
<source>Unknown tag &quot;%1&quot;.</source>
<translation>Неизвестный тэг &quot;%1&quot;.</translation>
Expand Down

0 comments on commit beaab34

Please sign in to comment.