Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Run minimal Python interpeter tests in direct script mode
run: |
PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$TWOD_EXEC_NAME" --generate-path "$i".py \
--close -s 5 --script-path "$i".py -m script "$i"; done'
--generate-mode python --close -s 5 --script-path "$i".py -m script "$i"; done'
timeout-minutes: 15

- name: Run minimal Javascript interpeter tests as fields in .qrs (For backward compatibility)
Expand All @@ -154,3 +154,16 @@ jobs:
PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$PATCHER_NAME" -s "$i".py "$i" \
&& "$TWOD_EXEC_NAME" --close -s 5 -m script "$i"; done'
timeout-minutes: 5

- name: Run nxt generation tests
run: |
curl --output nxt_tests.7z "https://dl.trikset.com/edu/.solutions20200701/nxt_generation.7z"
7z x nxt_tests.7z || 7za x nxt_tests.7z
set -x
for i in "$GITHUB_WORKSPACE"/nxt/*.qrs;
do
"$TWOD_EXEC_NAME" --generate-mode nxt --generate-path "$i".c --only-generate "$i"
ls "$GITHUB_WORKSPACE"/nxt/
cat "$i".c
done
timeout-minutes: 5
14 changes: 12 additions & 2 deletions plugins/robots/checker/twoDModelRunner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,13 @@ int main(int argc, char *argv[])
", to save the generated JavaScript or Python code.")
, "path-to-save-code", QString());
QCommandLineOption generateModeOption("generate-mode", QObject::tr("Select \"python\" or \"javascript\".")
, "generate-mode", "python");
, "generate-mode", "javascript");
QCommandLineOption directScriptExecutionPathOption("script-path"
, QObject::tr("The path to the Python or JavaScript file that will be used for interpretation.")
, "script-path", QString());
QCommandLineOption onlyGenerateOption("only-generate"
, QObject::tr("Do not run the interpretation in any mode, "\
"this is a parameter that is only used to generate a file."));
parser.addOption(backgroundOption);
parser.addOption(reportOption);
parser.addOption(trajectoryOption);
Expand All @@ -145,6 +148,7 @@ int main(int argc, char *argv[])
parser.addOption(generatePathOption);
parser.addOption(generateModeOption);
parser.addOption(directScriptExecutionPathOption);
parser.addOption(onlyGenerateOption);
parser.process(*app);
const QStringList positionalArgs = parser.positionalArguments();
if (positionalArgs.size() != 1) {
Expand All @@ -162,12 +166,14 @@ int main(int argc, char *argv[])
const QString generatePath = parser.value(generatePathOption);
const QString generateMode = parser.value(generateModeOption);
const QString scriptFilePath = parser.value(directScriptExecutionPathOption);
const bool onlyGenerate = parser.isSet(onlyGenerateOption);

QScopedPointer<twoDModel::Runner> runner(new twoDModel::Runner(report, trajectory, input, mode, qrsFile));
auto speedFactor = parser.value(speedOption).toInt();

if (!generatePath.isEmpty()) {
if (generateMode != "python" and generateMode != "javascript") {
if (generateMode != "python" and generateMode != "javascript"
and generateMode != "nxt") {
parser.showHelp();
QLOG_ERROR() << "Problem with generate code to " << generatePath;
return TWO_D_MODEL_RUNNER_GENERATE_MODE_NOT_EXIST;
Expand All @@ -178,6 +184,10 @@ int main(int argc, char *argv[])
}
}

if (onlyGenerate || mode == "nxt") {
return 0;
}

if (!runner->interpret(backgroundMode, speedFactor, closeOnFinishMode,
closeOnSuccessMode, showConsoleMode, scriptFilePath)) {
return TWO_D_MODEL_RUNNER_INTERPRET_ERROR;
Expand Down
5 changes: 5 additions & 0 deletions plugins/robots/checker/twoDModelRunner/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ bool Runner::generate(const QString &generatePath, const QString &generateMode)
emit action.action()->triggered();
}
}
if (generateMode == "nxt") {
if (action.action()->objectName() == "generateCode") {
emit action.action()->triggered();
}
}
}

auto codes = mTextManager->code(mMainWindow->activeDiagram());
Expand Down
9 changes: 7 additions & 2 deletions qrtranslations/fr/plugins/robots/twoDModelRunner_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ In background mode the session will be terminated just after the execution ended
<translation type="unfinished"></translation>
</message>
<message>
<location line="-3"/>
<location line="+3"/>
<source>Do not run the interpretation in any mode, this is a parameter that is only used to generate a file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-6"/>
<source>Select &quot;python&quot; or &quot;javascript&quot;.</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -87,7 +92,7 @@ In background mode the session will be terminated just after the execution ended
<context>
<name>twoDModel::Runner</name>
<message>
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+234"/>
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+239"/>
<source>Robot console</source>
<translation type="unfinished"></translation>
</message>
Expand Down
13 changes: 11 additions & 2 deletions qrtranslations/ru/plugins/robots/twoDModelRunner_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ In background mode the session will be terminated just after the execution ended
<translation>Путь к Python или Javascript файлу, который будет использоваться для интерпретации.</translation>
</message>
<message>
<location line="-3"/>
<location line="+3"/>
<source>Do not run the interpretation in any mode, this is a parameter that is only used to generate a file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Do not run the interpretation in any mode, this is a parameter used only to generate a file.</source>
<translation type="vanished">Не запускайте интерпретацию ни в каком режиме, этот параметр используется только для генерации файла.</translation>
</message>
<message>
<location line="-6"/>
<source>Select &quot;python&quot; or &quot;javascript&quot;.</source>
<translation>Выберите &quot;python&quot; или &quot;javascript&quot;.</translation>
</message>
Expand Down Expand Up @@ -89,7 +98,7 @@ In background mode the session will be terminated just after the execution ended
<context>
<name>twoDModel::Runner</name>
<message>
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+234"/>
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+239"/>
<source>Robot console</source>
<translation>Консоль робота</translation>
</message>
Expand Down
Loading