Skip to content

Commit

Permalink
trying a start only for button
Browse files Browse the repository at this point in the history
  • Loading branch information
tcorbly committed Nov 30, 2023
1 parent dc8f419 commit a22a0aa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions include/botui/Create3Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ private slots:
int m_position_1;
double m_vel_1;

// QProcess *startCreate3Service;
QProcess *stopCreate3Service;
QProcess *startCreate3Service;
// QProcess *stopCreate3Service;

};

Expand Down
70 changes: 35 additions & 35 deletions src/Create3Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a22a0aa

Please sign in to comment.