Skip to content

Commit fb3b878

Browse files
committed
Add support for NXT code generation in the 2D model
1 parent fd7e8c9 commit fb3b878

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

plugins/robots/checker/twoDModelRunner/main.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ int main(int argc, char *argv[])
129129
", to save the generated JavaScript or Python code.")
130130
, "path-to-save-code", QString());
131131
QCommandLineOption generateModeOption("generate-mode", QObject::tr("Select \"python\" or \"javascript\".")
132-
, "generate-mode", "python");
132+
, "generate-mode", "javascript");
133133
QCommandLineOption directScriptExecutionPathOption("script-path"
134134
, QObject::tr("The path to the Python or JavaScript file that will be used for interpretation.")
135135
, "script-path", QString());
136+
QCommandLineOption onlyGenerateOption("only-generate"
137+
, QObject::tr("Do not run the interpretation in any mode, this is a parameter that is only used to generate a file."));
136138
parser.addOption(backgroundOption);
137139
parser.addOption(reportOption);
138140
parser.addOption(trajectoryOption);
@@ -145,6 +147,7 @@ int main(int argc, char *argv[])
145147
parser.addOption(generatePathOption);
146148
parser.addOption(generateModeOption);
147149
parser.addOption(directScriptExecutionPathOption);
150+
parser.addOption(onlyGenerateOption);
148151
parser.process(*app);
149152
const QStringList positionalArgs = parser.positionalArguments();
150153
if (positionalArgs.size() != 1) {
@@ -162,12 +165,14 @@ int main(int argc, char *argv[])
162165
const QString generatePath = parser.value(generatePathOption);
163166
const QString generateMode = parser.value(generateModeOption);
164167
const QString scriptFilePath = parser.value(directScriptExecutionPathOption);
168+
const bool onlyGenerate = parser.isSet(onlyGenerateOption);
165169

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

169173
if (!generatePath.isEmpty()) {
170-
if (generateMode != "python" and generateMode != "javascript") {
174+
if (generateMode != "python" and generateMode != "javascript"
175+
and generateMode != "nxt") {
171176
parser.showHelp();
172177
QLOG_ERROR() << "Problem with generate code to " << generatePath;
173178
return TWO_D_MODEL_RUNNER_GENERATE_MODE_NOT_EXIST;
@@ -178,6 +183,10 @@ int main(int argc, char *argv[])
178183
}
179184
}
180185

186+
if (onlyGenerate || mode == "nxt") {
187+
return 0;
188+
}
189+
181190
if (!runner->interpret(backgroundMode, speedFactor, closeOnFinishMode,
182191
closeOnSuccessMode, showConsoleMode, scriptFilePath)) {
183192
return TWO_D_MODEL_RUNNER_INTERPRET_ERROR;

plugins/robots/checker/twoDModelRunner/runner.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ bool Runner::generate(const QString &generatePath, const QString &generateMode)
107107
emit action.action()->triggered();
108108
}
109109
}
110+
if (generateMode == "nxt") {
111+
qDebug() << action.action()->objectName();
112+
if (action.action()->objectName() == "generateCode") {
113+
emit action.action()->triggered();
114+
}
115+
}
110116
}
111117

112118
auto codes = mTextManager->code(mMainWindow->activeDiagram());

qrtranslations/fr/plugins/robots/twoDModelRunner_fr.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ In background mode the session will be terminated just after the execution ended
5151
<translation type="unfinished"></translation>
5252
</message>
5353
<message>
54-
<location line="-3"/>
54+
<location line="+3"/>
55+
<source>Do not run the interpretation in any mode, this is a parameter that is only used to generate a file.</source>
56+
<translation type="unfinished"></translation>
57+
</message>
58+
<message>
59+
<location line="-6"/>
5560
<source>Select &quot;python&quot; or &quot;javascript&quot;.</source>
5661
<translation type="unfinished"></translation>
5762
</message>
@@ -87,7 +92,7 @@ In background mode the session will be terminated just after the execution ended
8792
<context>
8893
<name>twoDModel::Runner</name>
8994
<message>
90-
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+234"/>
95+
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+240"/>
9196
<source>Robot console</source>
9297
<translation type="unfinished"></translation>
9398
</message>

qrtranslations/ru/plugins/robots/twoDModelRunner_ru.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ In background mode the session will be terminated just after the execution ended
5757
<translation>Путь к Python или Javascript файлу, который будет использоваться для интерпретации.</translation>
5858
</message>
5959
<message>
60-
<location line="-3"/>
60+
<location line="+3"/>
61+
<source>Do not run the interpretation in any mode, this is a parameter used only to generate a file.</source>
62+
<translation type>Не запускайте интерпретацию ни в каком режиме, этот параметр используется только для генерации файла.</translation>
63+
</message>
64+
<message>
65+
<location line="-6"/>
6166
<source>Select &quot;python&quot; or &quot;javascript&quot;.</source>
6267
<translation>Выберите &quot;python&quot; или &quot;javascript&quot;.</translation>
6368
</message>
@@ -89,7 +94,7 @@ In background mode the session will be terminated just after the execution ended
8994
<context>
9095
<name>twoDModel::Runner</name>
9196
<message>
92-
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+234"/>
97+
<location filename="../../../../plugins/robots/checker/twoDModelRunner/runner.cpp" line="+240"/>
9398
<source>Robot console</source>
9499
<translation>Консоль робота</translation>
95100
</message>

0 commit comments

Comments
 (0)