From beaab34fbf11b6f284667aa823a3df08ace8e7d3 Mon Sep 17 00:00:00 2001 From: IKhonakhbeeva <43929571+IKhonakhbeeva@users.noreply.github.com> Date: Mon, 17 Oct 2022 16:27:27 +0300 Subject: [PATCH] Add onSuccess event (#1604) * Add onSuccess event * Add true condition --- .../engine/constraints/constraintsChecker.cpp | 16 ++++++++++++++-- .../src/engine/constraints/constraintsChecker.h | 2 ++ .../constraints/details/constraintsParser.cpp | 4 ++++ qrtranslations/fr/plugins/robots/twoDModel_fr.ts | 2 +- qrtranslations/ru/plugins/robots/twoDModel_ru.ts | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.cpp b/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.cpp index 730f23c7be..bd6bf36d86 100644 --- a/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.cpp +++ b/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.cpp @@ -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; }); @@ -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(); +} diff --git a/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.h b/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.h index 8c327cd405..556b040d7f 100644 --- a/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.h +++ b/plugins/robots/common/twoDModel/src/engine/constraints/constraintsChecker.h @@ -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; diff --git a/plugins/robots/common/twoDModel/src/engine/constraints/details/constraintsParser.cpp b/plugins/robots/common/twoDModel/src/engine/constraints/details/constraintsParser.cpp index 64e1bbc82c..940faca527 100644 --- a/plugins/robots/common/twoDModel/src/engine/constraints/details/constraintsParser.cpp +++ b/plugins/robots/common/twoDModel/src/engine/constraints/details/constraintsParser.cpp @@ -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") diff --git a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts index 87144f9d65..ad74462dce 100644 --- a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts +++ b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts @@ -68,7 +68,7 @@ Attribut "glue" doit avoir une valeur "and" ou "or". - + Unknown tag "%1". Balise inconnue "%1". diff --git a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts index f114950a3d..f4beed7293 100644 --- a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts +++ b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts @@ -237,7 +237,7 @@ Аттрибут "glue" должен иметь значение "and" или "or". - + Unknown tag "%1". Неизвестный тэг "%1".