File tree Expand file tree Collapse file tree 3 files changed +12
-28
lines changed
generators/trik/trikPythonGeneratorLibrary/src
include/utils/robotCommunication Expand file tree Collapse file tree 3 files changed +12
-28
lines changed Original file line number Diff line number Diff line change 3030#include < utils/robotCommunication/uploadProgramProtocol.h>
3131#include < utils/robotCommunication/networkCommunicationErrorReporter.h>
3232#include < qrgui/textEditor/qscintillaTextEdit.h>
33+ #include < qrgui/textEditor/textManagerInterface.h>
3334#include < qrkernel/settingsManager.h>
3435#include < qrutils/widgets/qRealMessageBox.h>
3536
@@ -271,20 +272,19 @@ void TrikPythonGeneratorPluginBase::onProtocolFinished()
271272void TrikPythonGeneratorPluginBase::onUploadSuccess ()
272273{
273274 auto runPolicy = static_cast <RunPolicy>(SettingsManager::value (" trikRunPolicy" ).toInt ());
274- QFileInfo fileInfo;
275275 switch (runPolicy) {
276276 case RunPolicy::Ask:
277277 if (utils::QRealMessageBox::question (mMainWindowInterface ->windowWidget ()
278- , tr (" The program has been uploaded" )
279- , tr (" Do you want to run it?" )
278+ , tr (" The program has been uploaded" )
279+ , tr (" Do you want to run it?" )
280280 ) != QMessageBox::Yes) {
281281 break ;
282282 }
283283 Q_FALLTHROUGH ();
284284 case RunPolicy::AlwaysRun:
285285 if (mMainFile != QFileInfo ()) {
286286 if (mRunProgramProtocol ) {
287- mRunProgramProtocol ->runUploaded (mMainFile );
287+ mRunProgramProtocol ->run (mMainFile );
288288 return ;
289289 } else {
290290 QLOG_ERROR () << " Run program protocol is not initialized" ;
Original file line number Diff line number Diff line change @@ -42,10 +42,7 @@ class ROBOTS_UTILS_EXPORT RunProgramProtocol : public QObject
4242 ~RunProgramProtocol () override ;
4343
4444 // / Upload and run program from given file on a robot.
45- void run (const QFileInfo &fileToRun);
46-
47- // / Run uploaded program from given file on robot.
48- void runUploaded (const QFileInfo &fileToRun);
45+ void run (const QFileInfo &fileToRun, bool needUpload = true );
4946
5047signals:
5148 // / Emitted when protocol completed successfully.
Original file line number Diff line number Diff line change @@ -56,31 +56,18 @@ RunProgramProtocol::~RunProgramProtocol()
5656{
5757}
5858
59- void RunProgramProtocol::run (const QFileInfo &fileToRun)
59+ void RunProgramProtocol::run (const QFileInfo &fileToRun, bool needUpload )
6060{
6161 mProtocol ->setAction (mWaitingForCasingModel , [](TcpRobotCommunicatorInterface &communicator) {
6262 communicator.requestCasingVersion ();
6363 });
6464
65- mProtocol ->setAction (mWaitingForUploadingComplete , [fileToRun](TcpRobotCommunicatorInterface &communicator) {
66- communicator.uploadProgram (fileToRun.canonicalFilePath ());
67- });
68-
69- mProtocol ->setAction (mWaitingForRunComplete , [fileToRun](TcpRobotCommunicatorInterface &communicator) {
70- communicator.runProgram (fileToRun.fileName ());
71- });
72-
73- mProtocol ->run ();
74- }
75-
76- void RunProgramProtocol::runUploaded (const QFileInfo &fileToRun)
77- {
78- mProtocol ->setAction (mWaitingForCasingModel , [](TcpRobotCommunicatorInterface &communicator) {
79- communicator.requestCasingVersion ();
80- });
81-
82- mProtocol ->setAction (mWaitingForUploadingComplete , [](TcpRobotCommunicatorInterface &communicator) {
83- emit communicator.uploadProgramDone ();
65+ mProtocol ->setAction (mWaitingForUploadingComplete , [fileToRun, needUpload](TcpRobotCommunicatorInterface &communicator) {
66+ if (needUpload) {
67+ communicator.uploadProgram (fileToRun.canonicalFilePath ());
68+ } else {
69+ emit communicator.uploadProgramDone ();
70+ }
8471 });
8572
8673 mProtocol ->setAction (mWaitingForRunComplete , [fileToRun](TcpRobotCommunicatorInterface &communicator) {
You can’t perform that action at this time.
0 commit comments