From a22a0aa780db22a3089937bc8c209981f129c1f9 Mon Sep 17 00:00:00 2001 From: Tim Corbly Date: Thu, 30 Nov 2023 15:59:54 -0700 Subject: [PATCH] trying a start only for button --- include/botui/Create3Widget.h | 4 +- src/Create3Widget.cpp | 70 +++++++++++++++++------------------ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/botui/Create3Widget.h b/include/botui/Create3Widget.h index f1ea62a8..129085cd 100644 --- a/include/botui/Create3Widget.h +++ b/include/botui/Create3Widget.h @@ -39,8 +39,8 @@ private slots: int m_position_1; double m_vel_1; - // QProcess *startCreate3Service; - QProcess *stopCreate3Service; + QProcess *startCreate3Service; + // QProcess *stopCreate3Service; }; diff --git a/src/Create3Widget.cpp b/src/Create3Widget.cpp index 0927ca0e..c561a0d2 100644 --- a/src/Create3Widget.cpp +++ b/src/Create3Widget.cpp @@ -42,8 +42,8 @@ Create3Widget::Create3Widget(Device *device, QWidget *parent) connect(ui->Create3SensorListButton, SIGNAL(clicked()), SLOT(sensorList())); connect(ui->Create3ExampleProgramButton, SIGNAL(clicked()), SLOT(exampleList())); - // startCreate3Service = new QProcess(this); - stopCreate3Service = new QProcess(this); + startCreate3Service = new QProcess(this); + // stopCreate3Service = new QProcess(this); ui->create3IP->setText(getIP()); } @@ -116,51 +116,51 @@ int Create3Widget::isConnected() void Create3Widget::resetServer() { - QString stopCommand = "sudo"; - QStringList stopArgs = { - "systemctl", - "stop", - "create3_server.service" - }; - - connect(stopCreate3Service, &QProcess::readyReadStandardError, [=]() { - QByteArray data = stopCreate3Service->readAllStandardError(); - qDebug() << "Error:" << data; - }); - - // Start process to stop server - stopCreate3Service->start(stopCommand, stopArgs); - - if (stopCreate3Service->waitForFinished()) - { - qDebug() << "Create3 Server successfully stopped"; - } - else - { - qDebug() << "Create3 Server failed to stop or crashed."; - } - - // QString startCommand = "sudo"; - // QStringList startArgs = { + // QString stopCommand = "sudo"; + // QStringList stopArgs = { // "systemctl", - // "start", + // "stop", // "create3_server.service" // }; - // connect(startCreate3Service, &QProcess::readyReadStandardError, [=]() { - // QByteArray data = startCreate3Service->readAllStandardError(); + // connect(stopCreate3Service, &QProcess::readyReadStandardError, [=]() { + // QByteArray data = stopCreate3Service->readAllStandardError(); // qDebug() << "Error:" << data; // }); - // // Start process to start server - // if (startCreate3Service->startDetached(startCommand, startArgs)) + // // Start process to stop server + // stopCreate3Service->start(stopCommand, stopArgs); + + // if (stopCreate3Service->waitForFinished()) // { - // qDebug() << "Create3 Server successfully started"; + // qDebug() << "Create3 Server successfully stopped"; // } // else // { - // qDebug() << "Create3 Server failed to start or crashed."; + // qDebug() << "Create3 Server failed to stop or crashed."; // } + + QString startCommand = "sudo"; + QStringList startArgs = { + "systemctl", + "start", + "create3_server.service" + }; + + connect(startCreate3Service, &QProcess::readyReadStandardError, [=]() { + QByteArray data = startCreate3Service->readAllStandardError(); + qDebug() << "Error:" << data; + }); + + // Start process to start server + if (startCreate3Service->startDetached(startCommand, startArgs)) + { + qDebug() << "Create3 Server successfully started"; + } + else + { + qDebug() << "Create3 Server failed to start or crashed."; + } } void Create3Widget::sensorList()